matestack-ui-core 0.7.5 → 1.1.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/LICENSE +8 -0
- data/README.md +28 -216
- data/app/concepts/matestack/ui/core/abbr/abbr.haml +3 -3
- data/app/concepts/matestack/ui/core/abbr/abbr.rb +1 -8
- data/app/concepts/matestack/ui/core/action/action.haml +1 -1
- data/app/concepts/matestack/ui/core/action/action.js +120 -39
- data/app/concepts/matestack/ui/core/action/action.rb +40 -15
- data/app/concepts/matestack/ui/core/actionview/dynamic.haml +4 -4
- data/app/concepts/matestack/ui/core/address/address.haml +3 -3
- data/app/concepts/matestack/ui/core/address/address.rb +1 -1
- data/app/concepts/matestack/ui/core/app/app.haml +2 -3
- data/app/concepts/matestack/ui/core/app/app.js +6 -3
- data/app/concepts/matestack/ui/core/app/app.rb +33 -56
- data/app/concepts/matestack/ui/core/app/store.js +28 -2
- data/app/concepts/matestack/ui/core/area/area.haml +1 -1
- data/app/concepts/matestack/ui/core/area/area.rb +2 -14
- data/app/concepts/matestack/ui/core/article/article.haml +3 -3
- data/app/concepts/matestack/ui/core/article/article.rb +1 -1
- data/app/concepts/matestack/ui/core/aside/aside.haml +1 -1
- data/app/concepts/matestack/ui/core/aside/aside.rb +0 -1
- data/app/concepts/matestack/ui/core/async/async.haml +6 -2
- data/app/concepts/matestack/ui/core/async/async.js +43 -9
- data/app/concepts/matestack/ui/core/async/async.rb +29 -4
- data/app/concepts/matestack/ui/core/async/children_wrapper.haml +2 -0
- data/app/concepts/matestack/ui/core/b/b.haml +3 -3
- data/app/concepts/matestack/ui/core/b/b.rb +1 -1
- data/app/concepts/matestack/ui/core/bdi/bdi.haml +3 -3
- data/app/concepts/matestack/ui/core/bdi/bdi.rb +1 -0
- data/app/concepts/matestack/ui/core/bdo/bdo.haml +3 -3
- data/app/concepts/matestack/ui/core/bdo/bdo.rb +2 -7
- data/app/concepts/matestack/ui/core/blockquote/blockquote.haml +3 -3
- data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +2 -7
- data/app/concepts/matestack/ui/core/br/br.haml +4 -4
- data/app/concepts/matestack/ui/core/br/br.rb +1 -1
- data/app/concepts/matestack/ui/core/button/button.haml +3 -3
- data/app/concepts/matestack/ui/core/button/button.rb +3 -7
- data/app/concepts/matestack/ui/core/cable/cable.haml +4 -0
- data/app/concepts/matestack/ui/core/cable/cable.js +100 -0
- data/app/concepts/matestack/ui/core/cable/cable.rb +28 -0
- data/app/concepts/matestack/ui/core/cable/children_wrapper.haml +2 -0
- data/app/concepts/matestack/ui/core/caption/caption.haml +3 -3
- data/app/concepts/matestack/ui/core/caption/caption.rb +1 -1
- data/app/concepts/matestack/ui/core/cite/cite.haml +3 -3
- data/app/concepts/matestack/ui/core/cite/cite.rb +1 -1
- data/app/concepts/matestack/ui/core/code/code.haml +3 -3
- data/app/concepts/matestack/ui/core/code/code.rb +1 -1
- data/app/concepts/matestack/ui/core/collection/content/content.js +2 -2
- data/app/concepts/matestack/ui/core/collection/content/content.rb +4 -6
- data/app/concepts/matestack/ui/core/collection/content/next/next.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.rb +5 -3
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/filter/filter.rb +4 -5
- data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +11 -8
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/filter/select/select.haml +10 -0
- data/app/concepts/matestack/ui/core/collection/filter/select/select.rb +30 -0
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/helper.rb +14 -6
- data/app/concepts/matestack/ui/core/collection/order/order.js +1 -1
- data/app/concepts/matestack/ui/core/collection/order/order.rb +4 -5
- data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +9 -5
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +0 -1
- data/app/concepts/matestack/ui/core/component/base.rb +430 -0
- data/app/concepts/matestack/ui/core/component/children.haml +2 -2
- data/app/concepts/matestack/ui/core/component/component.js +9 -46
- data/app/concepts/matestack/ui/core/component/dynamic.haml +1 -1
- data/app/concepts/matestack/ui/core/component/dynamic.rb +25 -247
- data/app/concepts/matestack/ui/core/component/static.rb +3 -12
- data/app/concepts/matestack/ui/core/data/data.haml +3 -3
- data/app/concepts/matestack/ui/core/data/data.rb +2 -5
- data/app/concepts/matestack/ui/core/datalist/datalist.haml +2 -2
- data/app/concepts/matestack/ui/core/datalist/datalist.rb +1 -2
- data/app/concepts/matestack/ui/core/dd/dd.haml +3 -3
- data/app/concepts/matestack/ui/core/dd/dd.rb +1 -1
- data/app/concepts/matestack/ui/core/del/del.haml +3 -3
- data/app/concepts/matestack/ui/core/del/del.rb +2 -0
- data/app/concepts/matestack/ui/core/details/details.haml +1 -1
- data/app/concepts/matestack/ui/core/details/details.rb +1 -1
- data/app/concepts/matestack/ui/core/dfn/dfn.haml +3 -3
- data/app/concepts/matestack/ui/core/dfn/dfn.rb +1 -1
- data/app/concepts/matestack/ui/core/dialog/dialog.haml +3 -3
- data/app/concepts/matestack/ui/core/dialog/dialog.rb +2 -5
- data/app/concepts/matestack/ui/core/div/div.haml +1 -1
- data/app/concepts/matestack/ui/core/div/div.rb +0 -1
- data/app/concepts/matestack/ui/core/dl/dl.haml +3 -3
- data/app/concepts/matestack/ui/core/dl/dl.rb +2 -2
- data/app/concepts/matestack/ui/core/dt/dt.haml +3 -3
- data/app/concepts/matestack/ui/core/dt/dt.rb +1 -1
- data/app/concepts/matestack/ui/core/em/em.haml +3 -3
- data/app/concepts/matestack/ui/core/em/em.rb +1 -1
- data/app/concepts/matestack/ui/core/fieldset/fieldset.haml +4 -4
- data/app/concepts/matestack/ui/core/fieldset/fieldset.rb +3 -6
- data/app/concepts/matestack/ui/core/figure/figure.haml +1 -1
- data/app/concepts/matestack/ui/core/figure/figure.rb +0 -1
- data/app/concepts/matestack/ui/core/footer/footer.haml +1 -1
- data/app/concepts/matestack/ui/core/footer/footer.rb +0 -1
- data/app/concepts/matestack/ui/core/form/checkbox/checkbox.rb +79 -0
- data/app/concepts/matestack/ui/core/form/form.haml +1 -1
- data/app/concepts/matestack/ui/core/form/form.js +257 -123
- data/app/concepts/matestack/ui/core/form/form.rb +52 -19
- data/app/concepts/matestack/ui/core/form/has_errors.rb +54 -0
- data/app/concepts/matestack/ui/core/form/has_input_html_attributes.rb +13 -0
- data/app/concepts/matestack/ui/core/form/input/input.rb +32 -52
- data/app/concepts/matestack/ui/core/form/radio/radio.rb +71 -0
- data/app/concepts/matestack/ui/core/form/select/select.haml +9 -76
- data/app/concepts/matestack/ui/core/form/select/select.rb +44 -49
- data/app/concepts/matestack/ui/core/form/submit/submit.haml +1 -1
- data/app/concepts/matestack/ui/core/form/submit/submit.rb +5 -2
- data/app/concepts/matestack/ui/core/form/textarea/textarea.rb +28 -0
- data/app/concepts/matestack/ui/core/form/utils.rb +47 -0
- data/app/concepts/matestack/ui/core/header/header.haml +1 -1
- data/app/concepts/matestack/ui/core/header/header.rb +0 -1
- data/app/concepts/matestack/ui/core/heading/heading.haml +4 -49
- data/app/concepts/matestack/ui/core/heading/heading.rb +1 -1
- data/app/concepts/matestack/ui/core/hr/hr.haml +1 -1
- data/app/concepts/matestack/ui/core/hr/hr.rb +0 -1
- data/app/concepts/matestack/ui/core/icon/icon.haml +3 -3
- data/app/concepts/matestack/ui/core/icon/icon.rb +1 -1
- data/app/concepts/matestack/ui/core/iframe/iframe.haml +3 -3
- data/app/concepts/matestack/ui/core/iframe/iframe.rb +3 -10
- data/app/concepts/matestack/ui/core/img/img.haml +1 -1
- data/app/concepts/matestack/ui/core/img/img.rb +8 -8
- data/app/concepts/matestack/ui/core/input/input.haml +1 -2
- data/app/concepts/matestack/ui/core/input/input.rb +4 -4
- data/app/concepts/matestack/ui/core/ins/ins.haml +3 -3
- data/app/concepts/matestack/ui/core/ins/ins.rb +2 -6
- data/app/concepts/matestack/ui/core/isolated/children_wrapper.haml +2 -0
- data/app/concepts/matestack/ui/core/isolated/isolated.haml +10 -0
- data/app/concepts/matestack/ui/core/isolated/isolated.js +108 -0
- data/app/concepts/matestack/ui/core/isolated/isolated.rb +59 -0
- data/app/concepts/matestack/ui/core/js/core.js +6 -4
- data/app/concepts/matestack/ui/core/kbd/kbd.haml +3 -3
- data/app/concepts/matestack/ui/core/kbd/kbd.rb +1 -0
- data/app/concepts/matestack/ui/core/label/label.haml +3 -3
- data/app/concepts/matestack/ui/core/label/label.rb +2 -6
- data/app/concepts/matestack/ui/core/legend/legend.haml +3 -3
- data/app/concepts/matestack/ui/core/legend/legend.rb +1 -1
- data/app/concepts/matestack/ui/core/li/li.haml +3 -3
- data/app/concepts/matestack/ui/core/li/li.rb +2 -1
- data/app/concepts/matestack/ui/core/link/link.haml +3 -3
- data/app/concepts/matestack/ui/core/link/link.rb +10 -14
- data/app/concepts/matestack/ui/core/main/main.haml +1 -1
- data/app/concepts/matestack/ui/core/main/main.rb +0 -1
- data/app/concepts/matestack/ui/core/map/map.haml +1 -1
- data/app/concepts/matestack/ui/core/map/map.rb +1 -7
- data/app/concepts/matestack/ui/core/mark/mark.haml +3 -3
- data/app/concepts/matestack/ui/core/mark/mark.rb +1 -0
- data/app/concepts/matestack/ui/core/meter/meter.haml +1 -1
- data/app/concepts/matestack/ui/core/meter/meter.rb +1 -10
- data/app/concepts/matestack/ui/core/nav/nav.haml +1 -1
- data/app/concepts/matestack/ui/core/nav/nav.rb +0 -1
- data/app/concepts/matestack/ui/core/noscript/noscript.haml +3 -3
- data/app/concepts/matestack/ui/core/noscript/noscript.rb +1 -1
- data/app/concepts/matestack/ui/core/object/object.haml +1 -1
- data/app/concepts/matestack/ui/core/object/object.rb +1 -11
- data/app/concepts/matestack/ui/core/ol/ol.haml +1 -1
- data/app/concepts/matestack/ui/core/ol/ol.rb +1 -1
- data/app/concepts/matestack/ui/core/onclick/onclick.haml +1 -1
- data/app/concepts/matestack/ui/core/onclick/onclick.rb +1 -0
- data/app/concepts/matestack/ui/core/optgroup/optgroup.haml +1 -1
- data/app/concepts/matestack/ui/core/optgroup/optgroup.rb +1 -6
- data/app/concepts/matestack/ui/core/option/option.haml +3 -3
- data/app/concepts/matestack/ui/core/option/option.rb +2 -8
- data/app/concepts/matestack/ui/core/output/output.haml +3 -3
- data/app/concepts/matestack/ui/core/output/output.rb +2 -7
- data/app/concepts/matestack/ui/core/page/{content.js → content/content.js} +8 -2
- data/app/concepts/matestack/ui/core/page/content/content.rb +28 -0
- data/app/concepts/matestack/ui/core/page/page.haml +3 -9
- data/app/concepts/matestack/ui/core/page/page.rb +15 -175
- data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +3 -3
- data/app/concepts/matestack/ui/core/paragraph/paragraph.rb +1 -1
- data/app/concepts/matestack/ui/core/param/param.haml +1 -1
- data/app/concepts/matestack/ui/core/param/param.rb +1 -6
- data/app/concepts/matestack/ui/core/partial/partial.rb +0 -1
- data/app/concepts/matestack/ui/core/picture/picture.haml +1 -1
- data/app/concepts/matestack/ui/core/pre/pre.haml +3 -3
- data/app/concepts/matestack/ui/core/pre/pre.rb +1 -1
- data/app/concepts/matestack/ui/core/progress/progress.haml +1 -1
- data/app/concepts/matestack/ui/core/progress/progress.rb +1 -10
- data/app/concepts/matestack/ui/core/q/q.haml +3 -3
- data/app/concepts/matestack/ui/core/q/q.rb +2 -7
- data/app/concepts/matestack/ui/core/rp/rp.haml +3 -3
- data/app/concepts/matestack/ui/core/rp/rp.rb +1 -1
- data/app/concepts/matestack/ui/core/rt/rt.haml +3 -3
- data/app/concepts/matestack/ui/core/rt/rt.rb +1 -1
- data/app/concepts/matestack/ui/core/ruby/ruby.haml +3 -3
- data/app/concepts/matestack/ui/core/ruby/ruby.rb +1 -1
- data/app/concepts/matestack/ui/core/s/s.haml +3 -3
- data/app/concepts/matestack/ui/core/s/s.rb +1 -1
- data/app/concepts/matestack/ui/core/samp/samp.haml +3 -3
- data/app/concepts/matestack/ui/core/samp/samp.rb +1 -0
- data/app/concepts/matestack/ui/core/section/section.haml +1 -1
- data/app/concepts/matestack/ui/core/section/section.rb +0 -1
- data/app/concepts/matestack/ui/core/slot/slot.rb +1 -2
- data/app/concepts/matestack/ui/core/small/small.haml +3 -3
- data/app/concepts/matestack/ui/core/small/small.rb +1 -1
- data/app/concepts/matestack/ui/core/span/span.haml +3 -3
- data/app/concepts/matestack/ui/core/span/span.rb +1 -1
- data/app/concepts/matestack/ui/core/strong/strong.haml +3 -3
- data/app/concepts/matestack/ui/core/strong/strong.rb +1 -1
- data/app/concepts/matestack/ui/core/sub/sub.haml +3 -3
- data/app/concepts/matestack/ui/core/sub/sub.rb +1 -1
- data/app/concepts/matestack/ui/core/summary/summary.haml +3 -3
- data/app/concepts/matestack/ui/core/summary/summary.rb +1 -1
- data/app/concepts/matestack/ui/core/sup/sup.haml +3 -3
- data/app/concepts/matestack/ui/core/sup/sup.rb +1 -1
- data/app/concepts/matestack/ui/core/table/table.haml +1 -1
- data/app/concepts/matestack/ui/core/table/table.rb +0 -1
- data/app/concepts/matestack/ui/core/tbody/tbody.haml +1 -1
- data/app/concepts/matestack/ui/core/tbody/tbody.rb +0 -1
- data/app/concepts/matestack/ui/core/td/td.haml +3 -3
- data/app/concepts/matestack/ui/core/td/td.rb +2 -1
- data/app/concepts/matestack/ui/core/template/template.haml +1 -1
- data/app/concepts/matestack/ui/core/textarea/textarea.haml +5 -0
- data/app/concepts/matestack/ui/core/textarea/textarea.rb +10 -0
- data/app/concepts/matestack/ui/core/tfoot/tfoot.haml +1 -1
- data/app/concepts/matestack/ui/core/tfoot/tfoot.rb +0 -1
- data/app/concepts/matestack/ui/core/th/th.haml +3 -3
- data/app/concepts/matestack/ui/core/th/th.rb +2 -1
- data/app/concepts/matestack/ui/core/thead/thead.haml +1 -1
- data/app/concepts/matestack/ui/core/thead/thead.rb +0 -1
- data/app/concepts/matestack/ui/core/time/time.haml +1 -1
- data/app/concepts/matestack/ui/core/time/time.rb +1 -7
- data/app/concepts/matestack/ui/core/toggle/toggle.haml +2 -0
- data/app/concepts/matestack/ui/core/toggle/toggle.js +71 -0
- data/app/concepts/matestack/ui/core/toggle/toggle.rb +13 -0
- data/app/concepts/matestack/ui/core/tr/tr.haml +1 -1
- data/app/concepts/matestack/ui/core/tr/tr.rb +0 -1
- data/app/concepts/matestack/ui/core/transition/transition.haml +3 -3
- data/app/concepts/matestack/ui/core/transition/transition.js +17 -1
- data/app/concepts/matestack/ui/core/transition/transition.rb +15 -8
- data/app/concepts/matestack/ui/core/u/u.haml +3 -3
- data/app/concepts/matestack/ui/core/u/u.rb +1 -1
- data/app/concepts/matestack/ui/core/ul/ul.haml +1 -1
- data/app/concepts/matestack/ui/core/ul/ul.rb +0 -1
- data/app/concepts/matestack/ui/core/unescaped/unescaped.rb +3 -1
- data/app/concepts/matestack/ui/core/var/var.haml +3 -3
- data/app/concepts/matestack/ui/core/var/var.rb +1 -0
- data/app/concepts/matestack/ui/core/video/video.haml +2 -2
- data/app/concepts/matestack/ui/core/video/video.rb +4 -14
- data/app/concepts/matestack/ui/core/view/view.haml +1 -0
- data/app/concepts/matestack/ui/core/view/view.rb +30 -0
- data/app/concepts/matestack/ui/core/wbr/wbr.haml +5 -1
- data/app/concepts/matestack/ui/core/wbr/wbr.rb +1 -0
- data/app/concepts/matestack/ui/core/youtube/youtube.haml +1 -1
- data/app/concepts/matestack/ui/core/youtube/youtube.rb +18 -16
- data/app/helpers/matestack/ui/core/application_helper.rb +94 -20
- data/app/lib/matestack/ui/component.rb +1 -0
- data/app/lib/matestack/ui/core/has_view_context.rb +4 -4
- data/app/lib/matestack/ui/core/html_attributes.rb +43 -0
- data/app/lib/matestack/ui/core/properties.rb +161 -0
- data/app/lib/matestack/ui/core/rendering/default_renderer_class_determiner.rb +33 -0
- data/app/lib/matestack/ui/core/rendering/main_renderer.rb +200 -0
- data/app/lib/matestack/ui/isolated_component.rb +1 -0
- data/app/lib/matestack/ui/vue_js_component.rb +1 -0
- data/lib/matestack/ui/core.rb +4 -2
- data/lib/matestack/ui/core/cell.rb +0 -2
- data/lib/matestack/ui/core/component/registry.rb +47 -0
- data/lib/matestack/ui/core/components.rb +269 -0
- data/lib/matestack/ui/core/dsl.rb +6 -0
- data/lib/matestack/ui/core/engine.rb +16 -0
- data/lib/matestack/ui/core/version.rb +1 -1
- data/vendor/assets/javascripts/dist/manifest.json +6 -10
- data/vendor/assets/javascripts/dist/matestack-ui-core.js +834 -261
- data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +1 -1
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +1 -1
- 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 -1
- 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
- metadata +50 -65
- data/MIT-LICENSE +0 -20
- data/app/concepts/matestack/ui/core/absolute/absolute.haml +0 -3
- data/app/concepts/matestack/ui/core/absolute/absolute.rb +0 -17
- data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +0 -2
- data/app/concepts/matestack/ui/core/component/response.haml +0 -2
- data/app/concepts/matestack/ui/core/component/response_dynamic.haml +0 -7
- data/app/concepts/matestack/ui/core/component/response_dynamic_without_rerender.haml +0 -3
- data/app/concepts/matestack/ui/core/component/static.haml +0 -1
- data/app/concepts/matestack/ui/core/form/inline/inline.haml +0 -6
- data/app/concepts/matestack/ui/core/form/inline/inline.rb +0 -9
- data/app/concepts/matestack/ui/core/form/input/input.haml +0 -38
- data/app/concepts/matestack/ui/core/html/html.haml +0 -3
- data/app/concepts/matestack/ui/core/html/html.js +0 -10
- data/app/concepts/matestack/ui/core/html/html.rb +0 -17
- data/app/concepts/matestack/ui/core/isolate/isolate.haml +0 -2
- data/app/concepts/matestack/ui/core/isolate/isolate.rb +0 -11
- data/app/concepts/matestack/ui/core/page/content.haml +0 -7
- data/app/concepts/matestack/ui/core/page/content.rb +0 -5
- data/app/concepts/matestack/ui/core/pg/pg.haml +0 -5
- data/app/concepts/matestack/ui/core/pg/pg.rb +0 -5
- data/app/lib/matestack/ui/core/app_node.rb +0 -53
- data/app/lib/matestack/ui/core/component_node.rb +0 -87
- data/app/lib/matestack/ui/core/page_node.rb +0 -100
- data/app/lib/matestack/ui/core/render.rb +0 -89
- data/app/lib/matestack/ui/core/to_cell.rb +0 -129
@@ -1,5 +1,5 @@
|
|
1
|
-
%fieldset{
|
2
|
-
-if
|
1
|
+
%fieldset{ html_attributes }
|
2
|
+
- if text.nil? && block_given?
|
3
3
|
= yield
|
4
|
-
- else
|
5
|
-
=
|
4
|
+
- else
|
5
|
+
= text
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative '../utils'
|
2
|
+
require_relative '../has_input_html_attributes'
|
3
|
+
require_relative '../has_errors'
|
4
|
+
module Matestack::Ui::Core::Form::Checkbox
|
5
|
+
class Checkbox < Matestack::Ui::Core::Component::Static
|
6
|
+
include Matestack::Ui::Core::Form::Utils
|
7
|
+
include Matestack::Ui::Core::Form::HasInputHtmlAttributes
|
8
|
+
include Matestack::Ui::Core::Form::HasErrors
|
9
|
+
|
10
|
+
requires :key
|
11
|
+
optional :value, :false_value, :multiple, :init, for: { as: :input_for }, label: { as: :input_label }, options: { as: :checkbox_options }
|
12
|
+
|
13
|
+
def response
|
14
|
+
# multiple values
|
15
|
+
if checkbox_options
|
16
|
+
checkbox_options.to_a.each do |item|
|
17
|
+
input html_attributes.merge(
|
18
|
+
attributes: vue_attributes,
|
19
|
+
type: :checkbox,
|
20
|
+
id: "#{id_for_item(item_value(item))}",
|
21
|
+
name: item_name(item),
|
22
|
+
value: item_value(item)
|
23
|
+
)
|
24
|
+
label text: item_name(item), for: id_for_item(item_value(item))
|
25
|
+
end
|
26
|
+
# checked/unchecked checkbox
|
27
|
+
else
|
28
|
+
form_input type: :hidden, key: key, value: (false_value || 0), errors: false
|
29
|
+
form_input type: :checkbox, key: key, value: checked_value, id: id_for_item(value), errors: false
|
30
|
+
label text: input_label, for: id_for_item(value)
|
31
|
+
end
|
32
|
+
render_errors
|
33
|
+
end
|
34
|
+
|
35
|
+
def vue_attributes
|
36
|
+
(options[:attributes] || {}).merge({
|
37
|
+
"@change": change_event,
|
38
|
+
ref: "select.multiple.#{attr_key}",
|
39
|
+
'init-value': init_value,
|
40
|
+
'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
|
41
|
+
'value-type': value_type,
|
42
|
+
"#{v_model_type}": input_key,
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
def value_type
|
47
|
+
item_value(checkbox_options.first).is_a?(Integer) ? Integer : nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def item_value(item)
|
51
|
+
item.is_a?(Array) ? item.last : item
|
52
|
+
end
|
53
|
+
|
54
|
+
def item_name(item)
|
55
|
+
item.is_a?(Array) ? item.first : item
|
56
|
+
end
|
57
|
+
|
58
|
+
def checked_value
|
59
|
+
value || 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def v_model_type
|
63
|
+
if checkbox_options && checkbox_options.first.is_a?(Integer)
|
64
|
+
'v-model.number'
|
65
|
+
else
|
66
|
+
'v-model'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def change_event
|
71
|
+
"inputChanged('#{attr_key}')"
|
72
|
+
end
|
73
|
+
|
74
|
+
def id_for_item(value)
|
75
|
+
"#{html_attributes[:id]}_#{value}"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
%form{
|
1
|
+
%form{ form_attributes }
|
2
2
|
= yield
|
@@ -1,172 +1,306 @@
|
|
1
|
-
import Vue from
|
2
|
-
import Vuex from
|
3
|
-
import axios from
|
1
|
+
import Vue from "vue/dist/vue.esm";
|
2
|
+
import Vuex from "vuex";
|
3
|
+
import axios from "axios";
|
4
4
|
|
5
|
-
import matestackEventHub from
|
6
|
-
import componentMixin from
|
5
|
+
import matestackEventHub from "../js/event-hub";
|
6
|
+
import componentMixin from "../component/component";
|
7
7
|
|
8
8
|
const componentDef = {
|
9
9
|
mixins: [componentMixin],
|
10
|
-
data: function(){
|
10
|
+
data: function () {
|
11
11
|
return {
|
12
12
|
data: {},
|
13
|
-
|
14
|
-
|
15
|
-
}
|
13
|
+
errors: {},
|
14
|
+
loading: false
|
15
|
+
};
|
16
16
|
},
|
17
17
|
methods: {
|
18
|
-
initDataKey: function(key, initValue){
|
18
|
+
initDataKey: function (key, initValue) {
|
19
19
|
this.data[key] = initValue;
|
20
20
|
},
|
21
|
-
inputChanged: function(key){
|
22
|
-
this.resetErrors(key)
|
21
|
+
inputChanged: function (key) {
|
22
|
+
this.resetErrors(key);
|
23
23
|
},
|
24
|
-
updateFormValue: function(key, value){
|
24
|
+
updateFormValue: function (key, value) {
|
25
25
|
this.data[key] = value;
|
26
26
|
},
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
hasErrors: function(){
|
28
|
+
//https://stackoverflow.com/a/27709663/13886137
|
29
|
+
for (var key in this.errors) {
|
30
|
+
if (this.errors[key] !== null && this.errors[key] != ""){
|
31
|
+
return true;
|
32
|
+
}
|
30
33
|
}
|
34
|
+
return false;
|
31
35
|
},
|
32
|
-
|
33
|
-
this.
|
34
|
-
|
35
|
-
|
36
|
-
setTimeout(function () {
|
37
|
-
self.$refs.inlineinput.focus();
|
38
|
-
}, 300);
|
36
|
+
resetErrors: function (key) {
|
37
|
+
if (this.errors[key]) {
|
38
|
+
this.errors[key] = null;
|
39
|
+
}
|
39
40
|
},
|
40
|
-
|
41
|
-
|
41
|
+
setProps: function (flat, newVal) {
|
42
|
+
for (var i in flat) {
|
43
|
+
if (flat[i] === null){
|
44
|
+
flat[i] = newVal;
|
45
|
+
} else if (flat[i] instanceof File){
|
46
|
+
flat[i] = newVal;
|
47
|
+
this.$refs["input."+i].value = newVal
|
48
|
+
} else if (flat[i] instanceof Array) {
|
49
|
+
if(flat[i][0] instanceof File){
|
50
|
+
flat[i] = newVal
|
51
|
+
this.$refs["input."+i].value = newVal
|
52
|
+
}
|
53
|
+
} else if (typeof flat[i] === "object" && !(flat[i] instanceof Array)) {
|
54
|
+
setProps(flat[i], newVal);
|
55
|
+
} else {
|
56
|
+
flat[i] = newVal;
|
57
|
+
}
|
58
|
+
}
|
42
59
|
},
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
filesAdded: function (key) {
|
61
|
+
const dataTransfer = event.dataTransfer || event.target;
|
62
|
+
const files = dataTransfer.files;
|
63
|
+
if (event.target.attributes.multiple) {
|
64
|
+
this.data[key] = [];
|
65
|
+
for (let index in files) {
|
66
|
+
if (files[index] instanceof File) {
|
67
|
+
this.data[key].push(files[index]);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
} else {
|
71
|
+
this.data[key] = files[0];
|
51
72
|
}
|
52
73
|
},
|
53
|
-
initValues: function(){
|
74
|
+
initValues: function () {
|
54
75
|
let self = this;
|
55
|
-
let data = {}
|
76
|
+
let data = {};
|
56
77
|
for (let key in self.$refs) {
|
57
|
-
let initValue = self.$refs[key]["attributes"]["init-value"]
|
58
|
-
let valueType = self.$refs[key]["attributes"]["value-type"]
|
78
|
+
let initValue = self.$refs[key]["attributes"]["init-value"];
|
79
|
+
let valueType = self.$refs[key]["attributes"]["value-type"];
|
59
80
|
|
60
|
-
if (key.startsWith("input.")){
|
61
|
-
if(initValue){
|
62
|
-
data[key.replace(
|
63
|
-
}else{
|
64
|
-
data[key.replace(
|
81
|
+
if (key.startsWith("input.")) {
|
82
|
+
if (initValue) {
|
83
|
+
data[key.replace("input.", "")] = initValue["value"];
|
84
|
+
} else {
|
85
|
+
data[key.replace("input.", "")] = null;
|
65
86
|
}
|
66
87
|
}
|
67
|
-
if (key.startsWith("select.")){
|
68
|
-
if (key.startsWith("select.multiple.")){
|
69
|
-
if(initValue){
|
70
|
-
data[key.replace(
|
71
|
-
}else{
|
72
|
-
data[key.replace(
|
88
|
+
if (key.startsWith("select.")) {
|
89
|
+
if (key.startsWith("select.multiple.")) {
|
90
|
+
if (initValue) {
|
91
|
+
data[key.replace("select.multiple.", "")] = JSON.parse(initValue["value"]);
|
92
|
+
} else {
|
93
|
+
data[key.replace("select.multiple.", "")] = [];
|
73
94
|
}
|
74
|
-
}else{
|
75
|
-
if(initValue){
|
76
|
-
if(valueType && valueType["value"] == "Integer")
|
77
|
-
|
78
|
-
|
79
|
-
data[key.replace('select.', '')] = initValue["value"]
|
95
|
+
} else {
|
96
|
+
if (initValue) {
|
97
|
+
if (valueType && valueType["value"] == "Integer") data[key.replace("select.", "")] = parseInt(initValue["value"]);
|
98
|
+
else {
|
99
|
+
data[key.replace("select.", "")] = initValue["value"];
|
80
100
|
}
|
81
|
-
}else{
|
82
|
-
data[key.replace(
|
101
|
+
} else {
|
102
|
+
data[key.replace("select.", "")] = null;
|
83
103
|
}
|
84
104
|
}
|
85
|
-
|
86
105
|
}
|
87
106
|
}
|
88
107
|
self.data = data;
|
89
108
|
},
|
90
109
|
shouldResetFormOnSuccessfulSubmit() {
|
91
|
-
const self = this
|
92
|
-
if (self.componentConfig[
|
93
|
-
return self.componentConfig[
|
110
|
+
const self = this;
|
111
|
+
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["reset"] != undefined) {
|
112
|
+
return self.componentConfig["success"]["reset"];
|
94
113
|
} else {
|
95
|
-
return self.shouldResetFormOnSuccessfulSubmitByDefault()
|
114
|
+
return self.shouldResetFormOnSuccessfulSubmitByDefault();
|
96
115
|
}
|
97
116
|
},
|
98
117
|
shouldResetFormOnSuccessfulSubmitByDefault() {
|
99
|
-
const self = this
|
118
|
+
const self = this;
|
100
119
|
if (self.componentConfig["method"] == "put") {
|
101
|
-
return false
|
120
|
+
return false;
|
102
121
|
} else {
|
103
|
-
return true
|
122
|
+
return true;
|
104
123
|
}
|
105
124
|
},
|
106
125
|
perform: function(){
|
107
126
|
const self = this
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
data: payload,
|
114
|
-
headers: {
|
115
|
-
'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
|
116
|
-
}
|
117
|
-
})
|
118
|
-
.then(function(response){
|
119
|
-
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
|
120
|
-
matestackEventHub.$emit(self.componentConfig["success"]["emit"], response.data);
|
127
|
+
var form = self.$el.tagName == 'FORM' ? self.$el : self.$el.querySelector('form');
|
128
|
+
if(form.checkValidity()){
|
129
|
+
self.loading = true;
|
130
|
+
if (self.componentConfig["emit"] != undefined) {
|
131
|
+
matestackEventHub.$emit(self.componentConfig["emit"]);
|
121
132
|
}
|
122
|
-
if (self.componentConfig["
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
)
|
129
|
-
&& self.$store != undefined
|
130
|
-
) {
|
131
|
-
let path = self.componentConfig["success"]["transition"]["path"]
|
132
|
-
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
133
|
-
return;
|
133
|
+
if (self.componentConfig["delay"] != undefined) {
|
134
|
+
setTimeout(function () {
|
135
|
+
self.sendRequest()
|
136
|
+
}, parseInt(self.componentConfig["delay"]));
|
137
|
+
} else {
|
138
|
+
self.sendRequest()
|
134
139
|
}
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["transition"] != undefined && self.$store != undefined) {
|
159
|
-
let path = self.componentConfig["failure"]["transition"]["path"]
|
160
|
-
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
140
|
+
} else {
|
141
|
+
matestackEventHub.$emit('static_form_errors');
|
142
|
+
}
|
143
|
+
},
|
144
|
+
sendRequest: function(){
|
145
|
+
const self = this;
|
146
|
+
let payload = {};
|
147
|
+
payload[self.componentConfig["for"]] = self.data;
|
148
|
+
let axios_config = {};
|
149
|
+
if (self.componentConfig["multipart"] == true ) {
|
150
|
+
let form_data = new FormData();
|
151
|
+
for (let key in self.data) {
|
152
|
+
if (key.endsWith("[]")) {
|
153
|
+
for (let i in self.data[key]) {
|
154
|
+
let file = self.data[key][i];
|
155
|
+
form_data.append(self.componentConfig["for"] + "[" + key.slice(0, -2) + "][]", file);
|
156
|
+
}
|
157
|
+
} else {
|
158
|
+
if (self.data[key] != null){
|
159
|
+
form_data.append(self.componentConfig["for"] + "[" + key + "]", self.data[key]);
|
160
|
+
}
|
161
|
+
}
|
161
162
|
}
|
162
|
-
|
163
|
-
|
163
|
+
axios_config = {
|
164
|
+
method: self.componentConfig["method"],
|
165
|
+
url: self.componentConfig["submit_path"],
|
166
|
+
data: form_data,
|
167
|
+
headers: {
|
168
|
+
"X-CSRF-Token": document.getElementsByName("csrf-token")[0].getAttribute("content"),
|
169
|
+
"Content-Type": "multipart/form-data",
|
170
|
+
},
|
171
|
+
};
|
172
|
+
} else {
|
173
|
+
axios_config = {
|
174
|
+
method: self.componentConfig["method"],
|
175
|
+
url: self.componentConfig["submit_path"],
|
176
|
+
data: payload,
|
177
|
+
headers: {
|
178
|
+
"X-CSRF-Token": document.getElementsByName("csrf-token")[0].getAttribute("content"),
|
179
|
+
"Content-Type": "application/json",
|
180
|
+
},
|
181
|
+
};
|
182
|
+
}
|
183
|
+
axios(axios_config)
|
184
|
+
.then(function (response) {
|
185
|
+
self.loading = false;
|
186
|
+
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
|
187
|
+
matestackEventHub.$emit(self.componentConfig["success"]["emit"], response.data);
|
188
|
+
}
|
189
|
+
// transition handling
|
190
|
+
if (self.componentConfig["success"] != undefined
|
191
|
+
&& self.componentConfig["success"]["transition"] != undefined
|
192
|
+
&& (
|
193
|
+
self.componentConfig["success"]["transition"]["follow_response"] == undefined
|
194
|
+
||
|
195
|
+
self.componentConfig["success"]["transition"]["follow_response"] === false
|
196
|
+
)
|
197
|
+
&& self.$store != undefined
|
198
|
+
) {
|
199
|
+
let path = self.componentConfig["success"]["transition"]["path"]
|
200
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
if (self.componentConfig["success"] != undefined
|
204
|
+
&& self.componentConfig["success"]["transition"] != undefined
|
205
|
+
&& self.componentConfig["success"]["transition"]["follow_response"] === true
|
206
|
+
&& self.$store != undefined
|
207
|
+
) {
|
208
|
+
let path = response.data["transition_to"] || response.request.responseURL
|
209
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
// redirect handling
|
213
|
+
if (self.componentConfig["success"] != undefined
|
214
|
+
&& self.componentConfig["success"]["redirect"] != undefined
|
215
|
+
&& (
|
216
|
+
self.componentConfig["success"]["redirect"]["follow_response"] == undefined
|
217
|
+
||
|
218
|
+
self.componentConfig["success"]["redirect"]["follow_response"] === false
|
219
|
+
)
|
220
|
+
&& self.$store != undefined
|
221
|
+
) {
|
222
|
+
let path = self.componentConfig["success"]["redirect"]["path"]
|
223
|
+
window.location.href = path
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
if (self.componentConfig["success"] != undefined
|
227
|
+
&& self.componentConfig["success"]["redirect"] != undefined
|
228
|
+
&& self.componentConfig["success"]["redirect"]["follow_response"] === true
|
229
|
+
&& self.$store != undefined
|
230
|
+
) {
|
231
|
+
let path = response.data["redirect_to"] || response.request.responseURL
|
232
|
+
window.location.href = path
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
|
236
|
+
if (self.shouldResetFormOnSuccessfulSubmit())
|
237
|
+
{
|
238
|
+
self.setProps(self.data, null);
|
239
|
+
self.initValues();
|
240
|
+
}
|
241
|
+
})
|
242
|
+
.catch(function (error) {
|
243
|
+
self.loading = false;
|
244
|
+
if (error.response && error.response.data && error.response.data.errors) {
|
245
|
+
self.errors = error.response.data.errors;
|
246
|
+
}
|
247
|
+
if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
|
248
|
+
matestackEventHub.$emit(self.componentConfig["failure"]["emit"], error.response.data);
|
249
|
+
}
|
250
|
+
// transition handling
|
251
|
+
if (self.componentConfig["failure"] != undefined
|
252
|
+
&& self.componentConfig["failure"]["transition"] != undefined
|
253
|
+
&& (
|
254
|
+
self.componentConfig["failure"]["transition"]["follow_response"] == undefined
|
255
|
+
||
|
256
|
+
self.componentConfig["failure"]["transition"]["follow_response"] === false
|
257
|
+
)
|
258
|
+
&& self.$store != undefined
|
259
|
+
) {
|
260
|
+
let path = self.componentConfig["failure"]["transition"]["path"]
|
261
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
262
|
+
return;
|
263
|
+
}
|
264
|
+
if (self.componentConfig["failure"] != undefined
|
265
|
+
&& self.componentConfig["failure"]["transition"] != undefined
|
266
|
+
&& self.componentConfig["failure"]["transition"]["follow_response"] === true
|
267
|
+
&& self.$store != undefined
|
268
|
+
) {
|
269
|
+
let path = error.response.data["transition_to"] || response.request.responseURL
|
270
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
// redirect handling
|
274
|
+
if (self.componentConfig["failure"] != undefined
|
275
|
+
&& self.componentConfig["failure"]["redirect"] != undefined
|
276
|
+
&& (
|
277
|
+
self.componentConfig["failure"]["redirect"]["follow_response"] == undefined
|
278
|
+
||
|
279
|
+
self.componentConfig["failure"]["redirect"]["follow_response"] === false
|
280
|
+
)
|
281
|
+
&& self.$store != undefined
|
282
|
+
) {
|
283
|
+
let path = self.componentConfig["failure"]["redirect"]["path"]
|
284
|
+
window.location.href = path
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
if (self.componentConfig["failure"] != undefined
|
288
|
+
&& self.componentConfig["failure"]["redirect"] != undefined
|
289
|
+
&& self.componentConfig["failure"]["redirect"]["follow_response"] === true
|
290
|
+
&& self.$store != undefined
|
291
|
+
) {
|
292
|
+
let path = error.response.data["redirect_to"] || response.request.responseURL
|
293
|
+
window.location.href = path
|
294
|
+
return;
|
295
|
+
}
|
296
|
+
});
|
297
|
+
},
|
298
|
+
},
|
299
|
+
mounted: function () {
|
300
|
+
this.initValues();
|
164
301
|
},
|
165
|
-
|
166
|
-
this.initValues()
|
167
|
-
}
|
168
|
-
}
|
302
|
+
};
|
169
303
|
|
170
|
-
let component = Vue.component(
|
304
|
+
let component = Vue.component("matestack-ui-core-form", componentDef);
|
171
305
|
|
172
|
-
export default componentDef
|
306
|
+
export default componentDef;
|