glib-web 4.3.0 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/glib/glib_direct_uploads_controller.rb +1 -1
- data/app/controllers/glib/home_controller.rb +5 -0
- data/app/helpers/glib/enum_helper.rb +5 -6
- data/app/helpers/glib/json_ui/abstract_builder.rb +1 -1
- data/app/helpers/glib/json_ui/action_builder/browsers.rb +12 -0
- data/app/helpers/glib/json_ui/action_builder/fields.rb +6 -0
- data/app/helpers/glib/json_ui/action_builder/files.rb +8 -0
- data/app/helpers/glib/json_ui/action_builder/logics.rb +9 -0
- data/app/helpers/glib/json_ui/action_builder/storage_items.rb +23 -0
- data/app/helpers/glib/json_ui/action_builder.rb +0 -18
- data/app/helpers/glib/json_ui/list_builders.rb +16 -1
- data/app/helpers/glib/json_ui/menu_builder.rb +1 -1
- data/app/helpers/glib/json_ui/page_helper.rb +3 -2
- data/app/helpers/glib/json_ui/view_builder/charts.rb +3 -2
- data/app/helpers/glib/json_ui/view_builder/fields.rb +37 -29
- data/app/helpers/glib/json_ui/view_builder/panels.rb +40 -11
- data/app/helpers/glib/json_ui/view_builder.rb +20 -8
- data/app/models/glib/dummy_job_application.rb +3 -2
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/_alert_post_all_data.json.jbuilder +4 -0
- data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +2 -2
- data/app/views/json_ui/garage/forms/generic_post_all.json.jbuilder +3 -0
- data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -1
- data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +41 -7
- data/app/views/json_ui/garage/forms/submit_on_change.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +13 -8
- data/app/views/json_ui/garage/panels/index.json.jbuilder +4 -0
- data/app/views/json_ui/garage/panels/tree.json.jbuilder +77 -0
- data/app/views/json_ui/garage/test_page/_header.json.jbuilder +14 -0
- data/app/views/json_ui/garage/test_page/auto_validate.json.jbuilder +77 -0
- data/app/views/json_ui/garage/test_page/dialog.json.jbuilder +38 -0
- data/app/views/json_ui/garage/test_page/dialog_open.json.jbuilder +14 -0
- data/app/views/json_ui/garage/test_page/form.json.jbuilder +111 -0
- data/app/views/json_ui/garage/test_page/form_dynamic.json.jbuilder +63 -0
- data/app/views/json_ui/garage/test_page/multiupload.json.jbuilder +65 -0
- data/lib/glib/mailer_tester.rb +1 -1
- metadata +14 -2
- data/app/views/json_ui/garage/test_page/index.json.jbuilder +0 -120
@@ -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
|
110
|
-
|
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
|
@@ -349,12 +372,14 @@ page.form \
|
|
349
372
|
form.spacer height: 20
|
350
373
|
options = [
|
351
374
|
{ text: 'Option 1', value: 'option1' },
|
352
|
-
{ text: 'Option 2', value: 'option2' }
|
375
|
+
{ text: 'Option 2', value: 'option2' },
|
376
|
+
{ text: 'Option 3', value: 'option3' }
|
353
377
|
]
|
354
378
|
form.fields_select name: 'user[loadif7]', width: 'matchParent', label: 'Select "show"', options: options, value: '', onChangeAndLoad: ->(action) do
|
355
379
|
action.runMultiple childActions: ->(saction) do
|
356
380
|
saction.logics_set targetId: 'panel7a', conditionalData: { displayed: { "==": [{ "var": 'user[loadif7]' }, 'option1'] } }
|
357
381
|
saction.logics_set targetId: 'panel7b', conditionalData: { displayed: { "==": [{ "var": 'user[loadif7]' }, 'option2'] } }
|
382
|
+
saction.logics_set targetId: 'panel7c', conditionalData: { displayed: { "==": [{ "var": 'user[loadif7]' }, 'option3'] } }
|
358
383
|
end
|
359
384
|
end
|
360
385
|
|
@@ -363,8 +388,8 @@ page.form \
|
|
363
388
|
styleClass: 'border-2',
|
364
389
|
width: 'matchParent',
|
365
390
|
padding: { top: 8, right: 8, bottom: 8, left: 8 },
|
366
|
-
childViews: ->(
|
367
|
-
|
391
|
+
childViews: ->(vertical) do
|
392
|
+
vertical.fields_text name: 'user[0][loadif_target9]', width: 'matchParent', value: 'Value 7a'
|
368
393
|
end
|
369
394
|
|
370
395
|
form.panels_vertical \
|
@@ -372,8 +397,17 @@ page.form \
|
|
372
397
|
styleClass: 'border-2',
|
373
398
|
width: 'matchParent',
|
374
399
|
padding: { top: 8, right: 8, bottom: 8, left: 8 },
|
375
|
-
childViews: ->(
|
376
|
-
|
400
|
+
childViews: ->(vertical) do
|
401
|
+
vertical.fields_text name: 'user[1][loadif_target9]', width: 'matchParent', value: 'Value 7b'
|
402
|
+
end
|
403
|
+
|
404
|
+
form.panels_vertical \
|
405
|
+
id: 'panel7c',
|
406
|
+
styleClass: 'border-2',
|
407
|
+
width: 'matchParent',
|
408
|
+
padding: { top: 8, right: 8, bottom: 8, left: 8 },
|
409
|
+
childViews: ->(vertical) do
|
410
|
+
vertical.fields_text id: 'target_panel_3', name: 'user[2][loadif_target9]', width: 'matchParent', value: 'Value 7c'
|
377
411
|
end
|
378
412
|
|
379
413
|
form.spacer height: 20
|
@@ -107,7 +107,7 @@ page.scroll childViews: ->(scroll) do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
form.spacer height: 20
|
110
|
-
rules = { fileType: 'image', maxFileSize: 5000,
|
110
|
+
rules = { fileType: 'image', maxFileSize: 5000, maxFileSizeErrorText: 'Too big!' }
|
111
111
|
form.fields_file \
|
112
112
|
name: 'user[photo][]',
|
113
113
|
width: 'matchParent',
|
@@ -15,29 +15,32 @@ page.form \
|
|
15
15
|
name: 'user[name]',
|
16
16
|
width: 'matchParent',
|
17
17
|
label: 'Name'
|
18
|
-
|
18
|
+
form.spacer height: 8
|
19
19
|
|
20
20
|
form.fields_email \
|
21
21
|
name: 'user[email]',
|
22
22
|
width: 'matchParent',
|
23
23
|
label: 'Email'
|
24
|
+
form.spacer height: 8
|
24
25
|
|
25
26
|
form.fields_url \
|
26
27
|
name: 'user[url]',
|
27
28
|
width: 'matchParent',
|
28
29
|
label: 'URL'
|
30
|
+
form.spacer height: 8
|
29
31
|
|
30
32
|
form.fields_number \
|
31
33
|
prop: :age,
|
32
34
|
name: 'user[age]',
|
33
35
|
width: 'matchParent',
|
34
36
|
label: 'Age'
|
35
|
-
|
37
|
+
form.spacer height: 8
|
36
38
|
|
37
39
|
form.fields_phone \
|
38
40
|
name: 'user[phone1]',
|
39
41
|
width: 'matchParent',
|
40
42
|
label: 'Phone field'
|
43
|
+
form.spacer height: 8
|
41
44
|
|
42
45
|
form.fields_phone \
|
43
46
|
name: 'user[phone2]',
|
@@ -45,6 +48,7 @@ page.form \
|
|
45
48
|
label: 'Phone field with Australia as the default country',
|
46
49
|
disableAutoDetect: true, # Disable country auto detect by user IP
|
47
50
|
defaultCountry: 'AU' # ISO Country code, see: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
|
51
|
+
form.spacer height: 8
|
48
52
|
|
49
53
|
form.fields_password \
|
50
54
|
name: 'user[password]',
|
@@ -52,6 +56,7 @@ page.form \
|
|
52
56
|
label: 'Password',
|
53
57
|
hint: 'Should contain at least 6 characters',
|
54
58
|
leftIcon: 'lock'
|
59
|
+
form.spacer height: 8
|
55
60
|
|
56
61
|
form.fields_textarea \
|
57
62
|
prop: :words,
|
@@ -59,6 +64,7 @@ page.form \
|
|
59
64
|
width: 'matchParent',
|
60
65
|
label: 'Textarea with maxLength',
|
61
66
|
maxLength: 1000
|
67
|
+
form.spacer height: 8
|
62
68
|
|
63
69
|
|
64
70
|
options = ['programmer', 'devops', 'designer', 'ceo', 'office_boy'].map { |v| { text: v.humanize, value: v } }
|
@@ -68,11 +74,10 @@ page.form \
|
|
68
74
|
width: 'matchParent',
|
69
75
|
label: 'Position',
|
70
76
|
options: options
|
77
|
+
form.spacer height: 8
|
71
78
|
|
72
79
|
|
73
|
-
form.spacer height: 10
|
74
80
|
form.h4 text: 'Gender'
|
75
|
-
form.spacer height: 4
|
76
81
|
form.fields_radioGroup \
|
77
82
|
name: 'user[gender]',
|
78
83
|
validation: { required: { message: 'Required' } },
|
@@ -82,9 +87,9 @@ page.form \
|
|
82
87
|
group.fields_radio value: 'F', label: 'Female'
|
83
88
|
end
|
84
89
|
|
85
|
-
form.spacer height:
|
90
|
+
form.spacer height: 8
|
91
|
+
|
86
92
|
form.h4 text: 'Skills'
|
87
|
-
form.spacer height: 4
|
88
93
|
form.fields_checkGroup \
|
89
94
|
name: 'user[skills][]',
|
90
95
|
uncheckValue: 1,
|
@@ -95,10 +100,10 @@ page.form \
|
|
95
100
|
group.fields_check checkValue: 4, label: 'Mobile Development'
|
96
101
|
end
|
97
102
|
|
98
|
-
form.spacer height:
|
103
|
+
form.spacer height: 8
|
99
104
|
form.fields_check prop: :accept, label: 'Accept terms & condition', name: 'user[accept]'
|
100
105
|
|
101
|
-
form.spacer height:
|
106
|
+
form.spacer height: 8
|
102
107
|
form.fields_submit text: 'Submit'
|
103
108
|
form.fields_submit text: 'Submit (disable if form invalid)', disableIfFormInvalid: true
|
104
109
|
end
|
@@ -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
|
@@ -0,0 +1,14 @@
|
|
1
|
+
navs = ['form', 'dialog', 'form_dynamic', 'auto_validate', 'multiupload']
|
2
|
+
|
3
|
+
view.panels_flow innerPadding: { bottom: 0 }, styleClass: 'align-right', width: 'matchParent', childViews: ->(res) do
|
4
|
+
navs.each_with_index do |nav, index|
|
5
|
+
if index < navs.size && index != 0
|
6
|
+
res.spacer width: 4
|
7
|
+
res.label text: '|'
|
8
|
+
res.spacer width: 4
|
9
|
+
end
|
10
|
+
res.label text: nav, onClick: ->(action) do
|
11
|
+
action.windows_open url: json_ui_garage_url(path: "test_page/#{nav}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
json.title 'Test Page (Form)'
|
2
|
+
|
3
|
+
page = json_ui_page json
|
4
|
+
|
5
|
+
page.body childViews: ->(body) do
|
6
|
+
render 'json_ui/garage/test_page/header', view: body
|
7
|
+
|
8
|
+
model = Glib::DummyJobApplication.new(
|
9
|
+
name: 'John Deo',
|
10
|
+
accept: '0',
|
11
|
+
words: '',
|
12
|
+
age: 17,
|
13
|
+
position: 'ceo',
|
14
|
+
pet_you_have: 'crocodile'
|
15
|
+
)
|
16
|
+
|
17
|
+
body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
18
|
+
res.h2 text: 'Job Application'
|
19
|
+
res.spacer height: 8
|
20
|
+
res.panels_form \
|
21
|
+
url: json_ui_garage_url(path: 'forms/generic_post'),
|
22
|
+
method: 'post',
|
23
|
+
model: model,
|
24
|
+
autoValidate: true,
|
25
|
+
childViews: ->(form) do
|
26
|
+
form.fields_text prop: :name, label: 'name', name: 'user[name]', width: 'matchParent'
|
27
|
+
form.spacer height: 4
|
28
|
+
|
29
|
+
form.fields_text label: 'say hello', name: 'user[say]', width: 'matchParent', validation: { format: { regex: 'hello', message: 'Say hello!' } }, value: 'sup'
|
30
|
+
form.spacer height: 4
|
31
|
+
|
32
|
+
form.fields_number prop: :age, label: 'age', name: 'user[age]', width: 'matchParent'
|
33
|
+
form.spacer height: 4
|
34
|
+
|
35
|
+
form.fields_number \
|
36
|
+
name: 'user[height]',
|
37
|
+
label: 'height',
|
38
|
+
width: 'matchParent',
|
39
|
+
validation: { numericality: { greater_than_or_equal_to: 155, less_than_or_equal_to: 190, message: { greater_than_or_equal_to: 'Too short', less_than_or_equal_to: 'Too long' } } },
|
40
|
+
value: 150
|
41
|
+
form.spacer height: 4
|
42
|
+
|
43
|
+
form.fields_textarea prop: :words, label: 'words', name: 'user[words]', width: 'matchParent'
|
44
|
+
form.spacer height: 4
|
45
|
+
|
46
|
+
form.fields_textarea label: 'Tell me story', name: 'user[story]', width: 'matchParent', validation: { length: { minimum: 1, message: { too_short: { one: 'Min %{count} word', other: 'Min %{count} words' } } } }
|
47
|
+
form.spacer height: 4
|
48
|
+
|
49
|
+
options = ['programmer', 'devops', 'designer', 'ceo', 'office_boy'].map { |v| { text: v.humanize, value: v } }
|
50
|
+
form.fields_select prop: :position, label: 'postion', name: 'user[position]', width: 'matchParent', options: options
|
51
|
+
form.spacer height: 4
|
52
|
+
|
53
|
+
options2 = ['crocodile', 'cat', 'dog', 'bird', 'shark'].map { |v| { text: v.humanize, value: v } }
|
54
|
+
form.fields_select prop: :pet_you_have, label: 'Pet you have', name: 'user[pet_you_have]', width: 'matchParent', options: options2
|
55
|
+
form.spacer height: 4
|
56
|
+
|
57
|
+
form.label text: 'Decision'
|
58
|
+
options3 = ['choose me', 'dont choose me', 'whatever']
|
59
|
+
form.fields_radioGroup value: 'dont choose me', validation: { exclusion: { in: ['dont choose me'], message: 'dont choose me' } }, childViews: ->(radio) do
|
60
|
+
options3.each do |option|
|
61
|
+
radio.fields_radio label: option, value: option
|
62
|
+
end
|
63
|
+
end
|
64
|
+
form.spacer height: 4
|
65
|
+
|
66
|
+
form.fields_check prop: :accept, label: 'accept', name: 'user[accept]', width: 'matchParent', checkValue: '1'
|
67
|
+
form.spacer height: 4
|
68
|
+
|
69
|
+
form.spacer height: 4
|
70
|
+
form.fields_submit text: 'submit'
|
71
|
+
form.spacer height: 2
|
72
|
+
form.fields_submit text: 'submit (if form valid)', disableIfFormInvalid: true
|
73
|
+
end
|
74
|
+
|
75
|
+
res.spacer height: 16
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
json.title 'Test Page (Form)'
|
4
|
+
|
5
|
+
page = json_ui_page json
|
6
|
+
|
7
|
+
page.body childViews: ->(body) do
|
8
|
+
render 'json_ui/garage/test_page/header', view: body
|
9
|
+
|
10
|
+
body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
11
|
+
res.h2 text: 'Dialog'
|
12
|
+
res.spacer height: 8
|
13
|
+
res.button text: 'Dialog updateExisting', onClick: ->(action) do
|
14
|
+
action.runMultiple childActions: ->(saction) do
|
15
|
+
saction.dialogs_show content: ->(dialog) do
|
16
|
+
dialog.body padding: glib_json_padding_body, childViews: ->(sbody) do
|
17
|
+
sbody.h1 text: 'Hello world'
|
18
|
+
sbody.button text: 'change dialog content', onClick: ->(ssaction) do
|
19
|
+
ssaction.dialogs_show updateExisting: true, disableCloseButton: true, content: ->(sdialog) do
|
20
|
+
sdialog.body padding: glib_json_padding_body, childViews: ->(ssbody) do
|
21
|
+
ssbody.h1 text: 'Hello world (updated)'
|
22
|
+
ssbody.spacer height: 8
|
23
|
+
ssbody.button text: 'close', onClick: ->(xaction) do
|
24
|
+
xaction.dialogs_close
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
res.spacer height: 4
|
34
|
+
res.button text: 'Dialog open', onClick: ->(action) do
|
35
|
+
action.dialogs_open url: json_ui_garage_url(path: 'test_page/dialog_open')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
page = json_ui_page json
|
2
|
+
|
3
|
+
page.body padding: glib_json_padding_body, childViews: ->(body) do
|
4
|
+
body.panels_responsive width: 'matchParent', childViews: ->(res) do
|
5
|
+
res.h2 text: 'Title'
|
6
|
+
res.spacer height: 16
|
7
|
+
res.button text: 'open', onClick: ->(action) do
|
8
|
+
action.dialogs_open url: json_ui_garage_url(path: 'test_page/dialog_open')
|
9
|
+
end
|
10
|
+
res.button text: 'close', onClick: ->(action) do
|
11
|
+
action.dialogs_close
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
json.title 'Test Page (Form)'
|
2
|
+
|
3
|
+
page = json_ui_page json
|
4
|
+
|
5
|
+
page.body childViews: ->(body) do
|
6
|
+
render 'json_ui/garage/test_page/header', view: body
|
7
|
+
|
8
|
+
body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
9
|
+
res.h2 text: 'Form'
|
10
|
+
res.spacer height: 8
|
11
|
+
res.panels_form \
|
12
|
+
url: json_ui_garage_url(path: 'forms/generic_post'),
|
13
|
+
method: 'post',
|
14
|
+
childViews: ->(form) do
|
15
|
+
form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(hori) do
|
16
|
+
hori.button text: 'components/set', onClick: ->(action) do
|
17
|
+
action.runMultiple childActions: ->(saction) do
|
18
|
+
saction.components_set targetId: 'textarea', data: { value: 'The quick brown fox jumps over the lazy dog' }
|
19
|
+
new_options = [{ text: 'Option99', value: 'option99' }]
|
20
|
+
['select', 'chip_group'].each do |id|
|
21
|
+
saction.components_set targetId: id, data: { options: new_options, value: ['option99'] }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
hori.spacer width: 4
|
26
|
+
hori.button text: 'logics/set', onClick: ->(action) do
|
27
|
+
action.logics_set targetId: 'date', conditionalData: { value: { "+": [{ "var": ['user[date]'] }, 60 * 60 * 24 * 3] } }
|
28
|
+
end
|
29
|
+
hori.spacer width: 4
|
30
|
+
hori.button text: 'components/replace', onClick: ->(action) do
|
31
|
+
action.runMultiple childActions: ->(saction) do
|
32
|
+
saction.components_replace targetId: 'radio_group', newView: ->(view) do
|
33
|
+
view.fields_radioGroup value: '', childViews: ->(sview) do
|
34
|
+
sview.fields_radio label: 'Option99', value: 'option99'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
saction.components_replace targetId: 'check_group', newView: ->(view) do
|
39
|
+
view.fields_checkGroup value: '', childViews: ->(sview) do
|
40
|
+
sview.fields_check label: 'Option99', value: nil, checkValue: 'option99'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
hori.spacer width: 4
|
46
|
+
hori.button text: 'hide select', onClick: ->(action) do
|
47
|
+
action.components_set targetId: 'select', data: { displayed: false }
|
48
|
+
end
|
49
|
+
hori.spacer height: 4
|
50
|
+
hori.button text: 'hide jack', onClick: ->(action) do
|
51
|
+
action.runMultiple childActions: ->(saction) do
|
52
|
+
saction.components_set targetId: 'ver', data: { displayed: true }
|
53
|
+
saction.components_set targetId: 'ver1', data: { displayed: false }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
hori.spacer height: 4
|
57
|
+
hori.button text: 'show jack', onClick: ->(action) do
|
58
|
+
action.runMultiple childActions: ->(saction) do
|
59
|
+
saction.components_set targetId: 'ver', data: { displayed: false }
|
60
|
+
saction.components_set targetId: 'ver1', data: { displayed: true }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
form.spacer height: 8
|
66
|
+
form.hr width: 'matchParent'
|
67
|
+
form.spacer height: 8
|
68
|
+
|
69
|
+
validation = { required: { message: 'Required' } }
|
70
|
+
options = ['option1', 'option2', 'option3', 'option4'].map { |option| { 'text'=> option.humanize, 'value' => option } }
|
71
|
+
|
72
|
+
form.fields_date width: 'matchParent', name: 'user[date]', id: 'date', value: Date.new(2024, 7, 24), validation: validation
|
73
|
+
form.hr width: 'matchParent'
|
74
|
+
form.fields_select multiple: true, width: 'matchParent', name: 'user[select][]', id: 'select', options: options, value: ['option1', 'option2'], validation: validation
|
75
|
+
form.hr width: 'matchParent'
|
76
|
+
form.fields_chipGroup width: 'matchParent', name: 'user[chip_group]', id: 'chip_group', options: options, value: ['option2'], validation: validation
|
77
|
+
form.hr width: 'matchParent'
|
78
|
+
form.fields_radioGroup width: 'matchParent', name: 'user[radio_group]', id: 'radio_group', value: 'option3', validation: validation, childViews: ->(radio) do
|
79
|
+
options.each do |option|
|
80
|
+
radio.fields_radio label: option['text'], value: option['value']
|
81
|
+
end
|
82
|
+
end
|
83
|
+
form.hr width: 'matchParent'
|
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
|
86
|
+
options.each do |option|
|
87
|
+
radio.fields_check label: option['text'], checkValue: option['value']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
form.hr width: 'matchParent'
|
91
|
+
form.panels_vertical width: 'matchParent', id: 'ver', childViews: ->(ver) do
|
92
|
+
form.fields_text width: 'matchParent', name: 'user[text]', id: 'text', value: 'John Doe', validation: validation.merge(format: { regex: /Doe\z/, message: 'Must end with Doe' })
|
93
|
+
end
|
94
|
+
form.panels_vertical width: 'matchParent', id: 'ver1', displayed: false, childViews: ->(ver) do
|
95
|
+
form.fields_text width: 'matchParent', name: 'user[text]', value: 'Jack Doe', validation: validation.merge(format: { regex: /Doe\z/, message: 'Must end with Doe' })
|
96
|
+
end
|
97
|
+
|
98
|
+
form.hr width: 'matchParent'
|
99
|
+
|
100
|
+
form.fields_textarea width: 'matchParent', name: 'user[textarea]', id: 'textarea', value: 'Lorem ipsum et dumet bla bla bla...'
|
101
|
+
|
102
|
+
form.hr width: 'matchParent'
|
103
|
+
form.fields_submit text: 'submit'
|
104
|
+
form.spacer height: 2
|
105
|
+
form.fields_submit text: 'submit (if form valid)', disableIfFormInvalid: true
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
res.spacer height: 16
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
json.title 'Test Page (Form)'
|
2
|
+
|
3
|
+
page = json_ui_page json
|
4
|
+
|
5
|
+
page.body childViews: ->(body) do
|
6
|
+
render 'json_ui/garage/test_page/header', view: body
|
7
|
+
|
8
|
+
body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
9
|
+
res.h2 text: 'Form'
|
10
|
+
res.spacer height: 8
|
11
|
+
res.panels_form \
|
12
|
+
url: json_ui_garage_url(path: 'forms/generic_post'),
|
13
|
+
method: 'post',
|
14
|
+
childViews: ->(form) do
|
15
|
+
|
16
|
+
properties = [
|
17
|
+
[
|
18
|
+
{ name: 'question', value: 'Punctuality' },
|
19
|
+
{ name: 'type', value: 'rating' },
|
20
|
+
],
|
21
|
+
[
|
22
|
+
{ name: 'question', value: 'Quality of work' },
|
23
|
+
{ name: 'type', value: 'rating' },
|
24
|
+
{ name: 'enabled', value: '1' },
|
25
|
+
],
|
26
|
+
[
|
27
|
+
{ name: 'question', value: 'Satisfied?' },
|
28
|
+
{ name: 'type', value: 'yes_no' },
|
29
|
+
]
|
30
|
+
]
|
31
|
+
validation = { required: { message: 'Required' } }
|
32
|
+
form.fields_dynamicGroup width: 'matchParent', name: 'user[evaluation]', groupFieldProperties: properties, titlePrefix: 'Entry', content: ->(group) do
|
33
|
+
group.template padding: { left: 32 }, childViews: ->(template) do
|
34
|
+
template.spacer height: 10
|
35
|
+
template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question', validation: validation
|
36
|
+
|
37
|
+
options = [ :rating, :yes_no ]
|
38
|
+
template.fields_select \
|
39
|
+
width: 'matchParent',
|
40
|
+
name: 'type',
|
41
|
+
label: 'Answer Type',
|
42
|
+
placeholder: 'Answer Type',
|
43
|
+
options: options.map { |o| { text: o.to_s.humanize, value: o } },
|
44
|
+
validation: validation
|
45
|
+
|
46
|
+
template.fields_check \
|
47
|
+
width: 'matchParent',
|
48
|
+
name: 'enabled',
|
49
|
+
label: 'Enable',
|
50
|
+
checkValue: '1',
|
51
|
+
showIf: { "==": [{ "var": 'user[evaluation][{{index}}][type]' }, 'rating'] }
|
52
|
+
|
53
|
+
template.spacer height: 14
|
54
|
+
end
|
55
|
+
end
|
56
|
+
form.fields_submit text: 'submit'
|
57
|
+
form.spacer height: 2
|
58
|
+
form.fields_submit text: 'submit (if form valid)', disableIfFormInvalid: true
|
59
|
+
end
|
60
|
+
|
61
|
+
res.spacer height: 16
|
62
|
+
end
|
63
|
+
end
|