glib-web 0.15.1 → 0.15.3

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: 6ee300b7e05299ffaed9427513fada06ef2f248c68f8329bc6d07de7faf947a0
4
- data.tar.gz: 8c11c15ae46e15b7fcfaf5c43744fbe2f872a6b6ea2e185e75f882759473c3db
3
+ metadata.gz: 7c8f181923acfe45b4f5fc8db68d538d457518dec51a7f88591e9dd7f45b5fa2
4
+ data.tar.gz: 619177b9d7e1153eb15230797ba241c1c54c795b979aba1747a195d2310b7295
5
5
  SHA512:
6
- metadata.gz: 4b97228f7f53ea4f1fb86877c08c1cecadf12aaee9536e2ee8488eed58ffff4502c253984c9bc38d0e7df839e46283a5ac5aebbc6b63de63dcc98fa968e77bd6
7
- data.tar.gz: b5a3e5a45469e5486465a7b5f3c12400d15ade17bcee01c237528cda747b404478cbc500347b5442992a1a8ae84efd0895f8fb9eefa4ef91493a340977d0df6a
6
+ metadata.gz: 79b252be8c126c21548f4c4f100800156240026a96756ebbe5d97ff64684150392f3a76f2afaa1fffae0dce5c139026847ae12a836774a9aeeea1612b7b5ba5c
7
+ data.tar.gz: 82712cc9297d5ac4e76f79fe6f21cf42183b901dbbee57a01387c8cfb3e20311829078c600f069710f49db56d7c3c0e804bba25e8bb7a849e59d493cda144922
@@ -26,6 +26,8 @@ class Glib::JsonUi::ActionBuilder
26
26
  class Show < Action
27
27
  panels_builder :content, :body
28
28
  bool :showClose
29
+ string :fullscreen # mobile, always
30
+ length :width
29
31
 
30
32
  # Future plan
31
33
  # panels_builder :content, :body, :footer
@@ -34,12 +36,16 @@ class Glib::JsonUi::ActionBuilder
34
36
  class Open < Action
35
37
  string :url, cache: true
36
38
  bool :showClose
39
+ string :fullscreen
40
+ length :width
37
41
  end
38
42
 
39
43
  class Reload < Action
40
44
  panels_builder :content, :body
41
45
  string :url, cache: true
42
46
  bool :showClose
47
+ string :fullscreen # mobile, always
48
+ length :width
43
49
  end
44
50
 
45
51
  class Close < Action
@@ -224,7 +224,6 @@ module Glib
224
224
  end
225
225
  end
226
226
  end
227
-
228
227
  end
229
228
  end
230
229
  end
@@ -99,6 +99,10 @@ class Glib::JsonUi::ViewBuilder
99
99
  end
100
100
  end
101
101
 
102
+ if page.current_form
103
+ raise 'Nested form is not allowed'
104
+ end
105
+
102
106
  # NOTE: this pattern will not work for views that can be nested. Luckily forms shouldn't be nested anyway.
103
107
  page.current_form = self
104
108
  @childViewsBlock.call(page.view_builder)
@@ -23,6 +23,14 @@ module Glib
23
23
  add_view m, *args
24
24
  end
25
25
 
26
+ def form_if_not_exists(*args)
27
+ if page.current_form
28
+ panels_responsive *args
29
+ else
30
+ panels_form *args
31
+ end
32
+ end
33
+
26
34
  class View < JsonUiElement
27
35
  string :id
28
36
  length :width
@@ -59,7 +59,11 @@ section.rows builder: ->(template) do
59
59
  end
60
60
 
61
61
  template.thumbnail title: 'dialogs/open', onClick: ->(action) do
62
- action.dialogs_open url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog')
62
+ action.dialogs_open width: 950, url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog')
63
+ end
64
+
65
+ template.thumbnail title: 'dialogs/open (fullscreen on mobile)', onClick: ->(action) do
66
+ action.dialogs_open fullscreen: 'mobile', url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog')
63
67
  end
64
68
 
65
69
  template.thumbnail title: 'dialogs/oauth', onClick: ->(action) do
@@ -13,7 +13,7 @@ action.send "dialogs_#{dialog_mode}", showClose: true, content: ->(dialog) do
13
13
  split.left childViews: ->(left) do
14
14
  left.panels_horizontal height: 'matchParent', align: 'middle', childViews: ->(horizontal) do
15
15
  horizontal.label text: 'Open current', onClick: ->(subaction) do
16
- subaction.dialogs_reload url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog_reload')
16
+ subaction.dialogs_reload width: 900, fullscreen: 'mobile', url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog_reload')
17
17
  end
18
18
  end
19
19
  end
@@ -0,0 +1,28 @@
1
+ panel.panels_form width: 'matchParent', childViews: ->(visibility) do
2
+ state = {
3
+ has_content: false
4
+ }
5
+ style_classes ||= nil
6
+ style_class ||= nil
7
+ padding ||= nil
8
+ id ||= nil
9
+
10
+ visibility.banners_select \
11
+ id: id,
12
+ width: 'matchParent',
13
+ styleClass: style_class || (style_classes ? nil : 'warning'),
14
+ message: message,
15
+ padding: padding,
16
+ buttons: ->(menu) do
17
+ yield(menu, state)
18
+ end,
19
+ showIf: {
20
+ "==": [
21
+ {
22
+ "var": 'banner'
23
+ },
24
+ 'show'
25
+ ]
26
+ }
27
+ visibility.fields_hidden name: 'banner', value: state[:has_content] ? 'show' : 'hide'
28
+ end
@@ -0,0 +1,37 @@
1
+ if text.length > min_chars
2
+ panel.form_if_not_exists childViews: ->(form) do
3
+ form.markdown \
4
+ text: text.truncate(min_chars),
5
+ styleClasses: ['line-clamp', "line-clamp-#{max_lines}"],
6
+ showIf: {
7
+ "!=": [
8
+ {
9
+ "var": 'expand'
10
+ },
11
+ 'expand'
12
+ ]
13
+ }
14
+ form.markdown \
15
+ text: text,
16
+ showIf: {
17
+ "==": [
18
+ {
19
+ "var": 'expand'
20
+ },
21
+ 'expand'
22
+ ]
23
+ }
24
+ form.fields_check \
25
+ width: 'matchParent',
26
+ offIcon: 'expand_more',
27
+ onIcon: 'expand_less',
28
+ label: 'Read more',
29
+ onLabel: 'Read less',
30
+ checkValue: 'expand',
31
+ uncheckValue: nil,
32
+ name: 'expand',
33
+ disableDirtyCheck: true
34
+ end
35
+ else
36
+ panel.markdown text: text
37
+ end
@@ -4,18 +4,9 @@ page = json_ui_page json
4
4
 
5
5
  render "#{@path_prefix}/nav_menu", json: json, page: page
6
6
 
7
- page.form url: json_ui_garage_url(path: 'forms/basic_post?id=dialog'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
+ page.form url: json_ui_garage_url(path: 'forms/basic_post', id: :dialog), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
8
8
  form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
9
9
  form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
10
- end
11
-
12
- page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
13
- footer.label text: 'This button will submit the form above because this whole page is wrapped in a giant form.'
14
- footer.spacer height: 6
15
-
16
- footer.panels_split width: 'matchParent', content: ->(content) do
17
- content.right childViews: ->(right) do
18
- right.fields_submit text: 'Submit'
19
- end
20
- end
10
+ form.spacer height: 14
11
+ form.fields_submit text: 'Submit'
21
12
  end
@@ -4,6 +4,7 @@ page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
6
  page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
+ # page.scroll childViews: ->(form) do
7
8
  form.h1 text: 'Text'
8
9
  form.fields_password name: 'user[text1]', width: 'matchParent', label: 'Type "show"', value: ''
9
10
  form.label text: 'Typed', showIf: {
@@ -148,49 +149,20 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
148
149
  ]
149
150
  }
150
151
 
152
+ form.spacer height: 20
153
+ form.h1 text: 'Show more/less text'
154
+ form.label text: ''
155
+ render "#{@path_prefix}/forms/more_less_text",
156
+ panel: form,
157
+ min_chars: 300,
158
+ max_lines: 2,
159
+ text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
160
+
151
161
  form.spacer height: 20
152
162
  form.fields_submit text: 'Submit'
153
163
  form.spacer height: 40
154
164
  end
155
165
 
156
- # if text.length > 100
157
- # inner_column.panels_form local: true, childViews: ->(form) do
158
- # form.markdown \
159
- # text: text,
160
- # styleClasses: ['many-line'],
161
- # showIf: {
162
- # "!=": [
163
- # {
164
- # "var": 'expand[bundle_description]'
165
- # },
166
- # 'expand'
167
- # ]
168
- # }
169
- # form.markdown \
170
- # text: text,
171
- # showIf: {
172
- # "==": [
173
- # {
174
- # "var": 'expand[bundle_description]'
175
- # },
176
- # 'expand'
177
- # ]
178
- # }
179
- # form.fields_check \
180
- # width: 'matchParent',
181
- # offIcon: 'expand_more',
182
- # onIcon: 'expand_less',
183
- # label: 'Read more',
184
- # onLabel: 'Read less',
185
- # checkValue: 'expand',
186
- # uncheckValue: nil,
187
- # name: 'expand[bundle_description]',
188
- # disableDirtyCheck: true
189
- # end
190
- # else
191
- # inner_column.markdown text: text
192
- # end
193
-
194
166
  # panel.panels_form width: 'matchParent', childViews: ->(visibility) do
195
167
  # state = {
196
168
  # has_content: false
@@ -49,6 +49,7 @@ page.scroll childViews: ->(scroll) do
49
49
  childViews: ->(form) do
50
50
  form.h3 text: 'Perform custom actions on submit'
51
51
  form.spacer height: 6
52
+ # See https://stackoverflow.com/questions/4196681/form-not-submitting-when-pressing-enter
52
53
  form.label text: 'This also works when you press ENTER in the following text fields'
53
54
  form.spacer height: 6
54
55
 
@@ -77,6 +77,21 @@ page.scroll childViews: ->(scroll) do
77
77
  end
78
78
  end
79
79
  end
80
+
81
+ form.spacer height: 20
82
+ form.h2 text: 'Text (Asynchronous) -- TODO'
83
+ form.fields_text \
84
+ name: 'user[video_url]',
85
+ width: 'matchParent',
86
+ onChange: ->(action) do
87
+ action.sheets_select message: 'Submit data?', buttons: ->(menu) do
88
+ menu.http_post # TODO
89
+
90
+ # menu.button text: 'Yes, submit', onClick: ->(subaction) do
91
+ # action.forms_submit
92
+ # end
93
+ end
94
+ end
80
95
  end
81
96
 
82
97
  end
@@ -4,7 +4,7 @@ page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
6
  column_indexes = (1..5)
7
- page.table sections: [
7
+ page.table styleClass: 'table--grid', sections: [
8
8
  ->(section) do
9
9
  section.rows builder: ->(row) do
10
10
  row.default colSpans: [3, 2], cellViews: ->(cell) do
@@ -1,17 +1,22 @@
1
+
1
2
  module Glib
2
3
  module JsonCrawler
3
4
  class Router
4
- attr_reader :read_only_actions, :logger, :page_spec
5
+ attr_reader :read_only_actions, :logger
5
6
  attr_accessor :host
6
7
 
7
8
  def log(action, url, response = nil)
8
- @logger +=' ' * @depth + [
9
+ @logger += ' ' * @depth + [
9
10
  action,
10
11
  response.present? ? response.code : nil,
11
12
  url
12
13
  ].compact.join(' :: ') + "\n"
13
14
  end
14
15
 
16
+ def _puts(text)
17
+ puts ' ' * @depth + text
18
+ end
19
+
15
20
  def initialize
16
21
  @depth = -1
17
22
  @logger = ''
@@ -19,7 +24,7 @@ module Glib
19
24
  @read_only_actions = Set.new
20
25
  # default rails's development host
21
26
  @host ||= 'localhost:3000'
22
- @page_spec = nil
27
+ @page_specs = []
23
28
  end
24
29
 
25
30
  def step(http, args)
@@ -95,13 +100,17 @@ module Glib
95
100
  end
96
101
 
97
102
  def begin_page(spec)
98
- @page_spec = spec
99
- @visitor.begin_page spec
103
+ @page_specs << spec
104
+ @visitor.begin_page(spec)
100
105
  end
101
106
 
102
107
  def end_page(spec)
103
- @page_spec = nil
104
- @visitor.end_page spec
108
+ @page_specs.pop
109
+ @visitor.end_page(spec)
110
+ end
111
+
112
+ def page_spec
113
+ @page_specs.last
105
114
  end
106
115
 
107
116
  def allowed?(url)
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.15.1
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -143,6 +143,8 @@ files:
143
143
  - app/views/json_ui/garage/actions/dialogs_oauth_post.json.jbuilder
144
144
  - app/views/json_ui/garage/actions/index.json.jbuilder
145
145
  - app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder
146
+ - app/views/json_ui/garage/forms/_conditional_banner.json.jbuilder
147
+ - app/views/json_ui/garage/forms/_more_less_text.json.jbuilder
146
148
  - app/views/json_ui/garage/forms/basic.json.jbuilder
147
149
  - app/views/json_ui/garage/forms/basic_post.json.jbuilder
148
150
  - app/views/json_ui/garage/forms/checkboxes.json.jbuilder