@sedoo/unidoo 0.1.16 → 0.1.17
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.
- package/dist/unidoo/unidoo.common.js +7 -2
- package/dist/unidoo/unidoo.common.js.map +1 -1
- package/dist/unidoo/unidoo.umd.js +7 -2
- package/dist/unidoo/unidoo.umd.js.map +1 -1
- package/dist/unidoo/unidoo.umd.min.js +7 -2
- package/dist/unidoo/unidoo.umd.min.js.map +1 -1
- package/package.json +3 -2
- package/src/components/UnidooAlert.vue +101 -37
- package/src/components/UnidooMapGeoFeatures.vue +640 -0
- package/src/plugin.js +214 -176
package/src/plugin.js
CHANGED
|
@@ -1,202 +1,240 @@
|
|
|
1
1
|
// Import vue components
|
|
2
2
|
// import * as components from './components/index'
|
|
3
3
|
// var components = {}
|
|
4
|
+
import vueCustomElement from "vue-custom-element";
|
|
4
5
|
|
|
5
6
|
// install function executed by Vue.use()
|
|
6
7
|
function install(Vue) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
defaultParams(params) {
|
|
32
|
-
plugin.EventBus.$emit("unidoo-alert-params", params)
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
showSuccess(message, closeButtonLabel) {
|
|
36
|
-
if (closeButtonLabel) {
|
|
37
|
-
this.showMessage(message, "success", 4000, 'top', closeButtonLabel)
|
|
38
|
-
} else {
|
|
39
|
-
this.showMessage(message, "success")
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Display the given error message for 8 seconds
|
|
45
|
-
* @param {string} message
|
|
46
|
-
*/
|
|
47
|
-
showError(message, closeButtonLabel) {
|
|
48
|
-
if (closeButtonLabel) {
|
|
49
|
-
this.showMessage(message, "error", 8000, 'top', closeButtonLabel)
|
|
50
|
-
} else {
|
|
51
|
-
this.showMessage(message, "error", 8000)
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* This method return the message from an error object ResponseStatusException or RuntimeException
|
|
57
|
-
* @param {string} prefix e.g. 'An error has occured :'
|
|
58
|
-
* @param {*} error The error object from the catch(function(error)
|
|
59
|
-
* @returns {string} The error message
|
|
60
|
-
*/
|
|
61
|
-
formatError(prefix, error) {
|
|
62
|
-
let message = 'An error has occured'
|
|
63
|
-
if (typeof error === 'object') {
|
|
64
|
-
if (error.response && error.response.data && error.response.data.message) {
|
|
65
|
-
message = prefix + ' ' + error.response.data.message
|
|
66
|
-
} else if (error.message) {
|
|
67
|
-
message = prefix + ' ' + error.message
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return message
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
showMessage(message, type, timeout, position, closeButtonLabel) {
|
|
74
|
-
const params = {}
|
|
75
|
-
if (position) {
|
|
76
|
-
params.position = position
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (timeout) {
|
|
80
|
-
params.timeout = timeout
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (closeButtonLabel) {
|
|
84
|
-
params.closeButtonLabel = closeButtonLabel
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
params.message = message
|
|
88
|
-
params.type = type
|
|
89
|
-
this.show(params)
|
|
90
|
-
},
|
|
8
|
+
if (install.installed) return;
|
|
9
|
+
install.installed = true;
|
|
10
|
+
|
|
11
|
+
Vue.use(vueCustomElement);
|
|
12
|
+
|
|
13
|
+
// For each matching file name...
|
|
14
|
+
requireComponent.keys().forEach((fileName) => {
|
|
15
|
+
// Get the component config
|
|
16
|
+
const componentConfig = requireComponent(fileName);
|
|
17
|
+
// Get the PascalCase version of the component name
|
|
18
|
+
const componentName = fileName
|
|
19
|
+
.split("/")
|
|
20
|
+
.pop()
|
|
21
|
+
.replace(/\.\w+$/, "");
|
|
22
|
+
// components[componentName] = componentConfig.default || componentConfig
|
|
23
|
+
// Globally register the component
|
|
24
|
+
Vue.component(componentName, componentConfig.default || componentConfig);
|
|
25
|
+
// Use Vue.customElement to enable the be able to use the component UnidooMapGeoFeatures as a custom element in WordPress
|
|
26
|
+
if (componentName === "UnidooMapGeoFeatures") {
|
|
27
|
+
const kebabCaseComponentName = "unidoo-map-geo-features";
|
|
28
|
+
Vue.customElement(
|
|
29
|
+
kebabCaseComponentName,
|
|
30
|
+
componentConfig.default || componentConfig
|
|
31
|
+
);
|
|
91
32
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
Vue.prototype.$unidooHeatmap = {
|
|
154
|
-
setDate(date, key) {
|
|
155
|
-
plugin.EventBus.$emit("unidoo-heatmap-set-date", { date: date, key: key })
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
getDate(key) {
|
|
159
|
-
plugin.EventBus.$emit("unidoo-heatmap-get-date", { key: key })
|
|
33
|
+
});
|
|
34
|
+
// Register Global event to show AppMessage, related to AppSnackbar
|
|
35
|
+
// https://medium.com/@panzelva/writing-modals-for-vue-js-callable-from-anywhere-6994d180451
|
|
36
|
+
this.EventBus = new Vue();
|
|
37
|
+
Vue.prototype.$unidooAlert = {
|
|
38
|
+
show(params) {
|
|
39
|
+
plugin.EventBus.$emit("unidoo-alert-show", params);
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
defaultParams(params) {
|
|
43
|
+
plugin.EventBus.$emit("unidoo-alert-params", params);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
showSuccess(message, closeButtonLabel) {
|
|
47
|
+
if (closeButtonLabel) {
|
|
48
|
+
this.showMessage(message, "success", 4000, "top", closeButtonLabel);
|
|
49
|
+
} else {
|
|
50
|
+
this.showMessage(message, "success");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
showWarning(message, closeButtonLabel) {
|
|
55
|
+
if (closeButtonLabel) {
|
|
56
|
+
this.showMessage(message, "warning", 6000, "top", closeButtonLabel);
|
|
57
|
+
} else {
|
|
58
|
+
this.showMessage(message, "warning", 6000);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Display the given error message for 8 seconds
|
|
64
|
+
* @param {string} message
|
|
65
|
+
*/
|
|
66
|
+
showError(message, closeButtonLabel) {
|
|
67
|
+
if (closeButtonLabel) {
|
|
68
|
+
this.showMessage(message, "error", 8000, "top", closeButtonLabel);
|
|
69
|
+
} else {
|
|
70
|
+
this.showMessage(message, "error", 8000);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* This method return the message from an error object ResponseStatusException or RuntimeException
|
|
76
|
+
* @param {string} prefix e.g. 'An error has occured :'
|
|
77
|
+
* @param {*} error The error object from the catch(function(error)
|
|
78
|
+
* @returns {string} The error message
|
|
79
|
+
*/
|
|
80
|
+
formatError(prefix, error) {
|
|
81
|
+
let message = "An error has occured";
|
|
82
|
+
if (typeof error === "object") {
|
|
83
|
+
if (
|
|
84
|
+
error.response &&
|
|
85
|
+
error.response.data &&
|
|
86
|
+
error.response.data.message
|
|
87
|
+
) {
|
|
88
|
+
message = prefix + " " + error.response.data.message;
|
|
89
|
+
} else if (error.message) {
|
|
90
|
+
message = prefix + " " + error.message;
|
|
160
91
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
92
|
+
}
|
|
93
|
+
return message;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
showMessage(message, type, timeout, position, closeButtonLabel) {
|
|
97
|
+
const params = {};
|
|
98
|
+
if (position) {
|
|
99
|
+
params.position = position;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (timeout) {
|
|
103
|
+
params.timeout = timeout;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (closeButtonLabel) {
|
|
107
|
+
params.closeButtonLabel = closeButtonLabel;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
params.message = message;
|
|
111
|
+
params.type = type;
|
|
112
|
+
this.show(params);
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Vue.prototype.$unidooUuid = {
|
|
117
|
+
randomUuidV4() {
|
|
118
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
|
119
|
+
c
|
|
120
|
+
) {
|
|
121
|
+
var r = (Math.random() * 16) | 0;
|
|
122
|
+
var v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
123
|
+
return v.toString(16);
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
Vue.prototype.$unidooConfirmDialog = {
|
|
129
|
+
showWithParams(params) {
|
|
130
|
+
plugin.EventBus.$emit("unidoo-confirm-dialog-show", params);
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
defaultParams(params) {
|
|
134
|
+
plugin.EventBus.$emit("unidoo-confirm-dialog-params", params);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
show(
|
|
138
|
+
callback,
|
|
139
|
+
message,
|
|
140
|
+
title,
|
|
141
|
+
titleClasses,
|
|
142
|
+
width,
|
|
143
|
+
cancelButtonLabel,
|
|
144
|
+
confirmButtonLabel
|
|
145
|
+
) {
|
|
146
|
+
const params = {};
|
|
147
|
+
if (callback) {
|
|
148
|
+
params.callback = callback;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (message) {
|
|
152
|
+
params.message = message;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (title) {
|
|
156
|
+
params.title = title;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (titleClasses) {
|
|
160
|
+
params.titleClasses = titleClasses;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (width) {
|
|
164
|
+
params.width = width;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (cancelButtonLabel) {
|
|
168
|
+
params.cancelButtonLabel = cancelButtonLabel;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (confirmButtonLabel) {
|
|
172
|
+
params.confirmButtonLabel = confirmButtonLabel;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.showWithParams(params);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
Vue.prototype.$unidooCrudTable = {
|
|
180
|
+
show(params) {
|
|
181
|
+
plugin.EventBus.$emit("unidoo-crud-show", params);
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
Vue.prototype.$unidooHeatmap = {
|
|
186
|
+
setDate(date, key) {
|
|
187
|
+
plugin.EventBus.$emit("unidoo-heatmap-set-date", {
|
|
188
|
+
date: date,
|
|
189
|
+
key: key,
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
getDate(key) {
|
|
194
|
+
plugin.EventBus.$emit("unidoo-heatmap-get-date", { key: key });
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
Vue.prototype.$unidooDateSwitcher = {
|
|
199
|
+
update(data, key) {
|
|
200
|
+
plugin.EventBus.$emit("unidoo-dateswitcher-update", {
|
|
201
|
+
data: data,
|
|
202
|
+
key: key,
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
};
|
|
168
206
|
}
|
|
169
207
|
|
|
170
208
|
// Create module definition for Vue.use()
|
|
171
209
|
const plugin = {
|
|
172
|
-
|
|
173
|
-
}
|
|
210
|
+
install,
|
|
211
|
+
};
|
|
174
212
|
|
|
175
213
|
// To auto-install when vue is found
|
|
176
214
|
|
|
177
|
-
let GlobalVue = null
|
|
178
|
-
if (typeof window !==
|
|
179
|
-
|
|
180
|
-
} else if (typeof global !==
|
|
181
|
-
|
|
215
|
+
let GlobalVue = null;
|
|
216
|
+
if (typeof window !== "undefined") {
|
|
217
|
+
GlobalVue = window.Vue;
|
|
218
|
+
} else if (typeof global !== "undefined") {
|
|
219
|
+
GlobalVue = global.Vue;
|
|
182
220
|
}
|
|
183
221
|
if (GlobalVue) {
|
|
184
|
-
|
|
222
|
+
GlobalVue.use(plugin);
|
|
185
223
|
}
|
|
186
224
|
|
|
187
225
|
const requireComponent = require.context(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
)
|
|
226
|
+
// Look for files in the current directory
|
|
227
|
+
"./components",
|
|
228
|
+
// Look in subdirectories
|
|
229
|
+
true,
|
|
230
|
+
// Only include "_base-" prefixed .vue files
|
|
231
|
+
/[\w-]+\.vue$/
|
|
232
|
+
);
|
|
195
233
|
|
|
196
234
|
// Default export is library as a whole, registered via Vue.use()
|
|
197
|
-
export default plugin
|
|
235
|
+
export default plugin;
|
|
198
236
|
|
|
199
237
|
// To allow individual component use, export components
|
|
200
238
|
// each can be registered via Vue.component()
|
|
201
239
|
// console.log({components})
|
|
202
|
-
// export {components}
|
|
240
|
+
// export {components}
|