@mapomodule/uikit 1.0.0-alpha.23 → 1.0.0-alpha.24

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 (37) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/components/ConfirmDialog.vue +10 -14
  3. package/components/Detail/Detail.vue +12 -12
  4. package/components/DropArea.vue +17 -33
  5. package/components/Form/FormGroup.vue +15 -1
  6. package/components/Form/FormTabs.vue +13 -1
  7. package/components/Form/fields/DateField.vue +3 -3
  8. package/components/Form/fields/FksField.vue +2 -2
  9. package/components/Form/fields/MediaField.vue +4 -5
  10. package/components/Form/fields/MediaM2mField.vue +3 -3
  11. package/components/Form/fields/Repeater.vue +7 -7
  12. package/components/Form/fields/SeoPreview.vue +5 -9
  13. package/components/LangSwitcher.vue +44 -0
  14. package/components/List/List.vue +14 -15
  15. package/components/List/ListActions.vue +5 -5
  16. package/components/List/ListFilters.vue +9 -2
  17. package/components/List/ListHead.vue +1 -1
  18. package/components/List/ListQuickEdit.vue +4 -4
  19. package/components/List/ListTable.vue +11 -12
  20. package/components/Login.vue +5 -4
  21. package/components/LogoutButton.vue +43 -28
  22. package/components/MediaManager/MediaEditor.vue +20 -18
  23. package/components/MediaManager/MediaFolders.vue +14 -19
  24. package/components/MediaManager/MediaGallery.vue +1 -1
  25. package/components/MediaManager/MediaManager.vue +22 -15
  26. package/components/MediaManager/MediaManagerDialog.vue +2 -1
  27. package/components/MediaManager/MediaUploader.vue +6 -7
  28. package/components/SnackBar.vue +2 -3
  29. package/components/layout/Sidebar/SidebarFooter.vue +6 -25
  30. package/components/layout/Sidebar/SidebarListItem.vue +2 -2
  31. package/components/layout/Sidebar/SidebarProfile.vue +2 -2
  32. package/defaults.js +70 -24
  33. package/module.js +11 -3
  34. package/package.json +3 -2
  35. package/pages/index.vue +1 -1
  36. package/translations/en-US.js +129 -0
  37. package/translations/it-IT.js +131 -0
@@ -3,8 +3,8 @@
3
3
  <v-card-title class="d-flex flex-wrap pa-0">
4
4
  <div>
5
5
  <v-tabs v-model="tab" right background-color="transparent">
6
- <v-tab>Gallery</v-tab>
7
- <v-tab>Uploader</v-tab>
6
+ <v-tab>{{ $t("mapo.mediaManager.gallery") }}</v-tab>
7
+ <v-tab>{{ $t("mapo.mediaManager.uploader") }}</v-tab>
8
8
  </v-tabs>
9
9
  </div>
10
10
  <v-btn v-show="$vuetify.breakpoint.xs" class="ma-2 ml-auto" @click="getRoot" icon>
@@ -19,7 +19,7 @@
19
19
  search();
20
20
  "
21
21
  prepend-inner-icon="mdi-magnify"
22
- label="Search"
22
+ :label="$t('mapo.search')"
23
23
  single-line
24
24
  hide-details
25
25
  outlined
@@ -118,6 +118,12 @@ export default {
118
118
  required: false,
119
119
  },
120
120
  },
121
+ watch: {
122
+ '$i18n.locale': async function(locale) {
123
+ if (this.editMedia)
124
+ this.editMedia = await this.detailMedia(this.editMedia.id);
125
+ }
126
+ },
121
127
  computed: {
122
128
  mediaFolderCrud() {
123
129
  this._mediaFolderCrud =
@@ -125,8 +131,7 @@ export default {
125
131
  return this._mediaFolderCrud;
126
132
  },
127
133
  mediaFileCrud() {
128
- this._mediaFileCrud =
129
- this._mediaFileCrud || this.$mapo.$api.crud("api/media");
134
+ this._mediaFileCrud = this._mediaFileCrud || this.$mapo.$api.crud("api/media");
130
135
  return this._mediaFileCrud;
131
136
  },
132
137
  parentFolder: {
@@ -168,7 +173,7 @@ export default {
168
173
  ? await this.mediaFolderCrud.detail(id, { params })
169
174
  : await this.mediaFolderCrud.list({ params });
170
175
  } catch (error) {
171
- console.error({ code: error.response.status, response: error.response.data})
176
+ console.error({ code: error.response.status, response: error.response.data });
172
177
  }
173
178
 
174
179
  this.processResponse(response);
@@ -191,23 +196,25 @@ export default {
191
196
  },
192
197
 
193
198
  detailMedia(media_id) {
194
- return this.mediaFileCrud.detail(media_id);
199
+ return this.mediaFileCrud.detail(media_id, {
200
+ params: { language_code: this.$i18n.locale },
201
+ });
195
202
  },
196
203
 
197
204
  async updateMedia(media) {
198
205
  const files = ["file", "objectURL", "thumbnail"];
199
206
  const payload = this.$mapo.$api.multipart(media, files);
200
207
  const conf = { headers: { "Content-Type": "multipart/form-data" } };
201
- const res = await this.mediaFileCrud.partialUpdate(media.id, payload, conf)
202
- if (media.file){
203
- this.medias = []
204
- await this.getRoot()
208
+ const res = await this.mediaFileCrud.partialUpdate(media.id, payload, conf);
209
+ if (media.file) {
210
+ this.medias = [];
211
+ await this.getRoot();
205
212
  }
206
- this.editMedia = res
213
+ this.editMedia = res;
207
214
  this.$mapo.$snack.open({
208
- message: "File info succesfully updated."
209
- })
210
- return res
215
+ message: this.$t("mapo.mediaManager.fileInfo"),
216
+ });
217
+ return res;
211
218
  },
212
219
  processResponse(resp) {
213
220
  this.medias = resp?.media?.items || [];
@@ -12,12 +12,13 @@
12
12
  >
13
13
  <template v-slot:actions>
14
14
  <v-spacer></v-spacer>
15
- <v-btn v-if="select == 'multi'" color="primary" text @click="done">done</v-btn>
15
+ <v-btn v-if="select == 'multi'" color="primary" text @click="done">{{ $t("mapo.apply") }}</v-btn>
16
16
  </template>
17
17
  </media-manager>
18
18
  </v-dialog>
19
19
  </div>
20
20
  </template>
21
+
21
22
  <script>
22
23
  export default {
23
24
  name: "MediaManagerDialog",
@@ -18,31 +18,31 @@
18
18
  <v-select
19
19
  v-model="editedItem.folder"
20
20
  :items="folderOptions"
21
- label="Folder"
21
+ :label="$t('mapo.folder')"
22
22
  ></v-select>
23
23
  </v-col>
24
24
  <v-col cols="12">
25
25
  <v-text-field
26
26
  v-model="editedItem.name"
27
- label="Name"
27
+ :label="$t('mapo.name')"
28
28
  ></v-text-field>
29
29
  </v-col>
30
30
  <v-col cols="12">
31
31
  <v-text-field
32
32
  v-model="editedItem.title"
33
- label="Title"
33
+ :label="$('titleTag')"
34
34
  ></v-text-field>
35
35
  </v-col>
36
36
  <v-col cols="12">
37
37
  <v-text-field
38
38
  v-model="editedItem.description"
39
- label="Description"
39
+ :label="$t('mapo.description')"
40
40
  ></v-text-field>
41
41
  </v-col>
42
42
  <v-col cols="12">
43
43
  <v-text-field
44
44
  v-model="editedItem.alt_text"
45
- label="Alt name"
45
+ :label="$t('mapo.altTag')"
46
46
  ></v-text-field>
47
47
  </v-col>
48
48
  </v-row>
@@ -132,8 +132,7 @@ export default {
132
132
  ).then(response => {
133
133
  if (this.mediaList && this.mediaList.length) {
134
134
  this.$mapo.$snack.open({
135
- message: `${response.length ||
136
- this.mediaList.length} files succesfully uploaded`
135
+ message: this.$t("mapo.mediaUploader.success", {numberFiles: response.length || this.mediaList.length})
137
136
  });
138
137
  this.$emit("Upload", (response.length && response) || this.mediaList);
139
138
  this.$refs.closeButton.$el.click();
@@ -3,7 +3,7 @@
3
3
  {{ message }}
4
4
  <template v-slot:action="{ attrs }">
5
5
  <v-btn :color="color" text v-bind="attrs" @click="closeSnack">
6
- Close
6
+ {{ $t("mapo.close") }}
7
7
  </v-btn>
8
8
  </template>
9
9
  </v-snackbar>
@@ -56,7 +56,6 @@ export default {
56
56
  };
57
57
  </script>
58
58
 
59
-
60
59
  <docs>
61
60
  ### Example usage:
62
61
 
@@ -67,4 +66,4 @@ this.$mapo.$snack.open({
67
66
  });
68
67
  ```
69
68
 
70
- </docs>
69
+ </docs>
@@ -14,26 +14,10 @@
14
14
  />
15
15
  </v-list>
16
16
  <v-divider></v-divider>
17
- <v-list-item v-if="$mapo.$auth.user.isLoggedIn" dense class="logout__button" link @click.native="logout">
18
- <v-list-item-icon>
19
- <v-icon>mdi-logout</v-icon>
20
- </v-list-item-icon>
21
- <v-list-item-title> Logout </v-list-item-title>
22
- </v-list-item>
17
+ <LogoutButton></LogoutButton>
23
18
  </div>
24
19
  </template>
25
20
 
26
- <style lang="scss" scoped>
27
- .logout__button{
28
- &.theme--light{
29
- background: #ffffffd6;
30
- filter: invert(1);
31
- }
32
- &.theme--dark{
33
- background: #121212;
34
- }
35
- }
36
- </style>
37
21
  <script>
38
22
  import { buildRoutes } from "../routebuilder";
39
23
 
@@ -43,19 +27,19 @@ export default {
43
27
  props: {
44
28
  forceCollapse: {
45
29
  type: Boolean,
46
- default: false
47
- }
30
+ default: false,
31
+ },
48
32
  },
49
33
  data() {
50
34
  return {
51
35
  defaultIcon: ({ label }) => `mdi-alpha-${label[0]}-box`.toLowerCase(),
52
- routes: this.routes
36
+ routes: this.routes,
53
37
  };
54
38
  },
55
39
  mounted() {
56
40
  this.routes = this.buildRoutes(
57
41
  this.$router.options.routes.filter(
58
- route => route.meta && route.meta.sidebarFooter === true
42
+ (route) => route.meta && route.meta.sidebarFooter === true
59
43
  )
60
44
  );
61
45
  },
@@ -63,9 +47,6 @@ export default {
63
47
  buildRoutes(routes) {
64
48
  return buildRoutes(routes, this.defaultIcon);
65
49
  },
66
- logout() {
67
- this.$store.dispatch("mapo/user/logout");
68
- }
69
- }
50
+ },
70
51
  };
71
52
  </script>
@@ -12,7 +12,7 @@
12
12
  <v-icon>{{ icon }}</v-icon>
13
13
  </v-list-item-icon>
14
14
  <v-list-item-title>
15
- {{ label }}
15
+ {{ label.translate ? $t(label.translate) : label }}
16
16
  </v-list-item-title>
17
17
  <v-icon
18
18
  class="expand-icon"
@@ -149,7 +149,7 @@ export default {
149
149
  },
150
150
  props: {
151
151
  link: String,
152
- label: String,
152
+ label: String | Object,
153
153
  icon: String,
154
154
  childrens: Array,
155
155
  meta: Object,
@@ -10,7 +10,7 @@
10
10
  <span v-if="isLoggedIn">
11
11
  {{ username }}
12
12
  </span>
13
- <NuxtLink v-else to="/login"> Login </NuxtLink>
13
+ <NuxtLink v-else to="/login">{{ $t("mapo.login") }}</NuxtLink>
14
14
  </v-list-item-title>
15
15
  <v-btn icon @click.stop="toggleMiniVariant">
16
16
  <v-icon>mdi-chevron-left</v-icon>
@@ -39,4 +39,4 @@ export default {
39
39
  },
40
40
  },
41
41
  };
42
- </script>
42
+ </script>
package/defaults.js CHANGED
@@ -1,29 +1,75 @@
1
- import colors from 'vuetify/es5/util/colors'
1
+ import colors from "vuetify/es5/util/colors";
2
+ import { it, en } from "vuetify/lib/locale";
2
3
 
3
4
  export default {
4
- customVariables: ['@mapomodule/uikit/assets/variables.scss'],
5
- theme: {
6
- dark: true,
7
- themes: {
8
- dark: {
9
- primary: '#51beaa',
10
- accent: colors.grey.darken3,
11
- secondary: colors.amber.darken3,
12
- info: colors.teal.lighten1,
13
- warning: colors.amber.base,
14
- error: '#FF5252',
15
- success: colors.green.accent3
5
+ vuetify: {
6
+ customVariables: ["@mapomodule/uikit/assets/variables.scss"],
7
+ theme: {
8
+ dark: true,
9
+ themes: {
10
+ dark: {
11
+ primary: "#51beaa",
12
+ accent: colors.grey.darken3,
13
+ secondary: colors.amber.darken3,
14
+ info: colors.teal.lighten1,
15
+ warning: colors.amber.base,
16
+ error: "#FF5252",
17
+ success: colors.green.accent3,
18
+ },
19
+ light: {
20
+ primary: "#51beaa",
21
+ accent: colors.indigo.accent1,
22
+ secondary: colors.amber.accent2,
23
+ info: colors.teal.lighten1,
24
+ warning: colors.amber.base,
25
+ error: "#FF5252",
26
+ success: colors.green.accent3,
27
+ },
16
28
  },
17
- light: {
18
- primary: '#51beaa',
19
- accent: colors.indigo.accent1,
20
- secondary: colors.amber.accent2,
21
- info: colors.teal.lighten1,
22
- warning: colors.amber.base,
23
- error: '#FF5252',
24
- success: colors.green.accent3
29
+ },
30
+ lang: {
31
+ locales: { en, it },
32
+ },
33
+ treeShake: false,
34
+ },
35
+ i18n: {
36
+ detectBrowserLanguage: {
37
+ useCookie: true,
38
+ cookieKey: "i18n_redirected",
39
+ redirectOn: "root",
40
+ },
41
+ locales: [
42
+ {
43
+ code: "en",
44
+ name: "English",
45
+ file: "en-US.js",
46
+ iso: "en-US",
47
+ },
48
+ {
49
+ code: "it",
50
+ name: "Italiano",
51
+ file: "it-IT.js",
52
+ iso: "it-IT",
53
+ },
54
+ ],
55
+ lazy: true,
56
+ langDir: __dirname + "/translations/",
57
+ defaultLocale: "en",
58
+ strategy: "no_prefix",
59
+ onBeforeLanguageSwitch: (
60
+ oldLocale,
61
+ newLocale,
62
+ isInitialSetup,
63
+ context
64
+ ) => {
65
+ const locale =
66
+ context.i18n.locales.find((l) => l.code === newLocale) || {};
67
+ const isRTL = locale.dir === "rtl";
68
+ if (isInitialSetup) {
69
+ context.app.vuetify.preset.rtl = isRTL;
25
70
  }
26
- }
71
+ context.app.vuetify.framework.lang.current = locale.iso ? locale.iso.split("-")[0] : locale.code;
72
+ context.app.vuetify.framework.rtl = isRTL;
73
+ },
27
74
  },
28
- treeShake: false
29
- }
75
+ };
package/module.js CHANGED
@@ -20,7 +20,15 @@ export default async function (moduleOptions) {
20
20
  const userModuleOptions = Object.keys(moduleOptions).length === 0 ? (this.options['mapo'] || {}) : moduleOptions
21
21
 
22
22
  // INJECT VUETIFY MODULE
23
- this.requireModule(['@nuxtjs/vuetify', (this.options && this.options.vuetify) || userModuleOptions.vuetify || mapoDefaults.vuetify || {}])
23
+ this.requireModule(['@nuxtjs/vuetify', {
24
+ ...((this.options && this.options.vuetify) || userModuleOptions.vuetify || mapoDefaults.vuetify || {}),
25
+ lang: userModuleOptions.vuetify?.lang || mapoDefaults.vuetify.lang
26
+ }]);
27
+ // INJECT I18N MODULE
28
+ this.requireModule(['@nuxtjs/i18n', {
29
+ ...((this.options && this.options.i18n) || userModuleOptions.i18n || mapoDefaults.i18n || {}),
30
+ onBeforeLanguageSwitch: userModuleOptions.i18n?.onBeforeLanguageSwitch || mapoDefaults.i18n.onBeforeLanguageSwitch
31
+ }]);
24
32
 
25
33
  // INJECT ALL LAYOUTS
26
34
  const layouts = (await resolver.resolveRelative(__dirname, 'layouts')).map(({ src }) => src)
@@ -44,7 +52,7 @@ export default async function (moduleOptions) {
44
52
  })
45
53
  this.nuxt.hook('components:extend', (components) => {
46
54
  const clearName = (name) => name.replace(/^Mapoverride/, '').replace(/^mapoverride-/, '')
47
- const componentsOverride = Object.values(components.reduce((map, comp) => (
55
+ const componentsOverride = Object.values(components.reduce((map, comp) => (
48
56
  { ...map, [clearName(comp.pascalName)]: {...comp, pascalName:clearName(comp.pascalName), kebabName:clearName(comp.kebabName)} }
49
57
  ), {}))
50
58
  components.length = 0
@@ -72,7 +80,7 @@ export default async function (moduleOptions) {
72
80
  loader: require.resolve(path.resolve(__dirname, '../utils/loaders/dummy-loader.js'))
73
81
  })
74
82
  })
75
-
83
+
76
84
  }
77
85
 
78
86
  module.exports.meta = require('./package.json')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
- "version": "1.0.0-alpha.23",
3
+ "version": "1.0.0-alpha.24",
4
4
  "license": "MIT",
5
5
  "description": "This is part of Mapo nuxt module. Injects Mapo ui components in the nuxt component discovery system.",
6
6
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
@@ -8,11 +8,12 @@
8
8
  "main": "./module.js",
9
9
  "dependencies": {
10
10
  "@mapomodule/utils": "^1.0.0-alpha.23",
11
+ "@nuxtjs/i18n": "^7.2.2",
11
12
  "@nuxtjs/vuetify": "^1.12.3",
12
13
  "vuedraggable": "^2.24.3"
13
14
  },
14
15
  "publishConfig": {
15
16
  "access": "public"
16
17
  },
17
- "gitHead": "19399823330cb0123d2b224e857fb3094351df95"
18
+ "gitHead": "0d7a1d128b02ad74c49da6e89ee60a546fec21ba"
18
19
  }
package/pages/index.vue CHANGED
@@ -7,7 +7,7 @@
7
7
  </h1>
8
8
  <br>
9
9
  <br>
10
- <code>Congratulations!! 🥳 You succesfully installed Mapo! </code>
10
+ <code>{{ $t('mapo.index.welcomeMessage') }}</code>
11
11
  <br>
12
12
  <br>
13
13
  <code>
@@ -0,0 +1,129 @@
1
+ export default {
2
+ mapo: {
3
+ // Generics
4
+ cancel: "Cancel",
5
+ save: "Save",
6
+ apply: "Apply",
7
+ confirm: "Confirm",
8
+ ok: "OK",
9
+ close: "Close",
10
+ edit: "Edit",
11
+ delete: "Delete",
12
+ add: "Add",
13
+ remove: "Remove",
14
+ clear: "Clear",
15
+ expand: "Expand",
16
+ collapse: "Collapse",
17
+ search: "Search...",
18
+ create: "Create",
19
+ createContinue: "Create and continue",
20
+ saveContinue: "Save and continue",
21
+ back: "Back",
22
+ genericError: "Something whent bad, please try again later...",
23
+ confirmDelete: "Are you sure you want to delete this item?",
24
+ fetchingData: "Fetching data...",
25
+ login: "Login",
26
+ loginError: "Cannot login right now. Try again later.",
27
+ logout: "Logout",
28
+ // Elements
29
+ name: "Name",
30
+ description: "Description",
31
+ mime: "MIME Type",
32
+ fileName: "File name",
33
+ folder: "Folder",
34
+ created: "Created at",
35
+ size: "Size",
36
+ altTag: "Alt Tag",
37
+ titleTag: "Title Tag",
38
+ linkedModels: "Linked Models",
39
+
40
+ // pages/index.vue
41
+ index: {
42
+ welcomeMessage:
43
+ "Congratulations!! 🥳 You successfully installed Mapo!",
44
+ },
45
+
46
+ // ConfirmDialog.vue
47
+ confirmDialog: {
48
+ areYouSure: "Are you sure of what you are doing?",
49
+ },
50
+ // DropArea.vue
51
+ dropArea: {
52
+ dropOrClick: "Drop your file(s) here, or click to select them.",
53
+ onlyOneFile: "Only one file can be uploaded at a time...",
54
+ },
55
+
56
+ // Form/fields/MediaField.vue
57
+ mediaField: {
58
+ confirmRemove: "Are you sure to want to remove this media?",
59
+ },
60
+ // Form/fields/MediaM2mField.vue
61
+ mediaM2MField: {
62
+ mediaCarousel: "Media Carousel",
63
+ newSelection: "New Selection",
64
+ },
65
+ // Form/fields/Repeater.vue
66
+ repeater: {
67
+ addHere: "Add here",
68
+ selectTemplate: "Select template",
69
+ item: "Item {numberItem}",
70
+ },
71
+ // Form/fields/SeoPreview.vue
72
+ seoPreview: {
73
+ title: "It was the best of times, it was the blurst of times, it was the ...",
74
+ description:
75
+ "This is an example description that will get replaced when you start typing. Make sure to keep descriptions mobile-friendly and keyword-rich!",
76
+ },
77
+
78
+ // List/List.vue
79
+ list: {
80
+ allSelected: "All items selected",
81
+ NSelected: "{numberItems} items selected",
82
+ selectAll: "Select all",
83
+ },
84
+ // List/ListActions.vue
85
+ listActions: {
86
+ groupActions: "Group actions",
87
+ permanentDelete: "Permanent delete",
88
+ selectionRequired: "You need to select at least one item.",
89
+ },
90
+ // List/ListFilters.vue
91
+ listFilters: { filter: "Filter" },
92
+ // List/ListHead.vue
93
+ listHead: { addNew: "Add new" },
94
+ // List/ListQuickEdit.vue
95
+ listQuickEdit: { badInput: "Bad input, correct wrong fields." },
96
+ // List/ListTable.vue
97
+ listTable: {
98
+ quickAdd: "Quick Add",
99
+ toggleOrder: "Toggle reordering",
100
+ errorOrder: "Reorder failed",
101
+ },
102
+
103
+ // MediaManager/MediaEditor.vue
104
+ mediaEditor: {
105
+ changeFile: "Change File",
106
+ maintainOldUrl: "Maintain old URL",
107
+ confirmDelete: "Are you sure you want to delete this media?",
108
+ },
109
+ // MediaManager/MediaFolders.vue
110
+ mediaFolders: {
111
+ noFolders: "No folders here... Create a new one!",
112
+ newFolder: "Add new folder",
113
+ editFolder: "Edit folder",
114
+ folderName: "Folder name",
115
+ confirmDelete:
116
+ "Are you sure to delele this folder and all its content?",
117
+ },
118
+ // MediaManager/MediaGallery.vue
119
+ mediaGallery: { noMediaFound: "No media found..." },
120
+ // MediaManager/MediaManager.vue
121
+ mediaManager: {
122
+ gallery: "Gallery",
123
+ uploader: "Uploader",
124
+ fileInfo: "File info succesfully updated",
125
+ },
126
+ // MediaManager/MediaUploader.vue
127
+ mediaUploader: { success: "{numberFiles} files succesfully uploaded" },
128
+ },
129
+ };