glib-web 4.39.2 → 4.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -410,7 +410,11 @@ class Glib::JsonUi::ViewBuilder
410
410
  singleton_array :styleClass, :styleClasses
411
411
  array :events
412
412
  views :childViews
413
- string :truncateLine
413
+ # Controls which end(s) of the timeline line to truncate.
414
+ # @see https://vuetifyjs.com/en/api/v-timeline/#props-truncate-line Vuetify Timeline truncateLine
415
+ enum :truncateLine, options: [:start, :end, :both]
416
+ enum :side, options: [:start, :end]
417
+ enum :direction, options: [:horizontal, :vertical]
414
418
  end
415
419
 
416
420
  # deprecated
@@ -5,9 +5,14 @@ end
5
5
 
6
6
  section.rows builder: ->(template) do
7
7
  template.thumbnail title: 'dialogs/alert', onClick: ->(action) do
8
- action.dialogs_alert message: 'This is an alert dialog', onClose: ->(subaction) do
9
- subaction.snackbars_alert message: 'Closed'
10
- end
8
+ action.dialogs_alert \
9
+ message: 'This is an alert dialog',
10
+ onOpen: ->(subaction) do
11
+ subaction.snackbars_alert message: 'Opened'
12
+ end,
13
+ onClose: ->(subaction) do
14
+ subaction.snackbars_alert message: 'Closed'
15
+ end
11
16
  end
12
17
 
13
18
  # markdown = '# h1 Heading' + "\n" +
@@ -60,60 +65,109 @@ section.rows builder: ->(template) do
60
65
  res.skeleton template: 'commentList'
61
66
  end
62
67
  end,
68
+ onOpen: ->(saction) do
69
+ saction.snackbars_alert message: 'Opened'
70
+ end,
63
71
  onClose: ->(saction) do
64
72
  saction.snackbars_alert message: 'dialog closed'
65
73
  end
66
74
  end
67
75
 
68
76
  template.thumbnail title: 'dialogs/open (fullscreen on mobile)', onClick: ->(action) do
69
- action.dialogs_open fullscreen: 'mobile', url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog')
77
+ action.dialogs_open \
78
+ fullscreen: 'mobile',
79
+ url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog'),
80
+ onOpen: ->(saction) do
81
+ saction.snackbars_alert message: 'Opened'
82
+ end
70
83
  end
71
84
 
72
85
  template.thumbnail title: 'dialogs/reload (without url)', onClick: ->(action) do
73
86
  action.runMultiple childActions: ->(saction) do
74
- saction.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
75
- saction.timeouts_set interval: 1000, onTimeout: ->(ssaction) do
76
- ssaction.dialogs_reload onReload: ->(xaction) do
77
- xaction.snackbars_alert message: 'reload!'
87
+ saction.dialogs_open \
88
+ url: json_ui_garage_url(path: 'forms/dialogs_form'),
89
+ onOpen: ->(ssaction) do
90
+ ssaction.snackbars_alert message: 'Opened'
78
91
  end
92
+ saction.timeouts_set interval: 1000, onTimeout: ->(ssaction) do
93
+ ssaction.dialogs_reload \
94
+ onReload: ->(xaction) do
95
+ xaction.snackbars_alert message: 'reload!'
96
+ end
79
97
  end
80
98
  end
81
99
  end
82
100
 
83
101
  if !Rails.env.test? # Prevent test failure
84
102
  template.thumbnail title: 'dialogs/open (page with error)', onClick: ->(action) do
85
- action.dialogs_open url: json_ui_garage_url(path: 'forms/non_existent', mode: 'dialog')
103
+ action.dialogs_open \
104
+ url: json_ui_garage_url(path: 'forms/non_existent', mode: 'dialog'),
105
+ onOpen: ->(saction) do
106
+ saction.snackbars_alert message: 'Opened'
107
+ end
86
108
  end
87
109
  end
88
110
 
89
111
  template.thumbnail title: 'dialogs/open (page with dialogs/close)', onClick: ->(action) do
90
- action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_close', mode: 'dialog')
112
+ action.dialogs_open \
113
+ url: json_ui_garage_url(path: 'forms/dialogs_close', mode: 'dialog'),
114
+ onOpen: ->(saction) do
115
+ saction.snackbars_alert message: 'Opened'
116
+ end
91
117
  end
92
118
 
93
119
  template.thumbnail title: 'dialogs/open (page with dialogs/show with updateExisting)', onClick: ->(action) do
94
- action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_update', mode: 'dialog')
120
+ action.dialogs_open \
121
+ url: json_ui_garage_url(path: 'forms/dialogs_update', mode: 'dialog'),
122
+ onOpen: ->(saction) do
123
+ saction.snackbars_alert message: 'Opened'
124
+ end
95
125
  end
96
126
 
97
127
  template.thumbnail title: 'dialogs/open (page with dialogs/open with updateExisting)', onClick: ->(action) do
98
- action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_update2')
128
+ action.dialogs_open \
129
+ url: json_ui_garage_url(path: 'forms/dialogs_update2'),
130
+ onOpen: ->(saction) do
131
+ saction.snackbars_alert message: 'Opened'
132
+ end
99
133
  end
100
134
 
101
135
  template.thumbnail title: 'dialogs/open (update form inside dialog)', onClick: ->(action) do
102
- action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
136
+ action.dialogs_open \
137
+ url: json_ui_garage_url(path: 'forms/dialogs_form'),
138
+ onOpen: ->(saction) do
139
+ saction.snackbars_alert message: 'Opened'
140
+ end
103
141
  end
104
142
 
105
143
  template.thumbnail title: 'dialogs/open (with filePaster)', onClick: ->(action) do
106
- action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_update3')
144
+ action.dialogs_open \
145
+ url: json_ui_garage_url(path: 'forms/dialogs_update3'),
146
+ onOpen: ->(saction) do
147
+ saction.snackbars_alert message: 'Opened'
148
+ end
107
149
  end
108
150
 
109
151
  template.thumbnail title: 'dialogs/open (update form inside dialog)', onClick: ->(action) do
110
- action.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
152
+ action.dialogs_open \
153
+ url: json_ui_garage_url(path: 'forms/dialogs_form'),
154
+ onOpen: ->(saction) do
155
+ saction.snackbars_alert message: 'Opened'
156
+ end
111
157
  end
112
158
 
113
159
  template.thumbnail title: 'dialogs/closeAll', onClick: ->(action) do
114
160
  action.runMultiple childActions: ->(saction) do
115
- saction.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
116
- saction.dialogs_open url: json_ui_garage_url(path: 'forms/dialogs_form')
161
+ saction.dialogs_open \
162
+ url: json_ui_garage_url(path: 'forms/dialogs_form'),
163
+ onOpen: ->(ssaction) do
164
+ ssaction.snackbars_alert message: 'Opened'
165
+ end
166
+ saction.dialogs_open \
167
+ url: json_ui_garage_url(path: 'forms/dialogs_form'),
168
+ onOpen: ->(ssaction) do
169
+ ssaction.snackbars_alert message: 'Opened'
170
+ end
117
171
  saction.timeouts_set interval: 1000, onTimeout: ->(ssaction) do
118
172
  ssaction.dialogs_closeAll
119
173
  end
@@ -32,9 +32,18 @@ if (update_existing = local_assigns[:update_existing])
32
32
  options[:updateExisting] = update_existing
33
33
  end
34
34
 
35
+ dialog_mode_sym = (local_assigns[:dialog_mode] || :show).to_sym
36
+ dialog_callback_message = dialog_mode_sym == :reload ? 'onReload' : 'onShow'
37
+
38
+ if dialog_mode_sym == :reload
39
+ options[:onReload] = ->(action) { action.snackbars_alert message: dialog_callback_message }
40
+ else
41
+ options[:onShow] = ->(action) { action.snackbars_alert message: dialog_callback_message }
42
+ end
43
+
35
44
  include_form = local_assigns[:include_form]
36
45
 
37
- action.send "dialogs_#{dialog_mode}", **options,
46
+ action.send "dialogs_#{dialog_mode_sym}", **options,
38
47
  onClose: ->(action) { action.snackbars_alert message: 'dialog closed' },
39
48
  content: ->(dialog) do
40
49
  dialog.body padding: glib_json_padding_body, childViews: ->(body) do
@@ -78,6 +78,19 @@ page.form \
78
78
  max: '2021-03-01',
79
79
  value: '2021-11'
80
80
 
81
+ form.spacer height: 8
82
+ form.fields_date \
83
+ name: 'user[formatted_date]',
84
+ width: 'matchParent',
85
+ label: 'Date (formatted)',
86
+ placeholder: 'Select Date'
87
+ form.fields_datetime \
88
+ name: 'user[formatted_date_time]',
89
+ width: 'matchParent',
90
+ label: 'Date Time (formatted)',
91
+ format: 'keyboardDateTime12h',
92
+ placeholder: 'Select Date'
93
+
81
94
  if record.present?
82
95
  form.fields_datetime \
83
96
  prop: :created_at,
@@ -113,4 +113,8 @@ page.form \
113
113
  form.spacer height: 8
114
114
  form.fields_submit text: 'Submit'
115
115
  form.fields_submit text: 'Submit (disable if form invalid)', disableIfFormInvalid: true
116
+ form.spacer height: 8
117
+ form.button styleClass: 'link', text: 'Cancel', onClick: ->(action) do
118
+ action.http_get url: json_ui_garage_url(path: 'forms/index')
119
+ end
116
120
  end
@@ -7,73 +7,103 @@ end
7
7
  page = json_ui_page json
8
8
  render "#{@path_prefix}/nav_menu", json: json, page: page
9
9
 
10
- page.list firstSection: ->(section) do
11
- section.rows builder: ->(template) do
12
- template.thumbnail \
13
- title: 'Click menu (web) or swipe left (Android/iOS)',
14
- subtitle: "Page index: #{page_index}",
15
- leftButtons: ->(menu) do
16
- menu.button \
17
- styleClasses: ['icon', 'text', 'x-small'],
18
- icon: 'check_box',
19
- onClick: ->(subaction) do
20
- subaction.dialogs_alert message: 'Tick/untick'
10
+ page.list(
11
+ firstSection: ->(section) do
12
+ section.rows(
13
+ builder: ->(template) do
14
+ template.thumbnail(
15
+ title: 'Click menu (web) or swipe left (Android/iOS)',
16
+ subtitle: "Page index: #{page_index}",
17
+ leftButtons: ->(menu) do
18
+ menu.button(
19
+ styleClasses: ['icon', 'text', 'x-small'],
20
+ icon: 'check_box',
21
+ onClick: ->(subaction) do
22
+ subaction.dialogs_alert message: 'Tick/untick'
23
+ end
24
+ )
25
+ end,
26
+ rightButtons: ->(menu) do
27
+ menu.button(
28
+ styleClasses: ['icon', 'text', 'x-small'],
29
+ icon: 'share',
30
+ tooltip: { text: 'Share', placement: 'left' },
31
+ onClick: ->(subaction) do
32
+ subaction.dialogs_alert message: 'Share'
33
+ end
34
+ )
35
+ # TODO: Use popoever
36
+ # childButtons: ->(submenu) do
37
+ # submenu.button text: 'Dropdown item 1'
38
+ # submenu.button text: 'Dropdown item 2'
39
+ # submenu.button text: 'Dropdown item 3'
40
+ # end
41
+ menu.button(
42
+ styleClasses: ['icon', 'text', 'x-small'],
43
+ icon: 'open_in_new',
44
+ tooltip: { text: 'Open in new window' },
45
+ onClick: ->(subaction) do
46
+ subaction.dialogs_alert message: 'Open'
47
+ end
48
+ )
49
+ end,
50
+ # editButtons: ->(menu) do
51
+ # menu.button(
52
+ # text: "Edit (ID: #{page_index})",
53
+ # onClick: ->(action) do
54
+ # action.dialogs_alert message: 'Perform Edit action'
55
+ # end
56
+ # )
57
+ # menu.button(
58
+ # text: 'Delete',
59
+ # onClick: ->(action) do
60
+ # action.dialogs_alert message: 'Perform Delete action'
61
+ # end
62
+ # )
63
+ # end,
64
+ onClick: ->(action) do
65
+ action.windows_open url: json_ui_garage_url(path: 'lists/edit_actions', page: page_index + 1)
21
66
  end
22
- end, rightButtons: ->(menu) do
23
- menu.button \
24
- styleClasses: ['icon', 'text', 'x-small'],
25
- icon: 'share',
26
- tooltip: { text: 'Share', placement: 'left' }
27
-
28
- # TODO: Use popoever
29
- # childButtons: ->(submenu) do
30
- # submenu.button text: 'Dropdown item 1'
31
- # submenu.button text: 'Dropdown item 2'
32
- # submenu.button text: 'Dropdown item 3'
33
- # end
34
-
35
- menu.button \
36
- styleClasses: ['icon', 'text', 'x-small'],
37
- icon: 'open_in_new',
38
- tooltip: { text: 'Open in new window' },
39
- onClick: ->(subaction) do
40
- subaction.dialogs_alert message: 'Open'
67
+ )
68
+ template.thumbnail(
69
+ title: 'Long press to get an alert',
70
+ onLongPress: ->(action) do
71
+ action.dialogs_alert message: 'This is an alert'
41
72
  end
42
-
43
- end, editButtons: ->(menu) do
44
- menu.button text: "Edit (ID: #{page_index})", onClick: ->(action) do
45
- action.dialogs_alert message: 'Perform Edit action'
46
- end
47
- menu.button text: 'Delete', onClick: ->(action) do
48
- action.dialogs_alert message: 'Perform Delete action'
49
- end
50
- end, onClick: ->(action) do
51
- action.windows_open url: json_ui_garage_url(path: 'lists/edit_actions', page: page_index + 1)
52
- end
53
-
54
- template.thumbnail title: 'Long press to get an alert', onLongPress: ->(action) do
55
- action.dialogs_alert message: 'This is an alert'
56
- end
57
-
58
- template.thumbnail title: 'Long press to see menu', onLongPress: ->(action) do
59
- action.sheets_select message: 'Context Menu', buttons: ->(menu) do
60
- menu.button icon: 'edit', text: 'Edit', onClick: ->(subaction) do
61
- subaction.dialogs_alert message: 'Perform action'
62
- end
63
- menu.button icon: 'delete', text: 'Delete', onClick: ->(subaction) do
64
- subaction.dialogs_alert message: 'Perform action'
65
- end
73
+ )
74
+ template.thumbnail(
75
+ title: 'Long press to see menu',
76
+ onLongPress: ->(action) do
77
+ action.sheets_select(
78
+ message: 'Context Menu',
79
+ buttons: ->(menu) do
80
+ menu.button(
81
+ icon: 'edit',
82
+ text: 'Edit',
83
+ onClick: ->(subaction) do
84
+ subaction.dialogs_alert message: 'Perform action'
85
+ end
86
+ )
87
+ menu.button(
88
+ icon: 'delete',
89
+ text: 'Delete',
90
+ onClick: ->(subaction) do
91
+ subaction.dialogs_alert message: 'Perform action'
92
+ end
93
+ )
94
+ end
95
+ )
96
+ end
97
+ )
98
+ # template.thumbnail title: 'Long press to see menu', contextButtons: ->(menu) do
99
+ # menu.button text: 'Edit', onClick: ->(action) do
100
+ # action.dialogs_alert message: 'Perform action'
101
+ # end
102
+ # menu.button text: 'Delete', onClick: ->(action) do
103
+ # action.dialogs_alert message: 'Perform action'
104
+ # end
105
+ # end
66
106
  end
67
- end
68
-
69
- # template.thumbnail title: 'Long press to see menu', contextButtons: ->(menu) do
70
- # menu.button text: 'Edit', onClick: ->(action) do
71
- # action.dialogs_alert message: 'Perform action'
72
- # end
73
- # menu.button text: 'Delete', onClick: ->(action) do
74
- # action.dialogs_alert message: 'Perform action'
75
- # end
76
- # end
107
+ )
77
108
  end
78
-
79
- end
109
+ )
@@ -6,61 +6,78 @@ render "#{@path_prefix}/nav_menu", json: json, page: page
6
6
 
7
7
  tab_index = params[:tab].to_i
8
8
 
9
- page.header childViews: ->(header) do
10
- # Allow navigating to another "edit mode" page to test reuse issues.
11
- header.tabBar buttons: ->(menu) do
12
- ['FIRST', 'SECOND'].each_with_index do |text, index|
13
- menu.button \
14
- text: text,
15
- disabled: tab_index == index,
16
- onClick: ->(action) do
17
- action.windows_reload url: json_ui_garage_url(path: 'lists/edit_mode', tab: index)
9
+ page.header(
10
+ childViews: ->(header) do
11
+ # Allow navigating to another "edit mode" page to test reuse issues.
12
+ header.tabBar(
13
+ buttons: ->(menu) do
14
+ ['FIRST', 'SECOND'].each_with_index do |text, index|
15
+ menu.button(
16
+ text: text,
17
+ disabled: tab_index == index,
18
+ onClick: ->(action) do
19
+ action.windows_reload url: json_ui_garage_url(path: 'lists/edit_mode', tab: index)
20
+ end
21
+ )
18
22
  end
19
- end
23
+ end
24
+ )
20
25
  end
21
- end
26
+ )
22
27
 
23
- page.form \
28
+ page.form(
24
29
  width: 'matchParent',
25
30
  url: json_ui_garage_url(path: 'forms/generic_post'),
26
31
  method: 'post',
27
32
  padding: glib_json_padding_body,
28
33
  childViews: ->(form) do
29
- form.panels_list fieldPrefix: 'user[items]', fieldTitleName: 'name', width: 'matchParent', sections: [
30
- ->(section) do
31
- section.header padding: glib_json_padding_list, childViews: ->(header) do
32
-
33
- header.panels_horizontal childViews: ->(horizontal) do
34
- horizontal.fields_check name: 'user[check_all]', label: 'All', checkValue: true
35
-
36
- horizontal.spacer width: 20
37
- # header.fields_text width: 'matchParent', styleClass: 'outlined', name: 'user[new_name]', label: 'Item name'
38
- statuses = [:pending, :active]
39
- horizontal.fields_select \
40
- styleClass: 'outlined',
41
- name: 'user[status]',
42
- width: 'matchParent',
43
- label: 'Status',
44
- options: statuses.map { |status| { value: status, text: status.to_s.humanize } }
45
-
46
- horizontal.spacer width: 20
47
- horizontal.fields_submit text: 'Update'
48
- end
34
+ form.panels_list(
35
+ fieldPrefix: 'user[items]',
36
+ fieldTitleName: 'name',
37
+ width: 'matchParent',
38
+ sections: [
39
+ ->(section) do
40
+ section.header(
41
+ padding: glib_json_padding_list,
42
+ childViews: ->(header) do
43
+ header.panels_horizontal(
44
+ childViews: ->(horizontal) do
45
+ horizontal.fields_check name: 'user[check_all]', label: 'All', checkValue: true
46
+ horizontal.spacer width: 20
47
+ # header.fields_text width: 'matchParent', styleClass: 'outlined', name: 'user[new_name]', label: 'Item name'
48
+ statuses = [:pending, :active]
49
+ horizontal.fields_select(
50
+ styleClass: 'outlined',
51
+ name: 'user[status]',
52
+ width: 'matchParent',
53
+ label: 'Status',
54
+ options: statuses.map { |status| { value: status, text: status.to_s.humanize } }
55
+ )
56
+ horizontal.spacer width: 20
57
+ horizontal.fields_submit text: 'Update'
58
+ end
59
+ )
49
60
  end
50
- section.rows builder: ->(row) do
61
+ )
62
+ section.rows(
63
+ builder: ->(row) do
51
64
  batch_count = 20
52
65
  batch_count.times do |index|
53
66
  id = (batch_count * tab_index) + index
54
67
  row.editable title: "Item #{id}", recordId: "PK_#{id}"
55
68
  end
56
69
  end
57
- end
58
- ], fieldCheckValueIf: {
59
- "==": [
60
- {
61
- "var": 'user[check_all]'
62
- },
63
- true
64
- ]
70
+ )
71
+ end
72
+ ],
73
+ fieldCheckValueIf: {
74
+ "==": [
75
+ {
76
+ "var": 'user[check_all]'
77
+ },
78
+ true
79
+ ]
65
80
  }
81
+ )
66
82
  end
83
+ )