@mapomodule/uikit 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (90) hide show
  1. package/CHANGELOG.md +873 -0
  2. package/components/ConfirmDialog.vue +58 -37
  3. package/components/Detail/Detail.vue +450 -243
  4. package/components/Detail/DetailLangSwitch.vue +9 -2
  5. package/components/DropArea.vue +63 -56
  6. package/components/Form/Form.vue +218 -0
  7. package/components/Form/FormField.vue +214 -0
  8. package/components/Form/FormGroup.vue +146 -0
  9. package/components/Form/FormTabs.vue +188 -0
  10. package/components/Form/defaults.js +97 -0
  11. package/components/Form/fields/ColorField.vue +79 -0
  12. package/components/{fields → Form/fields}/DateField.vue +20 -11
  13. package/components/Form/fields/DateTimeField.vue +271 -0
  14. package/components/Form/fields/EnhancedMediaField.vue +224 -0
  15. package/components/Form/fields/FileField.vue +125 -0
  16. package/components/Form/fields/FksField.vue +88 -0
  17. package/components/Form/fields/MediaField.vue +159 -0
  18. package/components/Form/fields/MediaM2mField.vue +149 -0
  19. package/components/Form/fields/Repeater.vue +596 -0
  20. package/components/Form/fields/SeoPreview.vue +89 -0
  21. package/components/Form/fields/TimeField.vue +154 -0
  22. package/components/Form/fields/mapField/leaflet.injector.js +39 -0
  23. package/components/Form/fields/mapField/mapField.vue +348 -0
  24. package/components/Form/fields/wygEditor/defaults.js +25 -0
  25. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
  26. package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
  27. package/components/LangSwitcher.vue +44 -0
  28. package/components/List/List.vue +103 -51
  29. package/components/List/ListActions.vue +23 -5
  30. package/components/List/ListFilters.vue +166 -114
  31. package/components/List/ListHead.vue +30 -12
  32. package/components/List/ListQuickEdit.vue +130 -61
  33. package/components/List/ListTable.vue +210 -66
  34. package/components/Login.vue +17 -7
  35. package/components/LogoutButton.vue +43 -28
  36. package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
  37. package/components/MediaManager/MediaEditor.vue +297 -120
  38. package/components/MediaManager/MediaFileChanger.vue +78 -0
  39. package/components/MediaManager/MediaFolders.vue +224 -116
  40. package/components/MediaManager/MediaGallery.vue +224 -145
  41. package/components/MediaManager/MediaManager.vue +125 -159
  42. package/components/MediaManager/MediaManagerDialog.vue +36 -31
  43. package/components/MediaManager/MediaPreview.vue +258 -0
  44. package/components/MediaManager/MediaUploader.vue +91 -90
  45. package/components/MenuManager/MenuManager.vue +332 -0
  46. package/components/MenuManager/MenuNodeEditor.vue +255 -0
  47. package/components/MenuManager/MenuTreeview.vue +237 -0
  48. package/components/MenuManager/MenuTreeviewNode.vue +208 -0
  49. package/components/PagePreview.vue +58 -0
  50. package/components/SnackBar.vue +5 -7
  51. package/components/ThemeToggle.vue +13 -0
  52. package/components/layout/Sidebar/Sidebar.vue +61 -30
  53. package/components/layout/Sidebar/SidebarList.vue +19 -15
  54. package/components/layout/Sidebar/SidebarListItem.vue +122 -38
  55. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  56. package/components/layout/Sidebar/SidebarTitle.vue +45 -0
  57. package/components/layout/Topbar/Topbar.vue +11 -42
  58. package/components/layout/routebuilder.js +3 -3
  59. package/defaults/i18n.js +37 -0
  60. package/defaults/vuetify.js +34 -0
  61. package/layouts/default.vue +33 -18
  62. package/layouts/empty.vue +10 -0
  63. package/module.js +7 -5
  64. package/package.json +6 -4
  65. package/pages/index.vue +19 -18
  66. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
  67. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
  68. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
  69. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
  70. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
  71. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
  72. package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
  73. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
  74. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
  75. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
  76. package/translations/en-US.js +177 -0
  77. package/translations/it-IT.js +180 -0
  78. package/components/Detail/DetailField.vue +0 -129
  79. package/components/Detail/defaults.js +0 -50
  80. package/components/fields/M2mField.vue +0 -95
  81. package/components/fields/MediaField.vue +0 -195
  82. package/components/fields/MediaM2mField.vue +0 -238
  83. package/components/fields/TinyMce/TinyMce.vue +0 -177
  84. package/components/fields/TinyMce/defaults.js +0 -55
  85. package/components/layout/Sidebar/SidebarFooter.vue +0 -75
  86. package/defaults.js +0 -29
  87. package/layouts/error.vue +0 -45
  88. /package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  89. /package/components/{fields/TinyMce/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
  90. /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
@@ -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/tinymce.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;">&rarr; This is a full-featured editor demo. Please explore!
257
+ &larr;</span></p>
258
+ <p style="text-align: center;">&nbsp;</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;">&nbsp;</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>
@@ -3,7 +3,7 @@
3
3
  <ListHead v-bind="$attrs" />
4
4
 
5
5
  <div>
6
- <v-row class="mb-4">
6
+ <v-row class="mb-1">
7
7
  <v-col cols="12" md="4">
8
8
  <ListActions
9
9
  v-bind="$attrs"
@@ -14,25 +14,7 @@
14
14
  />
15
15
  </v-col>
16
16
  <v-col cols="12" md="8" class="d-flex flex-nowrap justify-end align-center">
17
- <!-- Overrides counter for selected items. -->
18
- <slot name="item-counter" v-bind="{ selection, canSelectAll, allSelected, toggleSelectAll }">
19
- <div class="caption mr-1">
20
- <b v-if="allSelected">All items selected</b>
21
- <span v-else-if="selection.length">
22
- {{ selection.length }} items selected
23
- <v-btn
24
- v-if="selection != 'all' && canSelectAll"
25
- @click="toggleSelectAll"
26
- outlined
27
- tile
28
- x-small
29
- class="ml-1 d-inline-flex"
30
- >Select all</v-btn
31
- >
32
- </span>
33
- </div>
34
- </slot>
35
- <ListFilters v-bind="$attrs" v-model="filters">
17
+ <ListFilters v-bind="$attrs" v-model="filters" :disabled="dragOrderingActive">
36
18
  <template v-for="(_, slot) in $slots" :slot="slot">
37
19
  <!-- @vuese-ignore -->
38
20
  <slot :name="slot"></slot>
@@ -44,12 +26,33 @@
44
26
  </ListFilters>
45
27
  </v-col>
46
28
  </v-row>
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>
47
49
  </div>
48
50
  <div>
49
51
  <ListTable
50
52
  v-model="selection"
51
53
  v-bind="{...$attrs, crud, filters}"
52
54
  v-on="$listeners"
55
+ @drag-order-change="setDragOrdering"
53
56
  ref="dtable"
54
57
  >
55
58
  <template v-for="(_, slot) in $slots" :slot="slot">
@@ -80,14 +83,15 @@ export default {
80
83
  tabActiveStatus: 1,
81
84
  selection: [],
82
85
  allSelected: false,
83
- filters: []
86
+ filters: [],
87
+ dragOrderingActive: false,
88
+ selectionQuery: null,
84
89
  };
85
90
  },
86
91
  props: {
87
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.
88
93
  endpoint: {
89
- type: String,
90
- required: true,
94
+ type: String
91
95
  },
92
96
  // Add option to select all items in all pages
93
97
  canSelectAll: Boolean,
@@ -96,17 +100,23 @@ export default {
96
100
  crud() {
97
101
  return this.$mapo.$api.crud(this.endpoint);
98
102
  },
99
- selectionQuery() {
100
- return this.$refs?.dtable?.getHttpParams();
101
- }
102
103
  },
103
104
  watch: {
104
105
  selection(val) {
105
106
  this.allSelected = val == 'all';
107
+ this.selectionQuery = this.$refs.dtable.getHttpParams();
106
108
  // Fires when you select some row of the table.
107
109
  // @arg Emit "all" if all items are selected, else the list of the selected rows.
108
110
  this.$emit("selectionChange", val);
109
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
+ }
110
120
  },
111
121
  methods: {
112
122
  refresh() {
@@ -114,6 +124,12 @@ export default {
114
124
  },
115
125
  toggleSelectAll() {
116
126
  return this.$refs?.dtable?.toggleSelectAll();
127
+ },
128
+ setDragOrdering(val){
129
+ this.dragOrderingActive = val;
130
+ if(val){
131
+ this.filters = [];
132
+ }
117
133
  }
118
134
  },
119
135
  mounted() {},
@@ -156,20 +172,27 @@ This is an interactive example. You can play with it but remember that all http
156
172
 
157
173
  ::: demo
158
174
  <template>
159
- <v-app >
160
- <List
175
+ <v-app>
176
+ <div class="d-flex justify-end"><ThemeToggle/></div>
177
+ <List
161
178
  show-select
179
+ title="Sweets archive:"
180
+ lookup="name"
162
181
  :headers="headers"
163
182
  :editFields="editFields"
164
183
  :filters="availableFilters"
165
- endpoint="api/camomilla/articles"
166
- title="List Example"
167
- addItem
168
- canSelectAll
184
+ multi-sort
185
+ can-select-all
169
186
  searchable
170
- >
171
- </List>
172
- </v-app>
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>
173
196
  </template>
174
197
 
175
198
  <script>
@@ -178,37 +201,66 @@ export default {
178
201
  return {
179
202
  headers: [
180
203
  {
181
- text: "ID",
204
+ text: "Dessert (100g serving)",
182
205
  align: "start",
183
206
  sortable: false,
184
- value: "id",
207
+ value: "name",
185
208
  },
186
- { text: "Title", value: "title" },
187
- { text: "Identifier", value: "identifier" },
209
+ { text: "Protein (g)", value: "protein" },
210
+ { text: "Gluten-Free", value: "glutenfree" },
188
211
  { text: "Actions", value: "actions", sortable: false },
189
212
  ],
190
213
  editFields: [
191
- { attrs: { rules:[v => !!v || 'Title is required'] }, value: "title" },
192
- { attrs: { rules:[v => !!v || 'Permalink is required'] }, value: "permalink" },
193
- { attrs: { rules:[v => !!v || 'Identifier is required'] }, value: "identifier" },
214
+ { attrs: { rules: [(v) => !!v || "Name is required"] }, value: "name" },
215
+ { value: "protein" }
194
216
  ],
195
217
  availableFilters: [
196
218
  {
197
- text: "Status",
198
- value: "status",
219
+ text: "Gluten Free",
220
+ value: "glutenfree",
199
221
  choices: [
200
- { text: "Draft", value: "DRF" },
201
- { text: "Published", value: "PUB" },
202
- { text: "Trash", value: "TRS" },
222
+ { text: "Yes", value: true },
223
+ { text: "No", value: false },
203
224
  ],
204
225
  },
226
+ ],
227
+ desserts: [
205
228
  {
206
- text: "Date",
207
- value: "date",
208
- datepicker: true
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
+ },
238
+ {
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,
209
262
  },
210
263
  ],
211
-
212
264
  };
213
265
  },
214
266
  };
@@ -1,10 +1,11 @@
1
1
  <template>
2
2
  <div v-if="isActive" class="d-flex flex-row align-center fill-height">
3
3
  <v-select
4
- label="Group Actions"
4
+ :label="$t('mapo.listActions.groupActions')"
5
5
  v-bind="$attrs"
6
6
  v-model="action"
7
7
  :items="filteredActions"
8
+ :item-disabled="isDisabled"
8
9
  item-text="label"
9
10
  item-value="handler"
10
11
  outlined
@@ -12,6 +13,7 @@
12
13
  hide-details
13
14
  clearable
14
15
  no-data-text="No actions available"
16
+ class="rounded-0"
15
17
  ></v-select>
16
18
  <v-btn
17
19
  class="rounded-0 elevation-0 ml-2"
@@ -19,7 +21,7 @@
19
21
  color="primary"
20
22
  :disabled="!action"
21
23
  @click="handleAction"
22
- >Apply</v-btn
24
+ >{{ $t("mapo.apply") }}</v-btn
23
25
  >
24
26
  </div>
25
27
  </template>
@@ -49,10 +51,11 @@ export default {
49
51
  default() {
50
52
  return [
51
53
  {
52
- label: "Permanent delete",
54
+ label: this.$t("mapo.listActions.permanentDelete"),
53
55
  handler: function ({ selection, lookup, crud }) {
54
- return Promise.all(selection.map((i) => crud.delete(i[lookup])));
56
+ return Promise.all(selection.map((i) => crud && crud.delete(i[lookup])));
55
57
  },
58
+ permissions: "delete"
56
59
  },
57
60
  ];
58
61
  },
@@ -89,10 +92,23 @@ export default {
89
92
  }
90
93
  },
91
94
  methods: {
95
+ isDisabled(action){
96
+ const p = typeof action.permissions == "string" ? [action.permissions] : action.permissions || []
97
+ if (p.length){
98
+ return !p.every(a => this.userCan(a))
99
+ }
100
+ return false
101
+ },
102
+ userCan(action) {
103
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
104
+ return this.$mapo.$auth.user.permissions.includes(action)
105
+ }
106
+ return true
107
+ },
92
108
  handleAction() {
93
109
  if (!this.selectAll && !this.selection.length) {
94
110
  return this.$mapo.$snack.open({
95
- message: "You need to select at least one item.",
111
+ message: this.$t("mapo.listActions.selectionRequired"),
96
112
  color: "error",
97
113
  });
98
114
  }
@@ -120,6 +136,7 @@ The actions prop is a list of `Action` objects containing these keys:
120
136
  - **"handleMultiple"** `Boolean` ==> Make the action callable on multiple items. Default: `true`.
121
137
  - **"handleAll"** `Boolean` ==> Make the action callable on all items. Default: `false`.
122
138
  - **"handler"** `Function` ==> The callback function that will be executed once the user confirms the action.
139
+ - **"permissions"** `String | Array` ==> The list of permissions needed by the user to perform action in a page with permission middleware
123
140
 
124
141
  The handler function will be called with a ctx containing:
125
142
  - **"selection"** `Array<Object>` or `String` ==> `"all"` if all items are selected else the list of selected objects.
@@ -140,6 +157,7 @@ const actions = [
140
157
  selection.map((i) => crud.delete(i[lookup]))
141
158
  );
142
159
  },
160
+ permissions: "delete"
143
161
  }
144
162
  ]
145
163
  ```