glib-web 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73e075cfe5041ccb4a1f0f6836a9fb5fe294fff00698ad0974a1ef70e34d8bb8
4
- data.tar.gz: 5ebb6ca2859d77329531ebec64019f655da409adc0a617c6567be6ef3acf9c88
3
+ metadata.gz: 324be9293b997d23666ea14d20515bb5e8aef6e7fa962f4cf1ccba6ade3d6d1e
4
+ data.tar.gz: 0b4a0e7f36dfb0e6cbac8f83dbc904451d1c59e02d212b5a6c2af4bda8e8c092
5
5
  SHA512:
6
- metadata.gz: 6dc692a9e877c4686fb64600813c1b14e6c9926a69a2d9ffaf0c65cb7ac7a48976ad727eea965c024694e79f5b2af9ae945bb013e02f68d0d434fe57f1bb2640
7
- data.tar.gz: 6e8a5f227bc198f957372c7de511f8e5b65d197419f3bc6a2e461cf894f6c26e3dbfab25859b0b76b22775186f8ed2106d58d309bfc1118ee68c9f33186389e0
6
+ metadata.gz: 752f7e4b42626d97625f169b933a9e44eb6d968a54c3adfc0945434e785a2d0ef03daf7708cd63f36cb28c6f6e235d3eb5e0cc491abd9ad10da3e377fcdeabd4
7
+ data.tar.gz: 7b9d408aeff03b974f026a26c96128569d0976f2d5bd4745cebaa0c3877a652fc335dc03e62b2ab3949c7dbff53a922b8462243b2f4a1bcc83df19b29409c515
@@ -19,12 +19,11 @@ module Glib
19
19
  # TZInfo::Timezone.default_dst = true
20
20
  return [] if Rails.env.test?
21
21
 
22
- ActiveSupport::TimeZone.all.sort { |a, b|
23
- a.utc_offset <=> b.utc_offset
24
- }.collect { |tz|
25
- utc_offset = "#{tz.utc_offset >= 0 ? '+' : ''}#{tz.utc_offset / 60 / 60}h"
26
- { value: tz.tzinfo.identifier, text: "#{utc_offset} #{tz.name}" }
27
- }
22
+ ActiveSupport::TimeZone.all.group_by { |tz| tz.tzinfo.identifier }.map do |identifier, timezones|
23
+ utc_offset = "#{timezones.first.utc_offset >= 0 ? '+' : ''}#{timezones.first.utc_offset / 60 / 60}h"
24
+ locations = timezones.map(&:name).join(', ')
25
+ { value: identifier, text: "#{utc_offset} #{locations}" }
26
+ end
28
27
  end
29
28
  end
30
29
  end
@@ -0,0 +1,8 @@
1
+ class Glib::JsonUi::ActionBuilder
2
+ module Files
3
+ class Upload < Action
4
+ include Glib::JsonUi::Upload
5
+ action :onFinished
6
+ end
7
+ end
8
+ end
@@ -1,7 +1,7 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  module ListBuilders
4
- class Template < AbstractBuilder
4
+ class ListTemplate < AbstractBuilder
5
5
  def method_missing(m, *args)
6
6
  add_element_to_array 'template', m, *args
7
7
  end
@@ -76,6 +76,21 @@ module Glib
76
76
  end
77
77
  end
78
78
 
79
+ class TreeTemplate < AbstractBuilder
80
+ def method_missing(m, *args)
81
+ add_element_to_array 'template', m, *args
82
+ end
83
+
84
+ class Standard < JsonUiElement
85
+ string :id
86
+ string :title
87
+ action :onClick
88
+ hash :dropData
89
+ hash :icon, required: [:name], optional: [:color]
90
+ array :rows
91
+ end
92
+ end
93
+
79
94
  class Section < AbstractBuilder
80
95
  def initialize(json, page, template)
81
96
  super json, page
@@ -85,7 +85,7 @@ module Glib
85
85
  include Glib::JsonUi::Default
86
86
 
87
87
  attr_reader :json, :context, :view_builder, :sview_builder, :action_builder, :menu_builder
88
- attr_reader :list_section_builder, :table_section_builder, :drawer_content_builder
88
+ attr_reader :list_section_builder, :table_section_builder, :drawer_content_builder, :tree_section_builder
89
89
 
90
90
  # See Panels::Form
91
91
  attr_accessor :current_form
@@ -99,7 +99,8 @@ module Glib
99
99
  @action_builder = ActionBuilder.new(json, self, false)
100
100
  @menu_builder = MenuBuilder.new(json, self)
101
101
 
102
- @list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::Template.new(json, self))
102
+ @list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::ListTemplate.new(json, self))
103
+ @tree_section_builder = ListBuilders::Section.new(json, self, ListBuilders::TreeTemplate.new(json, self))
103
104
  @drawer_content_builder = ListBuilders::Section.new(json, self, @menu_builder)
104
105
  @table_section_builder = TableBuilders::Section.new(json, self, TableBuilders::Template.new(json, self))
105
106
  # @split_content_builder = SplitBuilders::Content.new(json, self, @view_builder)
@@ -75,7 +75,9 @@ class Glib::JsonUi::ViewBuilder
75
75
  @label ||= context.field_label(@prop, @label_args || {})
76
76
  @hint ||= context.hint_label(@prop, @hint_args || {})
77
77
  @placeholder ||= context.placeholder_label(@prop, @placeholder_args || {})
78
- @validation ||= context.field_validation(@prop) if form._autoValidate || @autoValidate
78
+ if form._autoValidate && @autoValidate.nil? || !@autoValidate.nil? && @autoValidate
79
+ @validation ||= context.field_validation(@prop)
80
+ end
79
81
 
80
82
  if form.current_dynamic_group.nil?
81
83
  # This is not relevant inside a dynamic group
@@ -151,6 +153,8 @@ class Glib::JsonUi::ViewBuilder
151
153
  string :text
152
154
  color :color
153
155
  icon :icon
156
+ # This will not work if the form contains multiple fields with the same name,
157
+ # even if only one field is showing at any one time"
154
158
  bool :disableIfFormInvalid
155
159
  end
156
160
 
@@ -165,6 +169,7 @@ class Glib::JsonUi::ViewBuilder
165
169
  string :onIcon
166
170
  string :offIcon
167
171
  string :onLabel
172
+ hash :image, required: [:url, :template], optional: [:width, :height]
168
173
 
169
174
  def value(value)
170
175
  @value = value if value != Glib::Value::DEFAULT
@@ -266,10 +271,15 @@ class Glib::JsonUi::ViewBuilder
266
271
  action :onClick
267
272
  string :offIcon
268
273
  string :onIcon
269
- string :imageUrl
270
- string :icon
271
- string :iconColor
272
- string :iconSize
274
+ hash :image, required: [:url, :template], optional: [:width, :height]
275
+ hash :icon, required: [:name, :template], optional: [:color, :size]
276
+ # bool :featured
277
+ # bool :thumbnail
278
+ # hash :image
279
+ # string :imageUrl
280
+ # string :icon
281
+ # string :iconColor
282
+ # string :iconSize
273
283
 
274
284
  views :childViews
275
285
  end
@@ -352,10 +362,10 @@ class Glib::JsonUi::ViewBuilder
352
362
  @responseMessages[status] = I18n.t(key) if I18n.exists?(key)
353
363
  end
354
364
  json.responseMessages (@responseMessages || {}).reverse_merge({
355
- '200' => 'File uploaded',
365
+ '200' => 'Completed',
356
366
  '403' => 'Forbidden',
357
367
  '401' => 'Session expired',
358
- 'else' => 'Upload failed'
368
+ 'else' => 'Failed'
359
369
  })
360
370
 
361
371
  json.placeholder @placeholder if @placeholder
@@ -424,6 +424,23 @@ class Glib::JsonUi::ViewBuilder
424
424
  views :childViews
425
425
  end
426
426
 
427
+ class Tree < View
428
+ include Glib::JsonUi::Upload
429
+
430
+ string :selected
431
+ action :onDrop
432
+
433
+ def sections(blocks)
434
+ json.sections do
435
+ blocks.each do |block|
436
+ json.child! do
437
+ block.call page.tree_section_builder
438
+ end
439
+ end
440
+ end
441
+ end
442
+ end
443
+
427
444
  class Web < View
428
445
  string :url
429
446
  end
@@ -0,0 +1,4 @@
1
+ info = "Method: #{request.method}\nForm Data:\n"
2
+ info += JSON.pretty_generate(params.to_unsafe_h)
3
+
4
+ action.dialogs_alert message: info
@@ -0,0 +1,3 @@
1
+ json_ui_response json do |action|
2
+ render "#{@path_prefix}/forms/alert_post_all_data", action: action
3
+ end
@@ -54,7 +54,6 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
54
54
  value: ['melbourne', 'sydney'],
55
55
  multiple: true,
56
56
  onChange: ->(action) do
57
- # TODO: Fix needed. When closing this dialog, the dirty prompt appears.
58
57
  action.dialogs_alert message: 'Options selected'
59
58
  end
60
59
 
@@ -76,6 +76,23 @@ page.form \
76
76
  form.spacer height: 10
77
77
  form.label id: 'label5', text: 'Both Checked'
78
78
 
79
+ form.spacer height: 6
80
+ form.fields_check\
81
+ image: { template: 'thumbnail', url: 'https://cdn.pixabay.com/photo/2020/08/05/13/12/eco-5465432_1280.png', width: 24, height: 24 },
82
+ name: 'user[check22]', checkValue: 'on', label: 'check thumbnail', uncheckValue: 'off', onChangeAndLoad: ->(action) do
83
+ action.logics_set targetId: 'label22', conditionalData: { displayed: { "==": [{ "var": 'user[check22]' }, 'on'] } }
84
+ end
85
+ form.fields_check\
86
+ image: { template: 'featured', url: 'https://cdn.pixabay.com/photo/2020/08/05/13/12/eco-5465432_1280.png', width: 80, height: 80 },
87
+ name: 'user[check25]', checkValue: 'on', label: 'Check featured', uncheckValue: 'off', onChangeAndLoad: ->(action) do
88
+ action.logics_set targetId: 'label25', conditionalData: { displayed: { "==": [{ "var": 'user[check25]' }, 'on'] } }
89
+ end
90
+ form.spacer height: 10
91
+ form.label id: 'label25', text: 'Is Checked25'
92
+
93
+ form.spacer height: 10
94
+ form.label id: 'label22', text: 'Is Checked22'
95
+
79
96
  form.spacer height: 20
80
97
  form.h1 text: 'Radio Group'
81
98
  form.fields_radioGroup \
@@ -106,8 +123,14 @@ page.form \
106
123
  end
107
124
  end,
108
125
  childViews: ->(group) do
109
- group.fields_radio value: 'show', label: 'Show', icon: 'edit', iconSize: 40
110
- group.fields_radio value: 'hide', label: 'Hide', imageUrl: 'https://cdn.pixabay.com/photo/2020/08/05/13/12/eco-5465432_1280.png'
126
+ group.fields_radio\
127
+ value: 'show', label: 'Show', icon: { template: 'featured', name: 'edit', size: 40, color: '#d1d1d1' }
128
+ group.fields_radio\
129
+ value: 'hide', label: 'Hide',
130
+ image: { template: 'featured', url: 'https://cdn.pixabay.com/photo/2020/08/05/13/12/eco-5465432_1280.png', width: 80, height: 80 }
131
+ group.fields_radio\
132
+ value: 'no', label: 'No',
133
+ image: { template: 'thumbnail', url: 'https://cdn.pixabay.com/photo/2020/08/05/13/12/eco-5465432_1280.png', width: 24, height: 24 }
111
134
  group.fields_radio value: '', label: 'Empty'
112
135
  end
113
136
  form.spacer height: 10
@@ -131,6 +131,10 @@ json_ui_page json do |page|
131
131
  action.windows_open url: json_ui_garage_url(path: 'panels/grid')
132
132
  end
133
133
 
134
+ template.thumbnail title: 'Tree', subtitle: 'Tree like view just like folder and subfolder', onClick: ->(action) do
135
+ action.windows_open url: json_ui_garage_url(path: 'panels/tree')
136
+ end
137
+
134
138
  template.thumbnail title: 'List Template Accessory', onClick: ->(action) do
135
139
  # TODO
136
140
  end
@@ -0,0 +1,77 @@
1
+ json.title 'Panels'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
+ scroll.h2 text: 'Standard'
8
+ scroll.spacer height: 4
9
+
10
+ scroll.panels_tree selected: params[:selected] || 'arabian-1.mp3', width: 300, sections: [
11
+ ->(section) do
12
+ section.header childViews: ->(header) do
13
+ header.h2 text: 'Music 🎶'
14
+ end
15
+
16
+ section.rows builder: ->(template) do
17
+ template.standard id: 'pop', title: 'Pop', rows: ['pop-1.mp3', 'pop-2.mp3', 'pop-3.mp3']
18
+ template.standard id: 'arab', title: 'Arabian', rows: ['arabian-1.mp3', 'arabian-2.mp3', 'arabian-3.mp3']
19
+ template.standard id: 'phonk', title: 'Phonk', rows: ['phonk1.mp3', 'phonk-2.mp3', { id: 'hard-phonk', title: 'Hard Phonk', rows: ['hard-phonk-1.mp3', 'hard-phonk-2.mp3'] }]
20
+ end
21
+ end,
22
+ ->(section) do
23
+ section.header childViews: ->(header) do
24
+ header.h2 text: 'onClick windows/reload'
25
+ end
26
+
27
+ section.rows builder: ->(template) do
28
+ template.standard title: 'funny-video.mp4', id: 'fun', onClick: ->(action) { action.windows_reload url: json_ui_garage_current_url(selected: 'fun') }
29
+ template.standard title: 'animal-planet.mp4', id: 'animal', onClick: ->(action) { action.windows_reload url: json_ui_garage_current_url(selected: 'animal') }
30
+ template.standard title: 'wedding.mp4', id: 'wedding', onClick: ->(action) { action.windows_reload url: json_ui_garage_current_url(selected: 'wedding') }
31
+ end
32
+ end
33
+ ]
34
+
35
+ scroll.spacer height: 8
36
+ scroll.h2 text: 'Standard with drop functionality'
37
+ scroll.spacer height: 4
38
+
39
+ objects = [
40
+ { id: 'folder', name: 'folder', icon: { name: 'folder', color: '#6e6e6e' }, rows: ['subfolder1', 'subfolder2'], dropData: { key: 'folder' } },
41
+ { id: 'folder1', name: 'folder1', icon: { name: 'folder', color: '#6e6e6e' }, rows: ['subfolder1', 'subfolder2'] },
42
+ { id: 'folder2', name: 'folder2', icon: { name: 'folder', color: '#6e6e6e' }, rows: ['subfolder1', 'subfolder2'] },
43
+ ]
44
+
45
+ scroll.panels_column md: { cols: 6 }, childViews: ->(col) do
46
+ col.panels_tree \
47
+ selected: 'folder2',
48
+ width: 300,
49
+ onDrop: ->(action) do
50
+ action.files_upload directUploadUrl: glib_direct_uploads_url, onFinished: ->(saction) do
51
+ saction.http_post url: json_ui_garage_url(path: 'forms/generic_post_all')
52
+ end
53
+ end,
54
+ sections: [
55
+ ->(section) do
56
+ section.header childViews: ->(header) do
57
+ header.h2 text: 'Folder'
58
+ end
59
+
60
+ section.rows objects: objects, builder: ->(row, item, index) do
61
+ row.standard id: item[:id], title: item[:name], rows: item[:rows], dropData: item[:dropData], icon: item[:icon]
62
+ end
63
+ end
64
+ ]
65
+ end
66
+
67
+ scroll.panels_column md: { cols: 4 }, childViews: ->(col) do
68
+ col.panels_ul childViews: ->(li) do
69
+ li.label text: '🍌 Banana', dragData: { item: 'banana' }
70
+ li.label text: '💣 Bomb', dragData: { item: 'bomb' }
71
+ li.label text: '🍈 Melon', dragData: { item: 'melon' }
72
+ li.label text: '🐻 Bear', dragData: { item: 'bear' }
73
+ li.label text: '🍴 Fork and knife', dragData: { item: 'fork_and_knife' }
74
+ end
75
+ end
76
+ end
77
+ end
@@ -82,7 +82,7 @@ page.body childViews: ->(body) do
82
82
  end
83
83
  form.hr width: 'matchParent'
84
84
  check_group_value = ['option3', 'option1']
85
- form.fields_checkGroup width: 'matchParent', name: 'user[check_group]', id: 'check_group', value: check_group_value, validation: validation, childViews: ->(radio) do
85
+ form.fields_checkGroup width: 'matchParent', name: 'user[check_group][]', id: 'check_group', value: check_group_value, validation: validation, childViews: ->(radio) do
86
86
  options.each do |option|
87
87
  radio.fields_check label: option['text'], checkValue: option['value']
88
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -116,6 +116,7 @@ files:
116
116
  - app/helpers/glib/json_ui/action_builder/components.rb
117
117
  - app/helpers/glib/json_ui/action_builder/dialogs.rb
118
118
  - app/helpers/glib/json_ui/action_builder/fields.rb
119
+ - app/helpers/glib/json_ui/action_builder/files.rb
119
120
  - app/helpers/glib/json_ui/action_builder/global_states.rb
120
121
  - app/helpers/glib/json_ui/action_builder/http.rb
121
122
  - app/helpers/glib/json_ui/action_builder/iap.rb
@@ -178,6 +179,7 @@ files:
178
179
  - app/views/json_ui/garage/actions/index.json.jbuilder
179
180
  - app/views/json_ui/garage/actions/partial_update.json.jbuilder
180
181
  - app/views/json_ui/garage/empty.json.jbuilder
182
+ - app/views/json_ui/garage/forms/_alert_post_all_data.json.jbuilder
181
183
  - app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder
182
184
  - app/views/json_ui/garage/forms/_conditional_banner.json.jbuilder
183
185
  - app/views/json_ui/garage/forms/_partial_update_execute.json.jbuilder
@@ -203,6 +205,7 @@ files:
203
205
  - app/views/json_ui/garage/forms/full_page_form.json.jbuilder
204
206
  - app/views/json_ui/garage/forms/full_page_form_dialog.json.jbuilder
205
207
  - app/views/json_ui/garage/forms/generic_post.json.jbuilder
208
+ - app/views/json_ui/garage/forms/generic_post_all.json.jbuilder
206
209
  - app/views/json_ui/garage/forms/index.json.jbuilder
207
210
  - app/views/json_ui/garage/forms/local_request.json.jbuilder
208
211
  - app/views/json_ui/garage/forms/new_rich_text.json.jbuilder
@@ -275,6 +278,7 @@ files:
275
278
  - app/views/json_ui/garage/panels/responsive.json.jbuilder
276
279
  - app/views/json_ui/garage/panels/split.json.jbuilder
277
280
  - app/views/json_ui/garage/panels/timeline.json.jbuilder
281
+ - app/views/json_ui/garage/panels/tree.json.jbuilder
278
282
  - app/views/json_ui/garage/panels/ul.json.jbuilder
279
283
  - app/views/json_ui/garage/panels/vertical.json.jbuilder
280
284
  - app/views/json_ui/garage/panels/web.json.jbuilder