glib-web 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: f28df42b84aa95f3f0b7a62edc043922c794088b
4
- data.tar.gz: 15fcac1a3f3ff687de3282bec0e8cbe6b5cdc633
3
+ metadata.gz: c83072e2914de9cfd87a8186b2cedab3845c0e93
4
+ data.tar.gz: b6bdb92718c15e224f7036eaa8c7097938bb286f
5
5
  SHA512:
6
- metadata.gz: 1c5964f043ccf8d63df46718435865515652e7d484b01decb790bce8eacc49812dc3e348c92fbcd446077869764991f604a97dbc0254128ca2da200007eb145a
7
- data.tar.gz: 68be8065f0f8d9f1b18e142643c7355d91d8e5b6be608958abb5ad30c9e0f0619b1b9d0353c3014c39b5eddf4cd41670cf8cff58c1ceeb23e3ecbf430c3856e9
6
+ metadata.gz: 9dec1a9494b9fa83d8b354609f0fb47b0996be052b3192cb8e286fc7ae6737110a586f8b2764b8b042f02635f0ab8135bfe19891bebc057165543ad5f7e4af51
7
+ data.tar.gz: 0122da0480a928e4b3ad046223fefa581e2c27d1fef0cb36635d62917164b92330ec0e095dd13827a738f2ca88552d63b1ff77167ce2b3b7bfead67d350d67f2
@@ -56,16 +56,6 @@ module Concerns::Application::Json::Ui
56
56
 
57
57
  private
58
58
 
59
- # TODO: Remove. Deprecated
60
- def __json_ui_mdc(hash)
61
- prepend_view_path 'app/views/json_ui/mdc'
62
- if (next_action = hash['onResponse']).is_a?(Hash)
63
- response.body = render_to_string(file: 'renderer.js', layout: false, content_type: 'text/javascript', locals: { response: next_action })
64
- else
65
- response.body = render_to_string(file: 'renderer.html', layout: false, content_type: 'text/html', locals: { page: hash })
66
- end
67
- end
68
-
69
59
  def __json_ui_vue(hash, renderer_path)
70
60
  @__json_ui_orig_page = response.body
71
61
  response.body = render_to_string(file: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash })
@@ -13,6 +13,26 @@ module Glib
13
13
  icon :icon
14
14
  action :onClick
15
15
  bool :disabled
16
+
17
+ def created
18
+ json.type 'button'
19
+ end
20
+ end
21
+
22
+ class Divider < MenuItem
23
+ # Override
24
+ def created
25
+ json.type 'divider'
26
+ end
27
+ end
28
+
29
+ class Label < MenuItem
30
+ string :text
31
+
32
+ # Override
33
+ def created
34
+ json.type 'label'
35
+ end
16
36
  end
17
37
  end
18
38
  end
@@ -50,6 +50,7 @@ module Glib
50
50
  icon :icon
51
51
  string :text
52
52
  action :onClick
53
+ color :color
53
54
  end
54
55
 
55
56
  class Fab < View
@@ -47,8 +47,9 @@ class Glib::JsonUi::ViewBuilder
47
47
  class Hidden < Text
48
48
  end
49
49
 
50
- class CheckGroup < View
51
- string :name
50
+ # class CheckGroup < View
51
+ class CheckGroup < AbstractField
52
+ # string :name
52
53
  views :childViews
53
54
  string :uncheckValue
54
55
  end
@@ -76,12 +77,22 @@ class Glib::JsonUi::ViewBuilder
76
77
  bool :multiple
77
78
  end
78
79
 
80
+ class DynamicSelect < AbstractField
81
+ array :selectedOptions
82
+ string :url
83
+ bool :multiple
84
+
85
+ # Override
86
+ def value(value)
87
+ raise "Use selectedOptions instead (for clarity)"
88
+ end
89
+ end
90
+
79
91
  class RadioGroup < View
80
92
  string :name
81
93
  views :childViews
82
94
  end
83
95
 
84
- # TODO: Support array props
85
96
  class Radio < View
86
97
  string :label
87
98
  string :value
@@ -3,12 +3,21 @@ class Glib::JsonUi::ViewBuilder
3
3
  class Form < View
4
4
  # boolean :local
5
5
 
6
+ def is_association?(prop)
7
+ @model.class.reflect_on_association(prop)
8
+ end
9
+
6
10
  def field_name(prop)
7
- "#{@model_name}[#{prop}]"
11
+ suffix = is_association?(prop) ? '[]' : ''
12
+ "#{@model_name}[#{prop}]#{suffix}"
8
13
  end
9
14
 
10
15
  def field_value(prop)
11
- @model.send(prop)
16
+ if is_association?(prop)
17
+ @model.send(prop).map { |record| record.id }
18
+ else
19
+ @model.send(prop)
20
+ end
12
21
  end
13
22
 
14
23
  def url(url)
@@ -131,5 +140,10 @@ class Glib::JsonUi::ViewBuilder
131
140
  views :childViews
132
141
  end
133
142
 
143
+ class Custom < View
144
+ string :template
145
+ hash :data
146
+ end
147
+
134
148
  end
135
149
  end
@@ -4,17 +4,12 @@ if local_assigns[:top_nav] || json_ui_app_is_web?
4
4
  page.leftDrawer content: ->(drawer) do
5
5
  drawer.header childViews: ->(header) do
6
6
  header.h1 text: 'App', onClick: ->(action) do
7
- # action.windows_open url: json_ui_garage_url
8
7
  action.windows_open url: root_url
9
8
  end
10
9
  end
11
10
 
12
11
  drawer.rows builder: ->(menu) do
13
12
 
14
- menu.button text: 'Menu', onClick: ->(action) do
15
- action.windows_open url: json_ui_garage_url
16
- end
17
-
18
13
  menu.button text: 'Pages', onClick: ->(action) do
19
14
  action.windows_open url: json_ui_garage_url(path: 'pages/index')
20
15
  end
@@ -38,7 +33,14 @@ if local_assigns[:top_nav] || json_ui_app_is_web?
38
33
  menu.button text: 'Actions', onClick: ->(action) do
39
34
  action.windows_open url: json_ui_garage_url(path: 'actions/index')
40
35
  end
36
+
37
+ menu.divider
38
+ menu.label text: 'Misc Menu'
41
39
 
40
+ menu.button text: 'Categories', onClick: ->(action) do
41
+ action.windows_open url: json_ui_garage_url
42
+ end
43
+
42
44
  menu.button text: 'Diagnostics', onClick: ->(action) do
43
45
  action.dialogs_alert message: %{
44
46
  Bundle ID: #{json_ui_app_bundle_id || '<unknown>'}
@@ -0,0 +1,23 @@
1
+ json.title 'Forms'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
7
+ form.h2 text: 'Dynamic Select'
8
+ form.spacer height: 6
9
+
10
+ form.fields_dynamicSelect name: 'user[primary_language]', width: 'matchParent', label: 'Primary Language',
11
+ # value: 'id3',
12
+ selectedOptions: [ { value: 'id3', text: 'Item 3' } ],
13
+ url: json_ui_garage_url(path: 'forms/dynamic_select_data')
14
+
15
+ form.fields_dynamicSelect name: 'user[preferred_languages][]', width: 'matchParent', label: 'Preferred Languages',
16
+ # value: ['id3', 'id5'], multiple: true,
17
+ selectedOptions: [ { value: 'id3', text: 'Item 3' }, { value: 'id5', text: 'Item 5' } ],
18
+ url: json_ui_garage_url(path: 'forms/dynamic_select_data'),
19
+ multiple: true
20
+
21
+ form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+
2
+ sleep 0.5
3
+
4
+ page = params[:page].to_i
5
+ if page < 2
6
+ json.nextPageUrl json_ui_garage_url(path: 'forms/dynamic_select_data', page: page + 1)
7
+ end
8
+
9
+ json.rows do
10
+
11
+ count_per_page = 20
12
+ count_per_page.times do |i|
13
+ json.child! do
14
+ index = page * count_per_page + i
15
+ json.template 'thumbnail'
16
+ json.title "City #{index}"
17
+ json.subtitle "State #{index}"
18
+ json.subsubtitle "Country #{index}"
19
+ json.value "id#{index}"
20
+ json.text "Item #{index}"
21
+ end
22
+ end
23
+
24
+ # languages = {
25
+ # 'zh-HK' => 'Hong Kong',
26
+ # 'zh-TW' => 'Taiwan',
27
+ # 'zh-CN' => 'China',
28
+ # 'ja-JP' => 'Japan',
29
+ # 'ko-KR' => 'Korea',
30
+ # 'ru-RU' => 'Russian',
31
+ # 'en-PH' => 'Philippines'
32
+ # }
33
+ # languages.each do |k, v|
34
+ # json.child! do
35
+ # json.value k
36
+ # json.text v
37
+ # end
38
+ # end
39
+
40
+ end
@@ -13,7 +13,7 @@ json_ui_page json do |page|
13
13
  template.thumbnail title: 'Basic', onClick: ->(action) do
14
14
  action.windows_open url: json_ui_garage_url(path: 'forms/basic')
15
15
  end
16
- template.thumbnail title: 'Pickers (TODO: web, ios, android)', onClick: ->(action) do
16
+ template.thumbnail title: 'Pickers (TODO: ios, android)', onClick: ->(action) do
17
17
  action.windows_open url: json_ui_garage_url(path: 'forms/pickers')
18
18
  end
19
19
  template.thumbnail title: 'Checkboxes', onClick: ->(action) do
@@ -53,6 +53,9 @@ json_ui_page json do |page|
53
53
  template.thumbnail title: 'Rich Text Editor', onClick: ->(action) do
54
54
  action.windows_open url: json_ui_garage_url(path: 'forms/rich_text')
55
55
  end
56
+ template.thumbnail title: 'Dynamic Select', onClick: ->(action) do
57
+ action.windows_open url: json_ui_garage_url(path: 'forms/dynamic_select')
58
+ end
56
59
 
57
60
  end
58
61
  end
@@ -0,0 +1,19 @@
1
+ json.title 'Lists'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.list firstSection: ->(section) do
7
+ section.rows builder: ->(template) do
8
+ template.thumbnail title: 'Click menu (web) or swipe left (Android/iOS)', editButtons: ->(menu) do
9
+ menu.button text: 'Edit', onClick: ->(action) do
10
+ action.dialogs_alert message: 'Perform action'
11
+ end
12
+ menu.button text: 'Delete', onClick: ->(action) do
13
+ action.dialogs_alert message: 'Perform action'
14
+ end
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -8,6 +8,9 @@ json_ui_page json do |page|
8
8
  template.thumbnail title: 'Templating', onClick: ->(action) do
9
9
  action.windows_open url: json_ui_garage_url(path: 'lists/templating')
10
10
  end
11
+ template.thumbnail title: 'Edit Actions', onClick: ->(action) do
12
+ action.windows_open url: json_ui_garage_url(path: 'lists/edit_actions')
13
+ end
11
14
  template.thumbnail title: 'Infinite Scroll', onClick: ->(action) do
12
15
  action.windows_open url: json_ui_garage_url(path: 'lists/infinite_scroll')
13
16
  end
@@ -3,8 +3,8 @@ json.title 'Panels'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.scroll backgroundColor: '#fafafa', padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(scroll) do
7
- scroll.panels_card width: 'matchParent', padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(card) do
6
+ page.scroll backgroundColor: '#fafafa', padding: body_padding, childViews: ->(scroll) do
7
+ scroll.panels_card width: 'matchParent', padding: body_padding, childViews: ->(card) do
8
8
  card.h1 text: 'With Default Layout'
9
9
  card.spacer height: 6
10
10
  card.button text: 'Button1'
@@ -14,7 +14,7 @@ json_ui_page json do |page|
14
14
 
15
15
  scroll.spacer height: 20
16
16
 
17
- scroll.panels_card width: 'matchParent', padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(card) do
17
+ scroll.panels_card width: 'matchParent', padding: body_padding, childViews: ->(card) do
18
18
  card.h1 text: 'With Child Panel'
19
19
  card.spacer height: 6
20
20
  card.panels_horizontal backgroundColor: '#b3bac2', childViews: ->(panel) do
@@ -0,0 +1,10 @@
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: body_padding, childViews: ->(scroll) do
7
+ scroll.panels_custom template: 'thumbnail', data: { title: 'Title' }
8
+ scroll.panels_custom template: 'nonExistentTemplate'
9
+ end
10
+ end
@@ -20,6 +20,9 @@ json_ui_page json do |page|
20
20
  template.thumbnail title: 'Carousel', onClick: ->(action) do
21
21
  action.windows_open url: json_ui_garage_url(path: 'panels/carousel')
22
22
  end
23
+ template.thumbnail title: 'Custom', onClick: ->(action) do
24
+ action.windows_open url: json_ui_garage_url(path: 'panels/custom')
25
+ end
23
26
  end
24
27
 
25
28
  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: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -52,6 +52,8 @@ files:
52
52
  - app/views/json_ui/garage/forms/basic.json.jbuilder
53
53
  - app/views/json_ui/garage/forms/basic_post.json.jbuilder
54
54
  - app/views/json_ui/garage/forms/checkboxes.json.jbuilder
55
+ - app/views/json_ui/garage/forms/dynamic_select.json.jbuilder
56
+ - app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder
55
57
  - app/views/json_ui/garage/forms/file_upload.json.jbuilder
56
58
  - app/views/json_ui/garage/forms/floating_submit.json.jbuilder
57
59
  - app/views/json_ui/garage/forms/generic_post.json.jbuilder
@@ -65,6 +67,7 @@ files:
65
67
  - app/views/json_ui/garage/forms/text_validation.json.jbuilder
66
68
  - app/views/json_ui/garage/home/index.json.jbuilder
67
69
  - app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder
70
+ - app/views/json_ui/garage/lists/edit_actions.json.jbuilder
68
71
  - app/views/json_ui/garage/lists/index.json.jbuilder
69
72
  - app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder
70
73
  - app/views/json_ui/garage/lists/templating.json.jbuilder
@@ -75,6 +78,7 @@ files:
75
78
  - app/views/json_ui/garage/pages/tab_bar.json.jbuilder
76
79
  - app/views/json_ui/garage/panels/card.json.jbuilder
77
80
  - app/views/json_ui/garage/panels/carousel.json.jbuilder
81
+ - app/views/json_ui/garage/panels/custom.json.jbuilder
78
82
  - app/views/json_ui/garage/panels/horizontal.json.jbuilder
79
83
  - app/views/json_ui/garage/panels/index.json.jbuilder
80
84
  - app/views/json_ui/garage/panels/split.json.jbuilder