matestack-ui-vuejs 3.1.0 → 3.2.0.beta1
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/lib/matestack/ui/vue_js/components/async.js +2 -1
- data/lib/matestack/ui/vue_js/components/async.rb +1 -0
- data/lib/matestack/ui/vue_js/components/draggable.js +81 -0
- data/lib/matestack/ui/vue_js/components/draggable.rb +36 -0
- data/lib/matestack/ui/vue_js/components/drop_zone.js +113 -0
- data/lib/matestack/ui/vue_js/components/drop_zone.rb +50 -0
- data/lib/matestack/ui/vue_js/components/isolated.js +28 -3
- data/lib/matestack/ui/vue_js/components/isolated.rb +14 -7
- data/lib/matestack/ui/vue_js/components/onclick.js +5 -1
- data/lib/matestack/ui/vue_js/components/onclick.rb +2 -1
- data/lib/matestack/ui/vue_js/components.rb +8 -0
- data/lib/matestack/ui/vue_js/helper.rb +77 -0
- data/lib/matestack/ui/vue_js/index.js +4 -0
- data/lib/matestack/ui/vue_js/version.rb +1 -1
- data/lib/matestack/ui/vue_js.rb +3 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8af2be522edf8aee60f7b2192c44c4cda54fcd62101ae364a4fd509735e7ac3d
|
4
|
+
data.tar.gz: '08bfcd52eeb5f767a71af68f8587b87527e4b1d7aa2a50f3878168611efb69b8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d64bd745d6225931daac042ff11b223d9ad16d4785fe623e570d50de1edde7f5656677200656779188f5c78977c25dfb2cfbdb015eefb11b3ed5228363b5d308
|
7
|
+
data.tar.gz: 3ae4451d8d7706e4f8ca60a335b73d6342b12b2258d5ba6959ee1e5aee452ad4b2a4d9a9ed133c98f45df3cc8ac0c076876c525caa0a8a9b18e5e00cdaaa0744
|
@@ -58,7 +58,8 @@ const componentDef = {
|
|
58
58
|
},
|
59
59
|
params: {
|
60
60
|
"component_key": self.props["component_key"],
|
61
|
-
"component_class": self.props["parent_class"]
|
61
|
+
"component_class": self.props["parent_class"],
|
62
|
+
"public_context": self.props["public_context"]
|
62
63
|
}
|
63
64
|
})
|
64
65
|
.then(function(response){
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import matestackEventHub from '../event_hub'
|
2
|
+
import componentMixin from './mixin'
|
3
|
+
import componentHelpers from './helpers'
|
4
|
+
|
5
|
+
const componentDef = {
|
6
|
+
mixins: [componentMixin],
|
7
|
+
template: componentHelpers.inlineTemplate,
|
8
|
+
data() {
|
9
|
+
return {
|
10
|
+
originalDisplayValue: "",
|
11
|
+
dropPerformInProgress: false
|
12
|
+
};
|
13
|
+
},
|
14
|
+
methods: {
|
15
|
+
onDragStart: function(event){
|
16
|
+
let self = this
|
17
|
+
if(this.props["emit_on_drag_start"]){
|
18
|
+
matestackEventHub.$emit(this.props["emit_on_drag_start"], {
|
19
|
+
draggable_id: this.props["draggable_id"],
|
20
|
+
drag_key: this.props["drag_key"],
|
21
|
+
draggable_element: this.getElement()
|
22
|
+
})
|
23
|
+
}
|
24
|
+
event.dataTransfer.effectAllowed = 'move';
|
25
|
+
|
26
|
+
let draggableData = {
|
27
|
+
draggable_id: this.props["draggable_id"],
|
28
|
+
drag_key: this.props["drag_key"],
|
29
|
+
}
|
30
|
+
|
31
|
+
event.dataTransfer.setData('text/plain', JSON.stringify(draggableData));
|
32
|
+
|
33
|
+
this.originalDisplayValue = this.getElement().style.display
|
34
|
+
|
35
|
+
setTimeout(() => {
|
36
|
+
// if not wrapped in timeout, the dragged element would be hidden as well
|
37
|
+
// we only want the source element to hidden
|
38
|
+
// credits: https://www.javascripttutorial.net/web-apis/javascript-drag-and-drop/
|
39
|
+
self.getElement().style.display = "none"
|
40
|
+
}, 0);
|
41
|
+
},
|
42
|
+
onDragEnd: function(event){
|
43
|
+
let self = this
|
44
|
+
if(this.props["emit_on_drag_end"]){
|
45
|
+
matestackEventHub.$emit(this.props["emit_on_drag_end"], {
|
46
|
+
draggable_id: this.props["draggable_id"],
|
47
|
+
drag_key: this.props["drag_key"],
|
48
|
+
draggable_element: this.getElement()
|
49
|
+
})
|
50
|
+
}
|
51
|
+
this.getElement().style.display = this.originalDisplayValue
|
52
|
+
if(this.dropPerformInProgress){
|
53
|
+
this.getElement().style.opacity = 0.1
|
54
|
+
this.getElement().draggable = false
|
55
|
+
this.getElement().disabled = true
|
56
|
+
}else{
|
57
|
+
this.getElement().style.opacity = 1
|
58
|
+
}
|
59
|
+
},
|
60
|
+
setDropPerformInProgress: function(event){
|
61
|
+
if(event.draggableId == this.props["draggable_id"]){
|
62
|
+
this.dropPerformInProgress = true
|
63
|
+
}
|
64
|
+
},
|
65
|
+
unsetDropPerformInProgress: function(event){
|
66
|
+
if(event.draggableId == this.props["draggable_id"]){
|
67
|
+
this.dropPerformInProgress = false
|
68
|
+
}
|
69
|
+
}
|
70
|
+
},
|
71
|
+
mounted(){
|
72
|
+
matestackEventHub.$on(this.props["drag_key"]+"_drop_perform_in_progress", this.setDropPerformInProgress)
|
73
|
+
matestackEventHub.$on(this.props["drag_key"]+"_drop_perform_done", this.unsetDropPerformInProgress)
|
74
|
+
},
|
75
|
+
beforeUnmount(){
|
76
|
+
matestackEventHub.$off(this.props["drag_key"]+"_drop_perform_in_progress", this.setDropPerformInProgress)
|
77
|
+
matestackEventHub.$off(this.props["drag_key"]+"_drop_perform_done", this.unsetDropPerformInProgress)
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
export default componentDef
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Matestack
|
2
|
+
module Ui
|
3
|
+
module VueJs
|
4
|
+
module Components
|
5
|
+
class Draggable < Matestack::Ui::VueJs::Vue
|
6
|
+
|
7
|
+
vue_name "matestack-ui-core-draggable"
|
8
|
+
|
9
|
+
required :draggable_id
|
10
|
+
required :drag_key
|
11
|
+
|
12
|
+
def response
|
13
|
+
div options.merge({
|
14
|
+
":draggable": "true",
|
15
|
+
"@dragstart": "vc.onDragStart($event)",
|
16
|
+
"@dragend": "vc.onDragEnd($event)"}) do
|
17
|
+
yield
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def vue_props
|
24
|
+
{}.tap do |conf|
|
25
|
+
conf[:draggable_id] = ctx.draggable_id
|
26
|
+
conf[:drag_key] = ctx.drag_key
|
27
|
+
conf[:emit_on_drag_start] = "#{ctx.drag_key}_drag_start" if ctx.drag_key
|
28
|
+
conf[:emit_on_drag_end] = "#{ctx.drag_key}_drag_end" if ctx.drag_key
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import axios from "axios";
|
2
|
+
|
3
|
+
import matestackEventHub from '../event_hub'
|
4
|
+
import componentMixin from './mixin'
|
5
|
+
import componentHelpers from './helpers'
|
6
|
+
|
7
|
+
const componentDef = {
|
8
|
+
mixins: [componentMixin],
|
9
|
+
template: componentHelpers.inlineTemplate,
|
10
|
+
data() {
|
11
|
+
return {
|
12
|
+
highlighted: false,
|
13
|
+
hovered: false,
|
14
|
+
};
|
15
|
+
},
|
16
|
+
methods: {
|
17
|
+
highlight: function(eventData){
|
18
|
+
if(eventData["drag_key"] == this.props["drag_key"]){
|
19
|
+
this.highlighted = true
|
20
|
+
}
|
21
|
+
},
|
22
|
+
disableHighlight: function(eventData){
|
23
|
+
if(eventData["drag_key"] == this.props["drag_key"]){
|
24
|
+
this.highlighted = false
|
25
|
+
}
|
26
|
+
},
|
27
|
+
getHighlightClass: function(){
|
28
|
+
return this.props["highlight_class"]
|
29
|
+
},
|
30
|
+
getHoveredClass: function(){
|
31
|
+
return this.props["hover_class"]
|
32
|
+
},
|
33
|
+
onDrop: function(event) {
|
34
|
+
let draggableData = JSON.parse(event.dataTransfer.getData('text/plain'))
|
35
|
+
|
36
|
+
if(draggableData["drag_key"] == this.props["drag_key"]){
|
37
|
+
this.perform(draggableData)
|
38
|
+
}
|
39
|
+
|
40
|
+
this.hovered = false
|
41
|
+
this.highlighted = false
|
42
|
+
|
43
|
+
if (event.preventDefault) {
|
44
|
+
event.preventDefault()
|
45
|
+
}
|
46
|
+
return false
|
47
|
+
},
|
48
|
+
onDragEnter: function(event) {
|
49
|
+
if (event.preventDefault) {
|
50
|
+
event.preventDefault()
|
51
|
+
}
|
52
|
+
|
53
|
+
this.hovered = true
|
54
|
+
return false
|
55
|
+
},
|
56
|
+
onDragLeave: function(event) {
|
57
|
+
this.hovered = false
|
58
|
+
},
|
59
|
+
onDragOver: function(event) {
|
60
|
+
if (event.preventDefault) {
|
61
|
+
event.preventDefault()
|
62
|
+
}
|
63
|
+
this.hovered = true
|
64
|
+
return false
|
65
|
+
},
|
66
|
+
perform: function(draggableData){
|
67
|
+
let self = this
|
68
|
+
let data = this.props["data"]
|
69
|
+
data["draggable_id"] = draggableData["draggable_id"]
|
70
|
+
|
71
|
+
matestackEventHub.$emit(self.props["drag_key"]+"_drop_perform_in_progress", { draggableId: data["draggable_id"] });
|
72
|
+
axios({
|
73
|
+
method: this.props["method"],
|
74
|
+
url: this.props["path"],
|
75
|
+
data: data,
|
76
|
+
headers: {
|
77
|
+
'X-CSRF-Token': document.getElementsByName("csrf-token")[0].getAttribute('content')
|
78
|
+
}
|
79
|
+
}
|
80
|
+
)
|
81
|
+
.then(function(response){
|
82
|
+
if (self.props["success"] != undefined && self.props["success"]["emit"] != undefined) {
|
83
|
+
matestackEventHub.$emit(self.props["success"]["emit"], response.data);
|
84
|
+
}
|
85
|
+
matestackEventHub.$emit(self.props["drag_key"]+"_drop_perform_done", { draggableId: data["draggable_id"] });
|
86
|
+
})
|
87
|
+
.catch(function(error){
|
88
|
+
if (self.props["failure"] != undefined && self.props["failure"]["emit"] != undefined) {
|
89
|
+
matestackEventHub.$emit(self.props["failure"]["emit"], error.response.data);
|
90
|
+
}
|
91
|
+
matestackEventHub.$emit(self.props["drag_key"]+"_drop_perform_done", { draggableId: data["draggable_id"] });
|
92
|
+
})
|
93
|
+
}
|
94
|
+
},
|
95
|
+
mounted(){
|
96
|
+
if(this.props["highlight_on"]){
|
97
|
+
matestackEventHub.$on(this.props["highlight_on"], this.highlight)
|
98
|
+
}
|
99
|
+
if(this.props["disable_highlight_on"]){
|
100
|
+
matestackEventHub.$on(this.props["disable_highlight_on"], this.disableHighlight)
|
101
|
+
}
|
102
|
+
},
|
103
|
+
beforeUnmount(){
|
104
|
+
if(this.props["highlight_on"]){
|
105
|
+
matestackEventHub.$off(this.props["highlight_on"], this.highlight)
|
106
|
+
}
|
107
|
+
if(this.props["disable_highlight_on"]){
|
108
|
+
matestackEventHub.$off(this.props["disable_highlight_on"], this.disableHighlight)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
export default componentDef
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Matestack
|
2
|
+
module Ui
|
3
|
+
module VueJs
|
4
|
+
module Components
|
5
|
+
class DropZone < Matestack::Ui::VueJs::Vue
|
6
|
+
|
7
|
+
vue_name "matestack-ui-core-drop-zone"
|
8
|
+
|
9
|
+
required :path, :drag_key
|
10
|
+
optional :success, :failure, :data, :emit
|
11
|
+
optional :highlight_class, :hover_class
|
12
|
+
|
13
|
+
def response
|
14
|
+
div options.merge({
|
15
|
+
"@drop": "vc.onDrop($event)",
|
16
|
+
"@dragenter": "vc.onDragEnter($event)",
|
17
|
+
"@dragover": "vc.onDragOver($event)",
|
18
|
+
"@dragleave": "vc.onDragLeave($event)",
|
19
|
+
":class": "[vc.highlighted ? vc.getHighlightClass() : '', vc.hovered ? vc.getHoveredClass() : '']"}) do
|
20
|
+
yield
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def vue_props
|
27
|
+
{}.tap do |conf|
|
28
|
+
conf[:path] = ctx.path
|
29
|
+
conf[:method] = drop_method
|
30
|
+
conf[:success] = ctx.success
|
31
|
+
conf[:failure] = ctx.failure
|
32
|
+
conf[:data] = ctx.data
|
33
|
+
conf[:emit] = ctx.emit
|
34
|
+
conf[:drag_key] = ctx.drag_key
|
35
|
+
conf[:highlight_on] = "#{ctx.drag_key}_drag_start" if ctx.highlight_class
|
36
|
+
conf[:disable_highlight_on] = "#{ctx.drag_key}_drag_end" if ctx.highlight_class
|
37
|
+
conf[:highlight_class] = ctx.highlight_class
|
38
|
+
conf[:hover_class] = ctx.hover_class
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def drop_method
|
43
|
+
@drop_method ||= options.delete(:method)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -11,12 +11,23 @@ const componentDef = {
|
|
11
11
|
return {
|
12
12
|
isolatedTemplate: null,
|
13
13
|
loading: false,
|
14
|
-
loadingError: false
|
14
|
+
loadingError: false,
|
15
|
+
hideCurrentContent: false
|
15
16
|
}
|
16
17
|
},
|
17
18
|
methods: {
|
18
|
-
|
19
|
+
replace: function(payload){
|
20
|
+
this.hideCurrentContent = true
|
21
|
+
this.rerender(payload)
|
22
|
+
},
|
23
|
+
rerender: function(payload){
|
19
24
|
var self = this;
|
25
|
+
if(self.props["public_context"] == undefined && payload != undefined && payload["public_context"] != undefined){
|
26
|
+
self.props["public_context"] = {}
|
27
|
+
}
|
28
|
+
if(payload != undefined && payload["public_context"] != undefined){
|
29
|
+
self.props["public_context"] = payload["public_context"]
|
30
|
+
}
|
20
31
|
self.loading = true;
|
21
32
|
self.loadingError = false;
|
22
33
|
if(self.props["rerender_delay"] != undefined){
|
@@ -39,13 +50,14 @@ const componentDef = {
|
|
39
50
|
},
|
40
51
|
params: {
|
41
52
|
"component_class": self.props["component_class"],
|
42
|
-
"
|
53
|
+
"public_context": self.props["public_context"]
|
43
54
|
}
|
44
55
|
})
|
45
56
|
.then(function(response){
|
46
57
|
self.loading = false;
|
47
58
|
self.loadingStart = false;
|
48
59
|
self.loadingEnd = true;
|
60
|
+
self.hideCurrentContent = false;
|
49
61
|
self.isolatedTemplate = response['data'];
|
50
62
|
})
|
51
63
|
.catch(function(error){
|
@@ -67,9 +79,17 @@ const componentDef = {
|
|
67
79
|
beforeUnmount: function() {
|
68
80
|
const self = this
|
69
81
|
if(this.props["rerender_on"] != undefined){
|
82
|
+
var rerender_events = this.props["rerender_on"].split(",")
|
83
|
+
rerender_events.forEach(rerender_event => matestackEventHub.$off(rerender_event.trim(), self.rerender));
|
84
|
+
}
|
85
|
+
if(this.props["init_on"] != undefined){
|
70
86
|
var rerender_events = this.props["rerender_on"].split(",")
|
71
87
|
rerender_events.forEach(rerender_event => matestackEventHub.$off(rerender_event.trim(), self.renderIsolatedContent));
|
72
88
|
}
|
89
|
+
if(this.props["replace_on"] != undefined){
|
90
|
+
var replace_events = this.props["replace_on"].split(",")
|
91
|
+
replace_events.forEach(replace_event => matestackEventHub.$off(replace_event.trim(), self.replace));
|
92
|
+
}
|
73
93
|
},
|
74
94
|
mounted: function (){
|
75
95
|
const self = this
|
@@ -99,6 +119,11 @@ const componentDef = {
|
|
99
119
|
rerender_events.forEach(rerender_event => matestackEventHub.$on(rerender_event.trim(), self.rerender));
|
100
120
|
}
|
101
121
|
|
122
|
+
if(this.props["replace_on"] != undefined){
|
123
|
+
var replace_events = this.props["replace_on"].split(",")
|
124
|
+
replace_events.forEach(replace_event => matestackEventHub.$on(replace_event.trim(), self.replace));
|
125
|
+
}
|
126
|
+
|
102
127
|
}
|
103
128
|
}
|
104
129
|
|
@@ -5,11 +5,11 @@ module Matestack
|
|
5
5
|
class Isolated < Matestack::Ui::VueJs::Vue
|
6
6
|
vue_name 'matestack-ui-core-isolate'
|
7
7
|
|
8
|
-
optional :defer, :init_on, :public_options, :rerender_on, :rerender_delay
|
8
|
+
optional :defer, :init_on, :public_options, :public_context, :rerender_on, :rerender_delay, :replace_on
|
9
9
|
|
10
10
|
def initialize(html_tag = nil, text = nil, options = {}, &block)
|
11
11
|
extract_options(text, options)
|
12
|
-
|
12
|
+
only_public_context!
|
13
13
|
isolated_parent = Matestack::Ui::Core::Context.isolated_parent
|
14
14
|
Matestack::Ui::Core::Context.isolated_parent = self
|
15
15
|
super(html_tag, text, options, &block)
|
@@ -37,13 +37,13 @@ module Matestack
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
unless ctx.defer || ctx.init_on
|
40
|
-
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate == null', 'v-bind:class': '{ loading: vc.loading === true }' do
|
40
|
+
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate == null', 'v-bind:class': '{ loading: vc.loading === true }', 'v-show': '!vc.hideCurrentContent' do
|
41
41
|
div class: 'matestack-isolated-component-root' do
|
42
42
|
yield
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate != null', 'v-bind:class': '{ loading: vc.loading === true }' do
|
46
|
+
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate != null', 'v-bind:class': '{ loading: vc.loading === true }', 'v-show': '!vc.hideCurrentContent' do
|
47
47
|
div class: 'matestack-isolated-component-root' do
|
48
48
|
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.isolatedTemplate', ':vc': 'vc')
|
49
49
|
end
|
@@ -55,24 +55,31 @@ module Matestack
|
|
55
55
|
def vue_props
|
56
56
|
{
|
57
57
|
component_class: self.class.name,
|
58
|
-
|
58
|
+
public_context: ctx.public_context,
|
59
59
|
defer: ctx.defer,
|
60
60
|
rerender_on: ctx.rerender_on,
|
61
|
+
replace_on: ctx.replace_on,
|
61
62
|
rerender_delay: ctx.rerender_delay,
|
62
63
|
init_on: ctx.init_on,
|
63
64
|
}
|
64
65
|
end
|
65
66
|
|
67
|
+
# will be depracted in the future, just here in order to not have a breaking change
|
68
|
+
# public_context is the new way to access the context within an isolated component
|
66
69
|
def public_options
|
67
70
|
ctx.public_options || {}
|
68
71
|
end
|
69
72
|
|
73
|
+
def public_context
|
74
|
+
@public_context ||= OpenStruct.new(ctx.public_context || {})
|
75
|
+
end
|
76
|
+
|
70
77
|
def authorized?
|
71
78
|
raise "'authorized?' needs to be implemented by '#{self.class}'"
|
72
79
|
end
|
73
80
|
|
74
|
-
def
|
75
|
-
if self.options.except(:defer, :init_on, :public_options, :rerender_on, :rerender_delay).keys.any?
|
81
|
+
def only_public_context!
|
82
|
+
if self.options.except(:defer, :init_on, :public_options, :public_context, :rerender_on, :rerender_delay, :replace_on).keys.any?
|
76
83
|
error_message = "isolated components can only take params in a public_options hash, which will be exposed to the client side in order to perform an async request with these params."
|
77
84
|
error_message << " Check your usages of '#{self.class}' components"
|
78
85
|
raise error_message
|
@@ -10,7 +10,11 @@ const componentDef = {
|
|
10
10
|
},
|
11
11
|
methods: {
|
12
12
|
perform: function(){
|
13
|
-
|
13
|
+
if(this.props["public_context"]){
|
14
|
+
matestackEventHub.$emit(this.props["emit"], { public_context: this.props["public_context"] })
|
15
|
+
}else{
|
16
|
+
matestackEventHub.$emit(this.props["emit"], this.props["data"])
|
17
|
+
}
|
14
18
|
}
|
15
19
|
}
|
16
20
|
}
|
@@ -5,7 +5,7 @@ module Matestack
|
|
5
5
|
class Onclick < Matestack::Ui::VueJs::Vue
|
6
6
|
vue_name 'matestack-ui-core-onclick'
|
7
7
|
|
8
|
-
optional :emit, :data
|
8
|
+
optional :emit, :data, :public_context
|
9
9
|
|
10
10
|
def response
|
11
11
|
a onclick_attributes do
|
@@ -27,6 +27,7 @@ module Matestack
|
|
27
27
|
{
|
28
28
|
emit: ctx.emit,
|
29
29
|
data: ctx.data,
|
30
|
+
public_context: ctx.public_context,
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
@@ -35,6 +35,14 @@ module Matestack
|
|
35
35
|
Matestack::Ui::VueJs::Components::Cable.(text, options, &block)
|
36
36
|
end
|
37
37
|
|
38
|
+
def draggable(text=nil, options=nil, &block)
|
39
|
+
Matestack::Ui::VueJs::Components::Draggable.(text, options, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def drop_zone(text=nil, options=nil, &block)
|
43
|
+
Matestack::Ui::VueJs::Components::DropZone.(text, options, &block)
|
44
|
+
end
|
45
|
+
|
38
46
|
def matestack_form(text=nil, options=nil, &block)
|
39
47
|
Matestack::Ui::VueJs::Components::Form::Form.(text, options, &block)
|
40
48
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# overwriting core helper in order to extend request differentiation
|
2
|
+
|
3
|
+
module Matestack
|
4
|
+
module Ui
|
5
|
+
module Core
|
6
|
+
module Helper
|
7
|
+
|
8
|
+
def render(*args)
|
9
|
+
setup_context
|
10
|
+
if args.first.is_a?(Class) && args.first.ancestors.include?(Base)
|
11
|
+
raise 'expected a hash as second argument' unless args.second.is_a?(Hash) || args.second.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
controller_layout = self.class.send(:_layout)
|
15
|
+
rescue
|
16
|
+
controller_layout = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
options = args.second || {}
|
20
|
+
layout = options.delete(:matestack_layout) || self.class.matestack_layout
|
21
|
+
page = args.first
|
22
|
+
|
23
|
+
if controller_layout == false
|
24
|
+
root_layout = layout ? layout.layout : false
|
25
|
+
else
|
26
|
+
# when using the turbo-rails gem, controller_layout is a Proc
|
27
|
+
# https://github.com/hotwired/turbo-rails/blob/v1.0.1/app/controllers/turbo/frames/frame_request.rb#L16
|
28
|
+
# and not nil or a string indicating which layout to be used like before
|
29
|
+
if controller_layout.nil? || controller_layout.is_a?(Proc)
|
30
|
+
root_layout = "application"
|
31
|
+
else
|
32
|
+
root_layout = controller_layout
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if layout && params[:only_page].nil? && params[:component_key].nil? && params[:component_class].nil?
|
37
|
+
render_layout layout, page, options, root_layout
|
38
|
+
else
|
39
|
+
if params[:component_key] && params[:component_class].nil?
|
40
|
+
render_component_within_page layout, page, params[:component_key], options
|
41
|
+
elsif params[:component_class]
|
42
|
+
if params[:component_key]
|
43
|
+
render_component_within_isolated_component(
|
44
|
+
params[:component_class].constantize,
|
45
|
+
params[:component_key],
|
46
|
+
public_context: JSON.parse(params[:public_context] || '{}')
|
47
|
+
)
|
48
|
+
else
|
49
|
+
render html: params[:component_class].constantize.(public_context: JSON.parse(params[:public_context] || '{}'))
|
50
|
+
end
|
51
|
+
else
|
52
|
+
if params[:only_page]
|
53
|
+
render_page page, options, false
|
54
|
+
else
|
55
|
+
render_page page, options, root_layout
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def render_component_within_page(layout, page, component_key, options)
|
65
|
+
layout ? layout.new(options) { page.new(options) } : page.new(options) # create page structure in order to later access registered async components
|
66
|
+
render html: Matestack::Ui::Core::Context.async_components[component_key].render_content.html_safe, layout: false
|
67
|
+
end
|
68
|
+
|
69
|
+
def render_component_within_isolated_component(isolated_component, component_key, options)
|
70
|
+
isolated_component.new(nil, nil, options) # create isolated_component structure in order to later access registered async components
|
71
|
+
render html: Matestack::Ui::Core::Context.async_components[component_key].render_content.html_safe, layout: false
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -21,6 +21,8 @@ import transition from './components/transition'
|
|
21
21
|
import async from './components/async'
|
22
22
|
import action from './components/action'
|
23
23
|
import cable from './components/cable'
|
24
|
+
import draggable from './components/draggable'
|
25
|
+
import dropZone from './components/drop_zone'
|
24
26
|
import isolate from './components/isolated'
|
25
27
|
import form from './components/form/form'
|
26
28
|
import nestedForm from './components/form/nested_form'
|
@@ -49,6 +51,8 @@ const registerComponents = function(appInstance){
|
|
49
51
|
appInstance.component('matestack-ui-core-collection-content', collectionContent)
|
50
52
|
appInstance.component('matestack-ui-core-collection-filter', collectionFilter)
|
51
53
|
appInstance.component('matestack-ui-core-collection-order', collectionOrder)
|
54
|
+
appInstance.component('matestack-ui-core-draggable', draggable)
|
55
|
+
appInstance.component('matestack-ui-core-drop-zone', dropZone)
|
52
56
|
appInstance.component('matestack-ui-core-toggle', toggle)
|
53
57
|
appInstance.component('matestack-ui-core-onclick', onclick)
|
54
58
|
appInstance.component('matestack-ui-core-transition', transition)
|
data/lib/matestack/ui/vue_js.rb
CHANGED
@@ -13,6 +13,7 @@ require "#{vue_js_base_path}/version"
|
|
13
13
|
|
14
14
|
require "#{vue_js_base_path}/vue_attributes"
|
15
15
|
require "#{vue_js_base_path}/vue"
|
16
|
+
require "#{vue_js_base_path}/helper"
|
16
17
|
require "#{vue_js_base_path}/components/app"
|
17
18
|
require "#{vue_js_base_path}/components/page_switch"
|
18
19
|
require "#{vue_js_base_path}/components/toggle"
|
@@ -21,6 +22,8 @@ require "#{vue_js_base_path}/components/transition"
|
|
21
22
|
require "#{vue_js_base_path}/components/async"
|
22
23
|
require "#{vue_js_base_path}/components/action"
|
23
24
|
require "#{vue_js_base_path}/components/cable"
|
25
|
+
require "#{vue_js_base_path}/components/draggable"
|
26
|
+
require "#{vue_js_base_path}/components/drop_zone"
|
24
27
|
require "#{vue_js_base_path}/components/isolated"
|
25
28
|
require "#{vue_js_base_path}/components/form/context"
|
26
29
|
require "#{vue_js_base_path}/components/form/base"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matestack-ui-vuejs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Jabari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matestack-ui-core
|
@@ -76,6 +76,10 @@ files:
|
|
76
76
|
- lib/matestack/ui/vue_js/components/collection/order_toggle_indicator.rb
|
77
77
|
- lib/matestack/ui/vue_js/components/collection/page.rb
|
78
78
|
- lib/matestack/ui/vue_js/components/collection/previous.rb
|
79
|
+
- lib/matestack/ui/vue_js/components/draggable.js
|
80
|
+
- lib/matestack/ui/vue_js/components/draggable.rb
|
81
|
+
- lib/matestack/ui/vue_js/components/drop_zone.js
|
82
|
+
- lib/matestack/ui/vue_js/components/drop_zone.rb
|
79
83
|
- lib/matestack/ui/vue_js/components/form/base.rb
|
80
84
|
- lib/matestack/ui/vue_js/components/form/checkbox.js
|
81
85
|
- lib/matestack/ui/vue_js/components/form/checkbox.rb
|
@@ -115,6 +119,7 @@ files:
|
|
115
119
|
- lib/matestack/ui/vue_js/components/transition.rb
|
116
120
|
- lib/matestack/ui/vue_js/components/transition_handling_mixin.js
|
117
121
|
- lib/matestack/ui/vue_js/event_hub.js
|
122
|
+
- lib/matestack/ui/vue_js/helper.rb
|
118
123
|
- lib/matestack/ui/vue_js/helpers/query_params_helper.js
|
119
124
|
- lib/matestack/ui/vue_js/index.js
|
120
125
|
- lib/matestack/ui/vue_js/initialize.rb
|
@@ -139,9 +144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
144
|
version: '0'
|
140
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
146
|
requirements:
|
142
|
-
- - "
|
147
|
+
- - ">"
|
143
148
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
149
|
+
version: 1.3.1
|
145
150
|
requirements: []
|
146
151
|
rubygems_version: 3.2.15
|
147
152
|
signing_key:
|