matestack-ui-core 0.7.1 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -4
- data/Rakefile +32 -0
- data/app/concepts/matestack/ui/core/abbr/abbr.haml +5 -0
- data/app/concepts/matestack/ui/core/abbr/abbr.rb +12 -0
- data/app/concepts/matestack/ui/core/action/action.js +51 -29
- data/app/concepts/matestack/ui/core/action/action.rb +3 -0
- data/app/concepts/matestack/ui/core/actionview/dynamic.haml +6 -0
- data/app/concepts/matestack/ui/core/actionview/dynamic.rb +28 -0
- data/app/concepts/matestack/ui/core/actionview/static.haml +1 -0
- data/app/concepts/matestack/ui/core/actionview/static.rb +28 -0
- data/app/concepts/matestack/ui/core/address/address.haml +5 -0
- data/app/concepts/matestack/ui/core/address/address.rb +5 -0
- data/app/concepts/matestack/ui/core/app/app.js +14 -3
- data/app/concepts/matestack/ui/core/app/app.rb +3 -28
- data/app/concepts/matestack/ui/core/app/location.js +9 -0
- data/app/concepts/matestack/ui/core/app/store.js +12 -6
- data/app/concepts/matestack/ui/core/area/area.haml +1 -0
- data/app/concepts/matestack/ui/core/area/area.rb +18 -0
- data/app/concepts/matestack/ui/core/article/article.haml +5 -0
- data/app/concepts/matestack/ui/core/article/article.rb +5 -0
- data/app/concepts/matestack/ui/core/aside/aside.haml +3 -0
- data/app/concepts/matestack/ui/core/aside/aside.rb +5 -0
- data/app/concepts/matestack/ui/core/async/async.haml +1 -1
- data/app/concepts/matestack/ui/core/async/async.js +5 -4
- data/app/concepts/matestack/ui/core/async/async.rb +8 -6
- data/app/concepts/matestack/ui/core/b/b.haml +5 -0
- data/app/concepts/matestack/ui/core/b/b.rb +5 -0
- data/app/concepts/matestack/ui/core/bdi/bdi.haml +5 -0
- data/app/concepts/matestack/ui/core/bdi/bdi.rb +4 -0
- data/app/concepts/matestack/ui/core/bdo/bdo.haml +5 -0
- data/app/concepts/matestack/ui/core/bdo/bdo.rb +11 -0
- data/app/concepts/matestack/ui/core/blockquote/blockquote.rb +3 -1
- data/app/concepts/matestack/ui/core/button/button.haml +4 -6
- data/app/concepts/matestack/ui/core/caption/caption.haml +2 -3
- data/app/concepts/matestack/ui/core/cite/cite.haml +5 -0
- data/app/concepts/matestack/ui/core/cite/cite.rb +5 -0
- data/app/concepts/matestack/ui/core/code/code.haml +5 -0
- data/app/concepts/matestack/ui/core/code/code.rb +5 -0
- data/app/concepts/matestack/ui/core/collection/content/content.js +4 -6
- data/app/concepts/matestack/ui/core/collection/content/content.rb +1 -1
- data/app/concepts/matestack/ui/core/collection/filter/filter.js +3 -5
- data/app/concepts/matestack/ui/core/collection/filter/filter.rb +1 -1
- data/app/concepts/matestack/ui/core/collection/filter/input/input.haml +1 -7
- data/app/concepts/matestack/ui/core/collection/filter/input/input.rb +12 -0
- data/app/concepts/matestack/ui/core/collection/helper.rb +0 -1
- data/app/concepts/matestack/ui/core/collection/order/order.js +3 -5
- data/app/concepts/matestack/ui/core/collection/order/order.rb +1 -1
- data/app/concepts/matestack/ui/core/collection/order/toggle/indicator/indicator.rb +3 -1
- data/app/concepts/matestack/ui/core/collection/order/toggle/toggle.rb +0 -1
- data/app/concepts/matestack/ui/core/component/anonym-dynamic-component.js +1 -1
- data/app/concepts/matestack/ui/core/component/component.js +1 -2
- data/app/concepts/matestack/ui/core/component/dynamic.rb +38 -33
- data/app/concepts/matestack/ui/core/data/data.haml +5 -0
- data/app/concepts/matestack/ui/core/data/data.rb +9 -0
- data/app/concepts/matestack/ui/core/datalist/datalist.haml +3 -0
- data/app/concepts/matestack/ui/core/datalist/datalist.rb +5 -0
- data/app/concepts/matestack/ui/core/dd/dd.haml +5 -0
- data/app/concepts/matestack/ui/core/dd/dd.rb +5 -0
- data/app/concepts/matestack/ui/core/del/del.haml +5 -0
- data/app/concepts/matestack/ui/core/del/del.rb +4 -0
- data/app/concepts/matestack/ui/core/details/details.rb +1 -0
- data/app/concepts/matestack/ui/core/dfn/dfn.haml +5 -0
- data/app/concepts/matestack/ui/core/dfn/dfn.rb +6 -0
- data/app/concepts/matestack/ui/core/dialog/dialog.haml +5 -0
- data/app/concepts/matestack/ui/core/dialog/dialog.rb +9 -0
- data/app/concepts/matestack/ui/core/div/div.rb +0 -1
- data/app/concepts/matestack/ui/core/dl/dl.haml +5 -0
- data/app/concepts/matestack/ui/core/dl/dl.rb +5 -0
- data/app/concepts/matestack/ui/core/dt/dt.haml +5 -0
- data/app/concepts/matestack/ui/core/dt/dt.rb +5 -0
- data/app/concepts/matestack/ui/core/em/em.haml +5 -0
- data/app/concepts/matestack/ui/core/em/em.rb +5 -0
- data/app/concepts/matestack/ui/core/fieldset/fieldset.haml +5 -0
- data/app/concepts/matestack/ui/core/fieldset/fieldset.rb +9 -0
- data/app/concepts/matestack/ui/core/figure/figure.haml +3 -0
- data/app/concepts/matestack/ui/core/figure/figure.rb +5 -0
- data/app/concepts/matestack/ui/core/form/form.js +42 -6
- data/app/concepts/matestack/ui/core/form/input/input.haml +30 -21
- data/app/concepts/matestack/ui/core/form/input/input.rb +36 -29
- data/app/concepts/matestack/ui/core/form/select/select.haml +10 -6
- data/app/concepts/matestack/ui/core/html/html.js +1 -1
- data/app/concepts/matestack/ui/core/icon/icon.haml +2 -3
- data/app/concepts/matestack/ui/core/iframe/iframe.haml +5 -0
- data/app/concepts/matestack/ui/core/iframe/iframe.rb +14 -0
- data/app/concepts/matestack/ui/core/img/img.haml +1 -1
- data/app/concepts/matestack/ui/core/img/img.rb +10 -0
- data/app/concepts/matestack/ui/core/input/input.haml +2 -3
- data/app/concepts/matestack/ui/core/input/input.rb +4 -0
- data/app/concepts/matestack/ui/core/ins/ins.haml +5 -0
- data/app/concepts/matestack/ui/core/ins/ins.rb +10 -0
- data/app/concepts/matestack/ui/core/isolate/isolate.haml +2 -0
- data/app/concepts/matestack/ui/core/isolate/isolate.rb +11 -0
- data/app/concepts/matestack/ui/core/js/core.js +41 -18
- data/app/concepts/matestack/ui/core/kbd/kbd.haml +5 -0
- data/app/concepts/matestack/ui/core/kbd/kbd.rb +4 -0
- data/app/concepts/matestack/ui/core/label/label.haml +4 -6
- data/app/concepts/matestack/ui/core/label/label.rb +6 -1
- data/app/concepts/matestack/ui/core/legend/legend.haml +5 -0
- data/app/concepts/matestack/ui/core/legend/legend.rb +5 -0
- data/app/concepts/matestack/ui/core/li/li.haml +2 -3
- data/app/concepts/matestack/ui/core/link/link.rb +2 -1
- data/app/concepts/matestack/ui/core/map/map.haml +3 -0
- data/app/concepts/matestack/ui/core/map/map.rb +11 -0
- data/app/concepts/matestack/ui/core/mark/mark.haml +5 -0
- data/app/concepts/matestack/ui/core/mark/mark.rb +4 -0
- data/app/concepts/matestack/ui/core/meter/meter.haml +4 -0
- data/app/concepts/matestack/ui/core/meter/meter.rb +14 -0
- data/app/concepts/matestack/ui/core/noscript/noscript.haml +5 -0
- data/app/concepts/matestack/ui/core/noscript/noscript.rb +5 -0
- data/app/concepts/matestack/ui/core/object/object.haml +1 -0
- data/app/concepts/matestack/ui/core/object/object.rb +15 -0
- data/app/concepts/matestack/ui/core/onclick/onclick.haml +1 -1
- data/app/concepts/matestack/ui/core/onclick/onclick.js +2 -3
- data/app/concepts/matestack/ui/core/onclick/onclick.rb +1 -2
- data/app/concepts/matestack/ui/core/optgroup/optgroup.haml +3 -0
- data/app/concepts/matestack/ui/core/optgroup/optgroup.rb +10 -0
- data/app/concepts/matestack/ui/core/option/option.haml +5 -0
- data/app/concepts/matestack/ui/core/option/option.rb +12 -0
- data/app/concepts/matestack/ui/core/output/output.haml +5 -0
- data/app/concepts/matestack/ui/core/output/output.rb +11 -0
- data/app/concepts/matestack/ui/core/page/content.js +1 -1
- data/app/concepts/matestack/ui/core/page/page.rb +61 -22
- data/app/concepts/matestack/ui/core/paragraph/paragraph.haml +4 -7
- data/app/concepts/matestack/ui/core/param/param.haml +1 -0
- data/app/concepts/matestack/ui/core/param/param.rb +10 -0
- data/app/concepts/matestack/ui/core/pg/pg.haml +4 -7
- data/app/concepts/matestack/ui/core/picture/picture.haml +3 -0
- data/app/concepts/matestack/ui/core/picture/picture.rb +4 -0
- data/app/concepts/matestack/ui/core/plain/plain.rb +1 -2
- data/app/concepts/matestack/ui/core/pre/pre.haml +5 -0
- data/app/concepts/matestack/ui/core/pre/pre.rb +5 -0
- data/app/concepts/matestack/ui/core/q/q.haml +5 -0
- data/app/concepts/matestack/ui/core/q/q.rb +11 -0
- data/app/concepts/matestack/ui/core/rp/rp.haml +5 -0
- data/app/concepts/matestack/ui/core/rp/rp.rb +5 -0
- data/app/concepts/matestack/ui/core/rt/rt.haml +5 -0
- data/app/concepts/matestack/ui/core/rt/rt.rb +5 -0
- data/app/concepts/matestack/ui/core/ruby/ruby.haml +5 -0
- data/app/concepts/matestack/ui/core/ruby/ruby.rb +5 -0
- data/app/concepts/matestack/ui/core/s/s.haml +5 -0
- data/app/concepts/matestack/ui/core/s/s.rb +6 -0
- data/app/concepts/matestack/ui/core/samp/samp.haml +5 -0
- data/app/concepts/matestack/ui/core/samp/samp.rb +4 -0
- data/app/concepts/matestack/ui/core/sub/sub.haml +5 -0
- data/app/concepts/matestack/ui/core/sub/sub.rb +5 -0
- data/app/concepts/matestack/ui/core/summary/summary.haml +2 -3
- data/app/concepts/matestack/ui/core/summary/summary.rb +1 -0
- data/app/concepts/matestack/ui/core/sup/sup.haml +5 -0
- data/app/concepts/matestack/ui/core/sup/sup.rb +5 -0
- data/app/concepts/matestack/ui/core/tbody/tbody.haml +3 -0
- data/app/concepts/matestack/ui/core/tbody/tbody.rb +5 -0
- data/app/concepts/matestack/ui/core/td/td.haml +4 -7
- data/app/concepts/matestack/ui/core/template/template.haml +3 -0
- data/app/concepts/matestack/ui/core/template/template.rb +4 -0
- data/app/concepts/matestack/ui/core/tfoot/tfoot.haml +3 -0
- data/app/concepts/matestack/ui/core/tfoot/tfoot.rb +5 -0
- data/app/concepts/matestack/ui/core/th/th.haml +4 -7
- data/app/concepts/matestack/ui/core/thead/thead.haml +3 -0
- data/app/concepts/matestack/ui/core/thead/thead.rb +5 -0
- data/app/concepts/matestack/ui/core/transition/transition.haml +4 -6
- data/app/concepts/matestack/ui/core/transition/transition.js +1 -1
- data/app/concepts/matestack/ui/core/u/u.haml +5 -0
- data/app/concepts/matestack/ui/core/u/u.rb +6 -0
- data/app/concepts/matestack/ui/core/unescaped/unescaped.rb +7 -0
- data/app/concepts/matestack/ui/core/var/var.haml +5 -0
- data/app/concepts/matestack/ui/core/var/var.rb +4 -0
- data/app/concepts/matestack/ui/core/video/video.haml +3 -1
- data/app/concepts/matestack/ui/core/video/video.rb +17 -1
- data/app/concepts/matestack/ui/core/wbr/wbr.haml +1 -0
- data/app/concepts/matestack/ui/core/wbr/wbr.rb +4 -0
- data/app/concepts/matestack/ui/core/youtube/youtube.haml +1 -0
- data/app/concepts/matestack/ui/core/youtube/youtube.rb +26 -0
- data/app/helpers/matestack/ui/core/application_helper.rb +3 -1
- data/app/javascript/matestack-ui-core/index.js +22 -0
- data/app/javascript/matestack-ui-core/styles/index.scss +5 -0
- data/app/javascript/packs/matestack-ui-core.js +8 -0
- data/app/lib/matestack/ui/core/component_node.rb +30 -12
- data/app/lib/matestack/ui/core/has_view_context.rb +14 -0
- data/app/lib/matestack/ui/core/page_node.rb +26 -1
- data/app/lib/matestack/ui/core/render.rb +89 -0
- data/app/lib/matestack/ui/core/to_cell.rb +3 -1
- data/app/lib/matestack/ui/dynamic_actionview_component.rb +1 -0
- data/app/lib/matestack/ui/static_actionview_component.rb +1 -0
- data/config/routes.rb +0 -1
- data/lib/generators/matestack/app/USAGE +21 -0
- data/lib/generators/matestack/app/app_generator.rb +25 -0
- data/lib/generators/{matestack_app/templates/matestack_app_controller.erb → matestack/app/templates/app/controllers/%file_name%_controller.rb.tt} +0 -2
- data/lib/generators/matestack/app/templates/app/matestack/apps/%file_name%.rb.tt +28 -0
- data/lib/generators/matestack/component/USAGE +20 -0
- data/lib/generators/matestack/component/component_generator.rb +29 -0
- data/lib/generators/{matestack_component/templates/matestack_component.haml.erb → matestack/component/templates/app/matestack/components/%namespace%/%file_name%.haml.tt} +0 -0
- data/lib/generators/{matestack_component/templates/matestack_component.js.erb → matestack/component/templates/app/matestack/components/%namespace%/%file_name%.js.tt} +2 -2
- data/lib/generators/matestack/component/templates/app/matestack/components/%namespace%/%file_name%.rb.tt +11 -0
- data/lib/generators/{matestack_component/templates/matestack_component.scss.erb → matestack/component/templates/app/matestack/components/%namespace%/%file_name%.scss.tt} +0 -0
- data/lib/generators/matestack/core/component/USAGE +16 -0
- data/lib/generators/matestack/core/component/component_generator.rb +23 -0
- data/lib/generators/matestack/core/component/templates/app/concepts/matestack/ui/core/%file_name%/%file_name%.haml.tt +5 -0
- data/lib/generators/matestack/core/component/templates/app/concepts/matestack/ui/core/%file_name%/%file_name%.rb.tt +4 -0
- data/lib/generators/matestack/core/component/templates/docs/components/%file_name%.md.tt +45 -0
- data/lib/generators/matestack/core/component/templates/spec/usage/components/%file_name%_spec.rb +31 -0
- data/lib/generators/matestack/page/USAGE +28 -0
- data/lib/generators/matestack/page/page_generator.rb +54 -0
- data/lib/generators/matestack/page/templates/app/matestack/pages/%app_name%/%namespace%/%file_name%.rb.tt +29 -0
- data/lib/matestack/ui/core.rb +1 -0
- data/lib/matestack/ui/core/cell.rb +33 -0
- data/lib/matestack/ui/core/version.rb +1 -1
- data/vendor/assets/javascripts/dist/manifest.json +22 -0
- data/vendor/assets/javascripts/dist/manifest.json.br +0 -0
- data/vendor/assets/javascripts/dist/manifest.json.gz +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.css +3 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.css.map +1 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.js +16605 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +1 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.css +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +3 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.LICENSE.txt +18 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.br +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.gz +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map +1 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.br +0 -0
- data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.gz +0 -0
- data/vendor/assets/javascripts/matestack-ui-core.js.erb +2 -0
- data/vendor/assets/stylesheets/dist +1 -0
- data/vendor/assets/stylesheets/matestack-ui-core.css.erb +2 -0
- metadata +168 -32
- data/app/concepts/matestack/ui/core/view/view.haml +0 -2
- data/app/concepts/matestack/ui/core/view/view.js +0 -42
- data/app/concepts/matestack/ui/core/view/view.rb +0 -7
- data/lib/generators/matestack_app/USAGE +0 -21
- data/lib/generators/matestack_app/matestack_app_generator.rb +0 -26
- data/lib/generators/matestack_app/templates/matestack_app.erb +0 -26
- data/lib/generators/matestack_component/USAGE +0 -20
- data/lib/generators/matestack_component/matestack_component_generator.rb +0 -30
- data/lib/generators/matestack_component/templates/matestack_component.rb.erb +0 -13
- data/lib/generators/matestack_page/USAGE +0 -28
- data/lib/generators/matestack_page/matestack_page_generator.rb +0 -41
- data/lib/generators/matestack_page/templates/matestack_page.erb +0 -15
- data/vendor/assets/javascripts/manifest.json +0 -4
- data/vendor/assets/javascripts/matestack-ui-core.js +0 -15392
- data/vendor/assets/javascripts/matestack-ui-core.js.map +0 -1
@@ -2,9 +2,8 @@ import Vue from 'vue/dist/vue.esm'
|
|
2
2
|
import Vuex from 'vuex'
|
3
3
|
import axios from 'axios'
|
4
4
|
|
5
|
-
import matestackEventHub from 'js/event-hub'
|
6
|
-
|
7
|
-
import componentMixin from 'component/component'
|
5
|
+
import matestackEventHub from '../js/event-hub'
|
6
|
+
import componentMixin from '../component/component'
|
8
7
|
|
9
8
|
const componentDef = {
|
10
9
|
mixins: [componentMixin],
|
@@ -88,6 +87,22 @@ const componentDef = {
|
|
88
87
|
}
|
89
88
|
self.data = data;
|
90
89
|
},
|
90
|
+
shouldResetFormOnSuccessfulSubmit() {
|
91
|
+
const self = this
|
92
|
+
if (self.componentConfig['success'] != undefined && self.componentConfig['success']['reset'] != undefined) {
|
93
|
+
return self.componentConfig['success']['reset']
|
94
|
+
} else {
|
95
|
+
return self.shouldResetFormOnSuccessfulSubmitByDefault()
|
96
|
+
}
|
97
|
+
},
|
98
|
+
shouldResetFormOnSuccessfulSubmitByDefault() {
|
99
|
+
const self = this
|
100
|
+
if (self.componentConfig["method"] == "put") {
|
101
|
+
return false
|
102
|
+
} else {
|
103
|
+
return true
|
104
|
+
}
|
105
|
+
},
|
91
106
|
perform: function(){
|
92
107
|
const self = this
|
93
108
|
let payload = {}
|
@@ -104,12 +119,33 @@ const componentDef = {
|
|
104
119
|
if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
|
105
120
|
matestackEventHub.$emit(self.componentConfig["success"]["emit"], response.data);
|
106
121
|
}
|
107
|
-
if (self.componentConfig["success"] != undefined
|
122
|
+
if (self.componentConfig["success"] != undefined
|
123
|
+
&& self.componentConfig["success"]["transition"] != undefined
|
124
|
+
&& (
|
125
|
+
self.componentConfig["success"]["transition"]["follow_response"] == undefined
|
126
|
+
||
|
127
|
+
self.componentConfig["success"]["transition"]["follow_response"] === false
|
128
|
+
)
|
129
|
+
&& self.$store != undefined
|
130
|
+
) {
|
108
131
|
let path = self.componentConfig["success"]["transition"]["path"]
|
109
132
|
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
if (self.componentConfig["success"] != undefined
|
136
|
+
&& self.componentConfig["success"]["transition"] != undefined
|
137
|
+
&& self.componentConfig["success"]["transition"]["follow_response"] === true
|
138
|
+
&& self.$store != undefined
|
139
|
+
) {
|
140
|
+
let path = response.data["transition_to"] || response.request.responseURL
|
141
|
+
self.$store.dispatch('navigateTo', {url: path, backwards: false})
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
if (self.shouldResetFormOnSuccessfulSubmit())
|
145
|
+
{
|
146
|
+
self.setProps(self.data, null);
|
147
|
+
self.initValues();
|
110
148
|
}
|
111
|
-
self.setProps(self.data, null);
|
112
|
-
self.initValues()
|
113
149
|
self.showInlineForm = false;
|
114
150
|
})
|
115
151
|
.catch(function(error){
|
@@ -1,29 +1,38 @@
|
|
1
|
-
- if
|
2
|
-
%label=
|
1
|
+
- if label
|
2
|
+
%label=label
|
3
3
|
|
4
|
-
- if [:text, :number, :email, :date, :password].include?(
|
5
|
-
%input{
|
6
|
-
type:
|
7
|
-
|
8
|
-
id: component_id,
|
4
|
+
- if [:text, :number, :email, :date, :password].include?(type)
|
5
|
+
%input{ @tag_attributes,
|
6
|
+
"v-model#{'.number' if type == :number}": input_key,
|
7
|
+
type: type,
|
9
8
|
"@change": "inputChanged(\"#{attr_key}\")",
|
10
9
|
ref: "input.#{attr_key}",
|
11
|
-
placeholder:
|
12
|
-
"init-value": init_value}
|
13
|
-
%span{class: "errors", "v-if": error_key }
|
14
|
-
%span{class: "error", "v-for": "error in #{error_key}"}
|
15
|
-
{{ error }}
|
10
|
+
placeholder: placeholder,
|
11
|
+
"init-value": init_value }
|
16
12
|
|
17
|
-
- if
|
18
|
-
%textarea{
|
19
|
-
|
20
|
-
id: component_id,
|
13
|
+
- if type == :textarea
|
14
|
+
%textarea{ @tag_attributes,
|
15
|
+
"v-model": input_key,
|
21
16
|
"@change": "inputChanged(\"#{attr_key}\")",
|
22
17
|
ref: "input.#{attr_key}",
|
23
|
-
placeholder:
|
18
|
+
placeholder: placeholder,
|
24
19
|
"init-value": init_value,
|
25
20
|
rows: options[:rows],
|
26
|
-
cols: options[:cols]}
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
cols: options[:cols] }
|
22
|
+
|
23
|
+
- if type == :range
|
24
|
+
%input{ @tag_attributes,
|
25
|
+
"v-model": input_key,
|
26
|
+
type: :range,
|
27
|
+
"@change": "inputChanged(\"#{attr_key}\")",
|
28
|
+
ref: "input.#{attr_key}",
|
29
|
+
placeholder: placeholder,
|
30
|
+
"init-value": init_value,
|
31
|
+
min: options[:min],
|
32
|
+
max: options[:max],
|
33
|
+
step: options[:step],
|
34
|
+
list: options[:list] }
|
35
|
+
|
36
|
+
%span{ class: "errors", "v-if": error_key }
|
37
|
+
%span{ class: "error", "v-for": "error in #{error_key}" }
|
38
|
+
{{ error }}
|
@@ -7,21 +7,35 @@ module Matestack::Ui::Core::Form::Input
|
|
7
7
|
raise "included form config is missing, please add ':include' to parent form component" if @included_config.nil?
|
8
8
|
end
|
9
9
|
|
10
|
+
def key
|
11
|
+
options[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def label
|
15
|
+
options[:label]
|
16
|
+
end
|
17
|
+
|
18
|
+
def type
|
19
|
+
options[:type]
|
20
|
+
end
|
21
|
+
|
22
|
+
def placeholder
|
23
|
+
options[:placeholder]
|
24
|
+
end
|
25
|
+
|
10
26
|
def input_key
|
11
|
-
|
27
|
+
"data['#{key.to_s}']"
|
12
28
|
end
|
13
29
|
|
14
30
|
def error_key
|
15
|
-
|
31
|
+
"errors['#{key.to_s}']"
|
16
32
|
end
|
17
33
|
|
18
34
|
def input_wrapper
|
19
35
|
case options[:for]
|
20
36
|
when nil
|
21
37
|
return nil
|
22
|
-
when Symbol
|
23
|
-
return options[:for]
|
24
|
-
when String
|
38
|
+
when Symbol, String
|
25
39
|
return options[:for]
|
26
40
|
end
|
27
41
|
if options[:for].respond_to?(:model_name)
|
@@ -31,44 +45,37 @@ module Matestack::Ui::Core::Form::Input
|
|
31
45
|
|
32
46
|
def attr_key
|
33
47
|
if input_wrapper.nil?
|
34
|
-
return
|
48
|
+
return key.to_s
|
35
49
|
else
|
36
|
-
return "#{input_wrapper}.#{
|
50
|
+
return "#{input_wrapper}.#{key.to_s}"
|
37
51
|
end
|
38
52
|
end
|
39
53
|
|
40
54
|
def init_value
|
41
|
-
unless options[:init].nil?
|
42
|
-
return options[:init]
|
43
|
-
end
|
55
|
+
return options[:init] unless options[:init].nil?
|
44
56
|
|
45
57
|
unless options[:for].nil?
|
46
|
-
value = options[:for].send
|
47
|
-
if [true, false].include? value
|
48
|
-
value ? 1 : 0
|
49
|
-
else
|
50
|
-
return value
|
51
|
-
end
|
58
|
+
value = parse_value(options[:for].send key)
|
52
59
|
else
|
53
60
|
unless @included_config.nil? && @included_config[:for].nil?
|
54
|
-
if @included_config[:for].respond_to?(
|
55
|
-
value = @included_config[:for].send
|
56
|
-
if [true, false].include? value
|
57
|
-
value ? 1 : 0
|
58
|
-
else
|
59
|
-
return value
|
60
|
-
end
|
61
|
+
if @included_config[:for].respond_to?(key)
|
62
|
+
value = parse_value(@included_config[:for].send key)
|
61
63
|
else
|
62
|
-
|
63
|
-
return nil
|
64
|
-
end
|
65
|
-
if @included_config[:for].is_a?(Hash)
|
66
|
-
return @included_config[:for][options[:key]]
|
67
|
-
end
|
64
|
+
@included_config[:for][key] if @included_config[:for].is_a?(Hash)
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
71
68
|
end
|
72
69
|
|
70
|
+
private
|
71
|
+
|
72
|
+
def parse_value(value)
|
73
|
+
if [true, false].include? value
|
74
|
+
value ? 1 : 0
|
75
|
+
else
|
76
|
+
return value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
73
80
|
end
|
74
81
|
end
|
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
- if options[:type] == :dropdown
|
6
6
|
|
7
|
-
%select{
|
8
|
-
|
7
|
+
%select{@tag_attributes,
|
8
|
+
"#{model_binding}" => input_key,
|
9
9
|
ref: "select.#{attr_key}",
|
10
10
|
"@change": "inputChanged(\"#{attr_key}\")",
|
11
11
|
"init-value": init_value,
|
@@ -26,7 +26,8 @@
|
|
26
26
|
%div{id: component_id, ref: "select.multiple.#{attr_key}", "init-value": init_value}
|
27
27
|
- if options[:options].is_a?(Hash)
|
28
28
|
- options[:options].each do |key, value|
|
29
|
-
%input{
|
29
|
+
%input{@tag_attributes,
|
30
|
+
type: :checkbox,
|
30
31
|
"#{model_binding}": input_key,
|
31
32
|
"@change": "inputChanged(\"#{attr_key}\")",
|
32
33
|
"value-type": options_type,
|
@@ -35,7 +36,8 @@
|
|
35
36
|
%label=value
|
36
37
|
- if options[:options].is_a?(Array)
|
37
38
|
- options[:options].each do |value|
|
38
|
-
%input{
|
39
|
+
%input{@tag_attributes,
|
40
|
+
type: :checkbox,
|
39
41
|
"#{model_binding}": input_key,
|
40
42
|
"@change": "inputChanged(\"#{attr_key}\")",
|
41
43
|
"value-type": options_type,
|
@@ -51,7 +53,8 @@
|
|
51
53
|
%div{id: component_id, ref: "select.#{attr_key}", "init-value": init_value}
|
52
54
|
- if options[:options].is_a?(Hash)
|
53
55
|
- options[:options].each do |key, value|
|
54
|
-
%input{
|
56
|
+
%input{@tag_attributes,
|
57
|
+
type: :radio,
|
55
58
|
"#{model_binding}": input_key,
|
56
59
|
"@change": "inputChanged(\"#{attr_key}\")",
|
57
60
|
"value-type": options_type,
|
@@ -60,7 +63,8 @@
|
|
60
63
|
%label=value
|
61
64
|
- if options[:options].is_a?(Array)
|
62
65
|
- options[:options].each do |value|
|
63
|
-
%input{
|
66
|
+
%input{@tag_attributes,
|
67
|
+
type: :radio,
|
64
68
|
"#{model_binding}": input_key,
|
65
69
|
"@change": "inputChanged(\"#{attr_key}\")",
|
66
70
|
"value-type": options_type,
|