glib-web 4.28.0 → 4.30.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.
- checksums.yaml +4 -4
- data/app/helpers/glib/enum_helper.rb +3 -3
- data/app/helpers/glib/json_ui/action_builder/dialogs.rb +2 -0
- data/app/helpers/glib/json_ui/action_builder/sheets.rb +1 -0
- data/app/helpers/glib/json_ui/action_builder/windows.rb +13 -12
- data/app/helpers/glib/json_ui/view_builder.rb +6 -0
- data/app/models/concerns/glib/enum_humanization.rb +8 -8
- data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +8 -2
- data/app/views/json_ui/garage/actions/_sheets.json.jbuilder +9 -3
- data/app/views/json_ui/garage/actions/_windows.json.jbuilder +17 -4
- data/app/views/json_ui/garage/actions/sheet_content.json.jbuilder +1 -0
- data/app/views/json_ui/garage/forms/basic.json.jbuilder +4 -0
- data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +1 -0
- data/app/views/json_ui/garage/home/blank.json.jbuilder +3 -1
- data/app/views/json_ui/garage/home/index.json.jbuilder +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a50b0fa5825fa2970b43e4771a42fbe86d1c49360514ec4c8bae4b5554f1596
|
4
|
+
data.tar.gz: 6fd65894cc019aba9777c6d9ff74d76a3ae40d8fc86e15c4eba73e9aa67822e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64878db62f6fa1e21b896270394a04d3f9fdbab5a35efae8095f2c1f4a4bd8a70dd637f81aeb3716477f0aed6dba5a2eda8a95d70e778f7192674c26a9e38b49
|
7
|
+
data.tar.gz: b117f01edb9d5b3ce19cde4bf8ee53ff4895057d26a973b8ab28a1233a4b3fb452ab4dc9e0105061465307d441bd619afd544b9a8b82f668bf1eb6e2ef05410e
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Glib
|
2
2
|
module EnumHelper
|
3
|
-
def glib_enum_options(clazz, enum_field, keys: nil, hint_suffix: false, hint_subtitle: false)
|
3
|
+
def glib_enum_options(clazz, enum_field, keys: nil, hint_suffix: false, hint_subtitle: false, i18n_args: {})
|
4
4
|
enum_name = enum_field.to_s
|
5
5
|
keys ||= clazz.defined_enums[enum_name].keys
|
6
6
|
keys.map do |i|
|
7
|
-
text = clazz.glib_enum_humanize(enum_field, i, hint_suffix: hint_suffix)
|
7
|
+
text = clazz.glib_enum_humanize(enum_field, i, hint_suffix: hint_suffix, i18n_args: i18n_args)
|
8
8
|
option = { text: text, value: i }
|
9
|
-
if hint_subtitle && (hint = clazz.glib_enum_hint(enum_field, i))
|
9
|
+
if hint_subtitle && (hint = clazz.glib_enum_hint(enum_field, i, i18n_args: i18n_args))
|
10
10
|
option[:subtitle] = hint
|
11
11
|
end
|
12
12
|
option
|
@@ -28,6 +28,7 @@ class Glib::JsonUi::ActionBuilder
|
|
28
28
|
end
|
29
29
|
|
30
30
|
class Open < Action
|
31
|
+
views :loaderViews
|
31
32
|
string :url, cache: true
|
32
33
|
bool :disableCloseButton
|
33
34
|
string :fullscreen
|
@@ -39,6 +40,7 @@ class Glib::JsonUi::ActionBuilder
|
|
39
40
|
end
|
40
41
|
|
41
42
|
class Reload < Action
|
43
|
+
views :loaderViews
|
42
44
|
string :url, cache: true
|
43
45
|
bool :disableCloseButton
|
44
46
|
string :fullscreen # mobile, always
|
@@ -13,20 +13,20 @@ class Glib::JsonUi::ActionBuilder
|
|
13
13
|
string :url, cache: true
|
14
14
|
bool :updateExisting
|
15
15
|
action :onOpen
|
16
|
+
views :loaderViews
|
16
17
|
end
|
17
18
|
|
18
19
|
class OpenWeb < Action
|
19
20
|
# string :url
|
20
21
|
|
21
22
|
def url(value, options = {})
|
22
|
-
other_host = !!options[:other_host]
|
23
23
|
regex = /\/.+\.json|format=json/
|
24
24
|
|
25
|
-
if Rails.env.development? || Rails.env.test? &&
|
25
|
+
if Rails.env.development? || Rails.env.test? && same_host?(value)
|
26
26
|
raise "JSON url detected #{value}" if value.to_s.match?(regex)
|
27
27
|
end
|
28
28
|
|
29
|
-
if value.to_s.match?(regex) && Rails.env.production? &&
|
29
|
+
if value.to_s.match?(regex) && Rails.env.production? && same_host?(value)
|
30
30
|
Rollbar.error("JSON url detected #{value}")
|
31
31
|
# value = value.gsub('.json', '')
|
32
32
|
end
|
@@ -35,16 +35,15 @@ class Glib::JsonUi::ActionBuilder
|
|
35
35
|
json.set! 'url', value
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
private
|
39
|
+
def same_host?(url)
|
40
|
+
host = URI(url.to_s).host
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# return false unless url.to_s.start_with?("/")
|
46
|
-
# !url.to_s.start_with?("//")
|
47
|
-
# end
|
42
|
+
return true if host == page.context.request.host
|
43
|
+
return false unless host.nil?
|
44
|
+
return false unless url.to_s.start_with?('/')
|
45
|
+
!url.to_s.start_with?('//')
|
46
|
+
end
|
48
47
|
end
|
49
48
|
|
50
49
|
class Reload < Action
|
@@ -63,6 +62,7 @@ class Glib::JsonUi::ActionBuilder
|
|
63
62
|
class CloseWithOpen < Action
|
64
63
|
string :url
|
65
64
|
action :onOpen
|
65
|
+
views :loaderViews
|
66
66
|
|
67
67
|
required :url
|
68
68
|
end
|
@@ -70,6 +70,7 @@ class Glib::JsonUi::ActionBuilder
|
|
70
70
|
class CloseAllWithOpen < Action
|
71
71
|
string :url
|
72
72
|
action :onOpen
|
73
|
+
views :loaderViews
|
73
74
|
end
|
74
75
|
|
75
76
|
class Print < Action
|
@@ -11,23 +11,23 @@ module Glib
|
|
11
11
|
extend ClassMethods
|
12
12
|
end
|
13
13
|
|
14
|
-
def glib_enum_humanize(enum_name, default_enum_value = nil, hint_suffix: false)
|
15
|
-
self.class.glib_enum_humanize(enum_name, send(enum_name) || default_enum_value, hint_suffix: hint_suffix)
|
14
|
+
def glib_enum_humanize(enum_name, default_enum_value = nil, hint_suffix: false, i18n_args: {})
|
15
|
+
self.class.glib_enum_humanize(enum_name, send(enum_name) || default_enum_value, hint_suffix: hint_suffix, i18n_args: i18n_args)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
module ClassMethods
|
20
|
-
def glib_enum_humanize(enum_name, enum_value, default_translation = nil, hint_suffix: false)
|
20
|
+
def glib_enum_humanize(enum_name, enum_value, default_translation = nil, hint_suffix: false, i18n_args: {})
|
21
21
|
if enum_value
|
22
22
|
translation_key = "activerecord.attributes.#{model_name.i18n_key}.#{enum_name.to_s.pluralize}.#{enum_value}"
|
23
23
|
|
24
24
|
if default_translation.nil? && (Rails.env.development? || Rails.env.test?)
|
25
|
-
text = I18n.t(translation_key, raise: I18n::MissingTranslationData)
|
25
|
+
text = I18n.t(translation_key, **i18n_args.merge(raise: I18n::MissingTranslationData))
|
26
26
|
else
|
27
|
-
text = I18n.t(translation_key, default: default_translation)
|
27
|
+
text = I18n.t(translation_key, **i18n_args.merge(default: default_translation))
|
28
28
|
end
|
29
29
|
|
30
|
-
if hint_suffix && (hint = glib_enum_hint(enum_name, enum_value))
|
30
|
+
if hint_suffix && (hint = glib_enum_hint(enum_name, enum_value, i18n_args: i18n_args))
|
31
31
|
text += " #{hint}"
|
32
32
|
end
|
33
33
|
|
@@ -35,9 +35,9 @@ module Glib
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def glib_enum_hint(enum_name, enum_value)
|
38
|
+
def glib_enum_hint(enum_name, enum_value, i18n_args: {})
|
39
39
|
i18n_key = self.model_name.i18n_key
|
40
|
-
if (hint = I18n.t("dt_models.#{i18n_key}.#{enum_name.to_s.pluralize}.#{enum_value}.hint")).present?
|
40
|
+
if (hint = I18n.t("dt_models.#{i18n_key}.#{enum_name.to_s.pluralize}.#{enum_value}.hint", **i18n_args)).present?
|
41
41
|
# text += " #{hint}"
|
42
42
|
return hint
|
43
43
|
end
|
@@ -48,12 +48,18 @@ section.rows builder: ->(template) do
|
|
48
48
|
render 'json_ui/garage/actions/dialogs_show', json: json, action: action, dialog_mode: :show, include_form: true
|
49
49
|
end
|
50
50
|
|
51
|
-
template.thumbnail title: 'dialogs/open', onClick: ->(action) do
|
51
|
+
template.thumbnail title: 'dialogs/open with loaderViews', onClick: ->(action) do
|
52
52
|
action.dialogs_open \
|
53
53
|
width: 950,
|
54
|
-
url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog'),
|
54
|
+
url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog', sleep: true),
|
55
55
|
disableCloseButton: true,
|
56
56
|
closeOnBlur: true,
|
57
|
+
loaderViews: ->(view) do
|
58
|
+
view.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
59
|
+
res.skeleton template: 'textArea'
|
60
|
+
res.skeleton template: 'commentList'
|
61
|
+
end
|
62
|
+
end,
|
57
63
|
onClose: ->(saction) do
|
58
64
|
saction.snackbars_alert message: 'dialog closed'
|
59
65
|
end
|
@@ -18,9 +18,15 @@ section.rows builder: ->(template) do
|
|
18
18
|
template.thumbnail title: "sheets/open placement: 'top'", onClick: ->(action) do
|
19
19
|
action.sheets_open placement: 'top', url: json_ui_garage_url(path: 'actions/sheet_content')
|
20
20
|
end
|
21
|
-
template.thumbnail
|
22
|
-
|
23
|
-
|
21
|
+
template.thumbnail \
|
22
|
+
title: "sheets/open placement: 'right' with loaderViews", onClick: ->(action) do
|
23
|
+
action.sheets_open placement: 'right', url: json_ui_garage_url(path: 'actions/sheet_content'), loaderViews: ->(sview) do
|
24
|
+
sview.panels_responsive padding: { all: 16 }, childViews: ->(res) do
|
25
|
+
res.skeleton template: 'textArea'
|
26
|
+
res.skeleton template: 'commentList'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
24
30
|
template.thumbnail title: "sheets/open placement: 'bottom'", onClick: ->(action) do
|
25
31
|
action.sheets_open placement: 'bottom', url: json_ui_garage_url(path: 'actions/sheet_content')
|
26
32
|
end
|
@@ -11,16 +11,29 @@ section.rows builder: ->(template) do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
template.thumbnail title: 'windows/open', onClick: ->(action) do
|
14
|
-
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
14
|
+
action.windows_open url: json_ui_garage_url(path: 'home/blank', sleep: true), loaderViews: ->(view) do
|
15
|
+
view.panels_responsive padding: { all: 16 }, childViews: ->(res) do
|
16
|
+
res.skeleton template: 'bigProgressCircle'
|
17
|
+
end
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
template.thumbnail title: 'windows/open (updateExisting: true)', onClick: ->(action) do
|
18
|
-
action.windows_open updateExisting: true, url: json_ui_garage_url(path: 'home/blank')
|
22
|
+
action.windows_open updateExisting: true, url: json_ui_garage_url(path: 'home/blank', sleep: true), loaderViews: ->(view) do
|
23
|
+
view.panels_responsive padding: { all: 16 }, childViews: ->(res) do
|
24
|
+
res.skeleton template: 'textArea'
|
25
|
+
res.skeleton template: 'commentList'
|
26
|
+
end
|
27
|
+
end
|
19
28
|
end
|
20
29
|
|
21
30
|
template.thumbnail title: 'windows/closeAllWithOpen', onClick: ->(action) do
|
22
|
-
action.windows_closeAllWithOpen url: json_ui_garage_url(path: 'home/index')
|
23
|
-
|
31
|
+
action.windows_closeAllWithOpen url: json_ui_garage_url(path: 'home/index', sleep: true), loaderViews: ->(view) do
|
32
|
+
view.panels_responsive padding: { all: 16 }, childViews: ->(res) do
|
33
|
+
res.skeleton template: 'textArea'
|
34
|
+
res.skeleton template: 'commentList'
|
35
|
+
end
|
36
|
+
end
|
24
37
|
end
|
25
38
|
|
26
39
|
template.thumbnail title: 'windows/openWeb', onClick: ->(action) do
|
@@ -31,6 +31,7 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
|
|
31
31
|
template.spacer height: 10
|
32
32
|
template.fields_hidden name: 'message[error]'
|
33
33
|
template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question'
|
34
|
+
template.fields_richText width: 'matchParent', name: 'description', label: 'Desc', placeholder: 'Desc'
|
34
35
|
|
35
36
|
form.panels_responsive id: 'responsive_{{entryIndex}}', childViews: ->(column) do
|
36
37
|
column.panels_split width: 'matchParent', content: ->(split) do
|