matestack-ui-core 1.3.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +17 -5
- data/README.md +98 -113
- data/Rakefile +0 -2
- data/lib/matestack/ui/app.rb +1 -0
- data/lib/matestack/ui/component.rb +1 -0
- data/lib/matestack/ui/core.rb +60 -10
- data/lib/matestack/ui/core/app.rb +36 -0
- data/lib/matestack/ui/core/base.rb +117 -0
- data/lib/matestack/ui/core/component.rb +8 -0
- data/lib/matestack/ui/core/context.rb +17 -0
- data/lib/matestack/ui/core/helper.rb +91 -0
- data/lib/matestack/ui/core/page.rb +57 -0
- data/lib/matestack/ui/core/properties.rb +105 -0
- data/lib/matestack/ui/core/slots.rb +15 -0
- data/lib/matestack/ui/core/tag_helper.rb +94 -0
- data/lib/matestack/ui/core/version.rb +1 -1
- data/lib/matestack/ui/core/vue_attributes.rb +13 -0
- data/lib/matestack/ui/page.rb +1 -0
- data/{app/concepts/matestack/ui/core → lib/matestack/ui/vue_js}/app/app.js +2 -3
- data/{app/concepts/matestack/ui/core → lib/matestack/ui/vue_js}/app/location.js +0 -0
- data/{app/concepts/matestack/ui/core → lib/matestack/ui/vue_js}/app/store.js +1 -1
- data/lib/matestack/ui/vue_js/components.rb +111 -0
- data/lib/matestack/ui/vue_js/components/action.js +151 -0
- data/lib/matestack/ui/vue_js/components/action.rb +46 -0
- data/{app/concepts/matestack/ui/core/async → lib/matestack/ui/vue_js/components}/async.js +22 -22
- data/lib/matestack/ui/vue_js/components/async.rb +84 -0
- data/{app/concepts/matestack/ui/core/cable → lib/matestack/ui/vue_js/components}/cable.js +14 -14
- data/lib/matestack/ui/vue_js/components/cable.rb +69 -0
- data/{app/concepts/matestack/ui/core/collection/content → lib/matestack/ui/vue_js/components/collection}/content.js +21 -22
- data/lib/matestack/ui/vue_js/components/collection/content.rb +32 -0
- data/lib/matestack/ui/vue_js/components/collection/filter.js +46 -0
- data/lib/matestack/ui/vue_js/components/collection/filter.rb +29 -0
- data/lib/matestack/ui/vue_js/components/collection/filter_reset.rb +19 -0
- data/{app/concepts/matestack/ui/core → lib/matestack/ui/vue_js/components}/collection/helper.rb +68 -61
- data/lib/matestack/ui/vue_js/components/collection/next.rb +19 -0
- data/lib/matestack/ui/vue_js/components/collection/order.js +46 -0
- data/lib/matestack/ui/vue_js/components/collection/order.rb +28 -0
- data/lib/matestack/ui/vue_js/components/collection/order_toggle.rb +21 -0
- data/lib/matestack/ui/vue_js/components/collection/order_toggle_indicator.rb +30 -0
- data/lib/matestack/ui/vue_js/components/collection/page.rb +21 -0
- data/lib/matestack/ui/vue_js/components/collection/previous.rb +19 -0
- data/lib/matestack/ui/vue_js/components/form/base.rb +171 -0
- data/{app/concepts/matestack/ui/core/form/checkbox → lib/matestack/ui/vue_js/components/form}/checkbox.js +2 -2
- data/lib/matestack/ui/vue_js/components/form/checkbox.rb +105 -0
- data/{app/concepts/matestack/ui/core/form/checkbox/mixin.js → lib/matestack/ui/vue_js/components/form/checkbox_mixin.js} +16 -26
- data/lib/matestack/ui/vue_js/components/form/context.rb +15 -0
- data/lib/matestack/ui/vue_js/components/form/fields_for_add_item.rb +35 -0
- data/lib/matestack/ui/vue_js/components/form/fields_for_remove_item.rb +19 -0
- data/lib/matestack/ui/vue_js/components/form/form.js +474 -0
- data/lib/matestack/ui/vue_js/components/form/form.rb +84 -0
- data/{app/concepts/matestack/ui/core/form/input → lib/matestack/ui/vue_js/components/form}/input.js +2 -2
- data/lib/matestack/ui/vue_js/components/form/input.rb +42 -0
- data/{app/concepts/matestack/ui/core/form/input/mixin.js → lib/matestack/ui/vue_js/components/form/input_mixin.js} +9 -11
- data/{app/concepts/matestack/ui/core/form/radio → lib/matestack/ui/vue_js/components/form}/radio.js +2 -2
- data/lib/matestack/ui/vue_js/components/form/radio.rb +76 -0
- data/{app/concepts/matestack/ui/core/form/radio/mixin.js → lib/matestack/ui/vue_js/components/form/radio_mixin.js} +12 -19
- data/{app/concepts/matestack/ui/core/form/select → lib/matestack/ui/vue_js/components/form}/select.js +2 -2
- data/lib/matestack/ui/vue_js/components/form/select.rb +88 -0
- data/{app/concepts/matestack/ui/core/form/select/mixin.js → lib/matestack/ui/vue_js/components/form/select_mixin.js} +12 -15
- data/{app/concepts/matestack/ui/core/form/textarea → lib/matestack/ui/vue_js/components/form}/textarea.js +2 -2
- data/lib/matestack/ui/vue_js/components/form/textarea.rb +37 -0
- data/{app/concepts/matestack/ui/core/form/textarea/mixin.js → lib/matestack/ui/vue_js/components/form/textarea_mixin.js} +8 -12
- data/{app/concepts/matestack/ui/core/isolated → lib/matestack/ui/vue_js/components}/isolated.js +19 -19
- data/lib/matestack/ui/vue_js/components/isolated.rb +86 -0
- data/{app/concepts/matestack/ui/core/component/component.js → lib/matestack/ui/vue_js/components/mixin.js} +2 -2
- data/{app/concepts/matestack/ui/core/onclick → lib/matestack/ui/vue_js/components}/onclick.js +3 -4
- data/lib/matestack/ui/vue_js/components/onclick.rb +37 -0
- data/{app/concepts/matestack/ui/core/toggle → lib/matestack/ui/vue_js/components}/toggle.js +17 -17
- data/lib/matestack/ui/vue_js/components/toggle.rb +38 -0
- data/{app/concepts/matestack/ui/core/transition → lib/matestack/ui/vue_js/components}/transition.js +6 -6
- data/lib/matestack/ui/vue_js/components/transition.rb +40 -0
- data/lib/matestack/ui/vue_js/event_hub.js +5 -0
- data/{app/concepts/matestack/ui/core/js/helpers/query-params-helper.js → lib/matestack/ui/vue_js/helpers/query_params_helper.js} +0 -0
- data/lib/matestack/ui/vue_js/index.js +52 -0
- data/lib/matestack/ui/vue_js/initialize.rb +5 -0
- data/{app/concepts/matestack/ui/core/page/content → lib/matestack/ui/vue_js/page}/content.js +1 -1
- data/lib/matestack/ui/vue_js/vue.rb +63 -0
- data/lib/matestack/ui/vue_js_component.rb +2 -0
- metadata +79 -408
- data/app/concepts/matestack/ui/core/abbr/abbr.haml +0 -5
- data/app/concepts/matestack/ui/core/abbr/abbr.rb +0 -5
- data/app/concepts/matestack/ui/core/action/action.haml +0 -3
- data/app/concepts/matestack/ui/core/action/action.js +0 -152
- data/app/concepts/matestack/ui/core/action/action.rb +0 -80
- data/app/concepts/matestack/ui/core/actionview/dynamic.haml +0 -6
- data/app/concepts/matestack/ui/core/actionview/dynamic.rb +0 -28
- data/app/concepts/matestack/ui/core/actionview/static.haml +0 -1
- data/app/concepts/matestack/ui/core/actionview/static.rb +0 -28
- data/app/concepts/matestack/ui/core/address/address.haml +0 -5
- data/app/concepts/matestack/ui/core/address/address.rb +0 -5
- data/app/concepts/matestack/ui/core/app/app.haml +0 -3
- data/app/concepts/matestack/ui/core/app/app.rb +0 -51
- data/app/concepts/matestack/ui/core/area/area.haml +0 -1
- data/app/concepts/matestack/ui/core/area/area.rb +0 -6
- data/app/concepts/matestack/ui/core/article/article.haml +0 -5
- data/app/concepts/matestack/ui/core/article/article.rb +0 -5
- data/app/concepts/matestack/ui/core/aside/aside.haml +0 -3
- data/app/concepts/matestack/ui/core/aside/aside.rb +0 -4
- data/app/concepts/matestack/ui/core/async/async.haml +0 -6
- data/app/concepts/matestack/ui/core/async/async.rb +0 -37
- data/app/concepts/matestack/ui/core/async/children_wrapper.haml +0 -2
- data/app/concepts/matestack/ui/core/b/b.haml +0 -5
- data/app/concepts/matestack/ui/core/b/b.rb +0 -5
- data/app/concepts/matestack/ui/core/bdi/bdi.haml +0 -5
- data/app/concepts/matestack/ui/core/bdi/bdi.rb +0 -5
- data/app/concepts/matestack/ui/core/bdo/bdo.haml +0 -5
- data/app/concepts/matestack/ui/core/bdo/bdo.rb +0 -6
- data/app/concepts/matestack/ui/core/blockquote/blockquote.haml +0 -5
- data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +0 -6
- data/app/concepts/matestack/ui/core/br/br.haml +0 -5
- data/app/concepts/matestack/ui/core/br/br.rb +0 -5
- data/app/concepts/matestack/ui/core/button/button.haml +0 -5
- data/app/concepts/matestack/ui/core/button/button.rb +0 -7
- data/app/concepts/matestack/ui/core/cable/cable.haml +0 -4
- data/app/concepts/matestack/ui/core/cable/cable.rb +0 -28
- data/app/concepts/matestack/ui/core/cable/children_wrapper.haml +0 -2
- data/app/concepts/matestack/ui/core/caption/caption.haml +0 -5
- data/app/concepts/matestack/ui/core/caption/caption.rb +0 -5
- data/app/concepts/matestack/ui/core/cite/cite.haml +0 -5
- data/app/concepts/matestack/ui/core/cite/cite.rb +0 -5
- data/app/concepts/matestack/ui/core/code/code.haml +0 -5
- data/app/concepts/matestack/ui/core/code/code.rb +0 -5
- data/app/concepts/matestack/ui/core/collection/content/content.rb +0 -16
- data/app/concepts/matestack/ui/core/collection/content/next/next.haml +0 -3
- data/app/concepts/matestack/ui/core/collection/content/next/next.rb +0 -5
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.haml +0 -3
- data/app/concepts/matestack/ui/core/collection/content/page/link/link.rb +0 -7
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +0 -3
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.rb +0 -5
- data/app/concepts/matestack/ui/core/collection/filter/filter.js +0 -48
- data/app/concepts/matestack/ui/core/collection/filter/filter.rb +0 -16
- data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +0 -28
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.haml +0 -3
- data/app/concepts/matestack/ui/core/collection/filter/reset/reset.rb +0 -5
- data/app/concepts/matestack/ui/core/collection/filter/select/select.haml +0 -10
- data/app/concepts/matestack/ui/core/collection/filter/select/select.rb +0 -30
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +0 -3
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.rb +0 -5
- data/app/concepts/matestack/ui/core/collection/order/order.js +0 -56
- data/app/concepts/matestack/ui/core/collection/order/order.rb +0 -16
- data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +0 -17
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.haml +0 -3
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +0 -4
- data/app/concepts/matestack/ui/core/component/anonym-dynamic-component.js +0 -10
- data/app/concepts/matestack/ui/core/component/base.rb +0 -430
- data/app/concepts/matestack/ui/core/component/children.haml +0 -2
- data/app/concepts/matestack/ui/core/component/dynamic.haml +0 -6
- data/app/concepts/matestack/ui/core/component/dynamic.rb +0 -47
- data/app/concepts/matestack/ui/core/component/dynamic_without_rerender.haml +0 -2
- data/app/concepts/matestack/ui/core/component/static.rb +0 -7
- data/app/concepts/matestack/ui/core/data/data.haml +0 -5
- data/app/concepts/matestack/ui/core/data/data.rb +0 -6
- data/app/concepts/matestack/ui/core/datalist/datalist.haml +0 -3
- data/app/concepts/matestack/ui/core/datalist/datalist.rb +0 -4
- data/app/concepts/matestack/ui/core/dd/dd.haml +0 -5
- data/app/concepts/matestack/ui/core/dd/dd.rb +0 -5
- data/app/concepts/matestack/ui/core/del/del.haml +0 -5
- data/app/concepts/matestack/ui/core/del/del.rb +0 -6
- data/app/concepts/matestack/ui/core/details/details.haml +0 -3
- data/app/concepts/matestack/ui/core/details/details.rb +0 -5
- data/app/concepts/matestack/ui/core/dfn/dfn.haml +0 -5
- data/app/concepts/matestack/ui/core/dfn/dfn.rb +0 -6
- data/app/concepts/matestack/ui/core/dialog/dialog.haml +0 -5
- data/app/concepts/matestack/ui/core/dialog/dialog.rb +0 -6
- data/app/concepts/matestack/ui/core/div/div.haml +0 -3
- data/app/concepts/matestack/ui/core/div/div.rb +0 -4
- data/app/concepts/matestack/ui/core/dl/dl.haml +0 -5
- data/app/concepts/matestack/ui/core/dl/dl.rb +0 -5
- data/app/concepts/matestack/ui/core/dt/dt.haml +0 -5
- data/app/concepts/matestack/ui/core/dt/dt.rb +0 -5
- data/app/concepts/matestack/ui/core/em/em.haml +0 -5
- data/app/concepts/matestack/ui/core/em/em.rb +0 -5
- data/app/concepts/matestack/ui/core/fieldset/fieldset.haml +0 -5
- data/app/concepts/matestack/ui/core/fieldset/fieldset.rb +0 -6
- data/app/concepts/matestack/ui/core/figure/figure.haml +0 -3
- data/app/concepts/matestack/ui/core/figure/figure.rb +0 -4
- data/app/concepts/matestack/ui/core/footer/footer.haml +0 -3
- data/app/concepts/matestack/ui/core/footer/footer.rb +0 -4
- data/app/concepts/matestack/ui/core/form/checkbox/base.rb +0 -120
- data/app/concepts/matestack/ui/core/form/checkbox/checkbox.rb +0 -16
- data/app/concepts/matestack/ui/core/form/form.haml +0 -2
- data/app/concepts/matestack/ui/core/form/form.js +0 -275
- data/app/concepts/matestack/ui/core/form/form.rb +0 -104
- data/app/concepts/matestack/ui/core/form/has_errors.rb +0 -54
- data/app/concepts/matestack/ui/core/form/has_input_html_attributes.rb +0 -13
- data/app/concepts/matestack/ui/core/form/input/base.rb +0 -75
- data/app/concepts/matestack/ui/core/form/input/input.rb +0 -17
- data/app/concepts/matestack/ui/core/form/radio/base.rb +0 -90
- data/app/concepts/matestack/ui/core/form/radio/radio.rb +0 -16
- data/app/concepts/matestack/ui/core/form/select/base.rb +0 -98
- data/app/concepts/matestack/ui/core/form/select/select.rb +0 -19
- data/app/concepts/matestack/ui/core/form/submit/base.rb +0 -12
- data/app/concepts/matestack/ui/core/form/submit/submit.js +0 -19
- data/app/concepts/matestack/ui/core/form/submit/submit.rb +0 -15
- data/app/concepts/matestack/ui/core/form/textarea/base.rb +0 -49
- data/app/concepts/matestack/ui/core/form/textarea/textarea.rb +0 -17
- data/app/concepts/matestack/ui/core/form/utils.rb +0 -47
- data/app/concepts/matestack/ui/core/header/header.haml +0 -3
- data/app/concepts/matestack/ui/core/header/header.rb +0 -4
- data/app/concepts/matestack/ui/core/heading/heading.haml +0 -5
- data/app/concepts/matestack/ui/core/heading/heading.rb +0 -5
- data/app/concepts/matestack/ui/core/hr/hr.haml +0 -1
- data/app/concepts/matestack/ui/core/hr/hr.rb +0 -4
- data/app/concepts/matestack/ui/core/icon/icon.haml +0 -5
- data/app/concepts/matestack/ui/core/icon/icon.rb +0 -5
- data/app/concepts/matestack/ui/core/iframe/iframe.haml +0 -5
- data/app/concepts/matestack/ui/core/iframe/iframe.rb +0 -7
- data/app/concepts/matestack/ui/core/img/img.haml +0 -1
- data/app/concepts/matestack/ui/core/img/img.rb +0 -15
- data/app/concepts/matestack/ui/core/input/input.haml +0 -1
- data/app/concepts/matestack/ui/core/input/input.rb +0 -9
- data/app/concepts/matestack/ui/core/ins/ins.haml +0 -5
- data/app/concepts/matestack/ui/core/ins/ins.rb +0 -6
- data/app/concepts/matestack/ui/core/isolated/children_wrapper.haml +0 -2
- data/app/concepts/matestack/ui/core/isolated/isolated.haml +0 -10
- data/app/concepts/matestack/ui/core/isolated/isolated.rb +0 -59
- data/app/concepts/matestack/ui/core/js/core.js +0 -66
- data/app/concepts/matestack/ui/core/js/event-hub.js +0 -5
- data/app/concepts/matestack/ui/core/kbd/kbd.haml +0 -5
- data/app/concepts/matestack/ui/core/kbd/kbd.rb +0 -5
- data/app/concepts/matestack/ui/core/label/label.haml +0 -5
- data/app/concepts/matestack/ui/core/label/label.rb +0 -6
- data/app/concepts/matestack/ui/core/legend/legend.haml +0 -5
- data/app/concepts/matestack/ui/core/legend/legend.rb +0 -5
- data/app/concepts/matestack/ui/core/li/li.haml +0 -5
- data/app/concepts/matestack/ui/core/li/li.rb +0 -6
- data/app/concepts/matestack/ui/core/link/link.haml +0 -5
- data/app/concepts/matestack/ui/core/link/link.rb +0 -23
- data/app/concepts/matestack/ui/core/main/main.haml +0 -3
- data/app/concepts/matestack/ui/core/main/main.rb +0 -4
- data/app/concepts/matestack/ui/core/map/map.haml +0 -3
- data/app/concepts/matestack/ui/core/map/map.rb +0 -5
- data/app/concepts/matestack/ui/core/mark/mark.haml +0 -5
- data/app/concepts/matestack/ui/core/mark/mark.rb +0 -5
- data/app/concepts/matestack/ui/core/meter/meter.haml +0 -4
- data/app/concepts/matestack/ui/core/meter/meter.rb +0 -5
- data/app/concepts/matestack/ui/core/nav/nav.haml +0 -3
- data/app/concepts/matestack/ui/core/nav/nav.rb +0 -4
- data/app/concepts/matestack/ui/core/noscript/noscript.haml +0 -5
- data/app/concepts/matestack/ui/core/noscript/noscript.rb +0 -5
- data/app/concepts/matestack/ui/core/object/object.haml +0 -1
- data/app/concepts/matestack/ui/core/object/object.rb +0 -5
- data/app/concepts/matestack/ui/core/ol/ol.haml +0 -3
- data/app/concepts/matestack/ui/core/ol/ol.rb +0 -5
- data/app/concepts/matestack/ui/core/onclick/onclick.haml +0 -2
- data/app/concepts/matestack/ui/core/onclick/onclick.rb +0 -6
- data/app/concepts/matestack/ui/core/optgroup/optgroup.haml +0 -3
- data/app/concepts/matestack/ui/core/optgroup/optgroup.rb +0 -5
- data/app/concepts/matestack/ui/core/option/option.haml +0 -5
- data/app/concepts/matestack/ui/core/option/option.rb +0 -6
- data/app/concepts/matestack/ui/core/output/output.haml +0 -5
- data/app/concepts/matestack/ui/core/output/output.rb +0 -6
- data/app/concepts/matestack/ui/core/page/content/content.rb +0 -28
- data/app/concepts/matestack/ui/core/page/page.haml +0 -3
- data/app/concepts/matestack/ui/core/page/page.rb +0 -30
- data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +0 -5
- data/app/concepts/matestack/ui/core/paragraph/paragraph.rb +0 -5
- data/app/concepts/matestack/ui/core/param/param.haml +0 -1
- data/app/concepts/matestack/ui/core/param/param.rb +0 -5
- data/app/concepts/matestack/ui/core/partial/partial.haml +0 -2
- data/app/concepts/matestack/ui/core/partial/partial.rb +0 -4
- data/app/concepts/matestack/ui/core/picture/picture.haml +0 -3
- data/app/concepts/matestack/ui/core/picture/picture.rb +0 -4
- data/app/concepts/matestack/ui/core/plain/plain.rb +0 -9
- data/app/concepts/matestack/ui/core/pre/pre.haml +0 -5
- data/app/concepts/matestack/ui/core/pre/pre.rb +0 -5
- data/app/concepts/matestack/ui/core/progress/progress.haml +0 -3
- data/app/concepts/matestack/ui/core/progress/progress.rb +0 -5
- data/app/concepts/matestack/ui/core/q/q.haml +0 -5
- data/app/concepts/matestack/ui/core/q/q.rb +0 -6
- data/app/concepts/matestack/ui/core/rp/rp.haml +0 -5
- data/app/concepts/matestack/ui/core/rp/rp.rb +0 -5
- data/app/concepts/matestack/ui/core/rt/rt.haml +0 -5
- data/app/concepts/matestack/ui/core/rt/rt.rb +0 -5
- data/app/concepts/matestack/ui/core/ruby/ruby.haml +0 -5
- data/app/concepts/matestack/ui/core/ruby/ruby.rb +0 -5
- data/app/concepts/matestack/ui/core/s/s.haml +0 -5
- data/app/concepts/matestack/ui/core/s/s.rb +0 -6
- data/app/concepts/matestack/ui/core/samp/samp.haml +0 -5
- data/app/concepts/matestack/ui/core/samp/samp.rb +0 -5
- data/app/concepts/matestack/ui/core/section/section.haml +0 -3
- data/app/concepts/matestack/ui/core/section/section.rb +0 -4
- data/app/concepts/matestack/ui/core/select/select.haml +0 -3
- data/app/concepts/matestack/ui/core/select/select.rb +0 -7
- data/app/concepts/matestack/ui/core/slot/slot.haml +0 -2
- data/app/concepts/matestack/ui/core/slot/slot.rb +0 -4
- data/app/concepts/matestack/ui/core/small/small.haml +0 -5
- data/app/concepts/matestack/ui/core/small/small.rb +0 -5
- data/app/concepts/matestack/ui/core/span/span.haml +0 -5
- data/app/concepts/matestack/ui/core/span/span.rb +0 -5
- data/app/concepts/matestack/ui/core/strong/strong.haml +0 -5
- data/app/concepts/matestack/ui/core/strong/strong.rb +0 -5
- data/app/concepts/matestack/ui/core/sub/sub.haml +0 -5
- data/app/concepts/matestack/ui/core/sub/sub.rb +0 -5
- data/app/concepts/matestack/ui/core/summary/summary.haml +0 -5
- data/app/concepts/matestack/ui/core/summary/summary.rb +0 -5
- data/app/concepts/matestack/ui/core/sup/sup.haml +0 -5
- data/app/concepts/matestack/ui/core/sup/sup.rb +0 -5
- data/app/concepts/matestack/ui/core/table/table.haml +0 -3
- data/app/concepts/matestack/ui/core/table/table.rb +0 -4
- data/app/concepts/matestack/ui/core/tbody/tbody.haml +0 -3
- data/app/concepts/matestack/ui/core/tbody/tbody.rb +0 -4
- data/app/concepts/matestack/ui/core/td/td.haml +0 -5
- data/app/concepts/matestack/ui/core/td/td.rb +0 -6
- data/app/concepts/matestack/ui/core/template/template.haml +0 -3
- data/app/concepts/matestack/ui/core/template/template.rb +0 -4
- data/app/concepts/matestack/ui/core/textarea/textarea.haml +0 -5
- data/app/concepts/matestack/ui/core/textarea/textarea.rb +0 -10
- data/app/concepts/matestack/ui/core/tfoot/tfoot.haml +0 -3
- data/app/concepts/matestack/ui/core/tfoot/tfoot.rb +0 -4
- data/app/concepts/matestack/ui/core/th/th.haml +0 -5
- data/app/concepts/matestack/ui/core/th/th.rb +0 -6
- data/app/concepts/matestack/ui/core/thead/thead.haml +0 -3
- data/app/concepts/matestack/ui/core/thead/thead.rb +0 -4
- data/app/concepts/matestack/ui/core/time/time.haml +0 -3
- data/app/concepts/matestack/ui/core/time/time.rb +0 -5
- data/app/concepts/matestack/ui/core/toggle/toggle.haml +0 -2
- data/app/concepts/matestack/ui/core/toggle/toggle.rb +0 -13
- data/app/concepts/matestack/ui/core/tr/tr.haml +0 -3
- data/app/concepts/matestack/ui/core/tr/tr.rb +0 -4
- data/app/concepts/matestack/ui/core/transition/transition.haml +0 -5
- data/app/concepts/matestack/ui/core/transition/transition.rb +0 -38
- data/app/concepts/matestack/ui/core/u/u.haml +0 -5
- data/app/concepts/matestack/ui/core/u/u.rb +0 -6
- data/app/concepts/matestack/ui/core/ul/ul.haml +0 -3
- data/app/concepts/matestack/ui/core/ul/ul.rb +0 -4
- data/app/concepts/matestack/ui/core/unescaped/unescaped.rb +0 -9
- data/app/concepts/matestack/ui/core/var/var.haml +0 -5
- data/app/concepts/matestack/ui/core/var/var.rb +0 -5
- data/app/concepts/matestack/ui/core/video/video.haml +0 -3
- data/app/concepts/matestack/ui/core/video/video.rb +0 -13
- data/app/concepts/matestack/ui/core/view/view.haml +0 -1
- data/app/concepts/matestack/ui/core/view/view.rb +0 -30
- data/app/concepts/matestack/ui/core/wbr/wbr.haml +0 -5
- data/app/concepts/matestack/ui/core/wbr/wbr.rb +0 -5
- data/app/concepts/matestack/ui/core/youtube/youtube.haml +0 -1
- data/app/concepts/matestack/ui/core/youtube/youtube.rb +0 -28
- data/app/helpers/matestack/ui/core/application_helper.rb +0 -111
- data/app/javascript/matestack-ui-core/index.js +0 -32
- data/app/javascript/matestack-ui-core/styles/index.scss +0 -5
- data/app/javascript/packs/matestack-ui-core.js +0 -8
- data/app/lib/matestack/ui/app.rb +0 -1
- data/app/lib/matestack/ui/component.rb +0 -1
- data/app/lib/matestack/ui/core/has_view_context.rb +0 -16
- data/app/lib/matestack/ui/core/html_attributes.rb +0 -43
- data/app/lib/matestack/ui/core/properties.rb +0 -161
- data/app/lib/matestack/ui/core/rendering/default_renderer_class_determiner.rb +0 -33
- data/app/lib/matestack/ui/core/rendering/main_renderer.rb +0 -203
- data/app/lib/matestack/ui/dynamic_actionview_component.rb +0 -1
- data/app/lib/matestack/ui/dynamic_component.rb +0 -1
- data/app/lib/matestack/ui/isolated_component.rb +0 -1
- data/app/lib/matestack/ui/page.rb +0 -1
- data/app/lib/matestack/ui/static_actionview_component.rb +0 -1
- data/app/lib/matestack/ui/static_component.rb +0 -1
- data/app/lib/matestack/ui/vue_js_component.rb +0 -1
- data/config/routes.rb +0 -2
- data/lib/generators/matestack/app/USAGE +0 -21
- data/lib/generators/matestack/app/app_generator.rb +0 -25
- data/lib/generators/matestack/app/templates/app/controllers/%file_name%_controller.rb.tt +0 -5
- data/lib/generators/matestack/app/templates/app/matestack/apps/%file_name%.rb.tt +0 -28
- data/lib/generators/matestack/component/USAGE +0 -20
- data/lib/generators/matestack/component/component_generator.rb +0 -29
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.haml.tt +0 -5
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.js.tt +0 -17
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.rb.tt +0 -11
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.scss.tt +0 -1
- data/lib/generators/matestack/core/component/USAGE +0 -16
- data/lib/generators/matestack/core/component/component_generator.rb +0 -23
- data/lib/generators/matestack/core/component/templates/app/concepts/matestack/ui/core/%file_name%/%file_name%.haml.tt +0 -5
- data/lib/generators/matestack/core/component/templates/app/concepts/matestack/ui/core/%file_name%/%file_name%.rb.tt +0 -4
- data/lib/generators/matestack/core/component/templates/docs/components/%file_name%.md.tt +0 -45
- data/lib/generators/matestack/core/component/templates/spec/usage/components/%file_name%_spec.rb +0 -31
- data/lib/generators/matestack/page/USAGE +0 -28
- data/lib/generators/matestack/page/page_generator.rb +0 -54
- data/lib/generators/matestack/page/templates/app/matestack/pages/%app_name%/%namespace%/%file_name%.rb.tt +0 -29
- data/lib/matestack/ui/core/cell.rb +0 -31
- data/lib/matestack/ui/core/component/registry.rb +0 -47
- data/lib/matestack/ui/core/components.rb +0 -271
- data/lib/matestack/ui/core/dsl.rb +0 -6
- data/lib/matestack/ui/core/engine.rb +0 -35
- data/lib/tasks/matestack/ui/core_tasks.rake +0 -4
- data/vendor/assets/javascripts/dist/manifest.json +0 -18
- 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 +0 -3
- data/vendor/assets/javascripts/dist/matestack-ui-core.css.map +0 -1
- data/vendor/assets/javascripts/dist/matestack-ui-core.js +0 -17734
- data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +0 -1
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.css +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +0 -3
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.LICENSE.txt +0 -18
- 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 +0 -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
- data/vendor/assets/javascripts/matestack-ui-core.js.erb +0 -2
- data/vendor/assets/stylesheets/dist +0 -1
- data/vendor/assets/stylesheets/matestack-ui-core.css.erb +0 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
import Vue from "vue/dist/vue.esm";
|
2
2
|
|
3
|
-
import formCheckboxMixin from "./
|
4
|
-
import componentMixin from "
|
3
|
+
import formCheckboxMixin from "./checkbox_mixin";
|
4
|
+
import componentMixin from "../mixin";
|
5
5
|
|
6
6
|
const componentDef = {
|
7
7
|
mixins: [componentMixin, formCheckboxMixin],
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Matestack
|
2
|
+
module Ui
|
3
|
+
module VueJs
|
4
|
+
module Components
|
5
|
+
module Form
|
6
|
+
class Checkbox < Matestack::Ui::VueJs::Components::Form::Base
|
7
|
+
vue_name 'matestack-ui-core-form-checkbox'
|
8
|
+
|
9
|
+
def response
|
10
|
+
div class: 'matestack-ui-core-form-checkbox' do
|
11
|
+
render_options
|
12
|
+
render_errors
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_options
|
17
|
+
if checkbox_options
|
18
|
+
render_checkbox_options
|
19
|
+
else
|
20
|
+
render_true_false_checkbox
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def component_id
|
25
|
+
"checkbox-component-for-#{key}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def vue_props
|
29
|
+
{
|
30
|
+
init_value: init_value,
|
31
|
+
key: key,
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# checkbox rendering
|
36
|
+
|
37
|
+
def render_checkbox_options
|
38
|
+
checkbox_options.to_a.each do |item|
|
39
|
+
input checkbox_attributes(item)
|
40
|
+
label item_label(item), ":for": item_id(item)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def checkbox_attributes(item)
|
45
|
+
{
|
46
|
+
":id": item_id(item),
|
47
|
+
type: :checkbox,
|
48
|
+
name: item_label(item),
|
49
|
+
value: item_value(item),
|
50
|
+
ref: "select.multiple.#{key}",
|
51
|
+
'@change': change_event,
|
52
|
+
'init-value': (init_value || []).to_json,
|
53
|
+
'v-bind:class': "{ '#{error_class}': #{error_key} }",
|
54
|
+
'value-type': value_type(item),
|
55
|
+
"#{v_model_type(item)}": input_key,
|
56
|
+
}.merge(self.options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def render_true_false_checkbox
|
60
|
+
input true_false_checkbox_attributes.merge(type: :hidden, ":id": nil, value: 0)
|
61
|
+
input true_false_checkbox_attributes.merge(type: :checkbox, ":id": item_id(1))
|
62
|
+
label input_label, ":for": item_id(1) if input_label
|
63
|
+
end
|
64
|
+
|
65
|
+
def true_false_checkbox_attributes
|
66
|
+
attributes.merge({
|
67
|
+
'init-value': init_value_for_single_input,
|
68
|
+
})
|
69
|
+
end
|
70
|
+
|
71
|
+
def init_value_for_single_input
|
72
|
+
if init_value == true || init_value == 1
|
73
|
+
return "true"
|
74
|
+
end
|
75
|
+
if init_value == false || init_value == 0
|
76
|
+
return "false"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# checkbox options
|
81
|
+
|
82
|
+
def checkbox_options
|
83
|
+
@checkbox_options ||= options.delete(:options)
|
84
|
+
end
|
85
|
+
|
86
|
+
# calculated attributes
|
87
|
+
|
88
|
+
def item_value(item)
|
89
|
+
item.is_a?(Array) ? item.last : item
|
90
|
+
end
|
91
|
+
|
92
|
+
def item_label(item)
|
93
|
+
item.is_a?(Array) ? item.first : item
|
94
|
+
end
|
95
|
+
|
96
|
+
def item_id(item)
|
97
|
+
"#{id}+'_#{item_value(item).to_s.gsub(" ", '_')}'"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -10,68 +10,58 @@ const formCheckboxMixin = {
|
|
10
10
|
|
11
11
|
if (key.startsWith("select.")) {
|
12
12
|
if (key.startsWith("select.multiple.")) {
|
13
|
+
self.$set(self.$parent.data, key.replace("select.multiple.", ""), null)
|
13
14
|
if (initValue) {
|
14
|
-
|
15
|
-
Object.assign(self.$parent.data, data);
|
15
|
+
self.setValue(JSON.parse(initValue["value"]));
|
16
16
|
self.afterInitialize(JSON.parse(initValue["value"]))
|
17
17
|
} else {
|
18
|
-
|
19
|
-
|
20
|
-
self.afterInitialize([])
|
18
|
+
self.setValue([]);
|
19
|
+
self.afterInitialize([]);
|
21
20
|
}
|
22
21
|
} else {
|
22
|
+
self.$set(self.$parent.data, key.replace("select.", ""), null)
|
23
23
|
if (initValue) {
|
24
24
|
if (valueType && valueType["value"] == "Integer") {
|
25
|
-
|
26
|
-
Object.assign(self.$parent.data, data);
|
25
|
+
self.setValue(parseInt(initValue["value"]));
|
27
26
|
self.afterInitialize(parseInt(initValue["value"]))
|
28
27
|
} else {
|
29
|
-
|
30
|
-
data[key.replace("select.", "")] = initValue["value"];
|
31
|
-
Object.assign(self.$parent.data, data);
|
28
|
+
self.setValue(initValue["value"]);
|
32
29
|
self.afterInitialize(initValue["value"])
|
33
30
|
}
|
34
31
|
} else {
|
35
|
-
|
36
|
-
Object.assign(self.$parent.data, data);
|
32
|
+
self.setValue(null);
|
37
33
|
self.afterInitialize(null)
|
38
34
|
}
|
39
35
|
}
|
40
36
|
} else {
|
37
|
+
self.$set(self.$parent.data, key.replace("input.", ""), null)
|
41
38
|
if (initValue) {
|
42
39
|
if(initValue["value"] === "true"){
|
43
|
-
|
44
|
-
Object.assign(self.$parent.data, data);
|
40
|
+
self.setValue(true);
|
45
41
|
self.afterInitialize(true)
|
46
42
|
}
|
47
43
|
if(initValue["value"] === "false"){
|
48
|
-
|
49
|
-
Object.assign(self.$parent.data, data);
|
44
|
+
self.setValue(false);
|
50
45
|
self.afterInitialize(false)
|
51
46
|
}
|
52
47
|
} else {
|
53
|
-
|
54
|
-
Object.assign(self.$parent.data, data);
|
48
|
+
self.setValue(null);
|
55
49
|
self.afterInitialize(null)
|
56
50
|
}
|
57
51
|
}
|
58
52
|
}
|
59
|
-
|
60
|
-
//without the timeout it's somehow not working
|
61
|
-
setTimeout(function () {
|
62
|
-
self.$forceUpdate()
|
63
|
-
}, 1);
|
64
53
|
},
|
65
54
|
inputChanged: function (key) {
|
55
|
+
if (this.$parent.isNestedForm){
|
56
|
+
this.$parent.data["_destroy"] = false;
|
57
|
+
}
|
66
58
|
this.$parent.resetErrors(key);
|
67
|
-
this.$forceUpdate();
|
68
59
|
},
|
69
60
|
afterInitialize: function(value){
|
70
61
|
// can be used in the main component for further initialization steps
|
71
62
|
},
|
72
63
|
setValue: function (value){
|
73
|
-
this.$parent.data[this.
|
74
|
-
this.$forceUpdate();
|
64
|
+
this.$parent.data[this.props["key"]] = value
|
75
65
|
}
|
76
66
|
}
|
77
67
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Matestack
|
2
|
+
module Ui
|
3
|
+
module VueJs
|
4
|
+
module Components
|
5
|
+
module Form
|
6
|
+
class FieldsForAddItem < Matestack::Ui::Component
|
7
|
+
|
8
|
+
required :key
|
9
|
+
|
10
|
+
required :prototype
|
11
|
+
|
12
|
+
attr_accessor :prototype_template_json
|
13
|
+
|
14
|
+
def create_children(&block)
|
15
|
+
# first render prototype_template_json
|
16
|
+
self.prototype_template_json = context.prototype.call().to_json
|
17
|
+
# delete from children in order not to render the prototype
|
18
|
+
self.children.shift
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def response
|
23
|
+
div id: "prototype-template-for-#{context.key}", "v-pre": true, data: { ":template": self.prototype_template_json }
|
24
|
+
Matestack::Ui::Core::Base.new('v-runtime-template', ':template': "nestedFormRuntimeTemplates['#{context.key}']")
|
25
|
+
a class: 'matestack-ui-core-form-fields-for-add-item', "@click.prevent": "addItem('#{context.key}')" do
|
26
|
+
yield if block_given?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Matestack
|
2
|
+
module Ui
|
3
|
+
module VueJs
|
4
|
+
module Components
|
5
|
+
module Form
|
6
|
+
class FieldsForRemoveItem < Matestack::Ui::Component
|
7
|
+
|
8
|
+
def response
|
9
|
+
a class: 'matestack-ui-core-form-fields-for-remove-item', "@click.prevent": "removeItem()" do
|
10
|
+
yield if block_given?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,474 @@
|
|
1
|
+
import Vue from "vue/dist/vue.esm";
|
2
|
+
import Vuex from "vuex";
|
3
|
+
import VRuntimeTemplate from "v-runtime-template"
|
4
|
+
|
5
|
+
import axios from "axios";
|
6
|
+
|
7
|
+
import matestackEventHub from "../../event_hub";
|
8
|
+
import componentMixin from "../mixin";
|
9
|
+
|
10
|
+
const componentDef = {
|
11
|
+
mixins: [componentMixin],
|
12
|
+
data: function () {
|
13
|
+
return {
|
14
|
+
data: {},
|
15
|
+
errors: {},
|
16
|
+
loading: false,
|
17
|
+
nestedForms: {},
|
18
|
+
isNestedForm: false,
|
19
|
+
hideNestedForm: false,
|
20
|
+
nestedFormRuntimeTemplates: {},
|
21
|
+
nestedFormRuntimeTemplateDomElements: {},
|
22
|
+
deletedNestedForms: {},
|
23
|
+
nestedFormRuntimeId: "",
|
24
|
+
nestedFormServerErrorIndex: "",
|
25
|
+
};
|
26
|
+
},
|
27
|
+
methods: {
|
28
|
+
initDataKey: function (key, initValue) {
|
29
|
+
this.data[key] = initValue;
|
30
|
+
},
|
31
|
+
updateFormValue: function (key, value) {
|
32
|
+
this.data[key] = value;
|
33
|
+
},
|
34
|
+
hasErrors: function(){
|
35
|
+
//https://stackoverflow.com/a/27709663/13886137
|
36
|
+
for (var key in this.errors) {
|
37
|
+
if (this.errors[key] !== null && this.errors[key] != ""){
|
38
|
+
return true;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return false;
|
42
|
+
},
|
43
|
+
resetErrors: function (key) {
|
44
|
+
if (this.errors[key]) {
|
45
|
+
delete this.errors[key];
|
46
|
+
Vue.set(this.errors);
|
47
|
+
}
|
48
|
+
if (this.isNestedForm){
|
49
|
+
var serverErrorKey = this.props["fields_for"].replace("_attributes", "")+"["+this.nestedFormServerErrorIndex+"]."+key
|
50
|
+
if (this.$parent.errors[serverErrorKey]) {
|
51
|
+
delete this.$parent.errors[serverErrorKey];
|
52
|
+
Vue.set(this.$parent.errors);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
},
|
56
|
+
setErrors: function(errors){
|
57
|
+
this.errors = errors;
|
58
|
+
},
|
59
|
+
setNestedFormServerErrorIndex: function(value){
|
60
|
+
this.nestedFormServerErrorIndex = value;
|
61
|
+
},
|
62
|
+
setErrorKey: function(key, value){
|
63
|
+
Vue.set(this.errors, key, value);
|
64
|
+
},
|
65
|
+
flushErrors: function(key, value){
|
66
|
+
this.errors = {};
|
67
|
+
},
|
68
|
+
setNestedFormsError: function(errors){
|
69
|
+
let self = this;
|
70
|
+
Object.keys(errors).forEach(function(errorKey){
|
71
|
+
if (errorKey.includes(".")){
|
72
|
+
let childErrorKey = errorKey.split(".")[1]
|
73
|
+
let childModelName = errorKey.split(".")[0].split("[")[0]
|
74
|
+
let childModelIndex = errorKey.split(".")[0].split("[")[1].split("]")[0]
|
75
|
+
let mappedChildModelIndex = self.mapToNestedForms(parseInt(childModelIndex), childModelName+"_attributes")
|
76
|
+
self.nestedForms[childModelName+"_attributes"][mappedChildModelIndex].setNestedFormServerErrorIndex(parseInt(childModelIndex))
|
77
|
+
self.nestedForms[childModelName+"_attributes"][mappedChildModelIndex].setErrorKey(childErrorKey, errors[errorKey])
|
78
|
+
}
|
79
|
+
})
|
80
|
+
},
|
81
|
+
mapToNestedForms: function(serverIndex, nestedFormKey){
|
82
|
+
var primaryKey;
|
83
|
+
if(this.props["primary_key"] != undefined){
|
84
|
+
primaryKey = this.props["primary_key"];
|
85
|
+
}else{
|
86
|
+
primaryKey = "id";
|
87
|
+
}
|
88
|
+
|
89
|
+
var formIdMap = []
|
90
|
+
var childModelKey = 0;
|
91
|
+
while(this.data[nestedFormKey].length > childModelKey){
|
92
|
+
var ignore = this.data[nestedFormKey][childModelKey]["_destroy"] == true && this.data[nestedFormKey][childModelKey][primaryKey] == null
|
93
|
+
if(!ignore){
|
94
|
+
formIdMap.push(childModelKey)
|
95
|
+
}
|
96
|
+
childModelKey++;
|
97
|
+
}
|
98
|
+
|
99
|
+
return formIdMap[serverIndex];
|
100
|
+
},
|
101
|
+
resetNestedForms: function(){
|
102
|
+
var self = this;
|
103
|
+
Object.keys(self.nestedForms).forEach(function(childModelKey){
|
104
|
+
self.nestedForms[childModelKey].forEach(function(nestedFormInstance){
|
105
|
+
if(nestedFormInstance.data["_destroy"] == true){
|
106
|
+
var destroyed = true;
|
107
|
+
}
|
108
|
+
nestedFormInstance.initValues()
|
109
|
+
console.log(nestedFormInstance.data)
|
110
|
+
Vue.set(nestedFormInstance.data)
|
111
|
+
if(destroyed){
|
112
|
+
nestedFormInstance.hideNestedForm = true
|
113
|
+
Vue.set(nestedFormInstance.data, "_destroy", true)
|
114
|
+
}
|
115
|
+
})
|
116
|
+
})
|
117
|
+
},
|
118
|
+
removeItem: function(){
|
119
|
+
Vue.set(this.data, "_destroy", true)
|
120
|
+
this.hideNestedForm = true;
|
121
|
+
var id = parseInt(this.nestedFormRuntimeId.replace("_"+this.props["fields_for"]+"_child_", ""));
|
122
|
+
this.$parent.deletedNestedForms[this.props["fields_for"]].push(id);
|
123
|
+
var serverErrorKey = this.props["fields_for"].replace("_attributes", "")+"["+this.nestedFormServerErrorIndex+"]."
|
124
|
+
var self = this;
|
125
|
+
Object.keys(self.$parent.errors).forEach(function(errorKey){
|
126
|
+
if (errorKey.lastIndexOf(serverErrorKey, 0) == 0) {
|
127
|
+
delete self.$parent.errors[errorKey];
|
128
|
+
Vue.set(self.$parent.errors)
|
129
|
+
}
|
130
|
+
});
|
131
|
+
},
|
132
|
+
addItem: function(key){
|
133
|
+
var templateString = JSON.parse(this.$el.querySelector('#prototype-template-for-'+key).dataset[":template"])
|
134
|
+
if (this.nestedFormRuntimeTemplateDomElements[key] == null){
|
135
|
+
var dom_elem = document.createElement('div')
|
136
|
+
dom_elem.innerHTML = templateString
|
137
|
+
var existingItemsCount;
|
138
|
+
if (this.nestedForms[key] == undefined){
|
139
|
+
existingItemsCount = 0
|
140
|
+
}else{
|
141
|
+
existingItemsCount = this.nestedForms[key].length
|
142
|
+
}
|
143
|
+
dom_elem.querySelector('.matestack-form-fields-for').id = key+"_child_"+existingItemsCount
|
144
|
+
Vue.set(this.nestedFormRuntimeTemplateDomElements, key, dom_elem)
|
145
|
+
Vue.set(this.nestedFormRuntimeTemplates, key, this.nestedFormRuntimeTemplateDomElements[key].outerHTML)
|
146
|
+
}else{
|
147
|
+
var dom_elem = document.createElement('div')
|
148
|
+
dom_elem.innerHTML = templateString
|
149
|
+
var existingItemsCount = this.nestedForms[key].length
|
150
|
+
dom_elem.querySelector('.matestack-form-fields-for').id = key+"_child_"+existingItemsCount
|
151
|
+
this.nestedFormRuntimeTemplateDomElements[key].insertAdjacentHTML(
|
152
|
+
'beforeend',
|
153
|
+
dom_elem.innerHTML
|
154
|
+
)
|
155
|
+
Vue.set(this.nestedFormRuntimeTemplates, key, this.nestedFormRuntimeTemplateDomElements[key].outerHTML)
|
156
|
+
}
|
157
|
+
},
|
158
|
+
initValues: function () {
|
159
|
+
let self = this;
|
160
|
+
let data = {};
|
161
|
+
|
162
|
+
for (let key in self.$refs) {
|
163
|
+
if (key.startsWith("input-component")) {
|
164
|
+
self.$refs[key].initialize()
|
165
|
+
}
|
166
|
+
if (key.startsWith("textarea-component")) {
|
167
|
+
self.$refs[key].initialize()
|
168
|
+
}
|
169
|
+
if (key.startsWith("select-component")) {
|
170
|
+
self.$refs[key].initialize()
|
171
|
+
}
|
172
|
+
if (key.startsWith("radio-component")) {
|
173
|
+
self.$refs[key].initialize()
|
174
|
+
}
|
175
|
+
if (key.startsWith("checkbox-component")) {
|
176
|
+
self.$refs[key].initialize()
|
177
|
+
}
|
178
|
+
}
|
179
|
+
},
|
180
|
+
|
181
|
+
shouldResetFormOnSuccessfulSubmit() {
|
182
|
+
const self = this;
|
183
|
+
if (self.props["success"] != undefined && self.props["success"]["reset"] != undefined) {
|
184
|
+
return self.props["success"]["reset"];
|
185
|
+
} else {
|
186
|
+
return self.shouldResetFormOnSuccessfulSubmitByDefault();
|
187
|
+
}
|
188
|
+
},
|
189
|
+
shouldResetFormOnSuccessfulSubmitByDefault() {
|
190
|
+
const self = this;
|
191
|
+
if (self.props["method"] == "put") {
|
192
|
+
return false;
|
193
|
+
} else {
|
194
|
+
return true;
|
195
|
+
}
|
196
|
+
},
|
197
|
+
perform: function(){
|
198
|
+
const self = this
|
199
|
+
if (self.props["fields_for"] != null) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
var form = self.$el.tagName == 'FORM' ? self.$el : self.$el.querySelector('form');
|
203
|
+
if(form.checkValidity()){
|
204
|
+
self.loading = true;
|
205
|
+
if (self.props["emit"] != undefined) {
|
206
|
+
matestackEventHub.$emit(self.props["emit"]);
|
207
|
+
}
|
208
|
+
if (self.props["delay"] != undefined) {
|
209
|
+
setTimeout(function () {
|
210
|
+
self.sendRequest()
|
211
|
+
}, parseInt(self.props["delay"]));
|
212
|
+
} else {
|
213
|
+
self.sendRequest()
|
214
|
+
}
|
215
|
+
} else {
|
216
|
+
matestackEventHub.$emit('static_form_errors');
|
217
|
+
}
|
218
|
+
},
|
219
|
+
transformToFormData: function (formData, dataNode, parentKey=null) {
|
220
|
+
var self = this;
|
221
|
+
for (let key in dataNode) {
|
222
|
+
if (key.endsWith("[]")) {
|
223
|
+
for (let i in dataNode[key]) {
|
224
|
+
let file = dataNode[key][i];
|
225
|
+
if (parentKey != null) {
|
226
|
+
formData.append(self.props["for"] + parentKey + "[" + key.slice(0, -2) + "][]", file);
|
227
|
+
} else {
|
228
|
+
formData.append(self.props["for"] + "[" + key.slice(0, -2) + "][]", file);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
} else {
|
232
|
+
if (Array.isArray(dataNode[key])){
|
233
|
+
dataNode[key].forEach(function(item, index){
|
234
|
+
if (parentKey != null) {
|
235
|
+
let _key = parentKey + "[" + key + "]" + "[]";
|
236
|
+
formData = self.transformToFormData(formData, item, _key)
|
237
|
+
} else {
|
238
|
+
let _key = "[" + key + "]" + "[]";
|
239
|
+
formData = self.transformToFormData(formData, item, _key)
|
240
|
+
}
|
241
|
+
})
|
242
|
+
} else {
|
243
|
+
if (dataNode[key] != null){
|
244
|
+
if (parentKey != null) {
|
245
|
+
formData.append(self.props["for"] + parentKey + "[" + key + "]", dataNode[key]);
|
246
|
+
} else {
|
247
|
+
formData.append(self.props["for"] + "[" + key + "]", dataNode[key]);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
return formData;
|
255
|
+
},
|
256
|
+
sendRequest: function(){
|
257
|
+
const self = this;
|
258
|
+
let payload = {};
|
259
|
+
payload[self.props["for"]] = self.data;
|
260
|
+
let axios_config = {};
|
261
|
+
if (self.props["multipart"] == true ) {
|
262
|
+
let formData = new FormData();
|
263
|
+
formData = this.transformToFormData(formData, this.data)
|
264
|
+
axios_config = {
|
265
|
+
method: self.props["method"],
|
266
|
+
url: self.props["submit_path"],
|
267
|
+
data: formData,
|
268
|
+
headers: {
|
269
|
+
"X-CSRF-Token": document.getElementsByName("csrf-token")[0].getAttribute("content"),
|
270
|
+
"Content-Type": "multipart/form-data",
|
271
|
+
},
|
272
|
+
};
|
273
|
+
} else {
|
274
|
+
axios_config = {
|
275
|
+
method: self.props["method"],
|
276
|
+
url: self.props["submit_path"],
|
277
|
+
data: payload,
|
278
|
+
headers: {
|
279
|
+
"X-CSRF-Token": document.getElementsByName("csrf-token")[0].getAttribute("content"),
|
280
|
+
"Content-Type": "application/json",
|
281
|
+
},
|
282
|
+
};
|
283
|
+
}
|
284
|
+
axios(axios_config)
|
285
|
+
.then(function (response) {
|
286
|
+
self.loading = false;
|
287
|
+
if (self.props["success"] != undefined && self.props["success"]["emit"] != undefined) {
|
288
|
+
matestackEventHub.$emit(self.props["success"]["emit"], response.data);
|
289
|
+
}
|
290
|
+
// transition handling
|
291
|
+
if (self.props["success"] != undefined
|
292
|
+
&& self.props["success"]["transition"] != undefined
|
293
|
+
&& (
|
294
|
+
self.props["success"]["transition"]["follow_response"] == undefined
|
295
|
+
||
|
296
|
+
self.props["success"]["transition"]["follow_response"] === false
|
297
|
+
)
|
298
|
+
&& self.$store != undefined
|
299
|
+
) {
|
300
|
+
let path = self.props["success"]["transition"]["path"]
|
301
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
302
|
+
return;
|
303
|
+
}
|
304
|
+
if (self.props["success"] != undefined
|
305
|
+
&& self.props["success"]["transition"] != undefined
|
306
|
+
&& self.props["success"]["transition"]["follow_response"] === true
|
307
|
+
&& self.$store != undefined
|
308
|
+
) {
|
309
|
+
let path = response.data["transition_to"] || response.request.responseURL
|
310
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
311
|
+
return;
|
312
|
+
}
|
313
|
+
// redirect handling
|
314
|
+
if (self.props["success"] != undefined
|
315
|
+
&& self.props["success"]["redirect"] != undefined
|
316
|
+
&& (
|
317
|
+
self.props["success"]["redirect"]["follow_response"] == undefined
|
318
|
+
||
|
319
|
+
self.props["success"]["redirect"]["follow_response"] === false
|
320
|
+
)
|
321
|
+
&& self.$store != undefined
|
322
|
+
) {
|
323
|
+
let path = self.props["success"]["redirect"]["path"]
|
324
|
+
window.location.href = path
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
if (self.props["success"] != undefined
|
328
|
+
&& self.props["success"]["redirect"] != undefined
|
329
|
+
&& self.props["success"]["redirect"]["follow_response"] === true
|
330
|
+
&& self.$store != undefined
|
331
|
+
) {
|
332
|
+
let path = response.data["redirect_to"] || response.request.responseURL
|
333
|
+
window.location.href = path
|
334
|
+
return;
|
335
|
+
}
|
336
|
+
|
337
|
+
self.flushErrors();
|
338
|
+
|
339
|
+
if (self.shouldResetFormOnSuccessfulSubmit())
|
340
|
+
{
|
341
|
+
self.initValues();
|
342
|
+
self.resetNestedForms();
|
343
|
+
}
|
344
|
+
})
|
345
|
+
.catch(function (error) {
|
346
|
+
self.loading = false;
|
347
|
+
if (error.response && error.response.data && error.response.data.errors) {
|
348
|
+
self.errors = error.response.data.errors;
|
349
|
+
self.setErrors(error.response.data.errors);
|
350
|
+
self.setNestedFormsError(error.response.data.errors);
|
351
|
+
}
|
352
|
+
if (self.props["failure"] != undefined && self.props["failure"]["emit"] != undefined) {
|
353
|
+
matestackEventHub.$emit(self.props["failure"]["emit"], error.response.data);
|
354
|
+
}
|
355
|
+
// transition handling
|
356
|
+
if (self.props["failure"] != undefined
|
357
|
+
&& self.props["failure"]["transition"] != undefined
|
358
|
+
&& (
|
359
|
+
self.props["failure"]["transition"]["follow_response"] == undefined
|
360
|
+
||
|
361
|
+
self.props["failure"]["transition"]["follow_response"] === false
|
362
|
+
)
|
363
|
+
&& self.$store != undefined
|
364
|
+
) {
|
365
|
+
let path = self.props["failure"]["transition"]["path"]
|
366
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
if (self.props["failure"] != undefined
|
370
|
+
&& self.props["failure"]["transition"] != undefined
|
371
|
+
&& self.props["failure"]["transition"]["follow_response"] === true
|
372
|
+
&& self.$store != undefined
|
373
|
+
) {
|
374
|
+
let path = error.response.data["transition_to"] || response.request.responseURL
|
375
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
376
|
+
return;
|
377
|
+
}
|
378
|
+
// redirect handling
|
379
|
+
if (self.props["failure"] != undefined
|
380
|
+
&& self.props["failure"]["redirect"] != undefined
|
381
|
+
&& (
|
382
|
+
self.props["failure"]["redirect"]["follow_response"] == undefined
|
383
|
+
||
|
384
|
+
self.props["failure"]["redirect"]["follow_response"] === false
|
385
|
+
)
|
386
|
+
&& self.$store != undefined
|
387
|
+
) {
|
388
|
+
let path = self.props["failure"]["redirect"]["path"]
|
389
|
+
window.location.href = path
|
390
|
+
return;
|
391
|
+
}
|
392
|
+
if (self.props["failure"] != undefined
|
393
|
+
&& self.props["failure"]["redirect"] != undefined
|
394
|
+
&& self.props["failure"]["redirect"]["follow_response"] === true
|
395
|
+
&& self.$store != undefined
|
396
|
+
) {
|
397
|
+
let path = error.response.data["redirect_to"] || response.request.responseURL
|
398
|
+
window.location.href = path
|
399
|
+
return;
|
400
|
+
}
|
401
|
+
});
|
402
|
+
},
|
403
|
+
},
|
404
|
+
mounted: function () {
|
405
|
+
var self = this;
|
406
|
+
if (this.props["fields_for"] != undefined) {
|
407
|
+
this.isNestedForm = true;
|
408
|
+
|
409
|
+
this.data = { "_destroy": false };
|
410
|
+
|
411
|
+
//initialize nestedForm data in parent form if required
|
412
|
+
if(this.$parent.data[this.props["fields_for"]] == undefined){
|
413
|
+
this.$parent.data[this.props["fields_for"]] = [];
|
414
|
+
}
|
415
|
+
if(this.$parent.nestedForms[this.props["fields_for"]] == undefined){
|
416
|
+
this.$parent.nestedForms[this.props["fields_for"]] = [];
|
417
|
+
}
|
418
|
+
if(this.$parent.deletedNestedForms[this.props["fields_for"]] == undefined){
|
419
|
+
this.$parent.deletedNestedForms[this.props["fields_for"]] = []
|
420
|
+
}
|
421
|
+
|
422
|
+
var id = parseInt(self.$el.id.replace(this.props["fields_for"]+"_child_", ""));
|
423
|
+
|
424
|
+
//setup data binding for serverside rendered nested forms
|
425
|
+
if (isNaN(id)){
|
426
|
+
id = this.$parent.nestedForms[this.props["fields_for"]].length
|
427
|
+
this.nestedFormRuntimeId = "_"+this.props["fields_for"]+"_child_"+id
|
428
|
+
this.$el.id = this.props["fields_for"]+"_child_"+id
|
429
|
+
this.initValues()
|
430
|
+
this.$parent.data[this.props["fields_for"]].push(this.data);
|
431
|
+
this.$parent.nestedForms[this.props["fields_for"]].push(this);
|
432
|
+
}
|
433
|
+
|
434
|
+
//setup data binding for runtime nested forms (dynamic add via v-runtime-template)
|
435
|
+
if (!isNaN(id)){
|
436
|
+
this.nestedFormRuntimeId = "_"+this.props["fields_for"]+"_child_"+id
|
437
|
+
if(this.$parent.data[this.props["fields_for"]][id] == undefined){
|
438
|
+
//new runtime form
|
439
|
+
this.initValues()
|
440
|
+
this.$parent.data[this.props["fields_for"]].push(this.data);
|
441
|
+
this.$parent.nestedForms[this.props["fields_for"]].push(this);
|
442
|
+
}else{
|
443
|
+
//retreive state for existing runtime form (after remount for example)
|
444
|
+
this.data = this.$parent.data[this.props["fields_for"]][id]
|
445
|
+
if (this.data["_destroy"] == true){
|
446
|
+
this.hideNestedForm = true;
|
447
|
+
}
|
448
|
+
this.$parent.nestedForms[this.props["fields_for"]][id] = this;
|
449
|
+
Object.keys(this.$parent.errors).forEach(function(errorKey){
|
450
|
+
if (errorKey.includes(".")){
|
451
|
+
let childErrorKey = errorKey.split(".")[1]
|
452
|
+
let childModelName = errorKey.split(".")[0].split("[")[0]
|
453
|
+
let childModelIndex = errorKey.split(".")[0].split("[")[1].split("]")[0]
|
454
|
+
let mappedChildModelIndex = self.$parent.mapToNestedForms(parseInt(childModelIndex), childModelName+"_attributes")
|
455
|
+
if(childModelName+"_attributes" == self.props["fields_for"] && mappedChildModelIndex == id){
|
456
|
+
self.setNestedFormServerErrorIndex(parseInt(childModelIndex))
|
457
|
+
self.setErrorKey(childErrorKey, self.$parent.errors[errorKey])
|
458
|
+
}
|
459
|
+
}
|
460
|
+
})
|
461
|
+
}
|
462
|
+
}
|
463
|
+
} else {
|
464
|
+
this.initValues();
|
465
|
+
}
|
466
|
+
},
|
467
|
+
components: {
|
468
|
+
VRuntimeTemplate: VRuntimeTemplate
|
469
|
+
}
|
470
|
+
};
|
471
|
+
|
472
|
+
let component = Vue.component("matestack-ui-core-form", componentDef);
|
473
|
+
|
474
|
+
export default componentDef;
|