matestack-ui-core 1.0.0.rc.1 → 1.3.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/README.md +784 -18
- data/app/concepts/matestack/ui/core/abbr/abbr.haml +1 -1
- data/app/concepts/matestack/ui/core/abbr/abbr.rb +0 -8
- data/app/concepts/matestack/ui/core/action/action.haml +1 -1
- data/app/concepts/matestack/ui/core/actionview/dynamic.haml +4 -4
- data/app/concepts/matestack/ui/core/address/address.haml +2 -2
- data/app/concepts/matestack/ui/core/app/store.js +5 -1
- data/app/concepts/matestack/ui/core/area/area.haml +1 -1
- data/app/concepts/matestack/ui/core/area/area.rb +2 -16
- 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.js +6 -28
- data/app/concepts/matestack/ui/core/async/async.rb +11 -11
- data/app/concepts/matestack/ui/core/async/children_wrapper.haml +1 -1
- 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 +1 -1
- data/app/concepts/matestack/ui/core/collection/content/previous/previous.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/filter/filter.rb +1 -1
- 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 +6 -6
- data/app/concepts/matestack/ui/core/collection/filter/select/select.rb +10 -9
- data/app/concepts/matestack/ui/core/collection/filter/submit/submit.haml +1 -1
- data/app/concepts/matestack/ui/core/collection/order/order.rb +1 -1
- data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +5 -2
- 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 +10 -4
- data/app/concepts/matestack/ui/core/component/component.js +18 -1
- data/app/concepts/matestack/ui/core/component/dynamic.rb +2 -1
- 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/base.rb +120 -0
- data/app/concepts/matestack/ui/core/form/checkbox/checkbox.js +15 -0
- data/app/concepts/matestack/ui/core/form/checkbox/checkbox.rb +7 -70
- data/app/concepts/matestack/ui/core/form/checkbox/mixin.js +80 -0
- data/app/concepts/matestack/ui/core/form/form.haml +1 -1
- data/app/concepts/matestack/ui/core/form/form.js +15 -46
- data/app/concepts/matestack/ui/core/form/form.rb +34 -28
- data/app/concepts/matestack/ui/core/form/input/base.rb +75 -0
- data/app/concepts/matestack/ui/core/form/input/input.js +15 -0
- data/app/concepts/matestack/ui/core/form/input/input.rb +8 -52
- data/app/concepts/matestack/ui/core/form/input/mixin.js +55 -0
- data/app/concepts/matestack/ui/core/form/radio/base.rb +90 -0
- data/app/concepts/matestack/ui/core/form/radio/mixin.js +62 -0
- data/app/concepts/matestack/ui/core/form/radio/radio.js +15 -0
- data/app/concepts/matestack/ui/core/form/radio/radio.rb +7 -62
- data/app/concepts/matestack/ui/core/form/select/base.rb +98 -0
- data/app/concepts/matestack/ui/core/form/select/mixin.js +58 -0
- data/app/concepts/matestack/ui/core/form/select/select.js +15 -0
- data/app/concepts/matestack/ui/core/form/select/select.rb +11 -80
- data/app/concepts/matestack/ui/core/form/submit/base.rb +12 -0
- data/app/concepts/matestack/ui/core/form/submit/submit.js +19 -0
- data/app/concepts/matestack/ui/core/form/submit/submit.rb +9 -6
- data/app/concepts/matestack/ui/core/form/textarea/base.rb +49 -0
- data/app/concepts/matestack/ui/core/form/textarea/mixin.js +41 -0
- data/app/concepts/matestack/ui/core/form/textarea/textarea.js +15 -0
- data/app/concepts/matestack/ui/core/form/textarea/textarea.rb +10 -21
- 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 -3
- 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.rb +0 -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 +1 -1
- data/app/concepts/matestack/ui/core/isolated/isolated.rb +1 -1
- data/app/concepts/matestack/ui/core/js/core.js +12 -0
- 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/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/content.rb +0 -1
- data/app/concepts/matestack/ui/core/page/page.haml +1 -1
- 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/{form/submit/submit.haml → select/select.haml} +1 -1
- data/app/concepts/matestack/ui/core/select/select.rb +7 -0
- data/app/concepts/matestack/ui/core/slot/slot.rb +0 -1
- 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 +4 -1
- 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 +1 -1
- data/app/concepts/matestack/ui/core/toggle/toggle.rb +4 -5
- 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.rb +13 -7
- 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 +2 -0
- 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 +3 -13
- 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 +6 -2
- data/app/javascript/matestack-ui-core/index.js +12 -2
- data/app/lib/matestack/ui/core/has_view_context.rb +4 -2
- data/app/lib/matestack/ui/core/html_attributes.rb +1 -1
- data/app/lib/matestack/ui/core/properties.rb +95 -22
- data/app/lib/matestack/ui/core/rendering/main_renderer.rb +11 -7
- data/lib/matestack/ui/core/components.rb +6 -2
- data/lib/matestack/ui/core/version.rb +1 -1
- data/vendor/assets/javascripts/dist/matestack-ui-core.js +773 -99
- 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 +29 -8
- data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +0 -2
- data/app/concepts/matestack/ui/core/component/rerender.rb +0 -8
- data/app/concepts/matestack/ui/core/form/select/select.haml +0 -9
@@ -1,2 +1,2 @@
|
|
1
|
-
%form{
|
1
|
+
%form{ form_attributes }
|
2
2
|
= yield
|
@@ -18,9 +18,6 @@ const componentDef = {
|
|
18
18
|
initDataKey: function (key, initValue) {
|
19
19
|
this.data[key] = initValue;
|
20
20
|
},
|
21
|
-
inputChanged: function (key) {
|
22
|
-
this.resetErrors(key);
|
23
|
-
},
|
24
21
|
updateFormValue: function (key, value) {
|
25
22
|
this.data[key] = value;
|
26
23
|
},
|
@@ -44,11 +41,11 @@ const componentDef = {
|
|
44
41
|
flat[i] = newVal;
|
45
42
|
} else if (flat[i] instanceof File){
|
46
43
|
flat[i] = newVal;
|
47
|
-
this.$refs["input
|
44
|
+
this.$refs["input-component-for-"+i].value = newVal
|
48
45
|
} else if (flat[i] instanceof Array) {
|
49
46
|
if(flat[i][0] instanceof File){
|
50
47
|
flat[i] = newVal
|
51
|
-
this.$refs["input
|
48
|
+
this.$refs["input-component-for-"+i].value = newVal
|
52
49
|
}
|
53
50
|
} else if (typeof flat[i] === "object" && !(flat[i] instanceof Array)) {
|
54
51
|
setProps(flat[i], newVal);
|
@@ -57,54 +54,26 @@ const componentDef = {
|
|
57
54
|
}
|
58
55
|
}
|
59
56
|
},
|
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];
|
72
|
-
}
|
73
|
-
},
|
74
57
|
initValues: function () {
|
75
58
|
let self = this;
|
76
59
|
let data = {};
|
77
60
|
for (let key in self.$refs) {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
if (key.startsWith("input.")) {
|
82
|
-
if (initValue) {
|
83
|
-
data[key.replace("input.", "")] = initValue["value"];
|
84
|
-
} else {
|
85
|
-
data[key.replace("input.", "")] = null;
|
86
|
-
}
|
61
|
+
if (key.startsWith("input-component")) {
|
62
|
+
self.$refs[key].initialize()
|
87
63
|
}
|
88
|
-
if (key.startsWith("
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
data[key.replace("select.", "")] = initValue["value"];
|
100
|
-
}
|
101
|
-
} else {
|
102
|
-
data[key.replace("select.", "")] = null;
|
103
|
-
}
|
104
|
-
}
|
64
|
+
if (key.startsWith("textarea-component")) {
|
65
|
+
self.$refs[key].initialize()
|
66
|
+
}
|
67
|
+
if (key.startsWith("select-component")) {
|
68
|
+
self.$refs[key].initialize()
|
69
|
+
}
|
70
|
+
if (key.startsWith("radio-component")) {
|
71
|
+
self.$refs[key].initialize()
|
72
|
+
}
|
73
|
+
if (key.startsWith("checkbox-component")) {
|
74
|
+
self.$refs[key].initialize()
|
105
75
|
}
|
106
76
|
}
|
107
|
-
self.data = data;
|
108
77
|
},
|
109
78
|
shouldResetFormOnSuccessfulSubmit() {
|
110
79
|
const self = this;
|
@@ -1,49 +1,55 @@
|
|
1
1
|
module Matestack::Ui::Core::Form
|
2
2
|
class Form < Matestack::Ui::Core::Component::Dynamic
|
3
3
|
vue_js_component_name "matestack-ui-core-form"
|
4
|
+
|
5
|
+
html_attributes :'accept-charset', :action, :autocomplete, :enctype, :method, :name, :novalidate, :rel, :target
|
4
6
|
|
5
|
-
requires :
|
7
|
+
requires :path, for: { as: :for_option }, method: { as: :form_method }
|
8
|
+
optional :success, :failure, :multipart, params: { as: :form_params }
|
6
9
|
|
7
10
|
def setup
|
8
11
|
begin
|
9
12
|
@component_config[:for] = form_wrapper
|
10
13
|
@component_config[:submit_path] = submit_path
|
11
|
-
@component_config[:method] =
|
12
|
-
@component_config[:success] =
|
13
|
-
@component_config[:multipart] =
|
14
|
-
unless
|
15
|
-
unless
|
16
|
-
@component_config[:success][:transition][:path] = transition_path
|
14
|
+
@component_config[:method] = form_method
|
15
|
+
@component_config[:success] = success
|
16
|
+
@component_config[:multipart] = multipart == true
|
17
|
+
unless success.nil?
|
18
|
+
unless success[:transition].nil?
|
19
|
+
@component_config[:success][:transition][:path] = transition_path success
|
17
20
|
end
|
18
|
-
unless
|
19
|
-
@component_config[:success][:redirect][:path] = redirect_path
|
21
|
+
unless success[:redirect].nil?
|
22
|
+
@component_config[:success][:redirect][:path] = redirect_path success
|
20
23
|
end
|
21
24
|
end
|
22
|
-
@component_config[:failure] =
|
23
|
-
unless
|
24
|
-
unless
|
25
|
-
@component_config[:failure][:transition][:path] = transition_path
|
25
|
+
@component_config[:failure] = failure
|
26
|
+
unless failure.nil?
|
27
|
+
unless failure[:transition].nil?
|
28
|
+
@component_config[:failure][:transition][:path] = transition_path failure
|
26
29
|
end
|
27
|
-
unless
|
28
|
-
@component_config[:failure][:redirect][:path] = redirect_path
|
30
|
+
unless failure[:redirect].nil?
|
31
|
+
@component_config[:failure][:redirect][:path] = redirect_path failure
|
29
32
|
end
|
30
33
|
end
|
31
|
-
@tag_attributes.merge!({
|
32
|
-
"@submit.prevent": true,
|
33
|
-
"class": "matestack-form #{options[:class]}",
|
34
|
-
"v-bind:class": "{ 'has-errors': hasErrors(), 'loading': loading }"
|
35
|
-
})
|
36
34
|
rescue => e
|
37
35
|
raise "Form component could not be setted up. Reason: #{e}"
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
39
|
+
def form_attributes
|
40
|
+
html_attributes.merge({
|
41
|
+
"@submit.prevent": true,
|
42
|
+
"class": "matestack-form #{options[:class]}",
|
43
|
+
"v-bind:class": "{ 'has-errors': hasErrors(), 'loading': loading }"
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
41
47
|
def submit_path
|
42
48
|
begin
|
43
|
-
if
|
44
|
-
return ::Rails.application.routes.url_helpers.send(
|
49
|
+
if path.is_a?(Symbol)
|
50
|
+
return ::Rails.application.routes.url_helpers.send(path, form_params)
|
45
51
|
else
|
46
|
-
return
|
52
|
+
return path
|
47
53
|
end
|
48
54
|
rescue
|
49
55
|
raise "Submit path not found"
|
@@ -81,15 +87,15 @@ module Matestack::Ui::Core::Form
|
|
81
87
|
end
|
82
88
|
|
83
89
|
def form_wrapper
|
84
|
-
case
|
90
|
+
case for_option
|
85
91
|
when Symbol
|
86
|
-
return
|
92
|
+
return for_option
|
87
93
|
when String
|
88
|
-
return
|
94
|
+
return for_option
|
89
95
|
end
|
90
96
|
|
91
|
-
if
|
92
|
-
return
|
97
|
+
if for_option.respond_to?(:model_name)
|
98
|
+
return for_option.model_name.singular
|
93
99
|
end
|
94
100
|
end
|
95
101
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative '../utils'
|
2
|
+
require_relative '../has_input_html_attributes'
|
3
|
+
require_relative '../has_errors'
|
4
|
+
module Matestack::Ui::Core::Form::Input
|
5
|
+
class Base < Matestack::Ui::Core::Component::Dynamic
|
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, :type
|
11
|
+
optional :multiple, :init, for: { as: :input_for }, label: { as: :input_label }
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@component_config[:init_value] = init_value
|
15
|
+
end
|
16
|
+
|
17
|
+
def component_id
|
18
|
+
"input-component-for-#{attr_key}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def input_attributes
|
22
|
+
html_attributes.merge(attributes: vue_attributes)
|
23
|
+
end
|
24
|
+
|
25
|
+
def input_key
|
26
|
+
"$parent.data[\"#{key}\"]"
|
27
|
+
end
|
28
|
+
|
29
|
+
def error_key
|
30
|
+
"$parent.errors[\"#{key}\"]"
|
31
|
+
end
|
32
|
+
|
33
|
+
def change_event
|
34
|
+
"inputChanged('#{attr_key}'); #{ "filesAdded('#{attr_key}');" if type == :file }".strip
|
35
|
+
end
|
36
|
+
|
37
|
+
def vue_attributes
|
38
|
+
(options[:attributes] || {}).merge({
|
39
|
+
"@change": change_event,
|
40
|
+
ref: "input.#{attr_key}",
|
41
|
+
'init-value': init_value,
|
42
|
+
'v-bind:class': "{ '#{input_error_class}': #{error_key} }"
|
43
|
+
}).merge(
|
44
|
+
type != :file ? { "#{v_model_type}": input_key } : {}
|
45
|
+
) # file inputs are readonly, no v-model possible
|
46
|
+
end
|
47
|
+
|
48
|
+
def v_model_type
|
49
|
+
if type == :number || init_value.is_a?(Integer)
|
50
|
+
'v-model.number'
|
51
|
+
else
|
52
|
+
'v-model'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def custom_options_validation
|
57
|
+
raise "included form config is missing, please add ':include' to parent form component" if @included_config.nil?
|
58
|
+
end
|
59
|
+
|
60
|
+
def attr_key
|
61
|
+
super + "#{'[]' if multiple && type == :file}"
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def parse_value(value)
|
67
|
+
if [true, false].include? value
|
68
|
+
value ? 1 : 0
|
69
|
+
else
|
70
|
+
return value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import Vue from "vue/dist/vue.esm";
|
2
|
+
|
3
|
+
import formInputMixin from "./mixin";
|
4
|
+
import componentMixin from "../../component/component";
|
5
|
+
|
6
|
+
const componentDef = {
|
7
|
+
mixins: [componentMixin, formInputMixin],
|
8
|
+
data() {
|
9
|
+
return {};
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
let component = Vue.component("matestack-ui-core-form-input", componentDef);
|
14
|
+
|
15
|
+
export default componentDef;
|
@@ -1,59 +1,15 @@
|
|
1
|
-
require_relative '
|
2
|
-
|
3
|
-
require_relative '../has_errors'
|
1
|
+
require_relative './base'
|
2
|
+
|
4
3
|
module Matestack::Ui::Core::Form::Input
|
5
|
-
class Input <
|
6
|
-
include Matestack::Ui::Core::Form::Utils
|
7
|
-
include Matestack::Ui::Core::Form::HasInputHtmlAttributes
|
8
|
-
include Matestack::Ui::Core::Form::HasErrors
|
4
|
+
class Input < Base
|
9
5
|
|
10
|
-
|
11
|
-
optional :multiple, :init, for: { as: :input_for }, label: { as: :input_label }
|
6
|
+
vue_js_component_name "matestack-ui-core-form-input"
|
12
7
|
|
13
8
|
def response
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def vue_attributes
|
20
|
-
(options[:attributes] || {}).merge({
|
21
|
-
"@change": change_event,
|
22
|
-
ref: "input.#{attr_key}",
|
23
|
-
'init-value': init_value,
|
24
|
-
'v-bind:class': "{ '#{input_error_class}': #{error_key} }"
|
25
|
-
}).merge(
|
26
|
-
type != :file ? { "#{v_model_type}": input_key } : {}
|
27
|
-
) # file inputs are readonly, no v-model possible
|
28
|
-
end
|
29
|
-
|
30
|
-
def v_model_type
|
31
|
-
if type == :number || init_value.is_a?(Integer)
|
32
|
-
'v-model.number'
|
33
|
-
else
|
34
|
-
'v-model'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def change_event
|
39
|
-
"inputChanged('#{attr_key}'); #{ "filesAdded('#{attr_key}');" if type == :file }".strip
|
40
|
-
end
|
41
|
-
|
42
|
-
def custom_options_validation
|
43
|
-
raise "included form config is missing, please add ':include' to parent form component" if @included_config.nil?
|
44
|
-
end
|
45
|
-
|
46
|
-
def attr_key
|
47
|
-
super + "#{'[]' if multiple && type == :file}"
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def parse_value(value)
|
53
|
-
if [true, false].include? value
|
54
|
-
value ? 1 : 0
|
55
|
-
else
|
56
|
-
return value
|
9
|
+
div class: "matestack-ui-core-form-input" do
|
10
|
+
label text: input_label if input_label
|
11
|
+
input input_attributes
|
12
|
+
render_errors
|
57
13
|
end
|
58
14
|
end
|
59
15
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
const formInputMixin = {
|
2
|
+
methods: {
|
3
|
+
initialize: function(){
|
4
|
+
const self = this
|
5
|
+
let data = {};
|
6
|
+
|
7
|
+
for (let key in this.$refs) {
|
8
|
+
let initValue = this.$refs[key]["attributes"]["init-value"];
|
9
|
+
|
10
|
+
if (initValue) {
|
11
|
+
data[key.replace("input.", "")] = initValue["value"];
|
12
|
+
Object.assign(self.$parent.data, data);
|
13
|
+
self.afterInitialize(initValue["value"])
|
14
|
+
} else {
|
15
|
+
data[key.replace("input.", "")] = null;
|
16
|
+
Object.assign(self.$parent.data, data);
|
17
|
+
self.afterInitialize(null)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
//without the timeout it's somehow not working
|
22
|
+
setTimeout(function () {
|
23
|
+
self.$forceUpdate()
|
24
|
+
}, 1);
|
25
|
+
},
|
26
|
+
filesAdded: function (key) {
|
27
|
+
const dataTransfer = event.dataTransfer || event.target;
|
28
|
+
const files = dataTransfer.files;
|
29
|
+
if (event.target.attributes.multiple) {
|
30
|
+
this.$parent.data[key] = [];
|
31
|
+
for (let index in files) {
|
32
|
+
if (files[index] instanceof File) {
|
33
|
+
this.$parent.data[key].push(files[index]);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
} else {
|
37
|
+
this.$parent.data[key] = files[0];
|
38
|
+
}
|
39
|
+
},
|
40
|
+
inputChanged: function (key) {
|
41
|
+
this.$parent.resetErrors(key);
|
42
|
+
this.$forceUpdate();
|
43
|
+
},
|
44
|
+
afterInitialize: function(value){
|
45
|
+
// can be used in the main component for further initialization steps
|
46
|
+
},
|
47
|
+
setValue: function (value){
|
48
|
+
this.$parent.data[this.componentConfig["key"]] = value
|
49
|
+
this.$forceUpdate();
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
export default formInputMixin
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative '../utils'
|
2
|
+
require_relative '../has_input_html_attributes'
|
3
|
+
require_relative '../has_errors'
|
4
|
+
module Matestack::Ui::Core::Form::Radio
|
5
|
+
class Base < Matestack::Ui::Core::Component::Dynamic
|
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 :multiple, :init, for: { as: :input_for }, label: { as: :input_label }, options: { as: :radio_options }
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@component_config[:init_value] = init_value
|
15
|
+
end
|
16
|
+
|
17
|
+
def component_id
|
18
|
+
"radio-component-for-#{attr_key}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def input_key
|
22
|
+
"$parent.data[\"#{key}\"]"
|
23
|
+
end
|
24
|
+
|
25
|
+
def error_key
|
26
|
+
"$parent.errors[\"#{key}\"]"
|
27
|
+
end
|
28
|
+
|
29
|
+
def change_event
|
30
|
+
"inputChanged('#{attr_key}')"
|
31
|
+
end
|
32
|
+
|
33
|
+
def render_options
|
34
|
+
radio_options.to_a.each do |item|
|
35
|
+
input radio_attributes(item)
|
36
|
+
label text: item_label(item), for: id_for_item(item_value(item))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def radio_attributes(item)
|
41
|
+
html_attributes.merge(
|
42
|
+
attributes: vue_attributes,
|
43
|
+
type: :radio,
|
44
|
+
id: "#{id_for_item(item_value(item))}",
|
45
|
+
name: item_name(item),
|
46
|
+
value: item_value(item),
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def vue_attributes
|
51
|
+
(options[:attributes] || {}).merge({
|
52
|
+
"@change": change_event,
|
53
|
+
ref: "select.#{attr_key}",
|
54
|
+
'init-value': init_value,
|
55
|
+
'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
|
56
|
+
'value-type': value_type,
|
57
|
+
"#{v_model_type}": input_key,
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
def value_type
|
62
|
+
item_value(radio_options.first).is_a?(Integer) ? Integer : nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def item_value(item)
|
66
|
+
item.is_a?(Array) ? item.last : item
|
67
|
+
end
|
68
|
+
|
69
|
+
def item_name(item)
|
70
|
+
"#{attr_key}_#{item.is_a?(Array) ? item.first : item}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def item_label(item)
|
74
|
+
item.is_a?(Array) ? item.first : item
|
75
|
+
end
|
76
|
+
|
77
|
+
def v_model_type
|
78
|
+
if radio_options && item_value(radio_options.first).is_a?(Integer)
|
79
|
+
'v-model.number'
|
80
|
+
else
|
81
|
+
'v-model'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def id_for_item(value)
|
86
|
+
"#{html_attributes[:id] || attr_key}_#{value}"
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|