matestack-ui-core 0.7.5 → 0.7.6

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/concepts/matestack/ui/core/action/action.js +120 -39
  3. data/app/concepts/matestack/ui/core/action/action.rb +21 -0
  4. data/app/concepts/matestack/ui/core/app/app.js +3 -3
  5. data/app/concepts/matestack/ui/core/app/app.rb +1 -0
  6. data/app/concepts/matestack/ui/core/app/store.js +1 -1
  7. data/app/concepts/matestack/ui/core/async/async.js +25 -3
  8. data/app/concepts/matestack/ui/core/form/form.js +245 -116
  9. data/app/concepts/matestack/ui/core/form/form.rb +22 -0
  10. data/app/concepts/matestack/ui/core/form/input/input.haml +9 -1
  11. data/app/concepts/matestack/ui/core/form/input/input.rb +2 -2
  12. data/app/concepts/matestack/ui/core/form/select/select.haml +14 -10
  13. data/app/concepts/matestack/ui/core/form/select/select.rb +10 -0
  14. data/app/concepts/matestack/ui/core/page/page.rb +5 -1
  15. data/app/concepts/matestack/ui/core/transition/transition.js +16 -1
  16. data/app/concepts/matestack/ui/core/transition/transition.rb +1 -1
  17. data/app/helpers/matestack/ui/core/application_helper.rb +2 -1
  18. data/lib/matestack/ui/core/version.rb +1 -1
  19. data/vendor/assets/javascripts/dist/manifest.json +6 -10
  20. data/vendor/assets/javascripts/dist/matestack-ui-core.js +406 -158
  21. data/vendor/assets/javascripts/dist/matestack-ui-core.js.map +1 -1
  22. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js +1 -1
  23. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.gz +0 -0
  24. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map +1 -1
  25. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.gz +0 -0
  26. metadata +4 -6
  27. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.br +0 -0
  28. data/vendor/assets/javascripts/dist/matestack-ui-core.min.js.map.br +0 -0
@@ -9,16 +9,23 @@ module Matestack::Ui::Core::Form
9
9
  @component_config[:submit_path] = submit_path
10
10
  @component_config[:method] = options[:method]
11
11
  @component_config[:success] = options[:success]
12
+ @component_config[:multipart] = options[:multipart] == true
12
13
  unless options[:success].nil?
13
14
  unless options[:success][:transition].nil?
14
15
  @component_config[:success][:transition][:path] = transition_path options[:success]
15
16
  end
17
+ unless options[:success][:redirect].nil?
18
+ @component_config[:success][:redirect][:path] = redirect_path options[:success]
19
+ end
16
20
  end
17
21
  @component_config[:failure] = options[:failure]
18
22
  unless options[:failure].nil?
19
23
  unless options[:failure][:transition].nil?
20
24
  @component_config[:failure][:transition][:path] = transition_path options[:failure]
21
25
  end
26
+ unless options[:failure][:redirect].nil?
27
+ @component_config[:failure][:redirect][:path] = redirect_path options[:failure]
28
+ end
22
29
  end
23
30
  @tag_attributes.merge!({"@submit.prevent": true})
24
31
  rescue => e
@@ -53,6 +60,21 @@ module Matestack::Ui::Core::Form
53
60
  end
54
61
  end
55
62
 
63
+ def redirect_path callback_options
64
+ begin
65
+ if callback_options[:redirect][:path].is_a?(Symbol)
66
+ return ::Rails.application.routes.url_helpers.send(
67
+ callback_options[:redirect][:path],
68
+ callback_options[:redirect][:params]
69
+ )
70
+ else
71
+ return callback_options[:redirect][:path]
72
+ end
73
+ rescue
74
+ raise "Redirect path not found"
75
+ end
76
+ end
77
+
56
78
  def form_wrapper
57
79
  case options[:for]
58
80
  when Symbol
@@ -33,6 +33,14 @@
33
33
  step: options[:step],
34
34
  list: options[:list] }
35
35
 
36
+ - if [:file].include?(type)
37
+ %input{ @tag_attributes,
38
+ type: type,
39
+ "@change": "inputChanged(\"#{attr_key}\"); filesAdded('#{attr_key}')",
40
+ ref: "input.#{attr_key}",
41
+ placeholder: placeholder,
42
+ multiple: options[:multiple] }
43
+
36
44
  %span{ class: "errors", "v-if": error_key }
37
45
  %span{ class: "error", "v-for": "error in #{error_key}" }
38
- {{ error }}
46
+ {{ error }}
@@ -45,9 +45,9 @@ module Matestack::Ui::Core::Form::Input
45
45
 
46
46
  def attr_key
47
47
  if input_wrapper.nil?
48
- return key.to_s
48
+ return "#{key.to_s}#{'[]' if options[:multiple]}"
49
49
  else
50
- return "#{input_wrapper}.#{key.to_s}"
50
+ return "#{input_wrapper}.#{key.to_s}#{'[]' if options[:multiple]}"
51
51
  end
52
52
  end
53
53
 
@@ -26,24 +26,26 @@
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{@tag_attributes,
29
+ %input{@tag_attributes.except(:id),
30
+ id: id_for_option(value),
30
31
  type: :checkbox,
31
32
  "#{model_binding}": input_key,
32
33
  "@change": "inputChanged(\"#{attr_key}\")",
33
34
  "value-type": options_type,
34
35
  name: value,
35
36
  value: key}/
36
- %label=value
37
+ %label{for: id_for_option(value)}=value
37
38
  - if options[:options].is_a?(Array)
38
39
  - options[:options].each do |value|
39
- %input{@tag_attributes,
40
+ %input{@tag_attributes.except(:id),
41
+ id: id_for_option(value),
40
42
  type: :checkbox,
41
43
  "#{model_binding}": input_key,
42
44
  "@change": "inputChanged(\"#{attr_key}\")",
43
45
  "value-type": options_type,
44
46
  name: value,
45
47
  value: value}/
46
- %label=value
48
+ %label{for: id_for_option(value)}=value
47
49
  %span{class: "errors", "v-if": error_key }
48
50
  %span{class: "error", "v-for": "error in #{error_key}"}
49
51
  {{ error }}
@@ -53,24 +55,26 @@
53
55
  %div{id: component_id, ref: "select.#{attr_key}", "init-value": init_value}
54
56
  - if options[:options].is_a?(Hash)
55
57
  - options[:options].each do |key, value|
56
- %input{@tag_attributes,
58
+ %input{@tag_attributes.except(:id),
57
59
  type: :radio,
60
+ id: id_for_option(value),
58
61
  "#{model_binding}": input_key,
59
62
  "@change": "inputChanged(\"#{attr_key}\")",
60
63
  "value-type": options_type,
61
- name: value,
64
+ name: "#{attr_key}_#{key}",
62
65
  value: key}/
63
- %label=value
66
+ %label{for: id_for_option(value)}=value
64
67
  - if options[:options].is_a?(Array)
65
68
  - options[:options].each do |value|
66
- %input{@tag_attributes,
69
+ %input{@tag_attributes.except(:id),
67
70
  type: :radio,
71
+ id: id_for_option(value),
68
72
  "#{model_binding}": input_key,
69
73
  "@change": "inputChanged(\"#{attr_key}\")",
70
74
  "value-type": options_type,
71
- name: value,
75
+ name: "#{attr_key}_#{value}",
72
76
  value: value}/
73
- %label=value
77
+ %label{for: id_for_option(value)}=value
74
78
  %span{class: "errors", "v-if": error_key }
75
79
  %span{class: "error", "v-for": "error in #{error_key}"}
76
80
  {{ error }}
@@ -3,6 +3,12 @@ module Matestack::Ui::Core::Form::Select
3
3
 
4
4
  REQUIRED_KEYS = [:options]
5
5
 
6
+ def setup
7
+ if @tag_attributes[:id].nil?
8
+ @tag_attributes[:id] = attr_key
9
+ end
10
+ end
11
+
6
12
  def input_key
7
13
  'data["' + options[:key].to_s + '"]'
8
14
  end
@@ -68,6 +74,10 @@ module Matestack::Ui::Core::Form::Select
68
74
  end
69
75
  end
70
76
 
77
+ def id_for_option value
78
+ return "#{@tag_attributes[:id]}_#{value}"
79
+ end
80
+
71
81
 
72
82
  end
73
83
  end
@@ -89,7 +89,11 @@ module Matestack::Ui::Core::Page
89
89
  nodes_to_cell
90
90
  render :page
91
91
  when :render_page_with_app
92
- concept(@app_class).call(:show, @page_id, @nodes)
92
+ @app_class.new(nil, context: {
93
+ params: options[:context][:params],
94
+ request: options[:context][:request],
95
+ view_context: options[:context][:view_context]
96
+ }, controller_instance: options[:controller_instance]).call(:show, @page_id, @nodes)
93
97
  when :render_component
94
98
  begin
95
99
  render_child_component component_key
@@ -1,6 +1,7 @@
1
1
  import Vue from 'vue/dist/vue.esm'
2
2
  import Vuex from 'vuex'
3
3
  import componentMixin from '../component/component'
4
+ import matestackEventHub from '../js/event-hub'
4
5
 
5
6
  const componentDef = {
6
7
  mixins: [componentMixin],
@@ -9,11 +10,25 @@ const componentDef = {
9
10
  },
10
11
  computed: Vuex.mapState({
11
12
  isActive (state) {
12
- return this.componentConfig["link_path"] === state.currentPath
13
+ return (this.componentConfig["link_path"].split("?")[0]) === state.currentPathName
14
+ },
15
+ isChildActive (state) {
16
+ return ((this.componentConfig["link_path"].split("?")[0]) !== state.currentPathName) && (state.currentPathName.indexOf(this.componentConfig["link_path"].split("?")[0]) !== -1)
13
17
  }
14
18
  }),
15
19
  methods: {
16
20
  navigateTo: function(url){
21
+ const self = this
22
+ matestackEventHub.$emit("page_loading_triggered", url);
23
+ if (self.componentConfig["delay"] != undefined) {
24
+ setTimeout(function () {
25
+ self.performNavigation(url)
26
+ }, parseInt(self.componentConfig["delay"]));
27
+ } else {
28
+ this.performNavigation(url)
29
+ }
30
+ },
31
+ performNavigation: function(url){
17
32
  this.$store.dispatch('navigateTo', {url: url, backwards: false}).then((response) => {
18
33
  // self.asyncTemplate = response;
19
34
  })
@@ -6,7 +6,7 @@ module Matestack::Ui::Core::Transition
6
6
  @tag_attributes.merge!({
7
7
  "href": link_path,
8
8
  "@click.prevent": navigate_to(link_path),
9
- "v-bind:class": "{ active: isActive }"
9
+ "v-bind:class": "{ active: isActive, 'active-child': isChildActive }"
10
10
  })
11
11
  end
12
12
 
@@ -15,7 +15,8 @@ module Matestack
15
15
  def render_component(page_class, component_key)
16
16
  page_class.new(nil, context: {
17
17
  params: params,
18
- request: request
18
+ request: request,
19
+ view_context: view_context
19
20
  }, controller_instance: self).call(:show, component_key)
20
21
  end
21
22
 
@@ -1,7 +1,7 @@
1
1
  module Matestack
2
2
  module Ui
3
3
  module Core
4
- VERSION = '0.7.5'
4
+ VERSION = '0.7.6'
5
5
  end
6
6
  end
7
7
  end
@@ -2,21 +2,17 @@
2
2
  "entrypoints": {
3
3
  "matestack-ui-core": {
4
4
  "css": [
5
- "/dist/matestack-ui-core.css"
5
+ "/dist/matestack-ui-core.min.css"
6
6
  ],
7
7
  "js": [
8
- "/dist/matestack-ui-core.js"
9
- ],
10
- "css.map": [
11
- "/dist/matestack-ui-core.css.map"
8
+ "/dist/matestack-ui-core.min.js"
12
9
  ],
13
10
  "js.map": [
14
- "/dist/matestack-ui-core.js.map"
11
+ "/dist/matestack-ui-core.min.js.map"
15
12
  ]
16
13
  }
17
14
  },
18
- "matestack-ui-core.css": "/dist/matestack-ui-core.css",
19
- "matestack-ui-core.css.map": "/dist/matestack-ui-core.css.map",
20
- "matestack-ui-core.js": "/dist/matestack-ui-core.js",
21
- "matestack-ui-core.js.map": "/dist/matestack-ui-core.js.map"
15
+ "matestack-ui-core.css": "/dist/matestack-ui-core.min.css",
16
+ "matestack-ui-core.js": "/dist/matestack-ui-core.min.js",
17
+ "matestack-ui-core.js.map": "/dist/matestack-ui-core.min.js.map"
22
18
  }
@@ -120,51 +120,132 @@ const componentDef = {
120
120
  (self.componentConfig["confirm"] == undefined) || confirm(self.componentConfig["confirm_text"])
121
121
  )
122
122
  {
123
- axios__WEBPACK_IMPORTED_MODULE_2___default()({
123
+ if (self.componentConfig["emit"] != undefined) {
124
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["emit"]);
125
+ }
126
+ if (self.componentConfig["delay"] != undefined) {
127
+ setTimeout(function () {
128
+ self.sendRequest()
129
+ }, parseInt(self.componentConfig["delay"]));
130
+ } else {
131
+ this.sendRequest()
132
+ }
133
+ }
134
+ },
135
+ sendRequest: function(){
136
+ const self = this
137
+ axios__WEBPACK_IMPORTED_MODULE_2___default()({
124
138
  method: self.componentConfig["method"],
125
139
  url: self.componentConfig["action_path"],
126
140
  data: self.componentConfig["data"],
127
141
  headers: {
128
142
  'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
129
143
  }
130
- })
131
- .then(function(response){
132
- if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
133
- _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["success"]["emit"], response.data);
134
- }
135
- if (self.componentConfig["success"] != undefined
136
- && self.componentConfig["success"]["transition"] != undefined
137
- && (
138
- self.componentConfig["success"]["transition"]["follow_response"] == undefined
139
- ||
140
- self.componentConfig["success"]["transition"]["follow_response"] === false
141
- )
142
- && self.$store != undefined
143
- ) {
144
- let path = self.componentConfig["success"]["transition"]["path"]
145
- self.$store.dispatch('navigateTo', {url: path, backwards: false})
146
- return;
147
- }
148
- if (self.componentConfig["success"] != undefined
149
- && self.componentConfig["success"]["transition"] != undefined
150
- && self.componentConfig["success"]["transition"]["follow_response"] === true
151
- && self.$store != undefined
152
- ) {
153
- let path = response.data["transition_to"] || response.request.responseURL;
154
- self.$store.dispatch('navigateTo', {url: path, backwards: false});
155
- return;
156
- }
157
- })
158
- .catch(function(error){
159
- if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
160
- _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["failure"]["emit"], error.response.data);
161
- }
162
- if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["transition"] != undefined && self.$store != undefined) {
163
- let path = self.componentConfig["failure"]["transition"]["path"]
164
- self.$store.dispatch('navigateTo', {url: path, backwards: false})
165
- }
166
- })
167
- }
144
+ }
145
+ )
146
+ .then(function(response){
147
+ if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
148
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["success"]["emit"], response.data);
149
+ }
150
+
151
+ // transition handling
152
+ if (self.componentConfig["success"] != undefined
153
+ && self.componentConfig["success"]["transition"] != undefined
154
+ && (
155
+ self.componentConfig["success"]["transition"]["follow_response"] == undefined
156
+ ||
157
+ self.componentConfig["success"]["transition"]["follow_response"] === false
158
+ )
159
+ && self.$store != undefined
160
+ ) {
161
+ let path = self.componentConfig["success"]["transition"]["path"]
162
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
163
+ return;
164
+ }
165
+ if (self.componentConfig["success"] != undefined
166
+ && self.componentConfig["success"]["transition"] != undefined
167
+ && self.componentConfig["success"]["transition"]["follow_response"] === true
168
+ && self.$store != undefined
169
+ ) {
170
+ let path = response.data["transition_to"] || response.request.responseURL
171
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
172
+ return;
173
+ }
174
+ // redirect handling
175
+ if (self.componentConfig["success"] != undefined
176
+ && self.componentConfig["success"]["redirect"] != undefined
177
+ && (
178
+ self.componentConfig["success"]["redirect"]["follow_response"] == undefined
179
+ ||
180
+ self.componentConfig["success"]["redirect"]["follow_response"] === false
181
+ )
182
+ && self.$store != undefined
183
+ ) {
184
+ let path = self.componentConfig["success"]["redirect"]["path"]
185
+ window.location.href = path
186
+ return;
187
+ }
188
+ if (self.componentConfig["success"] != undefined
189
+ && self.componentConfig["success"]["redirect"] != undefined
190
+ && self.componentConfig["success"]["redirect"]["follow_response"] === true
191
+ && self.$store != undefined
192
+ ) {
193
+ let path = response.data["redirect_to"] || response.request.responseURL
194
+ window.location.href = path
195
+ return;
196
+ }
197
+ })
198
+ .catch(function(error){
199
+ if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
200
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["failure"]["emit"], error.response.data);
201
+ }
202
+ // transition handling
203
+ if (self.componentConfig["failure"] != undefined
204
+ && self.componentConfig["failure"]["transition"] != undefined
205
+ && (
206
+ self.componentConfig["failure"]["transition"]["follow_response"] == undefined
207
+ ||
208
+ self.componentConfig["failure"]["transition"]["follow_response"] === false
209
+ )
210
+ && self.$store != undefined
211
+ ) {
212
+ let path = self.componentConfig["failure"]["transition"]["path"]
213
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
214
+ return;
215
+ }
216
+ if (self.componentConfig["failure"] != undefined
217
+ && self.componentConfig["failure"]["transition"] != undefined
218
+ && self.componentConfig["failure"]["transition"]["follow_response"] === true
219
+ && self.$store != undefined
220
+ ) {
221
+ let path = error.response.data["transition_to"] || response.request.responseURL
222
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
223
+ return;
224
+ }
225
+ // redirect handling
226
+ if (self.componentConfig["failure"] != undefined
227
+ && self.componentConfig["failure"]["redirect"] != undefined
228
+ && (
229
+ self.componentConfig["failure"]["redirect"]["follow_response"] == undefined
230
+ ||
231
+ self.componentConfig["failure"]["redirect"]["follow_response"] === false
232
+ )
233
+ && self.$store != undefined
234
+ ) {
235
+ let path = self.componentConfig["failure"]["redirect"]["path"]
236
+ window.location.href = path
237
+ return;
238
+ }
239
+ if (self.componentConfig["failure"] != undefined
240
+ && self.componentConfig["failure"]["redirect"] != undefined
241
+ && self.componentConfig["failure"]["redirect"]["follow_response"] === true
242
+ && self.$store != undefined
243
+ ) {
244
+ let path = error.response.data["redirect_to"] || response.request.responseURL
245
+ window.location.href = path
246
+ return;
247
+ }
248
+ })
168
249
  }
169
250
  }
170
251
  }
@@ -207,15 +288,15 @@ const componentDef = {
207
288
  }),
208
289
  mounted: function(){
209
290
  const self = this;
210
- window.onpopstate = (event) => {
291
+ window.addEventListener("popstate", (event) => {
211
292
  if (Object(_location__WEBPACK_IMPORTED_MODULE_3__["default"])({
212
293
  origin: self.currentOrigin,
213
294
  pathName: self.currentPathName,
214
295
  search: self.currentSearch
215
296
  }, document.location)){
216
- self.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
297
+ self.$store.dispatch("navigateTo", { url: document.location.pathname + document.location.search, backwards: true } );
217
298
  }
218
- }
299
+ })
219
300
  },
220
301
  components: {
221
302
  VRuntimeTemplate: v_runtime_template__WEBPACK_IMPORTED_MODULE_1__["default"]
@@ -322,7 +403,7 @@ const store = new vuex__WEBPACK_IMPORTED_MODULE_1__["default"].Store({
322
403
  setTimeout(function () {
323
404
  resolve(response["data"])
324
405
  commit('setPageTemplate', response["data"])
325
- commit('setCurrentLocation', { path: url, search: document.location.search, origin: document.location.origin })
406
+ commit('setCurrentLocation', { path: url.split("?")[0], search: document.location.search, origin: document.location.origin })
326
407
  _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit("page_loaded", url);
327
408
  if (typeof matestackUiCoreTransitionSuccess !== 'undefined') {
328
409
  matestackUiCoreTransitionSuccess(url);
@@ -407,9 +488,19 @@ const componentDef = {
407
488
  },
408
489
  created: function () {
409
490
  const self = this
410
- _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$on(this.componentConfig["rerender_on"], self.rerender)
411
- _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$on(this.componentConfig["show_on"], self.show)
412
- _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$on(this.componentConfig["hide_on"], self.hide)
491
+ if(this.componentConfig["show_on"] != undefined){
492
+ this.showing = false
493
+ var show_events = this.componentConfig["show_on"].split(",")
494
+ show_events.forEach(show_event => _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$on(show_event.trim(), self.show));
495
+ }
496
+ if(this.componentConfig["hide_on"] != undefined){
497
+ var hide_events = this.componentConfig["hide_on"].split(",")
498
+ hide_events.forEach(hide_event => _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$on(hide_event.trim(), self.hide));
499
+ }
500
+ if(this.componentConfig["rerender_on"] != undefined){
501
+ var rerender_events = this.componentConfig["rerender_on"].split(",")
502
+ rerender_events.forEach(rerender_event => _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$on(rerender_event.trim(), self.rerender));
503
+ }
413
504
  if(this.componentConfig["show_on"] != undefined){
414
505
  this.showing = false
415
506
  }
@@ -430,6 +521,18 @@ const componentDef = {
430
521
  _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$off(this.componentConfig["rerender_on"], self.rerender);
431
522
  _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$off(this.componentConfig["show_on"], self.show);
432
523
  _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$off(this.componentConfig["hide_on"], self.hide);
524
+ if(this.componentConfig["show_on"] != undefined){
525
+ var shown_events = this.componentConfig["show_on"].split(",")
526
+ shown_events.forEach(show_event => _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$off(show_event.trim(), self.show));
527
+ }
528
+ if(this.componentConfig["hide_on"] != undefined){
529
+ var hiden_events = this.componentConfig["hide_on"].split(",")
530
+ hiden_events.forEach(hide_event => _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$off(hide_event.trim(), self.hide));
531
+ }
532
+ if(this.componentConfig["rerender_on"] != undefined){
533
+ var rerender_events = this.componentConfig["rerender_on"].split(",")
534
+ rerender_events.forEach(rerender_event => _js_event_hub__WEBPACK_IMPORTED_MODULE_1__["default"].$off(rerender_event.trim(), self.rerender));
535
+ }
433
536
  },
434
537
  }
435
538
 
@@ -820,29 +923,29 @@ __webpack_require__.r(__webpack_exports__);
820
923
 
821
924
  const componentDef = {
822
925
  mixins: [_component_component__WEBPACK_IMPORTED_MODULE_4__["default"]],
823
- data: function(){
926
+ data: function () {
824
927
  return {
825
928
  data: {},
826
929
  showInlineForm: false,
827
- errors: {}
828
- }
930
+ errors: {},
931
+ };
829
932
  },
830
933
  methods: {
831
- initDataKey: function(key, initValue){
934
+ initDataKey: function (key, initValue) {
832
935
  this.data[key] = initValue;
833
936
  },
834
- inputChanged: function(key){
835
- this.resetErrors(key)
937
+ inputChanged: function (key) {
938
+ this.resetErrors(key);
836
939
  },
837
- updateFormValue: function(key, value){
940
+ updateFormValue: function (key, value) {
838
941
  this.data[key] = value;
839
942
  },
840
- resetErrors: function(key){
841
- if (this.errors[key]){
943
+ resetErrors: function (key) {
944
+ if (this.errors[key]) {
842
945
  this.errors[key] = null;
843
946
  }
844
947
  },
845
- launchInlineForm: function(key, value){
948
+ launchInlineForm: function (key, value) {
846
949
  this.showInlineForm = true;
847
950
  this.data[key] = value;
848
951
  const self = this;
@@ -850,137 +953,266 @@ const componentDef = {
850
953
  self.$refs.inlineinput.focus();
851
954
  }, 300);
852
955
  },
853
- closeInlineForm: function(){
956
+ closeInlineForm: function () {
854
957
  this.showInlineForm = false;
855
958
  },
856
- setProps: function(flat, newVal){
857
- for(var i in flat){
858
- if((typeof flat[i] === "object") && !(flat[i] instanceof Array)){
859
- setProps(flat[i], newVal);
860
- return;
861
- } else {
862
- flat[i] = newVal;
863
- }
959
+ setProps: function (flat, newVal) {
960
+ for (var i in flat) {
961
+ if (flat[i] === null){
962
+ flat[i] = newVal;
963
+ } else if (flat[i] instanceof File){
964
+ flat[i] = newVal;
965
+ this.$refs["input."+i].value = newVal
966
+ } else if (flat[i] instanceof Array) {
967
+ if(flat[i][0] instanceof File){
968
+ flat[i] = newVal
969
+ this.$refs["input."+i].value = newVal
970
+ }
971
+ } else if (typeof flat[i] === "object" && !(flat[i] instanceof Array)) {
972
+ setProps(flat[i], newVal);
973
+ } else {
974
+ flat[i] = newVal;
975
+ }
976
+ }
977
+ },
978
+ filesAdded: function (key) {
979
+ const dataTransfer = event.dataTransfer || event.target;
980
+ const files = dataTransfer.files;
981
+ if (event.target.attributes.multiple) {
982
+ this.data[key] = [];
983
+ for (let index in files) {
984
+ if (files[index] instanceof File) {
985
+ this.data[key].push(files[index]);
986
+ }
987
+ }
988
+ } else {
989
+ this.data[key] = files[0];
864
990
  }
865
991
  },
866
- initValues: function(){
992
+ initValues: function () {
867
993
  let self = this;
868
- let data = {}
994
+ let data = {};
869
995
  for (let key in self.$refs) {
870
- let initValue = self.$refs[key]["attributes"]["init-value"]
871
- let valueType = self.$refs[key]["attributes"]["value-type"]
872
-
873
- if (key.startsWith("input.")){
874
- if(initValue){
875
- data[key.replace('input.', '')] = initValue["value"]
876
- }else{
877
- data[key.replace('input.', '')] = null
996
+ let initValue = self.$refs[key]["attributes"]["init-value"];
997
+ let valueType = self.$refs[key]["attributes"]["value-type"];
998
+
999
+ if (key.startsWith("input.")) {
1000
+ if (initValue) {
1001
+ data[key.replace("input.", "")] = initValue["value"];
1002
+ } else {
1003
+ data[key.replace("input.", "")] = null;
878
1004
  }
879
1005
  }
880
- if (key.startsWith("select.")){
881
- if (key.startsWith("select.multiple.")){
882
- if(initValue){
883
- data[key.replace('select.multiple.', '')] = JSON.parse(initValue["value"])
884
- }else{
885
- data[key.replace('select.multiple.', '')] = []
1006
+ if (key.startsWith("select.")) {
1007
+ if (key.startsWith("select.multiple.")) {
1008
+ if (initValue) {
1009
+ data[key.replace("select.multiple.", "")] = JSON.parse(initValue["value"]);
1010
+ } else {
1011
+ data[key.replace("select.multiple.", "")] = [];
886
1012
  }
887
- }else{
888
- if(initValue){
889
- if(valueType && valueType["value"] == "Integer")
890
- data[key.replace('select.', '')] = parseInt(initValue["value"])
891
- else{
892
- data[key.replace('select.', '')] = initValue["value"]
1013
+ } else {
1014
+ if (initValue) {
1015
+ if (valueType && valueType["value"] == "Integer") data[key.replace("select.", "")] = parseInt(initValue["value"]);
1016
+ else {
1017
+ data[key.replace("select.", "")] = initValue["value"];
893
1018
  }
894
- }else{
895
- data[key.replace('select.', '')] = null
1019
+ } else {
1020
+ data[key.replace("select.", "")] = null;
896
1021
  }
897
1022
  }
898
-
899
1023
  }
900
1024
  }
901
1025
  self.data = data;
902
1026
  },
903
1027
  shouldResetFormOnSuccessfulSubmit() {
904
- const self = this
905
- if (self.componentConfig['success'] != undefined && self.componentConfig['success']['reset'] != undefined) {
906
- return self.componentConfig['success']['reset']
1028
+ const self = this;
1029
+ if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["reset"] != undefined) {
1030
+ return self.componentConfig["success"]["reset"];
907
1031
  } else {
908
- return self.shouldResetFormOnSuccessfulSubmitByDefault()
1032
+ return self.shouldResetFormOnSuccessfulSubmitByDefault();
909
1033
  }
910
1034
  },
911
1035
  shouldResetFormOnSuccessfulSubmitByDefault() {
912
- const self = this
1036
+ const self = this;
913
1037
  if (self.componentConfig["method"] == "put") {
914
- return false
1038
+ return false;
915
1039
  } else {
916
- return true
1040
+ return true;
917
1041
  }
918
1042
  },
919
1043
  perform: function(){
920
1044
  const self = this
921
- let payload = {}
922
- payload[self.componentConfig["for"]] = self.data
923
- axios__WEBPACK_IMPORTED_MODULE_2___default()({
924
- method: self.componentConfig["method"],
925
- url: self.componentConfig["submit_path"],
926
- data: payload,
927
- headers: {
928
- 'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
929
- }
930
- })
931
- .then(function(response){
932
- if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
933
- _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["success"]["emit"], response.data);
934
- }
935
- if (self.componentConfig["success"] != undefined
936
- && self.componentConfig["success"]["transition"] != undefined
937
- && (
938
- self.componentConfig["success"]["transition"]["follow_response"] == undefined
939
- ||
940
- self.componentConfig["success"]["transition"]["follow_response"] === false
941
- )
942
- && self.$store != undefined
943
- ) {
944
- let path = self.componentConfig["success"]["transition"]["path"]
945
- self.$store.dispatch('navigateTo', {url: path, backwards: false})
946
- return;
947
- }
948
- if (self.componentConfig["success"] != undefined
949
- && self.componentConfig["success"]["transition"] != undefined
950
- && self.componentConfig["success"]["transition"]["follow_response"] === true
951
- && self.$store != undefined
952
- ) {
953
- let path = response.data["transition_to"] || response.request.responseURL
954
- self.$store.dispatch('navigateTo', {url: path, backwards: false})
955
- return;
956
- }
957
- if (self.shouldResetFormOnSuccessfulSubmit())
958
- {
959
- self.setProps(self.data, null);
960
- self.initValues();
961
- }
962
- self.showInlineForm = false;
963
- })
964
- .catch(function(error){
965
- if(error.response && error.response.data && error.response.data.errors){
966
- self.errors = error.response.data.errors;
967
- }
968
- if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
969
- _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["failure"]["emit"], error.response.data);
970
- }
971
- if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["transition"] != undefined && self.$store != undefined) {
972
- let path = self.componentConfig["failure"]["transition"]["path"]
973
- self.$store.dispatch('navigateTo', {url: path, backwards: false})
1045
+ if (self.componentConfig["emit"] != undefined) {
1046
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["emit"]);
1047
+ }
1048
+ if (self.componentConfig["delay"] != undefined) {
1049
+ setTimeout(function () {
1050
+ self.sendRequest()
1051
+ }, parseInt(self.componentConfig["delay"]));
1052
+ } else {
1053
+ this.sendRequest()
1054
+ }
1055
+ },
1056
+ sendRequest: function(){
1057
+ const self = this;
1058
+ let payload = {};
1059
+ payload[self.componentConfig["for"]] = self.data;
1060
+ let axios_config = {};
1061
+ if (self.componentConfig["multipart"] == true ) {
1062
+ let form_data = new FormData();
1063
+ for (let key in self.data) {
1064
+ if (key.endsWith("[]")) {
1065
+ for (let i in self.data[key]) {
1066
+ let file = self.data[key][i];
1067
+ form_data.append(self.componentConfig["for"] + "[" + key.slice(0, -2) + "][]", file);
1068
+ }
1069
+ } else {
1070
+ if (self.data[key] != null){
1071
+ form_data.append(self.componentConfig["for"] + "[" + key + "]", self.data[key]);
1072
+ }
1073
+ }
974
1074
  }
975
- })
976
- }
1075
+ axios_config = {
1076
+ method: self.componentConfig["method"],
1077
+ url: self.componentConfig["submit_path"],
1078
+ data: form_data,
1079
+ headers: {
1080
+ "X-CSRF-Token": document.getElementsByName("csrf-token")[0].getAttribute("content"),
1081
+ "Content-Type": "multipart/form-data",
1082
+ },
1083
+ };
1084
+ } else {
1085
+ axios_config = {
1086
+ method: self.componentConfig["method"],
1087
+ url: self.componentConfig["submit_path"],
1088
+ data: payload,
1089
+ headers: {
1090
+ "X-CSRF-Token": document.getElementsByName("csrf-token")[0].getAttribute("content"),
1091
+ "Content-Type": "application/json",
1092
+ },
1093
+ };
1094
+ }
1095
+ axios__WEBPACK_IMPORTED_MODULE_2___default()(axios_config)
1096
+ .then(function (response) {
1097
+ if (self.componentConfig["success"] != undefined && self.componentConfig["success"]["emit"] != undefined) {
1098
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["success"]["emit"], response.data);
1099
+ }
1100
+ // transition handling
1101
+ if (self.componentConfig["success"] != undefined
1102
+ && self.componentConfig["success"]["transition"] != undefined
1103
+ && (
1104
+ self.componentConfig["success"]["transition"]["follow_response"] == undefined
1105
+ ||
1106
+ self.componentConfig["success"]["transition"]["follow_response"] === false
1107
+ )
1108
+ && self.$store != undefined
1109
+ ) {
1110
+ let path = self.componentConfig["success"]["transition"]["path"]
1111
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
1112
+ return;
1113
+ }
1114
+ if (self.componentConfig["success"] != undefined
1115
+ && self.componentConfig["success"]["transition"] != undefined
1116
+ && self.componentConfig["success"]["transition"]["follow_response"] === true
1117
+ && self.$store != undefined
1118
+ ) {
1119
+ let path = response.data["transition_to"] || response.request.responseURL
1120
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
1121
+ return;
1122
+ }
1123
+ // redirect handling
1124
+ if (self.componentConfig["success"] != undefined
1125
+ && self.componentConfig["success"]["redirect"] != undefined
1126
+ && (
1127
+ self.componentConfig["success"]["redirect"]["follow_response"] == undefined
1128
+ ||
1129
+ self.componentConfig["success"]["redirect"]["follow_response"] === false
1130
+ )
1131
+ && self.$store != undefined
1132
+ ) {
1133
+ let path = self.componentConfig["success"]["redirect"]["path"]
1134
+ window.location.href = path
1135
+ return;
1136
+ }
1137
+ if (self.componentConfig["success"] != undefined
1138
+ && self.componentConfig["success"]["redirect"] != undefined
1139
+ && self.componentConfig["success"]["redirect"]["follow_response"] === true
1140
+ && self.$store != undefined
1141
+ ) {
1142
+ let path = response.data["redirect_to"] || response.request.responseURL
1143
+ window.location.href = path
1144
+ return;
1145
+ }
1146
+
1147
+ if (self.shouldResetFormOnSuccessfulSubmit())
1148
+ {
1149
+ self.setProps(self.data, null);
1150
+ self.initValues();
1151
+ }
1152
+ self.showInlineForm = false;
1153
+ })
1154
+ .catch(function (error) {
1155
+ if (error.response && error.response.data && error.response.data.errors) {
1156
+ self.errors = error.response.data.errors;
1157
+ }
1158
+ if (self.componentConfig["failure"] != undefined && self.componentConfig["failure"]["emit"] != undefined) {
1159
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit(self.componentConfig["failure"]["emit"], error.response.data);
1160
+ }
1161
+ // transition handling
1162
+ if (self.componentConfig["failure"] != undefined
1163
+ && self.componentConfig["failure"]["transition"] != undefined
1164
+ && (
1165
+ self.componentConfig["failure"]["transition"]["follow_response"] == undefined
1166
+ ||
1167
+ self.componentConfig["failure"]["transition"]["follow_response"] === false
1168
+ )
1169
+ && self.$store != undefined
1170
+ ) {
1171
+ let path = self.componentConfig["failure"]["transition"]["path"]
1172
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
1173
+ return;
1174
+ }
1175
+ if (self.componentConfig["failure"] != undefined
1176
+ && self.componentConfig["failure"]["transition"] != undefined
1177
+ && self.componentConfig["failure"]["transition"]["follow_response"] === true
1178
+ && self.$store != undefined
1179
+ ) {
1180
+ let path = error.response.data["transition_to"] || response.request.responseURL
1181
+ self.$store.dispatch('navigateTo', {url: path, backwards: false})
1182
+ return;
1183
+ }
1184
+ // redirect handling
1185
+ if (self.componentConfig["failure"] != undefined
1186
+ && self.componentConfig["failure"]["redirect"] != undefined
1187
+ && (
1188
+ self.componentConfig["failure"]["redirect"]["follow_response"] == undefined
1189
+ ||
1190
+ self.componentConfig["failure"]["redirect"]["follow_response"] === false
1191
+ )
1192
+ && self.$store != undefined
1193
+ ) {
1194
+ let path = self.componentConfig["failure"]["redirect"]["path"]
1195
+ window.location.href = path
1196
+ return;
1197
+ }
1198
+ if (self.componentConfig["failure"] != undefined
1199
+ && self.componentConfig["failure"]["redirect"] != undefined
1200
+ && self.componentConfig["failure"]["redirect"]["follow_response"] === true
1201
+ && self.$store != undefined
1202
+ ) {
1203
+ let path = error.response.data["redirect_to"] || response.request.responseURL
1204
+ window.location.href = path
1205
+ return;
1206
+ }
1207
+ });
1208
+ },
977
1209
  },
978
- mounted: function(){
979
- this.initValues()
980
- }
981
- }
1210
+ mounted: function () {
1211
+ this.initValues();
1212
+ },
1213
+ };
982
1214
 
983
- let component = vue_dist_vue_esm__WEBPACK_IMPORTED_MODULE_0__["default"].component('matestack-ui-core-form', componentDef)
1215
+ let component = vue_dist_vue_esm__WEBPACK_IMPORTED_MODULE_0__["default"].component("matestack-ui-core-form", componentDef);
984
1216
 
985
1217
  /* harmony default export */ __webpack_exports__["default"] = (componentDef);
986
1218
 
@@ -1263,6 +1495,8 @@ __webpack_require__.r(__webpack_exports__);
1263
1495
  /* harmony import */ var vue_dist_vue_esm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue/dist/vue.esm */ "../node_modules/vue/dist/vue.esm.js");
1264
1496
  /* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vuex */ "../node_modules/vuex/dist/vuex.esm.js");
1265
1497
  /* harmony import */ var _component_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../component/component */ "../app/concepts/matestack/ui/core/component/component.js");
1498
+ /* harmony import */ var _js_event_hub__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../js/event-hub */ "../app/concepts/matestack/ui/core/js/event-hub.js");
1499
+
1266
1500
 
1267
1501
 
1268
1502
 
@@ -1274,11 +1508,25 @@ const componentDef = {
1274
1508
  },
1275
1509
  computed: vuex__WEBPACK_IMPORTED_MODULE_1__["default"].mapState({
1276
1510
  isActive (state) {
1277
- return this.componentConfig["link_path"] === state.currentPath
1511
+ return (this.componentConfig["link_path"].split("?")[0]) === state.currentPathName
1512
+ },
1513
+ isChildActive (state) {
1514
+ return ((this.componentConfig["link_path"].split("?")[0]) !== state.currentPathName) && (state.currentPathName.indexOf(this.componentConfig["link_path"].split("?")[0]) !== -1)
1278
1515
  }
1279
1516
  }),
1280
1517
  methods: {
1281
1518
  navigateTo: function(url){
1519
+ const self = this
1520
+ _js_event_hub__WEBPACK_IMPORTED_MODULE_3__["default"].$emit("page_loading_triggered", url);
1521
+ if (self.componentConfig["delay"] != undefined) {
1522
+ setTimeout(function () {
1523
+ self.performNavigation(url)
1524
+ }, parseInt(self.componentConfig["delay"]));
1525
+ } else {
1526
+ this.performNavigation(url)
1527
+ }
1528
+ },
1529
+ performNavigation: function(url){
1282
1530
  this.$store.dispatch('navigateTo', {url: url, backwards: false}).then((response) => {
1283
1531
  // self.asyncTemplate = response;
1284
1532
  })