view · edit · sidebar · attach · print · history

20120420-update-fachinfo-link

<< | Index | >>


Summary

  • create links chapter in fachinfo document (not Fachinfo Document Object, but Fachinfo Object)
  • create admin form for this links chapter
    • add/delete input text by ajax

Commits

Index


Error handling

error handling by user input (POST/GET)

SBSM::State in path/to/sbsm/lib/sbsm/state.rb

    def error?
      !@errors.empty?
    end

ODDB::State::Global in src/state/global.rb

      def user_input(keys=[], mandatory=[])
        keys = [keys] unless keys.is_a?(Array)
        mandatory = [mandatory] unless mandatory.is_a?(Array)
        hash = @session.user_input(*keys)
        hash ||= {}
        unless(hash.is_a?(Hash))
          hash = {keys.first => hash}
        end 
        keys.each { |key| 
          carryval = nil 
          value = hash[key]
          if(value.is_a? RuntimeError)
            carryval = value.value
            @errors.store(key, hash.delete(key))
          elsif(mandatory.include?(key) && mandatory_violation(value))
            error = create_error('e_missing_' << key.to_s, key, value)
            @errors.store(key, error)
            hash.delete(key)
          else
            carryval = value
          end 
          if(@model.is_a? Persistence::CreateItem)
            @model.carry(key, carryval)
          end 
        }   
        hash
      end 

Input Validator

We can validate array format name

z.B.

  • names[0][1]
  • index[0]

Validator in src/util/validator.rb

STRING = [
  ...
  :names,
  ...
]
...
NUMERIC = [
  ...
   index,
  ...
]

SBSM State#user_input -> Session#user_input

 @@input_ptrn = /([^\[]+)\[([^\]]+)\]/
    def user_input(*keys)
      if(keys.size == 1)
        index = nil 
        key = keys.first.to_s
        if match = @@input_ptrn.match(key)
          key = match[1]
          index = match[2]
        end 
        key_sym = key.to_sym
        valid = @valid_input[key_sym]
        if(index && valid.respond_to?(:[]))
          valid[index]
        else
          valid
        end 
      else
        keys.inject({}) { |inj, key|
          inj.store(key, user_input(key))
          inj 
        }   
      end 
    end 

store by bin/admin

use update method with pointer. link this

# store new (update)
ch.oddb> update(registration('31706').fachinfo.pointer, {:links => [FachinfoLink.new]}, :admin)
-> #<ODDB::FachinfoDocument2001:0xe1a1fcc>
ch.oddb> registration('31706').fachinfo.links
-> [#<ODDB::FachinfoLink:0xe19a970 @name="", @url="">]

# after updating by browser
ch.oddb> registration('31706').fachinfo.links
-> [#<ODDB::FachinfoLink:0xc275824 @name="test", @url="http://example.com">]
ch.oddb> 
NOTE

HtmlGrid::List has these sort options.

    SORT_DEFAULT = :to_s
    SORT_HEADER = true
    SORT_REVERSE = false

Fachinfo view classes

View classes of Fachinfo

  • ODDB::View::Drugs [module, zone :drugs]
View
  * Fachinfo2001
  * FiChapterChooserLink < HtmlGrid::Link
  * FiChapterChooser < HtmlGrid::Composite
    * include View::AdditionalInformation
    * include View::Print
    * Container of FiChapterChooserLink
  * FachinfoPhotoView < HtmlGrid::Div
    * as virtual photos chapter (FachinfoDocument object does not have photo)
  * FachinfoInnerComposite < HtmlGrid::DivComposite
    * Container of View::Chapter and FachinfoPhotoView
  * FachinfoPreViewComposite < HtmlGrid::Composite
    * View class for VorShau after uploading fachinfo word file
    * Container of FachinfoInnerComposite
  * FachinfoPrintInnerComposite < FachinfoInnerComposite
    * no used ?
    * Container of View::PrintChapter
  * FachinfoPrintComposite < HtmlGrid::DivComposite
    * View class for Print action
    * Container of FachinfoInnerComposite
  * FachinfoComposite < FachinfoPreviewComposite
    * Container of FiChooserChapter, FachinfoInnerComposite, View::Chapter, usw.
  * CompanyFachinfoPrintComposite < FachinfoPrintComposite
  * RootFachinfoComposite <  FachinfoComposite
  • PrivateTemplate > Fachinfo
    • FachinfoPreviewComposite > FachinfoComposite
      • FiChapterChooser
      • FachinfoInnerComposite
      • View::Chapter
      • ...
Template
  * Fachinfo < PrivateTemplate
    * Container of FachinfoComposite
  * FachinfoPreview < PrivateTemplate
    * Container of FachinfoPreviewComposite
  * FachinfoPrint < PrivateTemplate
    * Container of FachinfoPrintComposte
  * CompanyFachinfoPrint < FachinfoPrint
  * RootFachinfo < PrivateTemplate
    * Container of RootFachinfoComposite
Admin
  * EditFiChapterChooser < FiChapterChooser
    * FiChapterChooser for admin user
  * RootFachinfoComposite < FachinfoComposite
    * Container of EditFiChapterChooser
    * Container of View::EditLinkForm, View::EditChapterForm
  • PrivateTemplate > RootFachinfo
    • FachinfoComposite > RootFachinfoComposte
      • View::EditChapterForm
        • View::Chapter
      • View::EditLinkForm
        • View::Links < HtmlGrid::List
view · edit · sidebar · attach · print · history
Page last modified on April 21, 2012, at 06:09 PM