glib-web 0.5.4 → 0.5.5

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: c258b37bbad81871f329c41e5b854b5b6563fb4f
4
- data.tar.gz: 3e8d5f94006a46084869252b667d0c9e405de569
3
+ metadata.gz: 3a631905663a326cc5d4da2aa0be179812d12aae
4
+ data.tar.gz: a167fd02e4db101e5067832225762ba410bc401b
5
5
  SHA512:
6
- metadata.gz: bece2c2bae109009e5b468e9e43cd52591b5c367977a8fec1b623e27876efd28d25a1432bde847943eb310fe62bef9f4e3b1b38ea93924f2767cb9e1a42c4477
7
- data.tar.gz: 756e23d1771b4f1dae8eebe2d4d0f0c4f5397fc8762baac96c2c5bfe7ffc73a6fcab6cad2575d8aae760d84570edffeb456231d70a815918c234a8e5153895bf
6
+ metadata.gz: 0a5094637dbe44532c384bd7e30a49bb3dd5377ef87cee6ea13da3528620aae8f2a43eba21f3077df4530a3356087851dcbd8be150d72a3ff1af70b4b3493afb
7
+ data.tar.gz: 03b85596d99b043700a6818feef54b6e45017e905800358502052a68bdf0d6cb472c64bc9bb352849a9628b587479bfbab41314da1543cb1f92317371639ac07
@@ -0,0 +1,16 @@
1
+ module Glib
2
+ module AppFeatureSupportHelper
3
+ def glib_app_feature_supported?(name, app_version, dictionary)
4
+ device = (app_device_os || :default).to_sym
5
+
6
+ version = dictionary[name.to_sym].try(:[], device)
7
+ except = dictionary[name.to_sym].try(:[], :except).try(:[], device)
8
+
9
+ !version.nil? && (version == :all || glib_app_version_gte(version, app_version)) && (except.nil? || except.to_s != app_version)
10
+ end
11
+
12
+ def glib_app_version_gte(feature_version, app_version)
13
+ app_version.blank? || Gem::Version.new(app_version) >= Gem::Version.new(feature_version)
14
+ end
15
+ end
16
+ end
@@ -104,6 +104,9 @@ class Glib::JsonUi::ViewBuilder
104
104
 
105
105
  class Check < Text
106
106
  string :uncheckValue
107
+ string :checkValue
108
+
109
+ # Where possible, use value instead of this
107
110
  bool :checked
108
111
  end
109
112
 
@@ -123,6 +123,8 @@ class Glib::JsonUi::ViewBuilder
123
123
  hash :nextPage
124
124
  hash :export
125
125
  hash :import
126
+ action :onScrollToTop
127
+ action :onScrollToBottom
126
128
 
127
129
  def firstSection(block)
128
130
  json.sections [1] do
@@ -10,7 +10,8 @@ json_ui_page json do |page|
10
10
  value = [
11
11
  {
12
12
  'question': 'Punctuality',
13
- 'type': 'rating'
13
+ 'type': 'rating',
14
+ 'enabled': '1'
14
15
  },
15
16
  {
16
17
  'question': 'Quality of work',
@@ -21,30 +22,20 @@ json_ui_page json do |page|
21
22
  'type': 'yes_no'
22
23
  }
23
24
  ]
24
- # form.fields_dynamicGroup width: 'matchParent', name: 'user[evaluation]', value: value, groupTitlePrefix: 'Entry', groupTemplateViews: ->(group) do
25
- # group.spacer height: 10
26
- # group.fields_text width: 'matchParent', name: 'question', label: 'Question'
27
- # group.fields_text width: 'matchParent', name: 'type', label: 'Answer type'
28
- # end
29
-
30
- # form.fields_dynamicGroup width: 'matchParent', name: 'user[evaluation]', value: value, group: ->(group) do
31
- # group.titlePrefix 'Entry'
32
- # group.template childViews: ->(template) do
33
- # template.spacer height: 10
34
- # template.fields_text width: 'matchParent', name: 'question', label: 'Question'
35
- # template.fields_text width: 'matchParent', name: 'type', label: 'Answer type'
36
- # end
37
- # end
38
25
 
39
26
  form.fields_dynamicGroup width: 'matchParent', name: 'user[evaluation]', value: value, titlePrefix: 'Entry', content: ->(group) do
40
27
  group.template padding: { left: 32 }, childViews: ->(template) do
41
28
  template.spacer height: 10
42
- template.fields_text width: 'matchParent', name: 'question', label: 'Question'
43
- template.fields_text width: 'matchParent', name: 'type', label: 'Answer type'
29
+ template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question'
30
+ options = [ :rating, :yes_no ]
31
+ template.fields_select width: 'matchParent', name: 'type', label: 'Answer Type', placeholder: 'Answer Type', options: options.map { |o| { text: o.to_s.humanize, value: o } }
32
+ template.fields_check width: 'matchParent', name: 'enabled', label: 'Enable', checkValue: '1'
33
+
34
+ template.spacer height: 14
44
35
  end
45
36
  end
46
37
 
47
38
  form.spacer height: 20
48
- form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
39
+ form.fields_submit text: 'Submit'
49
40
  end
50
41
  end
@@ -8,14 +8,16 @@ json_ui_page json do |page|
8
8
  form.spacer height: 6
9
9
  form.h4 text: 'Gender'
10
10
  form.fields_radioGroup name: 'user[gender]', value: 'F', childViews: ->(group) do
11
+ group.fields_radio value: '', label: 'Unknown'
11
12
  group.fields_radio value: 'M', label: 'Male'
12
13
  group.fields_radio value: 'F', label: 'Female'
13
14
  end
14
15
 
15
16
  form.spacer height: 20
16
17
  form.h2 text: 'Single Checkbox'
17
- form.fields_check name: 'user[age_range]', value: '16+', uncheckValue: '0-16', label: 'I am over 16 (has default value)'
18
- form.fields_check name: 'user[employer]', value: 1, label: 'I am an employer (no default value)'
18
+ form.fields_check name: 'user[age_range]', value: '16+', checkValue: '16+', uncheckValue: '0-16', label: 'I am over 16 (has default value)'
19
+ form.fields_check name: 'user[employer]', checkValue: 1, label: 'I am an employer (no default value)'
20
+ form.fields_check name: 'user[enabled]', checkValue: true, label: 'Enable', styleClass: 'switch', value: 'true'
19
21
 
20
22
  form.spacer height: 20
21
23
  form.h2 text: 'Date/Time'
@@ -36,7 +38,8 @@ json_ui_page json do |page|
36
38
  latitudeField: { name: 'user[latitude]', label: 'Lat', value: -33.8523063, readOnly: true },
37
39
  longitudeField: { name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true }
38
40
 
39
- form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
41
+ form.spacer height: 20
42
+ form.fields_submit text: 'Submit'
40
43
 
41
44
  end
42
45
 
@@ -14,7 +14,7 @@ json.ws({
14
14
  # "topic" => "room:30",
15
15
  # "event" => "comments_updated",
16
16
  "topic" => "links",
17
- "event" => "new_link_added",
17
+ "events" => ["new_link_added"],
18
18
  "header" => {
19
19
  "user_id" => 2,
20
20
  "prev_item_id" => nil,
@@ -23,31 +23,29 @@ json.ws({
23
23
  })
24
24
 
25
25
  page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, paramNameForFormData: 'formData', onSubmit: ->(action) do
26
- # action.dialogs_alert
27
-
28
- json.action "ws/push"
29
- json.topic "links"
30
- json.event "new_link"
31
- json.payload({
32
- "club_id": "2",
33
- "room_id": "30",
34
- "user_id": "2"
35
- # title: "TITLE",
36
- # url: "URL"
37
- })
38
-
39
- # "topic": "room:30",
40
- # "event": "create_comment",
41
- # "payload": {
42
- # "club_id": "2",
43
- # "room_id": "30",
44
- # "user_id": "2"
45
- # }
26
+ json.action "ws/push"
27
+ json.topic "links"
28
+ json.event "new_link"
29
+ json.payload({
30
+ "club_id": "2",
31
+ "room_id": "30",
32
+ "user_id": "2"
33
+ # title: "TITLE",
34
+ # url: "URL"
35
+ })
46
36
 
47
37
  end, childViews: ->(form) do
38
+ form.spacer height: 14
39
+ form.label text: "Message: #{params[:message]}"
40
+ form.spacer height: 14
41
+
48
42
  form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
43
+
44
+ # TODO: Change this to radio for selecting alert vs reload response
49
45
  form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
50
46
 
47
+ form.fields_hidden name: 'baseUrl', width: 'matchParent', value: json_ui_garage_url(path: 'notifications/web_socket')
48
+
51
49
  form.panels_split width: 'matchParent', content: ->(split) do
52
50
  # split.left childViews: ->(left) do
53
51
  # if params[:mode] == 'dialog'
@@ -0,0 +1,39 @@
1
+
2
+ page_index = params[:page].to_i
3
+ next_page = {
4
+ url: json_ui_garage_url(path: 'tables/autoload_all', page: page_index + 1, section_only: 'v1'),
5
+ autoload: 'asNeeded'
6
+ }
7
+
8
+ column_indexes = (1..3)
9
+ if params[:section_only].present?
10
+ json.nextPage next_page if page_index < 3
11
+ json_ui_page json do |page|
12
+ json.sections do
13
+ json.child! do
14
+ render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
15
+ end
16
+ end
17
+ end
18
+ else
19
+ json.title 'Tables'
20
+
21
+ json_ui_page json do |page|
22
+ render "#{@path_prefix}/nav_menu", json: json, page: page
23
+
24
+ page.table nextPage: next_page, firstSection: ->(section) do
25
+ section.header cellViews: ->(header) do
26
+ column_indexes.each do |i|
27
+ header.label text: "Heading#{i}"
28
+ end
29
+ end
30
+
31
+ render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
32
+ end, onScrollToBottom: ->(action) do
33
+ action.snackbars_alert message: 'Scrolled to Bottom'
34
+ end, onScrollToTop: ->(action) do
35
+ action.snackbars_alert message: 'Scrolled to Top'
36
+ end
37
+ end
38
+
39
+ end
@@ -17,6 +17,9 @@ json_ui_page json do |page|
17
17
  template.thumbnail title: 'Autoload All', onClick: ->(action) do
18
18
  action.windows_open url: json_ui_garage_url(path: 'tables/autoload_all')
19
19
  end
20
+ template.thumbnail title: 'Autoload as Needed', onClick: ->(action) do
21
+ action.windows_open url: json_ui_garage_url(path: 'tables/autoload_as_needed')
22
+ end
20
23
  end
21
24
 
22
25
  end
@@ -7,3 +7,4 @@ require_relative './json_crawler/action_crawlers/nav_initiate'
7
7
  require_relative './json_crawler/action_crawlers/windows_open'
8
8
  require_relative './json_crawler/action_crawlers/action_http'
9
9
  require_relative './json_crawler/action_crawlers/forms_submit'
10
+ require_relative './json_crawler/action_crawlers/menu'
@@ -0,0 +1,12 @@
1
+ module Glib
2
+ module JsonCrawler
3
+ class Menu < ActionCrawler
4
+ def initialize(http, args, action)
5
+ super(http)
6
+
7
+ @http.router.log action, nil
8
+ crawl args['buttons']
9
+ end
10
+ end
11
+ end
12
+ end
@@ -3,7 +3,7 @@ module Glib
3
3
  class NavInitiate < ActionCrawler
4
4
  def initialize(http, args, action)
5
5
  super(http)
6
-
6
+
7
7
  @http = http
8
8
  if (json = (@http.get args['url'], action, args.except('url'))) && (left_drawer = json['leftDrawer'])
9
9
  crawl left_drawer['header']&.[]('childViews')
@@ -8,8 +8,8 @@ module Glib
8
8
  VALID_RESPONSE_CODES = [
9
9
  (200..299).to_a,
10
10
  ## Note, the JSON API does not allow redirects
11
- 401, ## UNAUTHORIZED Should be used for not-logged-in
12
- 403, ## FORBIDDEN Should be used for logged-in but not allowed to access
11
+ # 401, ## UNAUTHORIZED Should be used for not-logged-in
12
+ # 403, ## FORBIDDEN Should be used for logged-in but not allowed to access
13
13
  ].flatten
14
14
 
15
15
  def initialize(context, user, router)
@@ -105,6 +105,7 @@ module Glib
105
105
  get redirect_uri.to_s, action, params
106
106
  else
107
107
  response_times << response.headers['X-Runtime'].to_f
108
+
108
109
  @context.assert_includes VALID_RESPONSE_CODES, code, "Expected a valid response but was [#{response.code}] #{Rack::Utils::HTTP_STATUS_CODES[response.code.to_i]}:\n#{url}"
109
110
  if response.media_type == 'application/json'
110
111
  JSON.parse(response.body)
@@ -36,7 +36,6 @@ module Glib
36
36
 
37
37
  if action.present?
38
38
  @depth += 1
39
- # child =
40
39
  case action
41
40
  when 'initiate_navigation'
42
41
  @read_only_actions.add([action, params['url']])
@@ -44,6 +43,8 @@ module Glib
44
43
  when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1', 'windows/open', 'dialogs/open', 'windows/reload'
45
44
  @read_only_actions.add([action, params['url']])
46
45
  JsonCrawler::WindowsOpen.new(http, params, action)
46
+ when 'sheets/select-v1', 'sheets/select'
47
+ JsonCrawler::Menu.new(http, params, action)
47
48
  when 'http/post-v1', 'http/post'
48
49
  JsonCrawler::ActionHttp.new(:post, http, params, action)
49
50
  when 'forms/submit-v1', 'forms/submit'
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.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -73,6 +73,7 @@ files:
73
73
  - app/controllers/concerns/glib/json/ui.rb
74
74
  - app/controllers/concerns/glib/json/validation.rb
75
75
  - app/controllers/glib/home_controller.rb
76
+ - app/helpers/glib/app_feature_support_helper.rb
76
77
  - app/helpers/glib/dynamic_images_helper.rb
77
78
  - app/helpers/glib/dynamic_texts_helper.rb
78
79
  - app/helpers/glib/forms_helper.rb
@@ -173,6 +174,7 @@ files:
173
174
  - app/views/json_ui/garage/services/index.json.jbuilder
174
175
  - app/views/json_ui/garage/tables/_autoload_section.json.jbuilder
175
176
  - app/views/json_ui/garage/tables/autoload_all.json.jbuilder
177
+ - app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder
176
178
  - app/views/json_ui/garage/tables/export_import.json.jbuilder
177
179
  - app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder
178
180
  - app/views/json_ui/garage/tables/index.json.jbuilder
@@ -208,6 +210,7 @@ files:
208
210
  - lib/glib/json_crawler/action_crawler.rb
209
211
  - lib/glib/json_crawler/action_crawlers/action_http.rb
210
212
  - lib/glib/json_crawler/action_crawlers/forms_submit.rb
213
+ - lib/glib/json_crawler/action_crawlers/menu.rb
211
214
  - lib/glib/json_crawler/action_crawlers/nav_initiate.rb
212
215
  - lib/glib/json_crawler/action_crawlers/windows_open.rb
213
216
  - lib/glib/json_crawler/coverage.rb