glib-web 0.4.28 → 0.4.29
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b077889e4be620efc4f9f9dd4ff92bbdb5f1755c
|
4
|
+
data.tar.gz: e05cceb6de9a7310141f60d46894571a7d0901c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86651872a1648412cce138ebe10ee1152bf99e3f996af3ff506bc7db0b1e955f08fa2adea1be6e93b6e2830ae05e70701f54a8ef64c0e953038ab7c74eac7c91
|
7
|
+
data.tar.gz: 11c2d3d86873d06958a70a72afae3ab8694768a264ae1755edfd5997183b082dfe970169dec916b8f0288192832d053bcc56adaf9fd37130e834c69991c88147
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Glib
|
2
|
+
module FormsHelper
|
3
|
+
def glib_form_field_label(model_name, prop, args = {})
|
4
|
+
I18n.t("dt_models.#{model_name}.#{prop}.label", args.merge(default: nil)) || I18n.t("activerecord.attributes.#{model_name}.#{prop}", args)
|
5
|
+
end
|
6
|
+
|
7
|
+
def glib_form_hint_label(model_name, prop, args = {})
|
8
|
+
I18n.t("dt_models.#{model_name}.#{prop}.hint", args.merge(default: nil))
|
9
|
+
end
|
10
|
+
|
11
|
+
def glib_form_placeholder_label(model_name, prop, args = {})
|
12
|
+
I18n.t("dt_models.#{model_name}.#{prop}.placeholder", args.merge(default: nil))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -167,30 +167,51 @@ module Glib
|
|
167
167
|
define_method(propName) do |value|
|
168
168
|
|
169
169
|
if value.is_a?(Hash)
|
170
|
-
|
170
|
+
data = value
|
171
|
+
name = data[:name]
|
172
|
+
else
|
173
|
+
data = {}
|
174
|
+
name = value
|
175
|
+
# data = { material: { name: value } }
|
176
|
+
|
177
|
+
# name = value
|
178
|
+
|
179
|
+
# TODO: deprecated
|
180
|
+
# json.set!(propName) do
|
181
|
+
# json.name name
|
182
|
+
# end
|
183
|
+
end
|
184
|
+
|
185
|
+
json.set!(propName) do
|
186
|
+
data[:material] ||= {}
|
187
|
+
data[:material][:name] = name if name
|
188
|
+
|
189
|
+
material = data[:material]
|
190
|
+
json.material do
|
191
|
+
json.name material[:name]
|
192
|
+
json.size material[:size] if material[:size]
|
193
|
+
end
|
171
194
|
|
172
|
-
|
173
|
-
json.
|
174
|
-
|
195
|
+
if (custom = data[:custom])
|
196
|
+
json.custom do
|
197
|
+
json.name custom[:name]
|
198
|
+
json.size custom[:size] if custom[:size]
|
199
|
+
end
|
200
|
+
end
|
175
201
|
|
176
|
-
|
202
|
+
if (badge = data[:badge])
|
203
|
+
if badge.is_a?(Hash)
|
177
204
|
json.badge badge
|
178
205
|
else
|
179
206
|
json.badge do
|
180
207
|
json.text badge
|
181
208
|
end
|
182
209
|
end
|
183
|
-
|
184
210
|
end
|
185
|
-
else
|
186
|
-
name = value
|
187
211
|
|
188
|
-
json.set!(propName) do
|
189
|
-
json.name name
|
190
|
-
end
|
191
212
|
end
|
192
213
|
|
193
|
-
instance_variable_set("@#{propName}", name) if options[:cache]
|
214
|
+
# instance_variable_set("@#{propName}", name) if options[:cache]
|
194
215
|
|
195
216
|
end
|
196
217
|
end
|
@@ -3,22 +3,25 @@ class Glib::JsonUi::ViewBuilder
|
|
3
3
|
class Form < View
|
4
4
|
# boolean :local
|
5
5
|
|
6
|
-
def
|
6
|
+
def is_array_association?(prop)
|
7
|
+
# # Not all model is ActiveRecord
|
8
|
+
# if @model.class.respond_to?(:reflect_on_association)
|
9
|
+
# return @model.class.reflect_on_association(prop).macro
|
10
|
+
# end
|
11
|
+
# false
|
12
|
+
|
7
13
|
# Not all model is ActiveRecord
|
8
|
-
|
9
|
-
return @model.class.reflect_on_association(prop)
|
10
|
-
end
|
11
|
-
return false
|
14
|
+
@model.class.send(:reflect_on_association, prop)&.macro == :has_many
|
12
15
|
end
|
13
16
|
|
14
17
|
def field_name(prop, multiple)
|
15
|
-
suffix =
|
18
|
+
suffix = is_array_association?(prop) || multiple ? '[]' : ''
|
16
19
|
"#{@model_name}[#{prop}]#{suffix}"
|
17
20
|
end
|
18
21
|
|
19
22
|
def field_value(prop)
|
20
|
-
if
|
21
|
-
@model.send(prop)
|
23
|
+
if is_array_association?(prop)
|
24
|
+
@model.send(prop)&.map { |record| record.id }
|
22
25
|
else
|
23
26
|
@model.send(prop)
|
24
27
|
end
|
@@ -169,6 +172,10 @@ class Glib::JsonUi::ViewBuilder
|
|
169
172
|
string :align
|
170
173
|
end
|
171
174
|
|
175
|
+
class Flow < View
|
176
|
+
views :childViews
|
177
|
+
end
|
178
|
+
|
172
179
|
class Carousel < View
|
173
180
|
views :childViews
|
174
181
|
string :distribution
|
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.4.
|
4
|
+
version: 0.4.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- app/controllers/glib/home_controller.rb
|
76
76
|
- app/helpers/glib/dynamic_images_helper.rb
|
77
77
|
- app/helpers/glib/dynamic_texts_helper.rb
|
78
|
+
- app/helpers/glib/forms_helper.rb
|
78
79
|
- app/helpers/glib/json_ui/abstract_builder.rb
|
79
80
|
- app/helpers/glib/json_ui/action_builder.rb
|
80
81
|
- app/helpers/glib/json_ui/action_builder/dialogs.rb
|