matestack-ui-core 0.7.0 → 0.7.4
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/README.md +16 -12
- data/Rakefile +32 -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/action/action.js +51 -29
- data/app/concepts/matestack/ui/core/action/action.rb +3 -0
- data/app/concepts/matestack/ui/core/actionview/dynamic.haml +6 -0
- data/app/concepts/matestack/ui/core/actionview/dynamic.rb +28 -0
- data/app/concepts/matestack/ui/core/actionview/static.haml +1 -0
- data/app/concepts/matestack/ui/core/actionview/static.rb +28 -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.js +7 -4
- data/app/concepts/matestack/ui/core/app/app.rb +3 -28
- data/app/concepts/matestack/ui/core/app/location.js +10 -0
- data/app/concepts/matestack/ui/core/app/store.js +1 -2
- data/app/concepts/matestack/ui/core/area/area.haml +1 -0
- data/app/concepts/matestack/ui/core/area/area.rb +18 -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/aside/aside.haml +3 -0
- data/app/concepts/matestack/ui/core/aside/aside.rb +5 -0
- data/app/concepts/matestack/ui/core/async/async.haml +1 -1
- data/app/concepts/matestack/ui/core/async/async.js +24 -5
- data/app/concepts/matestack/ui/core/async/async.rb +8 -6
- data/app/concepts/matestack/ui/core/b/b.haml +5 -0
- data/app/concepts/matestack/ui/core/b/b.rb +5 -0
- data/app/concepts/matestack/ui/core/bdi/bdi.haml +5 -0
- data/app/concepts/matestack/ui/core/bdi/bdi.rb +4 -0
- data/app/concepts/matestack/ui/core/bdo/bdo.haml +5 -0
- data/app/concepts/matestack/ui/core/bdo/bdo.rb +11 -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/button/button.haml +4 -6
- data/app/concepts/matestack/ui/core/button/button.rb +6 -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/cite/cite.haml +5 -0
- data/app/concepts/matestack/ui/core/cite/cite.rb +5 -0
- data/app/concepts/matestack/ui/core/code/code.haml +5 -0
- data/app/concepts/matestack/ui/core/code/code.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 +1 -1
- data/app/concepts/matestack/ui/core/component/component.js +3 -4
- data/app/concepts/matestack/ui/core/component/dynamic.rb +38 -33
- data/app/concepts/matestack/ui/core/data/data.haml +5 -0
- data/app/concepts/matestack/ui/core/data/data.rb +9 -0
- data/app/concepts/matestack/ui/core/dd/dd.haml +5 -0
- data/app/concepts/matestack/ui/core/dd/dd.rb +5 -0
- data/app/concepts/matestack/ui/core/del/del.haml +5 -0
- data/app/concepts/matestack/ui/core/del/del.rb +4 -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/dfn/dfn.haml +5 -0
- data/app/concepts/matestack/ui/core/dfn/dfn.rb +6 -0
- data/app/concepts/matestack/ui/core/dialog/dialog.haml +5 -0
- data/app/concepts/matestack/ui/core/dialog/dialog.rb +9 -0
- data/app/concepts/matestack/ui/core/div/div.rb +0 -1
- data/app/concepts/matestack/ui/core/dl/dl.haml +5 -0
- data/app/concepts/matestack/ui/core/dl/dl.rb +5 -0
- data/app/concepts/matestack/ui/core/dt/dt.haml +5 -0
- data/app/concepts/matestack/ui/core/dt/dt.rb +5 -0
- data/app/concepts/matestack/ui/core/em/em.haml +5 -0
- data/app/concepts/matestack/ui/core/em/em.rb +5 -0
- data/app/concepts/matestack/ui/core/fieldset/fieldset.haml +5 -0
- data/app/concepts/matestack/ui/core/fieldset/fieldset.rb +9 -0
- data/app/concepts/matestack/ui/core/figure/figure.haml +3 -0
- data/app/concepts/matestack/ui/core/figure/figure.rb +5 -0
- data/app/concepts/matestack/ui/core/form/form.js +42 -6
- data/app/concepts/matestack/ui/core/form/input/input.haml +4 -6
- data/app/concepts/matestack/ui/core/form/select/select.haml +10 -6
- data/app/concepts/matestack/ui/core/html/html.js +1 -1
- data/app/concepts/matestack/ui/core/icon/icon.haml +2 -3
- data/app/concepts/matestack/ui/core/iframe/iframe.haml +5 -0
- data/app/concepts/matestack/ui/core/iframe/iframe.rb +14 -0
- data/app/concepts/matestack/ui/core/img/img.haml +1 -1
- data/app/concepts/matestack/ui/core/img/img.rb +10 -0
- data/app/concepts/matestack/ui/core/ins/ins.haml +5 -0
- data/app/concepts/matestack/ui/core/ins/ins.rb +10 -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 +15 -12
- data/app/concepts/matestack/ui/core/js/helpers/query-params-helper.js +56 -0
- data/app/concepts/matestack/ui/core/kbd/kbd.haml +5 -0
- data/app/concepts/matestack/ui/core/kbd/kbd.rb +4 -0
- data/app/concepts/matestack/ui/core/label/label.haml +4 -6
- data/app/concepts/matestack/ui/core/label/label.rb +6 -1
- data/app/concepts/matestack/ui/core/legend/legend.haml +5 -0
- data/app/concepts/matestack/ui/core/legend/legend.rb +5 -0
- data/app/concepts/matestack/ui/core/li/li.haml +2 -3
- data/app/concepts/matestack/ui/core/link/link.haml +5 -6
- data/app/concepts/matestack/ui/core/link/link.rb +5 -2
- data/app/concepts/matestack/ui/core/map/map.haml +3 -0
- data/app/concepts/matestack/ui/core/map/map.rb +11 -0
- data/app/concepts/matestack/ui/core/mark/mark.haml +5 -0
- data/app/concepts/matestack/ui/core/mark/mark.rb +4 -0
- data/app/concepts/matestack/ui/core/meter/meter.haml +4 -0
- data/app/concepts/matestack/ui/core/meter/meter.rb +14 -0
- data/app/concepts/matestack/ui/core/noscript/noscript.haml +5 -0
- data/app/concepts/matestack/ui/core/noscript/noscript.rb +5 -0
- data/app/concepts/matestack/ui/core/object/object.haml +1 -0
- data/app/concepts/matestack/ui/core/object/object.rb +15 -0
- data/app/concepts/matestack/ui/core/onclick/onclick.haml +1 -1
- data/app/concepts/matestack/ui/core/onclick/onclick.js +2 -3
- data/app/concepts/matestack/ui/core/onclick/onclick.rb +1 -2
- data/app/concepts/matestack/ui/core/optgroup/optgroup.haml +3 -0
- data/app/concepts/matestack/ui/core/optgroup/optgroup.rb +10 -0
- data/app/concepts/matestack/ui/core/option/option.haml +5 -0
- data/app/concepts/matestack/ui/core/option/option.rb +12 -0
- data/app/concepts/matestack/ui/core/output/output.haml +5 -0
- data/app/concepts/matestack/ui/core/output/output.rb +11 -0
- data/app/concepts/matestack/ui/core/page/content.js +1 -1
- data/app/concepts/matestack/ui/core/page/page.rb +63 -23
- data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +4 -7
- data/app/concepts/matestack/ui/core/param/param.haml +1 -0
- data/app/concepts/matestack/ui/core/param/param.rb +10 -0
- data/app/concepts/matestack/ui/core/pg/pg.haml +4 -7
- data/app/concepts/matestack/ui/core/picture/picture.haml +3 -0
- data/app/concepts/matestack/ui/core/picture/picture.rb +4 -0
- data/app/concepts/matestack/ui/core/plain/plain.rb +1 -2
- data/app/concepts/matestack/ui/core/pre/pre.haml +5 -0
- data/app/concepts/matestack/ui/core/pre/pre.rb +5 -0
- data/app/concepts/matestack/ui/core/q/q.haml +5 -0
- data/app/concepts/matestack/ui/core/q/q.rb +11 -0
- data/app/concepts/matestack/ui/core/rp/rp.haml +5 -0
- data/app/concepts/matestack/ui/core/rp/rp.rb +5 -0
- data/app/concepts/matestack/ui/core/rt/rt.haml +5 -0
- data/app/concepts/matestack/ui/core/rt/rt.rb +5 -0
- data/app/concepts/matestack/ui/core/ruby/ruby.haml +5 -0
- data/app/concepts/matestack/ui/core/ruby/ruby.rb +5 -0
- data/app/concepts/matestack/ui/core/s/s.haml +5 -0
- data/app/concepts/matestack/ui/core/s/s.rb +6 -0
- data/app/concepts/matestack/ui/core/samp/samp.haml +5 -0
- data/app/concepts/matestack/ui/core/samp/samp.rb +4 -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 +3 -1
- 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/sup/sup.haml +5 -0
- data/app/concepts/matestack/ui/core/sup/sup.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 +4 -7
- data/app/concepts/matestack/ui/core/template/template.haml +3 -0
- data/app/concepts/matestack/ui/core/template/template.rb +4 -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 +4 -7
- 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/transition/transition.haml +4 -6
- data/app/concepts/matestack/ui/core/transition/transition.js +1 -1
- data/app/concepts/matestack/ui/core/u/u.haml +5 -0
- data/app/concepts/matestack/ui/core/u/u.rb +6 -0
- data/app/concepts/matestack/ui/core/unescaped/unescaped.rb +7 -0
- data/app/concepts/matestack/ui/core/var/var.haml +5 -0
- data/app/concepts/matestack/ui/core/var/var.rb +4 -0
- data/app/concepts/matestack/ui/core/video/video.haml +3 -0
- data/app/concepts/matestack/ui/core/video/video.rb +23 -0
- data/app/concepts/matestack/ui/core/wbr/wbr.haml +1 -0
- data/app/concepts/matestack/ui/core/wbr/wbr.rb +4 -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 +3 -1
- data/app/javascript/matestack-ui-core/index.js +22 -0
- data/app/javascript/matestack-ui-core/styles/index.scss +5 -0
- data/app/javascript/packs/matestack-ui-core.js +8 -0
- data/app/lib/matestack/ui/core/component_node.rb +30 -12
- data/app/lib/matestack/ui/core/has_view_context.rb +10 -0
- data/app/lib/matestack/ui/core/page_node.rb +40 -6
- data/app/lib/matestack/ui/core/render.rb +89 -0
- data/app/lib/matestack/ui/core/to_cell.rb +3 -1
- data/app/lib/matestack/ui/dynamic_actionview_component.rb +1 -0
- data/app/lib/matestack/ui/static_actionview_component.rb +1 -0
- data/config/routes.rb +0 -1
- data/lib/generators/matestack/app/USAGE +21 -0
- data/lib/generators/matestack/app/app_generator.rb +25 -0
- data/lib/generators/matestack/app/templates/app/controllers/%file_name%_controller.rb.tt +5 -0
- data/lib/generators/matestack/app/templates/app/matestack/apps/%file_name%.rb.tt +28 -0
- data/lib/generators/matestack/component/USAGE +20 -0
- data/lib/generators/matestack/component/component_generator.rb +29 -0
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.haml.tt +5 -0
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.js.tt +17 -0
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.rb.tt +11 -0
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.scss.tt +1 -0
- data/lib/generators/matestack/core/component/USAGE +16 -0
- data/lib/generators/matestack/core/component/component_generator.rb +23 -0
- data/lib/generators/matestack/core/component/templates/app/concepts/matestack/ui/core/%file_name%/%file_name%.haml.tt +5 -0
- data/lib/generators/matestack/core/component/templates/app/concepts/matestack/ui/core/%file_name%/%file_name%.rb.tt +4 -0
- data/lib/generators/matestack/core/component/templates/docs/components/%file_name%.md.tt +45 -0
- data/lib/generators/matestack/core/component/templates/spec/usage/components/%file_name%_spec.rb +31 -0
- data/lib/generators/matestack/page/USAGE +28 -0
- data/lib/generators/matestack/page/page_generator.rb +54 -0
- data/lib/generators/matestack/page/templates/app/matestack/pages/%app_name%/%namespace%/%file_name%.rb.tt +29 -0
- data/lib/matestack/ui/core.rb +1 -0
- data/lib/matestack/ui/core/cell.rb +33 -0
- data/lib/matestack/ui/core/version.rb +1 -1
- data/vendor/assets/javascripts/dist/manifest.json +18 -0
- data/vendor/assets/javascripts/dist/manifest.json.br +0 -0
- data/vendor/assets/javascripts/dist/manifest.json.gz +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.css +3 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.css.map +1 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.js +16523 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +1 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.css +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +3 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.LICENSE.txt +18 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.br +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.gz +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map +1 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.br +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.gz +0 -0
- data/vendor/assets/javascripts/matestack-ui-core.js.erb +2 -0
- data/vendor/assets/stylesheets/dist +1 -0
- data/vendor/assets/stylesheets/matestack-ui-core.css.erb +2 -0
- metadata +203 -19
- data/app/concepts/matestack/ui/core/view/view.haml +0 -2
- data/app/concepts/matestack/ui/core/view/view.js +0 -42
- data/app/concepts/matestack/ui/core/view/view.rb +0 -7
- data/vendor/assets/javascripts/manifest.json +0 -4
- data/vendor/assets/javascripts/matestack-ui-core.js +0 -15055
- data/vendor/assets/javascripts/matestack-ui-core.js.map +0 -1
@@ -0,0 +1,25 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection::Filter::Input
|
2
|
+
class Input < Matestack::Ui::Core::Component::Static
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@tag_attributes.merge!({
|
6
|
+
"v-model#{'.number' if options[:type] == :number}": input_key,
|
7
|
+
type: options[:type],
|
8
|
+
class: options[:class],
|
9
|
+
id: component_id,
|
10
|
+
"@keyup.enter": "submitFilter()",
|
11
|
+
ref: "filter.#{attr_key}",
|
12
|
+
placeholder: options[:placeholder]
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
def input_key
|
17
|
+
'filter["' + options[:key].to_s + '"]'
|
18
|
+
end
|
19
|
+
|
20
|
+
def attr_key
|
21
|
+
return options[:key].to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection
|
2
|
+
|
3
|
+
CollectionConfig = Struct.new(:id, :init_offset, :init_limit, :filtered_count, :base_count, :data, :context) do
|
4
|
+
|
5
|
+
def paginated_data
|
6
|
+
resulting_data = data
|
7
|
+
resulting_data = resulting_data.offset(get_collection_offset) unless get_collection_offset == 0
|
8
|
+
resulting_data = resulting_data.limit(get_collection_limit) unless get_collection_limit == 0
|
9
|
+
|
10
|
+
return resulting_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_collection_offset
|
14
|
+
(context[:params]["#{id}-offset".to_sym] ||= init_offset).to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_collection_limit
|
18
|
+
(context[:params]["#{id}-limit".to_sym] ||= init_limit).to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
def pages
|
22
|
+
offset = get_collection_offset
|
23
|
+
limit = get_collection_limit
|
24
|
+
if filtered_count.present?
|
25
|
+
count = filtered_count
|
26
|
+
else
|
27
|
+
count = base_count
|
28
|
+
end
|
29
|
+
page_count = count/limit
|
30
|
+
page_count += 1 if count%limit > 0
|
31
|
+
return (1..page_count).to_a
|
32
|
+
end
|
33
|
+
|
34
|
+
def from
|
35
|
+
return get_collection_offset + 1 if to > 0
|
36
|
+
return 0 if to == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
def to
|
40
|
+
current_to = get_collection_offset + get_collection_limit
|
41
|
+
if filtered_count.present?
|
42
|
+
if current_to > filtered_count
|
43
|
+
return filtered_count
|
44
|
+
else
|
45
|
+
return current_to
|
46
|
+
end
|
47
|
+
else
|
48
|
+
if current_to > base_count
|
49
|
+
return base_count
|
50
|
+
else
|
51
|
+
return current_to
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def config
|
57
|
+
self.to_h.except(:context)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
module Helper
|
63
|
+
|
64
|
+
def get_collection_filter collection_id, key=nil
|
65
|
+
filter_hash = {}
|
66
|
+
context[:params].each do |param_key, param_value|
|
67
|
+
if param_key.start_with?("#{collection_id}-filter-")
|
68
|
+
param_key.gsub("#{collection_id}-filter-", "")
|
69
|
+
filter_hash[param_key.gsub("#{collection_id}-filter-", "").to_sym] = param_value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
if key.nil?
|
73
|
+
return filter_hash
|
74
|
+
else
|
75
|
+
return filter_hash[key]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_collection_order collection_id, key=nil
|
80
|
+
order_hash = {}
|
81
|
+
context[:params].each do |param_key, param_value|
|
82
|
+
if param_key.start_with?("#{collection_id}-order-")
|
83
|
+
param_key.gsub("#{collection_id}-order-", "")
|
84
|
+
order_hash[param_key.gsub("#{collection_id}-order-", "").to_sym] = param_value
|
85
|
+
end
|
86
|
+
end
|
87
|
+
if key.nil?
|
88
|
+
return order_hash
|
89
|
+
else
|
90
|
+
return order_hash[key]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def set_collection id: nil, init_offset: 0, init_limit: nil, base_count: nil, filtered_count: nil, data: nil
|
95
|
+
@collections = {} if @collections.nil?
|
96
|
+
|
97
|
+
collection_config = CollectionConfig.new(
|
98
|
+
id,
|
99
|
+
init_offset,
|
100
|
+
init_limit,
|
101
|
+
filtered_count,
|
102
|
+
base_count,
|
103
|
+
data,
|
104
|
+
context
|
105
|
+
)
|
106
|
+
|
107
|
+
@collections[id.to_sym] = collection_config
|
108
|
+
|
109
|
+
return collection_config
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import Vue from 'vue/dist/vue.esm'
|
2
|
+
import matestackEventHub from '../../js/event-hub'
|
3
|
+
import queryParamsHelper from '../../js/helpers/query-params-helper'
|
4
|
+
import componentMixin from '../../component/component'
|
5
|
+
|
6
|
+
const componentDef = {
|
7
|
+
mixins: [componentMixin],
|
8
|
+
data: function(){
|
9
|
+
return {
|
10
|
+
ordering: {}
|
11
|
+
}
|
12
|
+
},
|
13
|
+
methods: {
|
14
|
+
toggleOrder: function(key){
|
15
|
+
if (this.ordering[key] == undefined) {
|
16
|
+
this.ordering[key] = "asc"
|
17
|
+
} else if (this.ordering[key] == "asc") {
|
18
|
+
this.ordering[key] = "desc"
|
19
|
+
} else if (this.ordering[key] = "desc") {
|
20
|
+
this.ordering[key] = undefined
|
21
|
+
}
|
22
|
+
var url;
|
23
|
+
url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-order-" + key, this.ordering[key])
|
24
|
+
url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-offset", 0, url)
|
25
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
26
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
27
|
+
this.$forceUpdate()
|
28
|
+
},
|
29
|
+
orderIndicator(key, indicators){
|
30
|
+
return indicators[this.ordering[key]]
|
31
|
+
},
|
32
|
+
resetFilter: function(){
|
33
|
+
var url;
|
34
|
+
for (var key in this.filter) {
|
35
|
+
url = queryParamsHelper.updateQueryParams(this.componentConfig["id"] + "-filter-" + key, null)
|
36
|
+
this.filter[key] = null;
|
37
|
+
this.$forceUpdate();
|
38
|
+
}
|
39
|
+
window.history.pushState({matestackApp: true, url: url}, null, url);
|
40
|
+
matestackEventHub.$emit(this.componentConfig["id"] + "-update")
|
41
|
+
}
|
42
|
+
},
|
43
|
+
created: function(){
|
44
|
+
var self = this;
|
45
|
+
var queryParamsObject = queryParamsHelper.queryParamsToObject()
|
46
|
+
Object.keys(queryParamsObject).forEach(function(key){
|
47
|
+
if (key.startsWith(self.componentConfig["id"] + "-order-")){
|
48
|
+
self.ordering[key.replace(self.componentConfig["id"] + "-order-", "")] = queryParamsObject[key]
|
49
|
+
}
|
50
|
+
})
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
let component = Vue.component('matestack-ui-core-collection-order', componentDef)
|
55
|
+
|
56
|
+
export default componentDef
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection::Order
|
2
|
+
class Order < Matestack::Ui::Core::Component::Dynamic
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@component_config = @component_config.except(:data, :paginated_data)
|
6
|
+
end
|
7
|
+
|
8
|
+
def response
|
9
|
+
components {
|
10
|
+
div @tag_attributes do
|
11
|
+
yield_components
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Matestack::Ui::Core::Collection::Order::Toggle::Indicator
|
2
|
+
class Indicator < Matestack::Ui::Core::Component::Static
|
3
|
+
|
4
|
+
def response
|
5
|
+
components {
|
6
|
+
span @tag_attributes do
|
7
|
+
plain "{{orderIndicator( '#{@component_config[:key]}', {asc: '#{@component_config[:asc]}', desc: '#{@component_config[:desc]}'} ) }}"
|
8
|
+
end
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import Vue from 'vue/dist/vue.esm'
|
2
2
|
import axios from 'axios'
|
3
3
|
import VRuntimeTemplate from "v-runtime-template"
|
4
|
-
|
5
|
-
import matestackEventHub from 'js/event-hub'
|
4
|
+
import matestackEventHub from '../js/event-hub'
|
6
5
|
|
7
6
|
const componentMixin = {
|
8
7
|
props: ['componentConfig', 'params'],
|
@@ -27,11 +26,11 @@ const componentMixin = {
|
|
27
26
|
self.params["component_key"] = self.componentConfig["component_key"]
|
28
27
|
axios({
|
29
28
|
method: "get",
|
30
|
-
url:
|
29
|
+
url: location.pathname + location.search,
|
31
30
|
headers: {
|
32
31
|
'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
|
33
32
|
},
|
34
|
-
params: self.
|
33
|
+
params: {"component_key": self.componentConfig["component_key"]}
|
35
34
|
})
|
36
35
|
.then(function(response){
|
37
36
|
self.asyncTemplate = response["data"];
|
@@ -1,36 +1,9 @@
|
|
1
1
|
module Matestack::Ui::Core::Component
|
2
2
|
class Dynamic < Trailblazer::Cell
|
3
|
-
|
4
|
-
|
5
|
-
include ActionView::Helpers::ActiveModelHelper
|
6
|
-
include ActionView::Helpers::ActiveModelInstanceTag
|
7
|
-
include ActionView::Helpers::AssetTagHelper
|
8
|
-
include ActionView::Helpers::AssetUrlHelper
|
9
|
-
include ActionView::Helpers::AtomFeedHelper
|
10
|
-
include ActionView::Helpers::CacheHelper
|
11
|
-
include ActionView::Helpers::CaptureHelper
|
12
|
-
include ActionView::Helpers::CspHelper
|
13
|
-
include ActionView::Helpers::CsrfHelper
|
14
|
-
include ActionView::Helpers::DateHelper
|
15
|
-
include ActionView::Helpers::DebugHelper
|
16
|
-
include ActionView::Helpers::FormHelper
|
17
|
-
include ActionView::Helpers::FormOptionsHelper
|
18
|
-
include ActionView::Helpers::FormTagHelper
|
19
|
-
include ActionView::Helpers::JavaScriptHelper
|
20
|
-
include ActionView::Helpers::NumberHelper
|
21
|
-
include ActionView::Helpers::OutputSafetyHelper
|
22
|
-
include ActionView::Helpers::RecordTagHelper
|
23
|
-
# include ActionView::Helpers::RenderingHelper
|
24
|
-
include ActionView::Helpers::SanitizeHelper
|
25
|
-
include ActionView::Helpers::TagHelper
|
26
|
-
include ActionView::Helpers::TextHelper
|
27
|
-
include ActionView::Helpers::TranslationHelper
|
28
|
-
include ActionView::Helpers::UrlHelper
|
29
|
-
# include ActionView::Helpers::UrlHelper
|
30
|
-
# include ActionView::Helpers::TranslationHelper
|
31
|
-
include ::Cell::Haml
|
3
|
+
include Matestack::Ui::Core::Cell
|
32
4
|
include Matestack::Ui::Core::ApplicationHelper
|
33
5
|
include Matestack::Ui::Core::ToCell
|
6
|
+
include Matestack::Ui::Core::HasViewContext
|
34
7
|
|
35
8
|
view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
|
36
9
|
view_paths << "#{::Rails.root}/app/matestack"
|
@@ -69,13 +42,14 @@ module Matestack::Ui::Core::Component
|
|
69
42
|
@nodes = {}
|
70
43
|
@cells = {}
|
71
44
|
@included_config = options[:included_config]
|
45
|
+
@cached_params = options[:cached_params]
|
72
46
|
@rerender = false
|
73
47
|
@options = options
|
48
|
+
set_tag_attributes
|
49
|
+
setup
|
74
50
|
generate_component_name
|
75
51
|
generate_children_cells
|
76
|
-
set_tag_attributes
|
77
52
|
validate_options
|
78
|
-
setup
|
79
53
|
end
|
80
54
|
|
81
55
|
def validate_options
|
@@ -160,7 +134,7 @@ module Matestack::Ui::Core::Component
|
|
160
134
|
@nodes = Matestack::Ui::Core::ComponentNode.build(self, nil, &block)
|
161
135
|
|
162
136
|
@nodes.each do |key, node|
|
163
|
-
@cells[key] = to_cell(key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"])
|
137
|
+
@cells[key] = to_cell("#{@component_key}__#{key}", node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
164
138
|
end
|
165
139
|
end
|
166
140
|
|
@@ -193,6 +167,37 @@ module Matestack::Ui::Core::Component
|
|
193
167
|
result.join(" ")
|
194
168
|
end
|
195
169
|
|
170
|
+
def render_child_component component_key, current_search_keys_array
|
171
|
+
if respond_to? :prepare
|
172
|
+
prepare
|
173
|
+
end
|
174
|
+
|
175
|
+
response
|
176
|
+
|
177
|
+
if current_search_keys_array.count > 1
|
178
|
+
if @nodes.dig(*current_search_keys_array) == nil
|
179
|
+
rest = []
|
180
|
+
while @nodes.dig(*current_search_keys_array) == nil
|
181
|
+
rest << current_search_keys_array.pop
|
182
|
+
end
|
183
|
+
node = @nodes.dig(*current_search_keys_array)
|
184
|
+
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
185
|
+
begin
|
186
|
+
return cell.render_child_component component_key, rest.reverse[1..-1]
|
187
|
+
rescue
|
188
|
+
return cell.render_content
|
189
|
+
end
|
190
|
+
else
|
191
|
+
node = @nodes.dig(*current_search_keys_array)
|
192
|
+
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
193
|
+
return cell.render_content
|
194
|
+
end
|
195
|
+
else
|
196
|
+
node = @nodes[current_search_keys_array[0]]
|
197
|
+
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
198
|
+
return cell.render_content
|
199
|
+
end
|
200
|
+
end
|
196
201
|
|
197
202
|
private
|
198
203
|
|
@@ -201,7 +206,7 @@ module Matestack::Ui::Core::Component
|
|
201
206
|
#needs refactoring --> in some cases, :component_key, :children, :origin_url, :url_params, :included_config get passed into options[:children] which causes errors
|
202
207
|
#quickfix: except them from iteration
|
203
208
|
options[:children].except(:component_key, :children, :origin_url, :url_params, :included_config).each do |key, node|
|
204
|
-
@children_cells[key] = to_cell("#{@component_key}__#{key}", node["component_name"], node["config"], node["argument"], node["components"], node["included_config"])
|
209
|
+
@children_cells[key] = to_cell("#{@component_key}__#{key}", node["component_name"], node["config"], node["argument"], node["components"], node["included_config"], node["cached_params"])
|
205
210
|
end
|
206
211
|
end
|
207
212
|
end
|