Class: UU::OS::VUC::View
- Inherits:
-
GVC::Container
- Object
- GVC::Container
- UU::OS::VUC::View
- Defined in:
- uu_adk-0.28.16/lib/uu/os/vuc/view.rb
Overview
View object used for communication with forms.
Instance Attribute Summary (collapse)
-
- (String) code
readonly
View code.
-
- (Numeric) component_type
readonly
View type.
-
- (UU::OS::VUC::Context) context
readonly
Use case context.
-
- (UU::OS::VUC::Event) event
readonly
Incoming event.
-
- (String) id
readonly
Unique view ID.
-
- (String) name
readonly
View name.
-
- (UU::OS::VUC::Navigation) navigation
readonly
What should form do next.
-
- (Object) result
The result of the VUC.
-
- (Numeric) status
HTTP status code of processed request (possible values are available on HTTPStatus).
-
- (UU::OS::VUC::ViewTemplate) view_template
readonly
View template that can be used for setting different sheet that will be rendered as form.
Instance Method Summary (collapse)
-
- (View) initialize(data = nil)
constructor
Creates new instance of view.
-
- (String) to_response
Serializes view to JSON.
Methods inherited from GVC::Container
#add_message, #components, #focus, #focused_component, #get_component_by_id, #get_components_by_code, #messages
Constructor Details
- (View) initialize(data = nil)
Creates new instance of view.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 95 def initialize(data = nil) if data.nil? super(data) return end if data.kind_of?String data = JSON.parse(data, :symbolize_names => true) end if !data.kind_of?Hash raise ArgumentError.new("View data must be JSON String or Hash, but was #{data.class}.") end super(data) @id = data[:id] @code = data[:code] @name = data[:name] @status = data[:status] @component_type = data[:componentType] @event = UU::OS::VUC::Event.new(data[:event]) @context = UU::OS::VUC::Context.new(data[:context]) @navigation = UU::OS::VUC::Navigation.new(data[:navigation]) @result = data[:result] @view_template = UU::OS::VUC::ViewTemplate.new(data[:viewTemplate]) end |
Instance Attribute Details
- (String) code (readonly)
View code.
23 24 25 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 23 def code @code end |
- (Numeric) component_type (readonly)
View type.
36 37 38 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 36 def component_type @component_type end |
- (UU::OS::VUC::Context) context (readonly)
Use case context.
44 45 46 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 44 def context @context end |
- (UU::OS::VUC::Event) event (readonly)
Incoming event.
40 41 42 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 40 def event @event end |
- (String) id (readonly)
Unique view ID.
19 20 21 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 19 def id @id end |
- (String) name (readonly)
View name.
27 28 29 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 27 def name @name end |
- (UU::OS::VUC::Navigation) navigation (readonly)
What should form do next.
48 49 50 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 48 def @navigation end |
- (Object) result
The result of the VUC. Setting the value to anything other than nil means that the VUC has finished and the user can be navigated elsewhere.
By convention, setting "false" means that the VUC was cancelled. The result will be passed to the parent VUC if the current VUC runs in a dialog window. Otherwise, if the value is an URI, it'll be used for navigation. Otherwise, the user will be navigated to the previous UC.
58 59 60 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 58 def result @result end |
- (Numeric) status
HTTP status code of processed request (possible values are available on HTTPStatus).
32 33 34 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 32 def status @status end |
- (UU::OS::VUC::ViewTemplate) view_template (readonly)
View template can be set only in on_before_init method, if you set data_uri in another method, it will have no effect.
View template that can be used for setting different sheet that will be rendered as form. Read UU::OS::VUC::ViewTemplate#data_uri for more info.
89 90 91 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 89 def view_template @view_template end |
Instance Method Details
- (String) to_response
Serializes view to JSON.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view.rb', line 122 def to_response response = {} response[:id] = @id response[:code] = @code response[:name] = @name response[:status] = @status response[:componentType] = @component_type response[:event] = @event.raw_attrs if (@event.raw_attrs) && (!@event.raw_attrs.empty?) response[:context] = @context.raw_attrs if (@context.raw_attrs) && (!@context.raw_attrs.empty?) if (@components) && (@components.values.size > 0) response[:components] = [] @components.values.each do |component| response[:components] << component.attributes end end if (@messages) && (@messages.size > 0) response[:messages] = [] @messages.each do || response[:messages] << .raw_attrs end end response[:navigation] = @navigation.raw_attrs if (@navigation.raw_attrs) && (!@navigation.raw_attrs.empty?) response[:focusOn] = @focus_on if @focus_on response[:result] = @result if !@result.nil? response[:viewTemplate] = @view_template.raw_attrs if (@view_template.raw_attrs) && (!@view_template.raw_attrs.empty?) response.to_json end |