matestack-ui-core 0.7.2
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +228 -0
- data/Rakefile +34 -0
- data/app/concepts/matestack/ui/core/abbr/abbr.haml +5 -0
- data/app/concepts/matestack/ui/core/abbr/abbr.rb +12 -0
- data/app/concepts/matestack/ui/core/absolute/absolute.haml +3 -0
- data/app/concepts/matestack/ui/core/absolute/absolute.rb +17 -0
- data/app/concepts/matestack/ui/core/action/action.haml +3 -0
- data/app/concepts/matestack/ui/core/action/action.js +49 -0
- data/app/concepts/matestack/ui/core/action/action.rb +52 -0
- data/app/concepts/matestack/ui/core/address/address.haml +5 -0
- data/app/concepts/matestack/ui/core/address/address.rb +5 -0
- data/app/concepts/matestack/ui/core/app/app.haml +4 -0
- data/app/concepts/matestack/ui/core/app/app.js +27 -0
- data/app/concepts/matestack/ui/core/app/app.rb +98 -0
- data/app/concepts/matestack/ui/core/app/store.js +70 -0
- data/app/concepts/matestack/ui/core/article/article.haml +5 -0
- data/app/concepts/matestack/ui/core/article/article.rb +5 -0
- data/app/concepts/matestack/ui/core/async/async.haml +2 -0
- data/app/concepts/matestack/ui/core/async/async.js +76 -0
- data/app/concepts/matestack/ui/core/async/async.rb +12 -0
- data/app/concepts/matestack/ui/core/blockquote/blockquote.haml +5 -0
- data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +11 -0
- data/app/concepts/matestack/ui/core/br/br.haml +5 -0
- data/app/concepts/matestack/ui/core/br/br.rb +5 -0
- data/app/concepts/matestack/ui/core/button/button.haml +5 -0
- data/app/concepts/matestack/ui/core/button/button.rb +11 -0
- data/app/concepts/matestack/ui/core/caption/caption.haml +5 -0
- data/app/concepts/matestack/ui/core/caption/caption.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/content.js +98 -0
- data/app/concepts/matestack/ui/core/collection/content/content.rb +18 -0
- data/app/concepts/matestack/ui/core/collection/content/next/next.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/content/next/next.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/filter/filter.js +48 -0
- data/app/concepts/matestack/ui/core/collection/filter/filter.rb +17 -0
- data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +2 -0
- data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +25 -0
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/helper.rb +113 -0
- data/app/concepts/matestack/ui/core/collection/order/order.js +56 -0
- data/app/concepts/matestack/ui/core/collection/order/order.rb +17 -0
- data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +13 -0
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.haml +3 -0
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +5 -0
- data/app/concepts/matestack/ui/core/component/anonym-dynamic-component.js +10 -0
- data/app/concepts/matestack/ui/core/component/children.haml +2 -0
- data/app/concepts/matestack/ui/core/component/component.js +59 -0
- data/app/concepts/matestack/ui/core/component/dynamic.haml +6 -0
- data/app/concepts/matestack/ui/core/component/dynamic.rb +261 -0
- data/app/concepts/matestack/ui/core/component/dynamic_without_rerender.haml +2 -0
- data/app/concepts/matestack/ui/core/component/response.haml +2 -0
- data/app/concepts/matestack/ui/core/component/response_dynamic.haml +7 -0
- data/app/concepts/matestack/ui/core/component/response_dynamic_without_rerender.haml +3 -0
- data/app/concepts/matestack/ui/core/component/static.haml +1 -0
- data/app/concepts/matestack/ui/core/component/static.rb +16 -0
- data/app/concepts/matestack/ui/core/details/details.haml +3 -0
- data/app/concepts/matestack/ui/core/details/details.rb +5 -0
- data/app/concepts/matestack/ui/core/div/div.haml +3 -0
- data/app/concepts/matestack/ui/core/div/div.rb +5 -0
- data/app/concepts/matestack/ui/core/footer/footer.haml +3 -0
- data/app/concepts/matestack/ui/core/footer/footer.rb +5 -0
- data/app/concepts/matestack/ui/core/form/form.haml +2 -0
- data/app/concepts/matestack/ui/core/form/form.js +136 -0
- data/app/concepts/matestack/ui/core/form/form.rb +71 -0
- data/app/concepts/matestack/ui/core/form/inline/inline.haml +6 -0
- data/app/concepts/matestack/ui/core/form/inline/inline.rb +9 -0
- data/app/concepts/matestack/ui/core/form/input/input.haml +27 -0
- data/app/concepts/matestack/ui/core/form/input/input.rb +74 -0
- data/app/concepts/matestack/ui/core/form/select/select.haml +76 -0
- data/app/concepts/matestack/ui/core/form/select/select.rb +73 -0
- data/app/concepts/matestack/ui/core/form/submit/submit.haml +3 -0
- data/app/concepts/matestack/ui/core/form/submit/submit.rb +9 -0
- data/app/concepts/matestack/ui/core/header/header.haml +3 -0
- data/app/concepts/matestack/ui/core/header/header.rb +5 -0
- data/app/concepts/matestack/ui/core/heading/heading.haml +50 -0
- data/app/concepts/matestack/ui/core/heading/heading.rb +5 -0
- data/app/concepts/matestack/ui/core/hr/hr.haml +1 -0
- data/app/concepts/matestack/ui/core/hr/hr.rb +5 -0
- data/app/concepts/matestack/ui/core/html/html.haml +3 -0
- data/app/concepts/matestack/ui/core/html/html.js +10 -0
- data/app/concepts/matestack/ui/core/html/html.rb +17 -0
- data/app/concepts/matestack/ui/core/icon/icon.haml +5 -0
- data/app/concepts/matestack/ui/core/icon/icon.rb +5 -0
- data/app/concepts/matestack/ui/core/img/img.haml +1 -0
- data/app/concepts/matestack/ui/core/img/img.rb +5 -0
- data/app/concepts/matestack/ui/core/input/input.haml +3 -0
- data/app/concepts/matestack/ui/core/input/input.rb +5 -0
- data/app/concepts/matestack/ui/core/isolate/isolate.haml +2 -0
- data/app/concepts/matestack/ui/core/isolate/isolate.rb +11 -0
- data/app/concepts/matestack/ui/core/js/core.js +30 -0
- data/app/concepts/matestack/ui/core/js/event-hub.js +5 -0
- data/app/concepts/matestack/ui/core/js/helpers/query-params-helper.js +56 -0
- data/app/concepts/matestack/ui/core/label/label.haml +5 -0
- data/app/concepts/matestack/ui/core/label/label.rb +5 -0
- data/app/concepts/matestack/ui/core/li/li.haml +5 -0
- data/app/concepts/matestack/ui/core/li/li.rb +5 -0
- data/app/concepts/matestack/ui/core/link/link.haml +5 -0
- data/app/concepts/matestack/ui/core/link/link.rb +26 -0
- data/app/concepts/matestack/ui/core/main/main.haml +3 -0
- data/app/concepts/matestack/ui/core/main/main.rb +5 -0
- data/app/concepts/matestack/ui/core/nav/nav.haml +3 -0
- data/app/concepts/matestack/ui/core/nav/nav.rb +5 -0
- data/app/concepts/matestack/ui/core/ol/ol.haml +3 -0
- data/app/concepts/matestack/ui/core/ol/ol.rb +5 -0
- data/app/concepts/matestack/ui/core/onclick/onclick.haml +2 -0
- data/app/concepts/matestack/ui/core/onclick/onclick.js +21 -0
- data/app/concepts/matestack/ui/core/onclick/onclick.rb +5 -0
- data/app/concepts/matestack/ui/core/page/content.haml +7 -0
- data/app/concepts/matestack/ui/core/page/content.js +17 -0
- data/app/concepts/matestack/ui/core/page/content.rb +5 -0
- data/app/concepts/matestack/ui/core/page/page.haml +9 -0
- data/app/concepts/matestack/ui/core/page/page.rb +175 -0
- data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +5 -0
- data/app/concepts/matestack/ui/core/paragraph/paragraph.rb +5 -0
- data/app/concepts/matestack/ui/core/partial/partial.haml +2 -0
- data/app/concepts/matestack/ui/core/partial/partial.rb +5 -0
- data/app/concepts/matestack/ui/core/pg/pg.haml +5 -0
- data/app/concepts/matestack/ui/core/pg/pg.rb +5 -0
- data/app/concepts/matestack/ui/core/plain/plain.rb +9 -0
- data/app/concepts/matestack/ui/core/progress/progress.haml +3 -0
- data/app/concepts/matestack/ui/core/progress/progress.rb +14 -0
- data/app/concepts/matestack/ui/core/section/section.haml +3 -0
- data/app/concepts/matestack/ui/core/section/section.rb +5 -0
- data/app/concepts/matestack/ui/core/slot/slot.haml +2 -0
- data/app/concepts/matestack/ui/core/slot/slot.rb +5 -0
- data/app/concepts/matestack/ui/core/small/small.haml +5 -0
- data/app/concepts/matestack/ui/core/small/small.rb +5 -0
- data/app/concepts/matestack/ui/core/span/span.haml +5 -0
- data/app/concepts/matestack/ui/core/span/span.rb +5 -0
- data/app/concepts/matestack/ui/core/strong/strong.haml +5 -0
- data/app/concepts/matestack/ui/core/strong/strong.rb +5 -0
- data/app/concepts/matestack/ui/core/sub/sub.haml +5 -0
- data/app/concepts/matestack/ui/core/sub/sub.rb +5 -0
- data/app/concepts/matestack/ui/core/summary/summary.haml +5 -0
- data/app/concepts/matestack/ui/core/summary/summary.rb +5 -0
- data/app/concepts/matestack/ui/core/table/table.haml +3 -0
- data/app/concepts/matestack/ui/core/table/table.rb +5 -0
- data/app/concepts/matestack/ui/core/tbody/tbody.haml +3 -0
- data/app/concepts/matestack/ui/core/tbody/tbody.rb +5 -0
- data/app/concepts/matestack/ui/core/td/td.haml +5 -0
- data/app/concepts/matestack/ui/core/td/td.rb +5 -0
- data/app/concepts/matestack/ui/core/tfoot/tfoot.haml +3 -0
- data/app/concepts/matestack/ui/core/tfoot/tfoot.rb +5 -0
- data/app/concepts/matestack/ui/core/th/th.haml +5 -0
- data/app/concepts/matestack/ui/core/th/th.rb +5 -0
- data/app/concepts/matestack/ui/core/thead/thead.haml +3 -0
- data/app/concepts/matestack/ui/core/thead/thead.rb +5 -0
- data/app/concepts/matestack/ui/core/time/time.haml +3 -0
- data/app/concepts/matestack/ui/core/time/time.rb +11 -0
- data/app/concepts/matestack/ui/core/tr/tr.haml +3 -0
- data/app/concepts/matestack/ui/core/tr/tr.rb +5 -0
- data/app/concepts/matestack/ui/core/transition/transition.haml +5 -0
- data/app/concepts/matestack/ui/core/transition/transition.js +26 -0
- data/app/concepts/matestack/ui/core/transition/transition.rb +31 -0
- data/app/concepts/matestack/ui/core/ul/ul.haml +3 -0
- data/app/concepts/matestack/ui/core/ul/ul.rb +5 -0
- data/app/concepts/matestack/ui/core/video/video.haml +1 -0
- data/app/concepts/matestack/ui/core/video/video.rb +7 -0
- data/app/concepts/matestack/ui/core/view/view.haml +2 -0
- data/app/concepts/matestack/ui/core/view/view.js +42 -0
- data/app/concepts/matestack/ui/core/view/view.rb +5 -0
- data/app/concepts/matestack/ui/core/youtube/youtube.haml +1 -0
- data/app/concepts/matestack/ui/core/youtube/youtube.rb +26 -0
- data/app/helpers/matestack/ui/core/application_helper.rb +35 -0
- data/app/lib/matestack/ui/app.rb +1 -0
- data/app/lib/matestack/ui/core/app_node.rb +53 -0
- data/app/lib/matestack/ui/core/component_node.rb +73 -0
- data/app/lib/matestack/ui/core/page_node.rb +96 -0
- data/app/lib/matestack/ui/core/to_cell.rb +129 -0
- data/app/lib/matestack/ui/dynamic_component.rb +1 -0
- data/app/lib/matestack/ui/page.rb +1 -0
- data/app/lib/matestack/ui/static_component.rb +1 -0
- data/config/routes.rb +3 -0
- data/lib/generators/matestack_app/USAGE +21 -0
- data/lib/generators/matestack_app/matestack_app_generator.rb +26 -0
- data/lib/generators/matestack_app/templates/matestack_app.erb +26 -0
- data/lib/generators/matestack_app/templates/matestack_app_controller.erb +7 -0
- data/lib/generators/matestack_component/USAGE +20 -0
- data/lib/generators/matestack_component/matestack_component_generator.rb +30 -0
- data/lib/generators/matestack_component/templates/matestack_component.haml.erb +5 -0
- data/lib/generators/matestack_component/templates/matestack_component.js.erb +17 -0
- data/lib/generators/matestack_component/templates/matestack_component.rb.erb +13 -0
- data/lib/generators/matestack_component/templates/matestack_component.scss.erb +1 -0
- data/lib/generators/matestack_page/USAGE +28 -0
- data/lib/generators/matestack_page/matestack_page_generator.rb +41 -0
- data/lib/generators/matestack_page/templates/matestack_page.erb +15 -0
- data/lib/matestack/ui/core.rb +15 -0
- data/lib/matestack/ui/core/engine.rb +19 -0
- data/lib/matestack/ui/core/version.rb +7 -0
- data/lib/tasks/matestack/ui/core_tasks.rake +4 -0
- data/vendor/assets/javascripts/manifest.json +4 -0
- data/vendor/assets/javascripts/matestack-ui-core.js +15309 -0
- data/vendor/assets/javascripts/matestack-ui-core.js.map +1 -0
- metadata +350 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
module Matestack::Ui::Core::Component
|
|
2
|
+
class Dynamic < Trailblazer::Cell
|
|
3
|
+
|
|
4
|
+
include ActionView::Helpers::ActiveModelHelper
|
|
5
|
+
include ActionView::Helpers::ActiveModelInstanceTag
|
|
6
|
+
include ActionView::Helpers::AssetTagHelper
|
|
7
|
+
include ActionView::Helpers::AssetUrlHelper
|
|
8
|
+
include ActionView::Helpers::AtomFeedHelper
|
|
9
|
+
include ActionView::Helpers::CacheHelper
|
|
10
|
+
include ActionView::Helpers::CaptureHelper
|
|
11
|
+
include ActionView::Helpers::CspHelper
|
|
12
|
+
include ActionView::Helpers::CsrfHelper
|
|
13
|
+
include ActionView::Helpers::DateHelper
|
|
14
|
+
include ActionView::Helpers::DebugHelper
|
|
15
|
+
include ActionView::Helpers::FormHelper
|
|
16
|
+
include ActionView::Helpers::FormOptionsHelper
|
|
17
|
+
include ActionView::Helpers::FormTagHelper
|
|
18
|
+
include ActionView::Helpers::JavaScriptHelper
|
|
19
|
+
include ActionView::Helpers::NumberHelper
|
|
20
|
+
include ActionView::Helpers::OutputSafetyHelper
|
|
21
|
+
include ActionView::Helpers::RecordTagHelper
|
|
22
|
+
# include ActionView::Helpers::RenderingHelper
|
|
23
|
+
include ActionView::Helpers::SanitizeHelper
|
|
24
|
+
include ActionView::Helpers::TagHelper
|
|
25
|
+
include ActionView::Helpers::TextHelper
|
|
26
|
+
include ActionView::Helpers::TranslationHelper
|
|
27
|
+
include ActionView::Helpers::UrlHelper
|
|
28
|
+
include ::Cell::Haml
|
|
29
|
+
include Matestack::Ui::Core::ApplicationHelper
|
|
30
|
+
include Matestack::Ui::Core::ToCell
|
|
31
|
+
|
|
32
|
+
view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
|
|
33
|
+
view_paths << "#{::Rails.root}/app/matestack"
|
|
34
|
+
|
|
35
|
+
extend ViewName::Flat
|
|
36
|
+
|
|
37
|
+
def self.prefixes
|
|
38
|
+
_prefixes = super
|
|
39
|
+
modified_prefixes = _prefixes.map do |prefix|
|
|
40
|
+
prefix_parts = prefix.split("/")
|
|
41
|
+
|
|
42
|
+
if prefix_parts.last.include?(self.name.split("::")[-1].downcase)
|
|
43
|
+
prefix_parts[0..-2].join("/")
|
|
44
|
+
else
|
|
45
|
+
prefix
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
return modified_prefixes + _prefixes
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.views_dir
|
|
54
|
+
return ""
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def initialize(model=nil, options={})
|
|
58
|
+
super
|
|
59
|
+
@component_config = options.except(:context, :children, :url_params, :included_config)
|
|
60
|
+
@url_params = options[:url_params].except(:action, :controller, :component_key)
|
|
61
|
+
@component_key = options[:component_key]
|
|
62
|
+
@children_cells = {}
|
|
63
|
+
@controller_context = context[:controller_context]
|
|
64
|
+
@argument = model
|
|
65
|
+
@static = false
|
|
66
|
+
@nodes = {}
|
|
67
|
+
@cells = {}
|
|
68
|
+
@included_config = options[:included_config]
|
|
69
|
+
@cached_params = options[:cached_params]
|
|
70
|
+
@rerender = false
|
|
71
|
+
@options = options
|
|
72
|
+
set_tag_attributes
|
|
73
|
+
setup
|
|
74
|
+
generate_component_name
|
|
75
|
+
generate_children_cells
|
|
76
|
+
validate_options
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def validate_options
|
|
80
|
+
if defined? self.class::REQUIRED_KEYS
|
|
81
|
+
self.class::REQUIRED_KEYS.each do |key|
|
|
82
|
+
raise "required key '#{key}' is missing" if options[key].nil?
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
custom_options_validation
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def custom_options_validation
|
|
89
|
+
true
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def setup
|
|
93
|
+
true
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def show(&block)
|
|
97
|
+
if respond_to? :prepare
|
|
98
|
+
prepare
|
|
99
|
+
end
|
|
100
|
+
if respond_to? :response
|
|
101
|
+
response &block
|
|
102
|
+
if @static
|
|
103
|
+
render :response
|
|
104
|
+
else
|
|
105
|
+
if @rerender
|
|
106
|
+
render :response_dynamic
|
|
107
|
+
else
|
|
108
|
+
render :response_dynamic_without_rerender
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
else
|
|
112
|
+
if @static
|
|
113
|
+
render(view: :static, &block)
|
|
114
|
+
else
|
|
115
|
+
if @rerender
|
|
116
|
+
render(view: :dynamic, &block)
|
|
117
|
+
else
|
|
118
|
+
render(view: :dynamic_without_rerender, &block)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def render_children
|
|
125
|
+
render(view: :children)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def render_content(&block)
|
|
129
|
+
if respond_to? :prepare
|
|
130
|
+
prepare
|
|
131
|
+
end
|
|
132
|
+
if respond_to? :response
|
|
133
|
+
response &block
|
|
134
|
+
render :response
|
|
135
|
+
else
|
|
136
|
+
# render(view: self.class.name.split("::")[-1].downcase.to_sym) do
|
|
137
|
+
render do
|
|
138
|
+
render_children
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def component_id
|
|
144
|
+
options[:id] ||= nil
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def js_action name, arguments
|
|
148
|
+
argumentString = arguments.join('", "')
|
|
149
|
+
argumentString = '"' + argumentString + '"'
|
|
150
|
+
[name, '(', argumentString, ')'].join("")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def navigate_to path
|
|
154
|
+
js_action("navigateTo", [path])
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def components(&block)
|
|
158
|
+
@nodes = Matestack::Ui::Core::ComponentNode.build(self, nil, &block)
|
|
159
|
+
|
|
160
|
+
@nodes.each do |key, node|
|
|
161
|
+
@cells[key] = to_cell(key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def partial(&block)
|
|
166
|
+
return Matestack::Ui::Core::ComponentNode.build(self, nil, &block)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def slot(&block)
|
|
170
|
+
return Matestack::Ui::Core::ComponentNode.build(self, nil, &block)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def get_children
|
|
174
|
+
return options[:children]
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def to_css_class(symbol)
|
|
178
|
+
symbol.to_s.gsub("_", "-")
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def modifiers
|
|
182
|
+
result = []
|
|
183
|
+
return unless defined? self.class::OPTIONS
|
|
184
|
+
self.class::OPTIONS.select{ |modifer_key, modifier_options|
|
|
185
|
+
modifier_options[:css_modifier] == true
|
|
186
|
+
}.each do |modifer_key, modifier_options|
|
|
187
|
+
if !options[modifer_key] == false || modifier_options[:default] == true
|
|
188
|
+
result << "#{to_css_class(self.class::CSSClASS)}--#{to_css_class(modifer_key)}"
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
result.join(" ")
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
private
|
|
195
|
+
|
|
196
|
+
def generate_children_cells
|
|
197
|
+
unless options[:children].nil?
|
|
198
|
+
#needs refactoring --> in some cases, :component_key, :children, :origin_url, :url_params, :included_config get passed into options[:children] which causes errors
|
|
199
|
+
#quickfix: except them from iteration
|
|
200
|
+
options[:children].except(:component_key, :children, :origin_url, :url_params, :included_config).each do |key, node|
|
|
201
|
+
@children_cells[key] = to_cell("#{@component_key}__#{key}", node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def generate_component_name
|
|
207
|
+
name_parts = self.class.name.split("::")
|
|
208
|
+
module_name = name_parts[0]
|
|
209
|
+
if module_name == "Components"
|
|
210
|
+
name_parts[0] = "Custom"
|
|
211
|
+
end
|
|
212
|
+
if name_parts.count > 1
|
|
213
|
+
if name_parts.include?("Cell")
|
|
214
|
+
name = name_parts[0] + name_parts[1]
|
|
215
|
+
if name_parts[0] == name_parts[2]
|
|
216
|
+
name = name_parts[0] + name_parts[1]
|
|
217
|
+
@component_class = name.underscore.gsub("_", "-")
|
|
218
|
+
else
|
|
219
|
+
name = name_parts[0] + name_parts[2] + name_parts[1]
|
|
220
|
+
@component_class = name.underscore.gsub("_", "-")
|
|
221
|
+
end
|
|
222
|
+
else
|
|
223
|
+
if name_parts[-2] == name_parts[-1]
|
|
224
|
+
@component_class = name_parts[0..-2].join("-").downcase
|
|
225
|
+
else
|
|
226
|
+
@component_class = name_parts.join("-").downcase
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
else
|
|
230
|
+
name = name_parts[0]
|
|
231
|
+
@component_class = name.underscore.gsub("_", "-")
|
|
232
|
+
end
|
|
233
|
+
@component_name = @component_class
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def set_tag_attributes
|
|
237
|
+
default_attributes = {
|
|
238
|
+
"id": component_id,
|
|
239
|
+
"class": options[:class]
|
|
240
|
+
}
|
|
241
|
+
unless options[:attributes].nil?
|
|
242
|
+
default_attributes.merge!(options[:attributes])
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
@tag_attributes = default_attributes
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def dynamic_tag_attributes
|
|
249
|
+
attrs = {
|
|
250
|
+
"is": @component_class,
|
|
251
|
+
"ref": component_id,
|
|
252
|
+
":params": @url_params.to_json,
|
|
253
|
+
":component-config": @component_config.to_json,
|
|
254
|
+
"inline-template": true,
|
|
255
|
+
}
|
|
256
|
+
attrs.merge!(options[:attributes]) unless options[:attributes].nil?
|
|
257
|
+
return attrs
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
%component{dynamic_tag_attributes}
|
|
2
|
+
%div{"id": component_id, "class": @component_class}
|
|
3
|
+
%div{"v-if": "asyncTemplate == null"}
|
|
4
|
+
- @cells.each do |key, cell|
|
|
5
|
+
= cell.call(:show)
|
|
6
|
+
%div{"v-if": "asyncTemplate != null"}
|
|
7
|
+
%v-runtime-template{":template":"asyncTemplate"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
= render_content
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Matestack::Ui::Core::Component
|
|
2
|
+
class Static < Matestack::Ui::Core::Component::Dynamic
|
|
3
|
+
|
|
4
|
+
def initialize(model=nil, options={})
|
|
5
|
+
super
|
|
6
|
+
if options[:dynamic]
|
|
7
|
+
@static = false
|
|
8
|
+
@rerender = true
|
|
9
|
+
@component_class = "anonym-dynamic-component"
|
|
10
|
+
else
|
|
11
|
+
@static = true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import Vue from 'vue/dist/vue.esm'
|
|
2
|
+
import Vuex from 'vuex'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
|
|
5
|
+
import matestackEventHub from 'js/event-hub'
|
|
6
|
+
|
|
7
|
+
import componentMixin from 'component/component'
|
|
8
|
+
|
|
9
|
+
const componentDef = {
|
|
10
|
+
mixins: [componentMixin],
|
|
11
|
+
data: function(){
|
|
12
|
+
return {
|
|
13
|
+
data: {},
|
|
14
|
+
showInlineForm: false,
|
|
15
|
+
errors: {}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
methods: {
|
|
19
|
+
initDataKey: function(key, initValue){
|
|
20
|
+
this.data[key] = initValue;
|
|
21
|
+
},
|
|
22
|
+
inputChanged: function(key){
|
|
23
|
+
this.resetErrors(key)
|
|
24
|
+
},
|
|
25
|
+
updateFormValue: function(key, value){
|
|
26
|
+
this.data[key] = value;
|
|
27
|
+
},
|
|
28
|
+
resetErrors: function(key){
|
|
29
|
+
if (this.errors[key]){
|
|
30
|
+
this.errors[key] = null;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
launchInlineForm: function(key, value){
|
|
34
|
+
this.showInlineForm = true;
|
|
35
|
+
this.data[key] = value;
|
|
36
|
+
const self = this;
|
|
37
|
+
setTimeout(function () {
|
|
38
|
+
self.$refs.inlineinput.focus();
|
|
39
|
+
}, 300);
|
|
40
|
+
},
|
|
41
|
+
closeInlineForm: function(){
|
|
42
|
+
this.showInlineForm = false;
|
|
43
|
+
},
|
|
44
|
+
setProps: function(flat, newVal){
|
|
45
|
+
for(var i in flat){
|
|
46
|
+
if((typeof flat[i] === "object") && !(flat[i] instanceof Array)){
|
|
47
|
+
setProps(flat[i], newVal);
|
|
48
|
+
return;
|
|
49
|
+
} else {
|
|
50
|
+
flat[i] = newVal;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
initValues: function(){
|
|
55
|
+
let self = this;
|
|
56
|
+
let data = {}
|
|
57
|
+
for (let key in self.$refs) {
|
|
58
|
+
let initValue = self.$refs[key]["attributes"]["init-value"]
|
|
59
|
+
let valueType = self.$refs[key]["attributes"]["value-type"]
|
|
60
|
+
|
|
61
|
+
if (key.startsWith("input.")){
|
|
62
|
+
if(initValue){
|
|
63
|
+
data[key.replace('input.', '')] = initValue["value"]
|
|
64
|
+
}else{
|
|
65
|
+
data[key.replace('input.', '')] = null
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (key.startsWith("select.")){
|
|
69
|
+
if (key.startsWith("select.multiple.")){
|
|
70
|
+
if(initValue){
|
|
71
|
+
data[key.replace('select.multiple.', '')] = JSON.parse(initValue["value"])
|
|
72
|
+
}else{
|
|
73
|
+
data[key.replace('select.multiple.', '')] = []
|
|
74
|
+
}
|
|
75
|
+
}else{
|
|
76
|
+
if(initValue){
|
|
77
|
+
if(valueType && valueType["value"] == "Integer")
|
|
78
|
+
data[key.replace('select.', '')] = parseInt(initValue["value"])
|
|
79
|
+
else{
|
|
80
|
+
data[key.replace('select.', '')] = initValue["value"]
|
|
81
|
+
}
|
|
82
|
+
}else{
|
|
83
|
+
data[key.replace('select.', '')] = null
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
self.data = data;
|
|
90
|
+
},
|
|
91
|
+
perform: function(){
|
|
92
|
+
const self = this
|
|
93
|
+
let payload = {}
|
|
94
|
+
payload[self.componentConfig["for"]] = self.data
|
|
95
|
+
axios({
|
|
96
|
+
method: self.componentConfig["method"],
|
|
97
|
+
url: self.componentConfig["submit_path"],
|
|
98
|
+
data: payload,
|
|
99
|
+
headers: {
|
|
100
|
+
'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.then(function(response){
|
|
104
|
+
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
|
|
105
|
+
matestackEventHub.$emit(self.componentConfig["success"]["emit"], response.data);
|
|
106
|
+
}
|
|
107
|
+
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["transition"] != undefined && self.$store != undefined) {
|
|
108
|
+
let path = self.componentConfig["success"]["transition"]["path"]
|
|
109
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
|
110
|
+
}
|
|
111
|
+
self.setProps(self.data, null);
|
|
112
|
+
self.initValues()
|
|
113
|
+
self.showInlineForm = false;
|
|
114
|
+
})
|
|
115
|
+
.catch(function(error){
|
|
116
|
+
if(error.response && error.response.data && error.response.data.errors){
|
|
117
|
+
self.errors = error.response.data.errors;
|
|
118
|
+
}
|
|
119
|
+
if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
|
|
120
|
+
matestackEventHub.$emit(self.componentConfig["failure"]["emit"], error.response.data);
|
|
121
|
+
}
|
|
122
|
+
if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["transition"] != undefined && self.$store != undefined) {
|
|
123
|
+
let path = self.componentConfig["failure"]["transition"]["path"]
|
|
124
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
mounted: function(){
|
|
130
|
+
this.initValues()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let component = Vue.component('matestack-ui-core-form', componentDef)
|
|
135
|
+
|
|
136
|
+
export default componentDef
|