@mapomodule/uikit 1.0.0-alpha.4 → 1.0.0-alpha.41
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/CHANGELOG.md +749 -0
- package/components/ConfirmDialog.vue +12 -16
- package/components/Detail/Detail.vue +406 -272
- package/components/Detail/DetailLangSwitch.vue +7 -2
- package/components/DropArea.vue +63 -56
- package/components/Form/Form.vue +218 -0
- package/components/Form/FormField.vue +213 -0
- package/components/Form/FormGroup.vue +146 -0
- package/components/Form/FormTabs.vue +188 -0
- package/components/Form/defaults.js +91 -0
- package/components/Form/fields/ColorField.vue +79 -0
- package/components/{fields → Form/fields}/DateField.vue +20 -11
- package/components/Form/fields/EnhancedMediaField.vue +224 -0
- package/components/Form/fields/FileField.vue +125 -0
- package/components/Form/fields/FksField.vue +88 -0
- package/components/Form/fields/MediaField.vue +159 -0
- package/components/Form/fields/MediaM2mField.vue +149 -0
- package/components/Form/fields/Repeater.vue +593 -0
- package/components/Form/fields/SeoPreview.vue +89 -0
- package/components/Form/fields/wygEditor/defaults.js +25 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
- package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
- package/components/LangSwitcher.vue +44 -0
- package/components/List/List.vue +119 -42
- package/components/List/ListActions.vue +60 -21
- package/components/List/ListFilters.vue +166 -114
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +130 -61
- package/components/List/ListTable.vue +292 -80
- package/components/Login.vue +17 -7
- package/components/LogoutButton.vue +43 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +330 -122
- package/components/MediaManager/MediaFolders.vue +169 -116
- package/components/MediaManager/MediaGallery.vue +151 -146
- package/components/MediaManager/MediaManager.vue +117 -159
- package/components/MediaManager/MediaManagerDialog.vue +36 -31
- package/components/MediaManager/MediaPreview.vue +203 -0
- package/components/MediaManager/MediaUploader.vue +55 -43
- package/components/SnackBar.vue +5 -7
- package/components/ThemeToggle.vue +13 -0
- package/components/layout/Sidebar/Sidebar.vue +61 -30
- package/components/layout/Sidebar/SidebarList.vue +19 -15
- package/components/layout/Sidebar/SidebarListItem.vue +122 -38
- package/components/layout/Sidebar/SidebarProfile.vue +42 -0
- package/components/layout/Sidebar/SidebarTitle.vue +45 -0
- package/components/layout/Topbar/Topbar.vue +11 -42
- package/components/layout/routebuilder.js +3 -3
- package/defaults/i18n.js +37 -0
- package/defaults/vuetify.js +34 -0
- package/layouts/default.vue +33 -18
- package/layouts/empty.vue +10 -0
- package/module.js +7 -5
- package/package.json +6 -4
- package/pages/index.vue +19 -18
- package/static/{favicon.ico → mapo/favicon.ico} +0 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
- package/translations/en-US.js +135 -0
- package/translations/it-IT.js +137 -0
- package/components/Detail/DetailField.vue +0 -129
- package/components/Detail/defaults.js +0 -50
- package/components/fields/M2mField.vue +0 -95
- package/components/fields/MediaField.vue +0 -195
- package/components/fields/MediaM2mField.vue +0 -238
- package/components/fields/TinyMce/TinyMce.vue +0 -177
- package/components/fields/TinyMce/defaults.js +0 -55
- package/components/layout/Sidebar/SidebarFooter.vue +0 -75
- package/defaults.js +0 -29
- package/layouts/error.vue +0 -45
|
File without changes
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
export default function (callback) {
|
|
2
2
|
const pluginmanager = window.tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const pluginname = "mapomedia"
|
|
4
|
+
pluginmanager.add(pluginname, function (editor, url) {
|
|
5
|
+
const conf = {
|
|
5
6
|
icon: 'image',
|
|
6
|
-
|
|
7
|
+
tooltip: 'Insert image/video/audio/docs',
|
|
7
8
|
onAction: () => callback().then(html => {
|
|
8
9
|
editor.focus();
|
|
9
10
|
editor.undoManager.transact(() => editor.selection.setContent(html))
|
|
10
11
|
editor.selection.setCursorLocation();
|
|
11
12
|
editor.nodeChanged();
|
|
12
13
|
}).catch(() => null)
|
|
13
|
-
}
|
|
14
|
+
}
|
|
14
15
|
editor.addCommand('mceMapoMedia', () => callback().then(html => {
|
|
15
16
|
editor.focus();
|
|
16
17
|
editor.undoManager.transact(() => editor.selection.setContent(html))
|
|
17
18
|
editor.selection.setCursorLocation();
|
|
18
19
|
editor.nodeChanged();
|
|
19
20
|
}).catch(() => null))
|
|
20
|
-
editor.ui.registry.addButton(
|
|
21
|
-
editor.ui.registry.addMenuItem(...conf);
|
|
21
|
+
editor.ui.registry.addButton(pluginname, conf);
|
|
22
|
+
editor.ui.registry.addMenuItem(pluginname, { text: "Mapo Media...", ...conf });
|
|
22
23
|
return {
|
|
23
24
|
getMetadata: function () {
|
|
24
25
|
return {
|
|
File without changes
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="mapo-wyg-editor">
|
|
3
|
+
<media-manager-dialog ref="mediaManager"></media-manager-dialog>
|
|
4
|
+
<span v-if="label" class="v-label" :class="{'error--text': hasErrors, 'text--secondary': !hasErrors}">{{ label }}:</span>
|
|
5
|
+
<div ref="editorNode">
|
|
6
|
+
<v-skeleton-loader
|
|
7
|
+
type="table-heading, list-item-two-line, list-item-avatar-two-line, list-item-three-lineimage, table-tfoot"
|
|
8
|
+
></v-skeleton-loader>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="mt-2">
|
|
11
|
+
<v-messages :value="errorMessages" color="error"></v-messages>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss">
|
|
17
|
+
.tox-notifications-container,
|
|
18
|
+
.tox-statusbar__branding {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
.v-label.error--text{
|
|
22
|
+
animation: v-shake 0.6s cubic-bezier(0.25, 0.8, 0.5, 1);
|
|
23
|
+
}
|
|
24
|
+
.tox-tinymce-aux {
|
|
25
|
+
z-index: 200 !important;
|
|
26
|
+
}
|
|
27
|
+
.mapo-field--has-errors{
|
|
28
|
+
.tox.tox-tinymce{
|
|
29
|
+
border: solid var(--v-error-base) 2px;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import initMapoMedia from "./utils/mapomedia.plugin.js";
|
|
36
|
+
import injectScript from "./utils/script.injector.js";
|
|
37
|
+
import defaults from "./defaults.js";
|
|
38
|
+
import validEvents from "./utils/events.js";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This component wraps a [wygEditor](https://www.tiny.cloud/) instance. With the use of the v-model you can use this component to edit any content you like.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
name: "wygEditor",
|
|
46
|
+
props: {
|
|
47
|
+
// V-model property. Is the content that will populate the wygEditor instance.
|
|
48
|
+
value: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "",
|
|
51
|
+
},
|
|
52
|
+
// This is the main configuration of wygEditor. If setted will be merged with this component defaults.
|
|
53
|
+
conf: {
|
|
54
|
+
type: Object,
|
|
55
|
+
default: () => ({}),
|
|
56
|
+
},
|
|
57
|
+
// This label will be shown at the top of the editor.
|
|
58
|
+
label: String,
|
|
59
|
+
// This is an array of validation errors that will be displayed under the editor.
|
|
60
|
+
errorMessages: Array,
|
|
61
|
+
// This set the component status to readonly, stopping the user interaction.
|
|
62
|
+
readonly: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false,
|
|
65
|
+
},
|
|
66
|
+
// Use this prop to bind events. If set to true the component will emit every [wygEditor Event](https://www.tiny.cloud/docs/advanced/events/).
|
|
67
|
+
bindevents: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
data() {
|
|
74
|
+
return {
|
|
75
|
+
editorInstance: null,
|
|
76
|
+
editorContent: this.value,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
computed: {
|
|
81
|
+
hasErrors () { return this.errorMessages && this.errorMessages.length },
|
|
82
|
+
editor: {
|
|
83
|
+
cache: false,
|
|
84
|
+
get() {
|
|
85
|
+
return this.editorInstance;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
defaultConfiguration(){
|
|
89
|
+
const { base } = this.$router.options;
|
|
90
|
+
const { isDark } = this.$vuetify.theme;
|
|
91
|
+
return defaults({ base, isDark })
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
mounted() {
|
|
96
|
+
injectScript().then(this.initEditor);
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
methods: {
|
|
100
|
+
initEditor() {
|
|
101
|
+
initMapoMedia(this.insertMediaCallback);
|
|
102
|
+
window.tinymce.init(
|
|
103
|
+
Object.assign(this.defaultConfiguration, this.conf, {
|
|
104
|
+
target: this.$refs.editorNode,
|
|
105
|
+
readonly: this.readonly,
|
|
106
|
+
setup: (ctx) => this.setupEditor(ctx),
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
window.document.addEventListener('click', this.closeModal);
|
|
110
|
+
},
|
|
111
|
+
setupEditor(editor) {
|
|
112
|
+
this.editorInstance = editor;
|
|
113
|
+
editor.on("init", () => {
|
|
114
|
+
if (this.value){
|
|
115
|
+
editor.setContent(this.value);
|
|
116
|
+
this.emitContent(editor);
|
|
117
|
+
} else {
|
|
118
|
+
editor.setContent("");
|
|
119
|
+
}
|
|
120
|
+
editor.on("change input undo redo keyup", () =>
|
|
121
|
+
this.emitContent(editor)
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
this.bindEvents(editor);
|
|
125
|
+
},
|
|
126
|
+
emitContent(editor) {
|
|
127
|
+
this.editorContent = editor.getContent();
|
|
128
|
+
// Fired when the v-model changes
|
|
129
|
+
//@arg Emits the content of the editor
|
|
130
|
+
this.$emit("input", this.editorContent);
|
|
131
|
+
},
|
|
132
|
+
bindEvents(editor) {
|
|
133
|
+
if (this.bindevents) {
|
|
134
|
+
validEvents.forEach((eventName) => {
|
|
135
|
+
// This is a dynamic event emitter. If you activate the bindevents prop, you will be able to listen to every [wygEditor Event](https://www.tiny.cloud/docs/advanced/events/).
|
|
136
|
+
editor.on(eventName, (event) => this.$emit(eventName, event));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
closeModal(event){
|
|
141
|
+
if (event.target.classList.contains("tox-dialog-wrap__backdrop"))
|
|
142
|
+
this.editor.windowManager.close();
|
|
143
|
+
},
|
|
144
|
+
insertMediaCallback: async function () {
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
this.$refs.mediaManager.open()
|
|
147
|
+
.then((result) => {
|
|
148
|
+
if (result) {
|
|
149
|
+
let html;
|
|
150
|
+
switch (result.mime_type && result.mime_type.split("/")[0]) {
|
|
151
|
+
case "image":
|
|
152
|
+
html = `<img width="300px" src="${result.file}" alt="${result.alt_text}">`;
|
|
153
|
+
break;
|
|
154
|
+
case "video":
|
|
155
|
+
html = `<video controls><source src="${result.file}" type="${result.mime_type}"></video>`;
|
|
156
|
+
break;
|
|
157
|
+
case "audio":
|
|
158
|
+
html = `<audio controls><source src="${result.file}" type="${result.mime_type}"></audio>`;
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
html = `<a href="${result.file}" target="_blank">${result.file}</a>`;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
resolve(html);
|
|
165
|
+
} else {
|
|
166
|
+
reject("No image selected");
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
.catch((error) => reject(error));
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
destroyEditor(){
|
|
173
|
+
window?.document?.removeEventListener('click', this.closeModal);
|
|
174
|
+
window?.tinymce?.remove(this.editor);
|
|
175
|
+
},
|
|
176
|
+
reloadEditor(){
|
|
177
|
+
this.destroyEditor();
|
|
178
|
+
this.initEditor();
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
beforeDestroy() {
|
|
182
|
+
this.destroyEditor();
|
|
183
|
+
},
|
|
184
|
+
watch: {
|
|
185
|
+
value(val) {
|
|
186
|
+
if (this.editor && this.editor.initialized && val !== this.editorContent) {
|
|
187
|
+
this.editorContent = val
|
|
188
|
+
this.editor.setContent(val || "");
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
readonly(val) {
|
|
192
|
+
if (this.editor && this.editor.initialized) {
|
|
193
|
+
this.editor.setMode(val ? "readonly" : "design");
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
'$vuetify.theme.isDark'(){ this.reloadEditor(); }
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<docs>
|
|
202
|
+
|
|
203
|
+
### Defaults
|
|
204
|
+
|
|
205
|
+
This is the default [wygEditor configuration](https://www.tiny.cloud/docs/configure/).
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
{
|
|
209
|
+
plugins: 'mapomedia preview paste importcss searchreplace autolink directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount textpattern noneditable help charmap quickbars emoticons',
|
|
210
|
+
menubar: 'file edit view insert format tools table help',
|
|
211
|
+
menu: { insert: { title: 'Insert', items: 'link mapomedia media template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor | insertdatetime' } },
|
|
212
|
+
toolbar: 'undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview | mapomedia media template link anchor codesample | ltr rtl',
|
|
213
|
+
toolbar_sticky: true,
|
|
214
|
+
image_advtab: true,
|
|
215
|
+
importcss_append: true,
|
|
216
|
+
template_cdate_format: '[Date Created (CDATE): %m/%d/%Y : %H:%M:%S]',
|
|
217
|
+
template_mdate_format: '[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S]',
|
|
218
|
+
height: 400,
|
|
219
|
+
image_caption: true,
|
|
220
|
+
quickbars_insert_toolbar: 'mapomedia quicktable',
|
|
221
|
+
quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote mapomedia quicktable',
|
|
222
|
+
noneditable_noneditable_class: 'mceNonEditable',
|
|
223
|
+
toolbar_mode: 'sliding',
|
|
224
|
+
contextmenu: 'link mapomedia table',
|
|
225
|
+
skin: useDarkMode ? 'oxide-dark' : 'oxide',
|
|
226
|
+
content_css: useDarkMode ? 'dark' : 'default',
|
|
227
|
+
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
<br><br>
|
|
231
|
+
|
|
232
|
+
## Live Demo
|
|
233
|
+
|
|
234
|
+
<br>
|
|
235
|
+
|
|
236
|
+
::: warning LIVE DEMO 🎉🎉🎉
|
|
237
|
+
This is an interactive example. You can play with it but remember that all http features are disabled since there is no backend server.
|
|
238
|
+
:::
|
|
239
|
+
|
|
240
|
+
::: demo
|
|
241
|
+
<template>
|
|
242
|
+
<v-app>
|
|
243
|
+
<wygEditor v-model="tinyInput" :readonly="readonly" />
|
|
244
|
+
<v-btn dark class="mb-2" @click.native="readonly = !readonly">
|
|
245
|
+
{{ readonly ? "Enable" : "Disable" }} editor
|
|
246
|
+
</v-btn>
|
|
247
|
+
</v-app>
|
|
248
|
+
</template>
|
|
249
|
+
|
|
250
|
+
<script>
|
|
251
|
+
export default {
|
|
252
|
+
data() {
|
|
253
|
+
return {
|
|
254
|
+
readonly: false,
|
|
255
|
+
tinyInput: `
|
|
256
|
+
<p style="text-align: center;"><span style="color: #bdc3c7;">→ This is a full-featured editor demo. Please explore!
|
|
257
|
+
←</span></p>
|
|
258
|
+
<p style="text-align: center;"> </p>
|
|
259
|
+
<h2 style="text-align: center;">TinyMCE is the world's most customizable, and flexible, rich text editor.</h2>
|
|
260
|
+
<p style="text-align: center;"><strong> <span style="font-size: 14pt;"> <span style="color: #7e8c8d; font-weight: 600;">
|
|
261
|
+
A featherweight download, TinyMCE can handle any challenge you throw at it. </span> </span> </strong>
|
|
262
|
+
</p>
|
|
263
|
+
<p style="text-align: center;"> </p>
|
|
264
|
+
<table style="border-collapse: collapse; width: 85%; margin-left: auto; margin-right: auto; border: 0;">
|
|
265
|
+
<tbody>
|
|
266
|
+
<tr>
|
|
267
|
+
<td style="width: 25%; text-align: center; padding: 7px;"><span style="color: #95a5a6;">🛠 50+
|
|
268
|
+
Plugins</span></td>
|
|
269
|
+
<td style="width: 25%; text-align: center; padding: 7px;"><span style="color: #95a5a6;">💡 Premium
|
|
270
|
+
Support</span></td>
|
|
271
|
+
<td style="width: 25%; text-align: center; padding: 7px;"><span style="color: #95a5a6;">🖍 Custom
|
|
272
|
+
Skins</span></td>
|
|
273
|
+
<td style="width: 25%; text-align: center; padding: 7px;"><span style="color: #95a5a6;">⚙ Full API
|
|
274
|
+
Access</span></td>
|
|
275
|
+
</tr>
|
|
276
|
+
</tbody>
|
|
277
|
+
</table>
|
|
278
|
+
`,
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
</script>
|
|
283
|
+
:::
|
|
284
|
+
|
|
285
|
+
</docs>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-select
|
|
3
|
+
:items="$i18n.locales"
|
|
4
|
+
:value="$i18n.locale"
|
|
5
|
+
@input="$i18n.setLocale($event)"
|
|
6
|
+
dense
|
|
7
|
+
flat
|
|
8
|
+
hide-details
|
|
9
|
+
solo
|
|
10
|
+
background-color="transparent"
|
|
11
|
+
item-value="code"
|
|
12
|
+
>
|
|
13
|
+
<template v-slot:selection="{ item }">
|
|
14
|
+
{{ item.iso ? getFlag(item.iso) : item.name }}
|
|
15
|
+
</template>
|
|
16
|
+
<template v-slot:item="{ item, on, attrs }">
|
|
17
|
+
<v-list-item v-on="on" v-bind="attrs">
|
|
18
|
+
<v-list-item-icon class="mr-2">
|
|
19
|
+
{{ item.iso ? getFlag(item.iso) : item.name }}
|
|
20
|
+
</v-list-item-icon>
|
|
21
|
+
<v-list-item-title>
|
|
22
|
+
{{ item.name }}
|
|
23
|
+
</v-list-item-title>
|
|
24
|
+
</v-list-item>
|
|
25
|
+
</template>
|
|
26
|
+
</v-select>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
export default {
|
|
31
|
+
name: "LangSwitcher",
|
|
32
|
+
methods: {
|
|
33
|
+
getFlag(isoCode) {
|
|
34
|
+
const codePoints = isoCode
|
|
35
|
+
.split("-")
|
|
36
|
+
.slice(-1)[0]
|
|
37
|
+
.toUpperCase()
|
|
38
|
+
.split("")
|
|
39
|
+
.map((char) => 127397 + char.charCodeAt());
|
|
40
|
+
return String.fromCodePoint(...codePoints);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
</script>
|
package/components/List/List.vue
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
<ListHead v-bind="$attrs" />
|
|
4
4
|
|
|
5
5
|
<div>
|
|
6
|
-
<v-row class="mb-
|
|
6
|
+
<v-row class="mb-1">
|
|
7
7
|
<v-col cols="12" md="4">
|
|
8
8
|
<ListActions
|
|
9
9
|
v-bind="$attrs"
|
|
10
10
|
:crud="crud"
|
|
11
|
-
:selection="selection"
|
|
11
|
+
:selection="allSelected ? 'all' : selection"
|
|
12
|
+
:selectionQuery="selectionQuery"
|
|
12
13
|
@actionCompleted="refresh"
|
|
13
14
|
/>
|
|
14
15
|
</v-col>
|
|
15
|
-
<v-col cols="12" md="8">
|
|
16
|
-
<ListFilters v-bind="$attrs" v-model="filters">
|
|
16
|
+
<v-col cols="12" md="8" class="d-flex flex-nowrap justify-end align-center">
|
|
17
|
+
<ListFilters v-bind="$attrs" v-model="filters" :disabled="dragOrderingActive">
|
|
17
18
|
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
18
19
|
<!-- @vuese-ignore -->
|
|
19
20
|
<slot :name="slot"></slot>
|
|
@@ -25,15 +26,33 @@
|
|
|
25
26
|
</ListFilters>
|
|
26
27
|
</v-col>
|
|
27
28
|
</v-row>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
<div class="d-flex justify-end">
|
|
30
|
+
<!-- Overrides counter for selected items. -->
|
|
31
|
+
<slot name="item-counter" v-bind="{ selection, canSelectAll, allSelected, toggleSelectAll }">
|
|
32
|
+
<div v-if="selection" class="caption mr-1 mb-1">
|
|
33
|
+
<b v-if="allSelected">{{ $t("mapo.list.allSelected") }}</b>
|
|
34
|
+
<span v-else-if="selection.length">
|
|
35
|
+
{{ $t("mapo.list.NSelected", {numberItems: selection.length}) }}
|
|
36
|
+
<v-btn
|
|
37
|
+
v-if="selection != 'all' && canSelectAll"
|
|
38
|
+
@click="toggleSelectAll"
|
|
39
|
+
outlined
|
|
40
|
+
tile
|
|
41
|
+
x-small
|
|
42
|
+
class="ml-1 d-inline-flex"
|
|
43
|
+
>{{ $t("mapo.list.selectAll") }}</v-btn
|
|
44
|
+
>
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
</slot>
|
|
48
|
+
</div>
|
|
31
49
|
</div>
|
|
32
50
|
<div>
|
|
33
51
|
<ListTable
|
|
34
52
|
v-model="selection"
|
|
35
53
|
v-bind="{...$attrs, crud, filters}"
|
|
36
54
|
v-on="$listeners"
|
|
55
|
+
@drag-order-change="setDragOrdering"
|
|
37
56
|
ref="dtable"
|
|
38
57
|
>
|
|
39
58
|
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
@@ -54,7 +73,7 @@
|
|
|
54
73
|
* The purpose of this component is to provide you with a very quick way to create a page that can show a list of resources retrieved from the server.
|
|
55
74
|
* A use case example could be "build a page that lists all the products of an ecommerce". <br><br>
|
|
56
75
|
* This component is a wrapper and is made up of several parts.
|
|
57
|
-
* The props and slots of this component are passed to its childs.
|
|
76
|
+
* The props and slots of this component are passed to its childs.
|
|
58
77
|
* For detailed explanations see [Transparent Wrapping](#transparent-wrapping). <br> <h4>Index:</h4> [[toc]]
|
|
59
78
|
*/
|
|
60
79
|
export default {
|
|
@@ -63,15 +82,19 @@ export default {
|
|
|
63
82
|
return {
|
|
64
83
|
tabActiveStatus: 1,
|
|
65
84
|
selection: [],
|
|
66
|
-
|
|
85
|
+
allSelected: false,
|
|
86
|
+
filters: [],
|
|
87
|
+
dragOrderingActive: false,
|
|
88
|
+
selectionQuery: null,
|
|
67
89
|
};
|
|
68
90
|
},
|
|
69
91
|
props: {
|
|
70
92
|
// The url of the endpoint that provides the data to display. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
|
|
71
93
|
endpoint: {
|
|
72
|
-
type: String
|
|
73
|
-
required: true,
|
|
94
|
+
type: String
|
|
74
95
|
},
|
|
96
|
+
// Add option to select all items in all pages
|
|
97
|
+
canSelectAll: Boolean,
|
|
75
98
|
},
|
|
76
99
|
computed: {
|
|
77
100
|
crud() {
|
|
@@ -80,15 +103,34 @@ export default {
|
|
|
80
103
|
},
|
|
81
104
|
watch: {
|
|
82
105
|
selection(val) {
|
|
106
|
+
this.allSelected = val == 'all';
|
|
107
|
+
this.selectionQuery = this.$refs.dtable.getHttpParams();
|
|
83
108
|
// Fires when you select some row of the table.
|
|
84
|
-
// @arg Emit the list of the selected rows.
|
|
109
|
+
// @arg Emit "all" if all items are selected, else the list of the selected rows.
|
|
85
110
|
this.$emit("selectionChange", val);
|
|
86
111
|
},
|
|
112
|
+
filters: {
|
|
113
|
+
deep: true,
|
|
114
|
+
handler(val) {
|
|
115
|
+
// Fires when you change filters options.
|
|
116
|
+
// @arg Emits the same array prop `filters` passed to the component and every filter object inside it contains an `active` array that contains the selected options.
|
|
117
|
+
this.$emit("filtersChange", val);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
87
120
|
},
|
|
88
121
|
methods: {
|
|
89
122
|
refresh() {
|
|
90
123
|
return this.$refs.dtable.getDataFromApi();
|
|
91
124
|
},
|
|
125
|
+
toggleSelectAll() {
|
|
126
|
+
return this.$refs?.dtable?.toggleSelectAll();
|
|
127
|
+
},
|
|
128
|
+
setDragOrdering(val){
|
|
129
|
+
this.dragOrderingActive = val;
|
|
130
|
+
if(val){
|
|
131
|
+
this.filters = [];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
92
134
|
},
|
|
93
135
|
mounted() {},
|
|
94
136
|
};
|
|
@@ -113,10 +155,7 @@ Each component within it inherits its props and slots.
|
|
|
113
155
|
For the list of available prop refer to the documentation of each single part.
|
|
114
156
|
|
|
115
157
|
### Slots
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Each part can be reached with a namespace.
|
|
119
|
-
|
|
158
|
+
Other slots related to sub-components can be reached through these namespaces:
|
|
120
159
|
- `"filter"` is the namespace of [`ListFilters`](../ListFilters/#slots) slots.
|
|
121
160
|
- `"dtable"` is the namespace of [`ListTable`](../ListTable/#slots) slots.
|
|
122
161
|
- `"qedit"` is the namespace of [`ListQuickEdit`](../ListQuickEdit/#slots) slots.
|
|
@@ -133,18 +172,27 @@ This is an interactive example. You can play with it but remember that all http
|
|
|
133
172
|
|
|
134
173
|
::: demo
|
|
135
174
|
<template>
|
|
136
|
-
<v-app
|
|
137
|
-
|
|
175
|
+
<v-app>
|
|
176
|
+
<div class="d-flex justify-end"><ThemeToggle/></div>
|
|
177
|
+
<List
|
|
138
178
|
show-select
|
|
179
|
+
title="Sweets archive:"
|
|
180
|
+
lookup="name"
|
|
139
181
|
:headers="headers"
|
|
140
182
|
:editFields="editFields"
|
|
141
|
-
:filters="availableFilters"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
183
|
+
:filters="availableFilters"
|
|
184
|
+
multi-sort
|
|
185
|
+
can-select-all
|
|
186
|
+
searchable
|
|
187
|
+
:data.sync="desserts"
|
|
188
|
+
:actions="[]"
|
|
189
|
+
drag-reorder
|
|
190
|
+
>
|
|
191
|
+
</List>
|
|
192
|
+
<br>
|
|
193
|
+
<h3> Data: </h3>
|
|
194
|
+
<pre style="background-color: unset">{{ desserts }}</pre>
|
|
195
|
+
</v-app>
|
|
148
196
|
</template>
|
|
149
197
|
|
|
150
198
|
<script>
|
|
@@ -153,37 +201,66 @@ export default {
|
|
|
153
201
|
return {
|
|
154
202
|
headers: [
|
|
155
203
|
{
|
|
156
|
-
text: "
|
|
204
|
+
text: "Dessert (100g serving)",
|
|
157
205
|
align: "start",
|
|
158
206
|
sortable: false,
|
|
159
|
-
value: "
|
|
207
|
+
value: "name",
|
|
160
208
|
},
|
|
161
|
-
{ text: "
|
|
162
|
-
{ text: "
|
|
209
|
+
{ text: "Protein (g)", value: "protein" },
|
|
210
|
+
{ text: "Gluten-Free", value: "glutenfree" },
|
|
163
211
|
{ text: "Actions", value: "actions", sortable: false },
|
|
164
212
|
],
|
|
165
213
|
editFields: [
|
|
166
|
-
{ attrs: { rules:[v => !!v ||
|
|
167
|
-
{
|
|
168
|
-
{ attrs: { rules:[v => !!v || 'Identifier is required'] }, value: "identifier" },
|
|
214
|
+
{ attrs: { rules: [(v) => !!v || "Name is required"] }, value: "name" },
|
|
215
|
+
{ value: "protein" }
|
|
169
216
|
],
|
|
170
217
|
availableFilters: [
|
|
171
218
|
{
|
|
172
|
-
text: "
|
|
173
|
-
value: "
|
|
219
|
+
text: "Gluten Free",
|
|
220
|
+
value: "glutenfree",
|
|
174
221
|
choices: [
|
|
175
|
-
{ text: "
|
|
176
|
-
{ text: "
|
|
177
|
-
{ text: "Trash", value: "TRS" },
|
|
222
|
+
{ text: "Yes", value: true },
|
|
223
|
+
{ text: "No", value: false },
|
|
178
224
|
],
|
|
179
225
|
},
|
|
226
|
+
],
|
|
227
|
+
desserts: [
|
|
228
|
+
{
|
|
229
|
+
name: "Frozen Yogurt",
|
|
230
|
+
protein: 4.0,
|
|
231
|
+
glutenfree: true,
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "Ice cream sandwich",
|
|
235
|
+
protein: 4.3,
|
|
236
|
+
glutenfree: false,
|
|
237
|
+
},
|
|
180
238
|
{
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
239
|
+
name: "Eclair",
|
|
240
|
+
protein: 6.0,
|
|
241
|
+
glutenfree: false,
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "Jelly bean",
|
|
245
|
+
protein: 0.0,
|
|
246
|
+
glutenfree: true,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "Lollipop",
|
|
250
|
+
protein: 0,
|
|
251
|
+
glutenfree: true,
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "KitKat",
|
|
255
|
+
protein: 7,
|
|
256
|
+
glutenfree: false,
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "KitKat2",
|
|
260
|
+
protein: 77,
|
|
261
|
+
glutenfree: false,
|
|
184
262
|
},
|
|
185
263
|
],
|
|
186
|
-
|
|
187
264
|
};
|
|
188
265
|
},
|
|
189
266
|
};
|
|
@@ -191,4 +268,4 @@ export default {
|
|
|
191
268
|
:::
|
|
192
269
|
|
|
193
270
|
|
|
194
|
-
</docs>
|
|
271
|
+
</docs>
|