@mapomodule/uikit 1.0.0-alpha.7 → 1.0.0-alpha.8

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 (29) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/components/Detail/Detail.vue +28 -12
  3. package/components/Detail/DetailField.vue +7 -6
  4. package/components/Detail/DetailLangSwitch.vue +1 -1
  5. package/components/Detail/defaults.js +28 -27
  6. package/components/DropArea.vue +2 -2
  7. package/components/List/ListActions.vue +18 -0
  8. package/components/List/ListHead.vue +9 -1
  9. package/components/List/ListQuickEdit.vue +192 -58
  10. package/components/List/ListTable.vue +11 -5
  11. package/components/Login.vue +14 -5
  12. package/components/MediaManager/MediaEditor.vue +8 -2
  13. package/components/MediaManager/MediaFolders.vue +3 -3
  14. package/components/MediaManager/MediaManager.vue +1 -1
  15. package/components/SnackBar.vue +3 -4
  16. package/components/fields/DateField.vue +8 -3
  17. package/components/fields/FksField.vue +60 -0
  18. package/components/fields/MediaField.vue +13 -5
  19. package/components/fields/MediaM2mField.vue +8 -3
  20. package/components/fields/{TinyMce → wygEditor}/defaults.js +0 -0
  21. package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
  22. package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +0 -0
  23. package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
  24. package/components/fields/{TinyMce/TinyMce.vue → wygEditor/wygEditor.vue} +11 -11
  25. package/components/layout/Sidebar/SidebarFooter.vue +1 -0
  26. package/components/layout/Sidebar/SidebarList.vue +1 -0
  27. package/components/layout/Sidebar/SidebarListItem.vue +17 -1
  28. package/package.json +3 -3
  29. package/components/fields/M2mField.vue +0 -95
package/CHANGELOG.md CHANGED
@@ -3,6 +3,50 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.8](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2022-01-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **detail:** fix lang switch crop in small devices ([fc05f1e](https://github.com/lotrekagency/mapo/commit/fc05f1e437c8c9318354a95c9edd19fb12e0cff9))
12
+ * **detailfield:** fix default prop handling ([b3297f1](https://github.com/lotrekagency/mapo/commit/b3297f10a1ca2bf8db1690c6dcf680baaf96f71b))
13
+ * **langs:** fixed lang detection from model api ([1653740](https://github.com/lotrekagency/mapo/commit/165374080e91571e89b1fc48f43983b681b1ffc0))
14
+ * **list:** remove quickadd if user cannot add ([aef919e](https://github.com/lotrekagency/mapo/commit/aef919ee94c71475b812378126369233df09d055))
15
+ * **login:** fix bad handling of login call ([2d73570](https://github.com/lotrekagency/mapo/commit/2d73570720c91cf8922ed750adeb8cf7f89360c7))
16
+ * **m2m:** let v-model be an object to let field manage fk ([5500870](https://github.com/lotrekagency/mapo/commit/550087025235adf5016ea9340090b3ce1278e126))
17
+ * **mediamanager:** fix linked models ([35611ed](https://github.com/lotrekagency/mapo/commit/35611ed104643c72d5317beef3349928eed09ee8))
18
+ * **permissions:** collect route middleware info directly from ([e1937cc](https://github.com/lotrekagency/mapo/commit/e1937cc835cd4d331a43c4bbf9581c16bfc03f41))
19
+ * **quickedit:** fix close button position ([8e15d47](https://github.com/lotrekagency/mapo/commit/8e15d47c6dd69dfbb2cbf3f70f2fb342202bf9a2))
20
+ * **quickedit:** temporary disable patch diff to fix translation problems ([1ec4b04](https://github.com/lotrekagency/mapo/commit/1ec4b04723d2d25ffdabfb5e5e69dd7c66735fe4))
21
+ * **sidebar:** fix footer menu auth ([6a986ba](https://github.com/lotrekagency/mapo/commit/6a986ba6def87a341e2bf670278716811336c725))
22
+ * **snackbar:** fix snack color ([9fcc053](https://github.com/lotrekagency/mapo/commit/9fcc053a1a52c3970706dcb4393be3aec0aa8c55))
23
+ * fix m2mfield for null values ([fbdf045](https://github.com/lotrekagency/mapo/commit/fbdf0456660b4cc6f46ac7d0ca40278451e87059))
24
+ * **uikit:** fix color mismatch in some components ([06cc23c](https://github.com/lotrekagency/mapo/commit/06cc23c8835c891e9ff15d277ba8bc4e54f1b8b8))
25
+
26
+
27
+ ### Features
28
+
29
+ * **detail:** added permission logics to detail component ([475d063](https://github.com/lotrekagency/mapo/commit/475d063ac1979380ec64afc057786a6b2ec142ba))
30
+ * **detail:** added permission logics to list actions component ([eebe25a](https://github.com/lotrekagency/mapo/commit/eebe25a8e0ef6f7d89dd7e1eca762d65ecc090a0))
31
+ * **detail:** added permission logics to list component ([83343ca](https://github.com/lotrekagency/mapo/commit/83343ca4038002d4528de0ec5d746c4420d5d157))
32
+ * **detail:** added permission logics to list head component ([95a37a2](https://github.com/lotrekagency/mapo/commit/95a37a2139726eed85824cf425dd15022d37bf88))
33
+ * **detail:** show backend error messages on model update ([a456a81](https://github.com/lotrekagency/mapo/commit/a456a81610b7b95e231f33cc35f2c87fb9a80071))
34
+ * **fields:** added readonly prop to date custom field ([682bab5](https://github.com/lotrekagency/mapo/commit/682bab59ce88a0dbfa1be644103ccf8b0cb6bf41))
35
+ * **fields:** added readonly prop to various custom fields ([ed45190](https://github.com/lotrekagency/mapo/commit/ed45190cec6250bb26e91b26dc570e07e0fd800c))
36
+ * **m2m:** added autocomplete by default ([1956427](https://github.com/lotrekagency/mapo/commit/19564271f71a289d840a3e1200098e911935da4f))
37
+ * **m2m:** autodisable chips if multiple = false ([5dcc88d](https://github.com/lotrekagency/mapo/commit/5dcc88d671b4c06bd378573a27c9bc1b44b4b736))
38
+ * **m2m:** restyle m2m field ([bb49f3d](https://github.com/lotrekagency/mapo/commit/bb49f3dbf9ba3d6fb2a78e69113645fdde2e1cce))
39
+ * **M2m:** added max height ([d32a383](https://github.com/lotrekagency/mapo/commit/d32a3831f903d20924408536b2921fba3f5e683e))
40
+ * **quickedit:** add close button on hover ([c365f51](https://github.com/lotrekagency/mapo/commit/c365f515dbb2edbf9d964c63b170bf3247309d70))
41
+ * **quickedit:** added non field errors ([4b63e73](https://github.com/lotrekagency/mapo/commit/4b63e734818a0d690831c39ccbe73403400dffd4))
42
+ * **quickedit:** merge detail component logics in to quickedit ([691f610](https://github.com/lotrekagency/mapo/commit/691f610b156f58a5d30598d89bf06425d90451d8))
43
+ * **sidebar:** hide not navigable entries depending on user permissions ([349dd6c](https://github.com/lotrekagency/mapo/commit/349dd6c102cdf80d25de4db988f1ccf29047dfcd))
44
+ * **uikit:** more consistent ui style ([54c464f](https://github.com/lotrekagency/mapo/commit/54c464f0c8ea86d87e5ae2004b7744bb4126ebba))
45
+
46
+
47
+
48
+
49
+
6
50
  # [1.0.0-alpha.7](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2022-01-13)
7
51
 
8
52
 
@@ -34,7 +34,7 @@
34
34
  v-for="(field, index) in mainFields"
35
35
  :key="index"
36
36
  >
37
- <v-card v-if="field.group" class="my-2">
37
+ <v-card v-if="field.group" class="my-2 rounded-0">
38
38
  <v-card-title>
39
39
  <v-icon left> {{ field.group.icon }} </v-icon>
40
40
  <span>{{ field.group.name }}</span>
@@ -93,14 +93,14 @@
93
93
  <!-- Use this to override the Save button. -->
94
94
  <slot name="button.save" v-bind="slotBindings">
95
95
  <!-- The Save button. -->
96
- <v-btn class="mb-2" tile block @click="saveItem(true)">{{
96
+ <v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
97
97
  isNew ? "Create" : "Save"
98
98
  }}</v-btn>
99
99
  </slot>
100
100
  <!-- Use this to override the Save and continue button. -->
101
101
  <slot name="button.savecontinue" v-bind="slotBindings">
102
102
  <!-- The Save and continue button. -->
103
- <v-btn class="mb-2" tile block @click="saveItem(false)"
103
+ <v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
104
104
  >{{ isNew ? "Create" : "Save" }} and continue</v-btn
105
105
  >
106
106
  </slot>
@@ -120,6 +120,7 @@
120
120
  color="error"
121
121
  tile
122
122
  block
123
+ :disabled="!canDelete"
123
124
  @click="deleteItem"
124
125
  >Delete</v-btn
125
126
  >
@@ -135,7 +136,7 @@
135
136
  v-for="(field, index) in sideFields"
136
137
  :key="index"
137
138
  >
138
- <v-card v-if="field.group" class="mb-4">
139
+ <v-card v-if="field.group" class="rounded-0 mb-4">
139
140
  <v-card-title>
140
141
  <v-icon left> {{ field.group.icon }} </v-icon>
141
142
  <span>{{ field.group.name }}</span>
@@ -254,7 +255,7 @@ export default {
254
255
  this.errors =
255
256
  (error.response.status == 400 && error.response.data) || null;
256
257
  this.$mapo.$snack.open({
257
- message: "Something whent bad, please try again later...",
258
+ message: error.response?.data?.detail || "Something whent bad, please try again later...",
258
259
  color: "error"
259
260
  });
260
261
  });
@@ -264,7 +265,7 @@ export default {
264
265
  .open({
265
266
  title: "Delete",
266
267
  question: "Are you sure you want to delete this item?",
267
- approveButton: { text: "Delete", attrs: { color: "red" } }
268
+ approveButton: { text: "Delete", attrs: { color: "red", text: true } }
268
269
  })
269
270
  .then(res => {
270
271
  if (res) {
@@ -273,7 +274,7 @@ export default {
273
274
  .then(() => this.$router.back())
274
275
  .catch(error =>
275
276
  this.$mapo.$snack.open({
276
- message: "Something whent bad, please try again later...",
277
+ message: error.response?.data?.detail || "Something whent bad, please try again later...",
277
278
  color: "error"
278
279
  })
279
280
  );
@@ -291,12 +292,15 @@ export default {
291
292
  parseConf(field, i) {
292
293
  const conf = typeof field === "string" ? { value: field } : field;
293
294
  conf.value = conf.value || "";
294
- conf.value = conf.value.replace(new RegExp(`^translations\.(${this.languages.join("|")})\.?`), "");
295
+ conf.value = conf.value.replace(new RegExp(`^translations\.(${this.langs.join("|")})\.?`), "");
295
296
  conf.slotName = `fields.${conf.value || i}`;
296
297
  if (this.currentLang && !field.synci18n) {
297
298
  const base = `translations.${this.currentLang}`;
298
299
  conf.value = (conf.value && `${base}.${conf.value}`) || base;
299
300
  }
301
+ if (this.isReadonly){
302
+ conf.attrs = {...conf.attrs, readonly: true}
303
+ }
300
304
  return conf;
301
305
  },
302
306
  mapConf(fields) {
@@ -340,6 +344,18 @@ export default {
340
344
  crud() {
341
345
  return this.$mapo.$api.crud(this.endpoint);
342
346
  },
347
+ isReadonly() {
348
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
349
+ return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change")
350
+ }
351
+ return false
352
+ },
353
+ canDelete() {
354
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
355
+ return this.$mapo.$auth.user.permissions.includes("delete")
356
+ }
357
+ return true
358
+ },
343
359
  mainFields() {
344
360
  return this.mapConf(
345
361
  this.fields instanceof Array ? this.fields : this.fields.main || []
@@ -361,7 +377,7 @@ export default {
361
377
  },
362
378
  langs() {
363
379
  return (
364
- this.model?.active_languages?.languages.map(l => l.id) || this.languages
380
+ this.model?.lang_info?.site_languages.map(l => l.id) || this.languages
365
381
  );
366
382
  },
367
383
  slotBindings() {
@@ -443,10 +459,10 @@ Here the list of the FieldConfiguration type association.
443
459
  - `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
444
460
  - `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
445
461
  - `file` ==> [v-file-input](https://vuetifyjs.com/en/components/file-inputs/),
446
- - `editor` ==> [tiny-mce](/components/fields/TinyMce/TinyMce/),
462
+ - `editor` ==> [wyg-editor](/components/fields/wygEditor/wygEditor/),
447
463
  - `media` ==> [media-field](/components/fields/MediaField/),
448
- - `m2m` ==> [m2m-field](/components/fields/M2mField/),
449
- - `mediaList` ==> [media-m2m-field](/components/fields/MediaM2mField/)
464
+ - `m2m` ==> [fks-field](/components/fields/FksField/),
465
+ - `mediaList` ==> [media-fks-field](/components/fields/MediaM2mField/)
450
466
 
451
467
 
452
468
  #### Example of a [`FieldConfiguration`](#fieldconfiguration):
@@ -3,9 +3,9 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
- import TinyMce from "@mapomodule/uikit/components/fields/TinyMce/TinyMce.vue";
6
+ import wygEditor from "@mapomodule/uikit/components/fields/wygEditor/wygEditor.vue";
7
7
  import DateField from "@mapomodule/uikit/components/fields/DateField.vue";
8
- import M2mField from "@mapomodule/uikit/components/fields/M2mField.vue";
8
+ import FksField from "@mapomodule/uikit/components/fields/FksField.vue";
9
9
  import MediaM2mField from "@mapomodule/uikit/components/fields/MediaM2mField.vue";
10
10
  import MediaField from "@mapomodule/uikit/components/fields/MediaField.vue";
11
11
  import SeoPreview from "@mapomodule/uikit/components/fields/SeoPreview.vue";
@@ -20,9 +20,9 @@ import defaults from "./defaults";
20
20
  export default {
21
21
  name: "DetailField",
22
22
  components: {
23
- TinyMce,
23
+ wygEditor,
24
24
  DateField,
25
- M2mField,
25
+ FksField,
26
26
  MediaM2mField,
27
27
  MediaField,
28
28
  SeoPreview
@@ -101,7 +101,8 @@ export default {
101
101
  return {
102
102
  label: this.label,
103
103
  errorMessages: getPointed(this.errors || {}, this.conf.value, []),
104
- ...(this.defaultAttrs[this.is] || {}),
104
+ ...this.defaultAttrs.All,
105
+ ...(this.defaultAttrs[this.is.replace(/-./g, x=>x[1].toUpperCase())] || {}),
105
106
  ...this.conf.attrs
106
107
  };
107
108
  },
@@ -124,7 +125,7 @@ export default {
124
125
  return (
125
126
  this.conf.is ||
126
127
  (this.conf.type && this.defaultMap[this.conf.type]) ||
127
- "v-text-field"
128
+ "vTextField"
128
129
  );
129
130
  }
130
131
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <v-tabs v-model="tab">
2
+ <v-tabs v-model="tab" show-arrows>
3
3
  <v-tab v-for="lang in langs" :key="lang">
4
4
  <v-badge :value="hasErrors(lang)" color="error" dot>
5
5
  {{ lang }}
@@ -1,36 +1,37 @@
1
1
  const mapping = {
2
- text: "v-text-field",
3
- select: "v-select",
4
- date: "date-field",
5
- textarea: "v-textarea",
6
- switch: "v-switch",
7
- slider: "v-slider",
8
- file: "v-file-input",
9
- editor: "tiny-mce",
10
- media: "media-field",
11
- m2m: "m2m-field",
12
- mediaList: "media-m2m-field",
13
- seoPreview: "seo-preview"
2
+ text: "vTextField",
3
+ select: "vSelect",
4
+ date: "DateField",
5
+ textarea: "vTextarea",
6
+ switch: "vSwitch",
7
+ slider: "vSlider",
8
+ file: "vFileInput",
9
+ editor: "wygEditor",
10
+ media: "MediaField",
11
+ m2m: "FksField",
12
+ mediaList: "MediaM2mField",
13
+ seoPreview: "SeoPreview"
14
14
  }
15
15
 
16
16
  const props = {
17
- "v-text-field": {
18
- outlined: true
19
- },
20
- "v-textarea": {
21
- outlined: true
22
- },
23
- "date-field": {
24
- outlined: true
25
- },
26
- "v-select": {
27
- outlined: true,
17
+ vSelect: {
28
18
  itemText: "text",
29
19
  itemValue: "value"
30
20
  },
31
- "v-switch": {
21
+ MediaField: {
22
+ outlined: false
23
+ },
24
+ vSwitch: {
32
25
  inset: true,
33
26
  ripple: false
27
+ },
28
+ FksField:{
29
+ itemValue: "id",
30
+ returnObject: true,
31
+ },
32
+ All : {
33
+ outlined: true,
34
+ class: "rounded-0",
34
35
  }
35
36
  }
36
37
 
@@ -39,13 +40,13 @@ const dateFunc = function ({ val }) {
39
40
  };
40
41
 
41
42
  const accessor = {
42
- "v-date-picker": {
43
+ vDatePicker: {
43
44
  get: dateFunc, set: dateFunc
44
45
  },
45
- "date-field": {
46
+ DateField: {
46
47
  get: dateFunc, set: dateFunc
47
48
  },
48
- "seo-preview": {
49
+ SeoPreview: {
49
50
  get: ({ val }) => ({ title: "", permalink: "", description: "", ...val }),
50
51
  set: ({ val }) => ({ title: "", permalink: "", description: "", ...val })
51
52
  }
@@ -112,8 +112,8 @@
112
112
 
113
113
  <v-card-actions>
114
114
  <v-spacer></v-spacer>
115
- <v-btn color="green darken-1" text @click="closeEdit"> Cancel </v-btn>
116
- <v-btn color="green darken-1" text @click="saveEdit"> Save </v-btn>
115
+ <v-btn color="primary" text @click="closeEdit"> Cancel </v-btn>
116
+ <v-btn color="primary" text @click="saveEdit"> Save </v-btn>
117
117
  </v-card-actions>
118
118
  </v-card>
119
119
  </v-dialog>
@@ -5,6 +5,7 @@
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"
@@ -53,6 +55,7 @@ export default {
53
55
  handler: function ({ selection, lookup, crud }) {
54
56
  return Promise.all(selection.map((i) => crud && crud.delete(i[lookup])));
55
57
  },
58
+ permissions: "delete"
56
59
  },
57
60
  ];
58
61
  },
@@ -89,6 +92,19 @@ 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({
@@ -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
  ```
@@ -3,7 +3,7 @@
3
3
  <h1 class="list__head__title display-1">{{ title }}</h1>
4
4
  <div class="list__head__button">
5
5
  <v-btn
6
- v-if="addItem"
6
+ v-if="addItem && canAdd"
7
7
  class="rounded-0 elevation-0"
8
8
  color="primary"
9
9
  :to="{ path: `${$route.path}/new` }"
@@ -54,6 +54,14 @@ export default {
54
54
  },
55
55
  // This is a boolean that determines the visibility of "new item" button. If set to true will provide the user a link to a detail page for new content creation.
56
56
  addItem: Boolean
57
+ },
58
+ computed: {
59
+ canAdd() {
60
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
61
+ return this.$mapo.$auth.user.permissions.includes("add")
62
+ }
63
+ return true
64
+ },
57
65
  }
58
66
  };
59
67
  </script>