Class: Glib::JsonUi::PageHelper::Page
- Inherits:
-
Object
- Object
- Glib::JsonUi::PageHelper::Page
- Includes:
- Default
- Defined in:
- app/helpers/glib/json_ui/page_helper.rb
Instance Attribute Summary collapse
-
#action_builder ⇒ Object
readonly
Returns the value of attribute action_builder.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#current_form ⇒ Object
See Panels::Form.
-
#drawer_content_builder ⇒ Object
readonly
Returns the value of attribute drawer_content_builder.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#list_section_builder ⇒ Object
readonly
Returns the value of attribute list_section_builder.
-
#menu_builder ⇒ Object
readonly
Returns the value of attribute menu_builder.
-
#sview_builder ⇒ Object
readonly
Returns the value of attribute sview_builder.
-
#table_section_builder ⇒ Object
readonly
Returns the value of attribute table_section_builder.
-
#tree_section_builder ⇒ Object
readonly
Returns the value of attribute tree_section_builder.
-
#view_builder ⇒ Object
readonly
Returns the value of attribute view_builder.
Instance Method Summary collapse
- #actionCable(options = {}) ⇒ Object
- #body(options = {}) ⇒ Object
- #bodyFooter(options = {}) ⇒ Object
- #containerStyleClasses(styleClasses) ⇒ Object
- #content_builder(panelNames) ⇒ Object
- #data(options = {}) ⇒ Object
- #filePaster(options = {}) ⇒ Object
- #footer(options = {}) ⇒ Object
- #form(options = {}) ⇒ Object
- #header(options = {}) ⇒ Object
-
#initialize(json, context) ⇒ Page
constructor
A new instance of Page.
- #leftDrawer(options = {}) ⇒ Object
- #list(options = {}) ⇒ Object
- #navBar(options = {}) ⇒ Object
- #on(options = {}) ⇒ Object
- #scroll(options = {}) ⇒ Object
- #table(options = {}) ⇒ Object
-
#template(template) ⇒ Object
def rightNavButtons json.rightNavButtons do yield @menu_builder end end.
- #vertical_content(options) ⇒ Object
Methods included from Default
Constructor Details
#initialize(json, context) ⇒ Page
Returns a new instance of Page.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 107 def initialize(json, context) @json = json @context = context @view_builder = ViewBuilder.new(json, self, true) @sview_builder = ViewBuilder.new(json, self, false) @action_builder = ActionBuilder.new(json, self, false) @menu_builder = MenuBuilder.new(json, self) @list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::ListTemplate.new(json, self)) @tree_section_builder = ListBuilders::Section.new(json, self, ListBuilders::TreeTemplate.new(json, self)) @drawer_content_builder = ListBuilders::Section.new(json, self, @menu_builder) @table_section_builder = TableBuilders::Section.new(json, self, TableBuilders::Template.new(json, self)) # @split_content_builder = SplitBuilders::Content.new(json, self, @view_builder) # TODO: Deprecate # For generic `body` builder. For others, use content_builder() # @generic_content_builder = GenericBuilders::Content.new(json, self, @view_builder) end |
Instance Attribute Details
#action_builder ⇒ Object (readonly)
Returns the value of attribute action_builder.
101 102 103 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 101 def action_builder @action_builder end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
101 102 103 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 101 def context @context end |
#current_form ⇒ Object
See Panels::Form
105 106 107 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 105 def current_form @current_form end |
#drawer_content_builder ⇒ Object (readonly)
Returns the value of attribute drawer_content_builder.
102 103 104 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 102 def drawer_content_builder @drawer_content_builder end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
101 102 103 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 101 def json @json end |
#list_section_builder ⇒ Object (readonly)
Returns the value of attribute list_section_builder.
102 103 104 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 102 def list_section_builder @list_section_builder end |
#menu_builder ⇒ Object (readonly)
Returns the value of attribute menu_builder.
101 102 103 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 101 def @menu_builder end |
#sview_builder ⇒ Object (readonly)
Returns the value of attribute sview_builder.
101 102 103 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 101 def sview_builder @sview_builder end |
#table_section_builder ⇒ Object (readonly)
Returns the value of attribute table_section_builder.
102 103 104 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 102 def table_section_builder @table_section_builder end |
#tree_section_builder ⇒ Object (readonly)
Returns the value of attribute tree_section_builder.
102 103 104 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 102 def tree_section_builder @tree_section_builder end |
#view_builder ⇒ Object (readonly)
Returns the value of attribute view_builder.
101 102 103 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 101 def view_builder @view_builder end |
Instance Method Details
#actionCable(options = {}) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 139 def actionCable( = {}) json.actionCable do if (on_error = [:onError]) json.onError do @action_builder.with_isolated_singleton_tracking { on_error.call(@action_builder) } end end if (on_open = [:onOpen]) json.onOpen do @action_builder.with_isolated_singleton_tracking { on_open.call(@action_builder) } end end if (on_close = [:onClose]) json.onClose do @action_builder.with_isolated_singleton_tracking { on_close.call(@action_builder) } end end json.channels [:channels] end end |
#body(options = {}) ⇒ Object
231 232 233 234 235 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 231 def body( = {}) json.body do vertical_content() end end |
#bodyFooter(options = {}) ⇒ Object
213 214 215 216 217 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 213 def ( = {}) json. do vertical_content() end end |
#containerStyleClasses(styleClasses) ⇒ Object
180 181 182 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 180 def containerStyleClasses(styleClasses) json.containerStyleClasses styleClasses end |
#content_builder(panelNames) ⇒ Object
163 164 165 166 167 168 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 163 def content_builder(panelNames) # NOTE: Can potentially be cached builder = GenericBuilders::Content.new(json, self, @view_builder) builder.definePanels(panelNames) builder end |
#data(options = {}) ⇒ Object
277 278 279 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 277 def data( = {}) [:content].call(ViewBuilder.new(json, self, false)) end |
#filePaster(options = {}) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 127 def filePaster( = {}) json.filePaster do json.accepts default_accepts([:accepts]) json.directUploadUrl [:directUploadUrl] json.url [:url] json.inputName [:inputName] json.strategy [:strategy] json.storagePrefix [:storagePrefix] json. [:metadata] end end |
#footer(options = {}) ⇒ Object
225 226 227 228 229 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 225 def ( = {}) json. do vertical_content() end end |
#form(options = {}) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 261 def form( = {}) form = Glib::JsonUi::ViewBuilder::Panels::Form.new(json, self) form.childViews(->(view_builder) { }) = .slice!(:url, :method, :local, :onSubmit, :paramNameForFormData, :model, :onChange, :onChangeAndLoad, :autoValidate, :disableDirtyCheck) json.fullPageForm do json.view 'panels/fullPageForm' form.props() end # So that the containing fields have context (e.g. can use form's model for naming). self.current_form = form scroll self.current_form = nil end |
#header(options = {}) ⇒ Object
219 220 221 222 223 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 219 def header( = {}) json.header do vertical_content() end end |
#leftDrawer(options = {}) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 184 def leftDrawer( = {}) json.leftDrawer do [:styleClasses, :backgroundColor, :drawerWidth].each do |name| if (value = .delete(name)) json.set! name, value end end if [:body] json.set!(:body) { [:body].call(sview_builder) } end [:content]&.call drawer_content_builder end end |
#list(options = {}) ⇒ Object
237 238 239 240 241 242 243 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 237 def list( = {}) json.body do json.childViews do @view_builder.add_view('panels_list', .reverse_merge(width: 'matchParent')) end end end |
#navBar(options = {}) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 198 def navBar( = {}) json.navBar do # json.leftItems do # options[:leftItems]&.call @menu_builder # end # json.logoUrl "http://localhost:3000/assets/logo_dark-02d9b6a91fdbf22515da7b921d31367b70696214415f6789d2f90232e4a287b7.svg" # json.rightItems do # options[:rightItems]&.call @menu_builder # end @view_builder.add_singleton_view('appBar', ) end end |
#on(options = {}) ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 303 def on( = {}) if (on_load = [:load]) json.onLoad do @action_builder.with_isolated_singleton_tracking { on_load.call @action_builder } end end if (on_rerender = [:reRender]) json.onRerender do @action_builder.with_isolated_singleton_tracking { on_rerender.call @action_builder } end end if (on_unload = [:unload]) json.onUnload do @action_builder.with_isolated_singleton_tracking { on_unload.call @action_builder } end end if (on_refocus = [:refocus]) json.onRefocus do @action_builder.with_isolated_singleton_tracking { on_refocus.call @action_builder } end end if (on_foreground = [:foreground]) json.onForeground do @action_builder.with_isolated_singleton_tracking { on_foreground.call @action_builder } end end end |
#scroll(options = {}) ⇒ Object
253 254 255 256 257 258 259 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 253 def scroll( = {}) json.body do json.childViews do @view_builder.add_view('panels_scroll', .reverse_merge(width: 'matchParent')) end end end |
#table(options = {}) ⇒ Object
245 246 247 248 249 250 251 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 245 def table( = {}) json.body do json.childViews do @view_builder.add_view('panels_table', .reverse_merge(width: 'matchParent')) end end end |
#template(template) ⇒ Object
def rightNavButtons
json.rightNavButtons do
yield @menu_builder
end
end
176 177 178 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 176 def template(template) json.template template end |
#vertical_content(options) ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'app/helpers/glib/json_ui/page_helper.rb', line 281 def vertical_content() # TODO: try disabling this # options = options.reverse_merge(width: 'matchParent') if (styleClass = .delete(:styleClass)) json.styleClasses [styleClass] end [:styleClasses, :padding, :backgroundColor, :width, :height].each do |name| if (value = .delete(name)) json.set! name, value end end json.childViews do if (childViews = .delete(:childViews)) childViews.call @view_builder end end raise "Invalid properties: #{.keys}" if .size > 0 end |