Class: ODDB::State::Admin::CommercialForm

Inherits:
Global show all
Defined in:
src/state/admin/root.rb,
src/state/admin/commercial_form.rb

Constant Summary

VIEW =
View::Admin::CommercialForm

Constants inherited from Global

HOME_STATE, ZONE

Constants inherited from Global

DIRECT_EVENT, GLOBAL_MAP, HOME_STATE, LIMITED, PRINT_STATES, READONLY_STATES, RESOLVE_STATES, REVERSE_MAP, VIEW, ZONE_NAVIGATION

Constants included from UmlautSort

FILTER_PAIRS

Instance Method Summary (collapse)

Methods inherited from Global

#zone_navigation

Methods inherited from Global

#_search_drugs, #_search_drugs_state, #_trigger, #add_to_interaction_basket, #allowed?, #atc_chooser, #checkout, #clear_interaction_basket, #creditable?, #direct_request_path, #doctorlist, #download, #export_csv, #extend, #fachinfo, #feedbacks, #help_navigation, #home_navigation, #home_state, #hospitallist, #interaction_basket, #limit_state, #limited?, #logout, #navigation, #notify, #password_reset, #paypal_return, #powerlink, #print, #proceed_download, #proceed_poweruser, #resolve, #resolve_state, #rss, #search, #show, #snapback_event, #sort, #sponsorlink, #suggest_address, #switch, #unique_email, #user_input, #user_navigation, #ywesee_contact, #zone_navigation, #zones

Methods included from LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Method Details

- (Object) delete



12
13
14
15
16
17
18
19
# File 'src/state/admin/commercial_form.rb', line 12

def delete
  if(@model.empty?)
    @session.app.delete(@model.pointer)
    commercial_forms
  else
    State::Admin::MergeCommercialForm.new(@session, @model)
  end
end

- (Boolean) duplicate?(string)

Returns:

  • (Boolean)


20
21
22
23
# File 'src/state/admin/commercial_form.rb', line 20

def duplicate?(string)
  !(string.to_s.empty? \
    || [nil, @model].include?(ODDB::CommercialForm.find_by_name(string)))
end

- (Object) update



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'src/state/admin/commercial_form.rb', line 24

def update
  languages = @session.lookandfeel.languages
  input = languages.inject({}) { |inj, key|
    sym = key.intern
    value = @session.user_input(sym)
    if(duplicate?(value))
      @errors.store(sym, 
        create_error('e_duplicate_commercial_form', key, value))
    end
    inj.store(key, value)
    inj
  }
  if(syn_list = @session.user_input(:synonym_list))
    syns = syn_list.split(/\s*,\s*/u)
    syns.each { |syn| 
      if(duplicate?(syn))
        @errors.store(:synonym_list, 
          create_error('e_duplicate_commercial_form', 
            :synonym_list, syn))
      end
    }
    input.store(:synonyms, syns)
  end
  unless error?
    @model = @session.app.update(@model.pointer, input, unique_email)
  end
  self
end