Class: ODDB::State::Admin::AddressSuggestion

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

Defined Under Namespace

Classes: AddressWrapper

Constant Summary

VIEW =
View::Admin::AddressSuggestion

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 Attribute Summary (collapse)

Instance Method Summary (collapse)

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, #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, #zones

Methods included from LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Attribute Details

- (Object) active_address (readonly)

Returns the value of attribute active_address



15
16
17
# File 'src/state/admin/address_suggestion.rb', line 15

def active_address
  @active_address
end

Instance Method Details

- (Object) accept



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'src/state/admin/address_suggestion.rb', line 33

def accept
  mandatory = [:name]
  keys = [:additional_lines, :address, :location,
    :fon, :fax, :title, :canton, :pointer,
    :email_suggestion, :address_type] + mandatory
  input = user_input(keys, mandatory)
  input[:fax] = input[:fax].to_s.split(/\s*,\s*/u)
  input[:fon] = input[:fon].to_s.split(/\s*,\s*/u)
  lns = input[:additional_lines].to_s
  input.store(:additional_lines, 
    lns.split(/[\n\r]+/u))
  input.store(:type, input.delete(:address_type))
  if(!error? && (pointer = input.delete(:pointer)) \
    && (sugg = pointer.resolve(@session)) \
    && (addr_pointer = sugg.address_pointer))
    addr = addr_pointer.resolve(@session)
    if(addr.nil?)
      addr = addr_pointer.creator.resolve(@session)
      @active_address = AddressWrapper.new(addr)
    end
     = input.delete(:email_suggestion)
    parent_input = {
      :email  => ,
    }
    @session.app.update(pointer, input, unique_email)
    addr.replace_with(sugg)
    @session.app.update(addr_pointer.parent,
      parent_input, unique_email)
    ## nur nötig wenn suggestion nicht gelöscht wird
    @active_address. = 
    self
  end
end

- (Object) delete



66
67
68
69
70
71
72
# File 'src/state/admin/address_suggestion.rb', line 66

def delete
  if((pointer = @session.user_input(:pointer)) \
    && pointer.is_a?(Persistence::Pointer))
    @session.app.delete(pointer)
    trigger(:addresses)
  end
end

- (Object) home_state



73
74
75
76
77
78
79
80
81
82
83
84
# File 'src/state/admin/address_suggestion.rb', line 73

def home_state
  case zone
  when :companies
    State::Companies::Init
  when :doctors
    State::Doctors::Init
  when :hospitals
    State::Hospitals::Init
  else
    super
  end
end

- (Object) init



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'src/state/admin/address_suggestion.rb', line 19

def init
  if(pointer = @model.address_pointer)
    addr = pointer.resolve(@session)
    if(addr.nil?)
      addr = Address2.new
      addr.pointer = pointer
    end
    @active_address = AddressWrapper.new(addr)
    parent = pointer.parent.resolve(@session)
    select_zone(parent)
    @active_address. = parent.
  end
  super
end

- (Object) zone



85
86
87
# File 'src/state/admin/address_suggestion.rb', line 85

def zone
  @zone || super
end

- (Object) zone_navigation



88
89
90
91
92
93
94
95
96
97
98
99
# File 'src/state/admin/address_suggestion.rb', line 88

def zone_navigation
  case zone
  when :companies
    State::Companies::Global::ZONE_NAVIGATION
  when :doctors
    State::Doctors::Global::ZONE_NAVIGATION
  when :hospitals
    State::Hospitals::Global::ZONE_NAVIGATION
  else
    State::Admin::Global::ZONE_NAVIGATION
  end
end