@mapomodule/uikit 1.0.0-alpha.26 → 1.0.0-alpha.27

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 CHANGED
@@ -3,6 +3,26 @@
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.27](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2022-08-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **colorfield:** return string in colorfield ([3acbd5c](https://github.com/lotrekagency/mapo/commit/3acbd5caa6555835c168718303f1ca555e8efc75))
12
+ * **detail:** added force option to languages ([8ed4b69](https://github.com/lotrekagency/mapo/commit/8ed4b69f746b136755cbda17cdab176632869cdf))
13
+
14
+
15
+ ### Features
16
+
17
+ * **fields:** added color field ([ead7448](https://github.com/lotrekagency/mapo/commit/ead744861be2c9c24ea2911e68c8b4d1259cab15))
18
+ * **mediapreview:** added title tag to medias ([d063162](https://github.com/lotrekagency/mapo/commit/d063162036a4294fbd3c5ed347dfde78061a1f33))
19
+ * implemented enhanced media compomentent ([fe336e1](https://github.com/lotrekagency/mapo/commit/fe336e170d42a67562c8e4abfa387b806e7c7a6a))
20
+ * implemented media preview through MediaPreview component ([575c285](https://github.com/lotrekagency/mapo/commit/575c2853eb774ca4c635ce099302a429cc479be5))
21
+
22
+
23
+
24
+
25
+
6
26
  # [1.0.0-alpha.26](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2022-08-11)
7
27
 
8
28
 
@@ -141,6 +141,7 @@ export default {
141
141
  this.resolve(this.response);
142
142
  }
143
143
  this.dialog = false;
144
+ this.response = false;
144
145
  this.options = { ...this.optionsBk };
145
146
  }
146
147
  }
@@ -186,6 +186,11 @@ export default {
186
186
  type: Array,
187
187
  default: () => []
188
188
  },
189
+ // Forces use of languages passed as prop, instead of those loaded with model
190
+ forceLanguages: {
191
+ type: Boolean,
192
+ default: false
193
+ },
189
194
  // The url of the endpoint to which the payload is to be sent. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
190
195
  endpoint: {
191
196
  type: String,
@@ -320,7 +325,7 @@ export default {
320
325
  return !Object.keys(this.model).length;
321
326
  },
322
327
  langs() {
323
- return (this.modelLanguages || []).length ? this.modelLanguages : this.languages;
328
+ return (!this.forceLanguages && (this.modelLanguages || []).length) ? this.modelLanguages : this.languages;
324
329
  },
325
330
  slotBindings() {
326
331
  return {
@@ -410,6 +415,7 @@ Here the list of the FieldConfiguration type association.
410
415
  - `file` ==> [file-field](/components/Form/fields/FileField/),
411
416
  - `editor` ==> [wyg-editor](/components/Form/fields/wygEditor/wygEditor/),
412
417
  - `media` ==> [media-field](/components/Form/fields/MediaField/),
418
+ - `enhancedMedia` ==> [enhanced-media-field](/components/Form/fields/EnhancedMediaField/),
413
419
  - `mediaList` ==> [media-m2m-field](/components/Form/fields/MediaM2mField/)
414
420
  - `m2m` or `fks` ==> [fks-field](/components/Form/fields/FksField/),
415
421
  - `repeater` ==> [repeater](/components/Form/fields/Repeater/),
@@ -26,6 +26,8 @@ import DateField from "@mapomodule/uikit/components/Form/fields/DateField.vue";
26
26
  import FksField from "@mapomodule/uikit/components/Form/fields/FksField.vue";
27
27
  import MediaM2mField from "@mapomodule/uikit/components/Form/fields/MediaM2mField.vue";
28
28
  import MediaField from "@mapomodule/uikit/components/Form/fields/MediaField.vue";
29
+ import EnhancedMediaField from "@mapomodule/uikit/components/Form/fields/EnhancedMediaField.vue";
30
+
29
31
  import SeoPreview from "@mapomodule/uikit/components/Form/fields/SeoPreview.vue";
30
32
  import FileField from "@mapomodule/uikit/components/Form/fields/FileField.vue";
31
33
  import Repeater from "@mapomodule/uikit/components/Form/fields/Repeater.vue"
@@ -46,6 +48,7 @@ export default {
46
48
  FksField,
47
49
  MediaM2mField,
48
50
  MediaField,
51
+ EnhancedMediaField,
49
52
  SeoPreview,
50
53
  FileField,
51
54
  Repeater,
@@ -8,11 +8,13 @@ const mapping = {
8
8
  file: "FileField",
9
9
  editor: "wygEditor",
10
10
  media: "MediaField",
11
+ enhancedMedia: "EnhancedMediaField",
11
12
  fks: "FksField",
12
13
  m2m: "FksField",
13
14
  mediaList: "MediaM2mField",
14
15
  seoPreview: "SeoPreview",
15
16
  repeater: "Repeater",
17
+ color: "ColorField"
16
18
  }
17
19
 
18
20
  const props = {
@@ -23,6 +25,9 @@ const props = {
23
25
  MediaField: {
24
26
  outlined: false
25
27
  },
28
+ EnhancedMediaField: {
29
+ outlined: false
30
+ },
26
31
  vSwitch: {
27
32
  inset: true,
28
33
  ripple: false
@@ -55,4 +60,4 @@ const accessor = {
55
60
  }
56
61
  export default {
57
62
  mapping, props, accessor
58
- }
63
+ }
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <div>
3
+ <v-menu
4
+ v-model="menu"
5
+ :close-on-content-click="false"
6
+ transition="scale-transition"
7
+ offset-y
8
+ min-width="auto"
9
+ >
10
+ <template v-slot:activator="{ on, attrs }">
11
+ <v-text-field
12
+ v-model="model"
13
+ readonly
14
+ v-bind="{ ...$attrs, ...attrs }"
15
+ v-on="readonly ? undefined : on"
16
+ class="rounded-0"
17
+ >
18
+ <template v-slot:prepend-inner>
19
+ <div class="color-picker-inner-icon" :style="`background-color: ${model}`"></div>
20
+ </template>
21
+ </v-text-field>
22
+ </template>
23
+ <v-card>
24
+ <v-color-picker
25
+ v-model="model"
26
+ mode="hexa"
27
+ hide-mode-switch
28
+ v-bind="$attrs"
29
+ v-on="$listeners"
30
+ ></v-color-picker>
31
+ </v-card>
32
+ </v-menu>
33
+ </div>
34
+ </template>
35
+
36
+ <style scoped>
37
+ .color-picker-inner-icon {
38
+ width: 20px;
39
+ height: 20px;
40
+ border-radius: 20px;
41
+ }
42
+ </style>
43
+
44
+ <script>
45
+ /**
46
+ * This component wraps vuetify's color picker as a Mapo field.
47
+ */
48
+ export default {
49
+ name: "ColorField",
50
+ data() {
51
+ return {
52
+ model: this.value || "",
53
+ menu: null,
54
+ };
55
+ },
56
+ props: {
57
+ // V-model property. Color must be hex codified.
58
+ value: {
59
+ type: String,
60
+ },
61
+ // This set the component status to readonly, stopping the user interaction.
62
+ readonly: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ },
67
+ watch: {
68
+ value(val) {
69
+ this.model = val || "";
70
+ },
71
+ model(val) {
72
+ this.$emit("input", val);
73
+ },
74
+ },
75
+ };
76
+ </script>
@@ -0,0 +1,224 @@
1
+ <template>
2
+ <div>
3
+ <v-text-field
4
+ v-if="title"
5
+ v-model="title"
6
+ class="mb-n8 pb-0"
7
+ solo
8
+ readonly
9
+ v-bind="$attrs"
10
+ ></v-text-field>
11
+
12
+ <!-- If the media is not avaible, it shows a btn to add new media -->
13
+ <v-card
14
+ class="rounded-0"
15
+ v-bind="{
16
+ height,
17
+ width,
18
+ maxWidth,
19
+ maxHeight,
20
+ minWidth,
21
+ minHeight,
22
+ ...$attrs,
23
+ }"
24
+ >
25
+ <MediaPreview
26
+ class="media-preview"
27
+ :key="childKey"
28
+ v-if="mediaExists"
29
+ :media="internalValue"
30
+ :video-preview="internalValue.is_image ? false : true"
31
+ />
32
+
33
+ <v-card-title>{{ label }}</v-card-title>
34
+ <v-card-text v-show="internalValue">
35
+ <h4>{{ $t("mapo.fileName") }}:</h4>
36
+ {{ fileName }}
37
+ <h4>{{ $t("mapo.created") }}:</h4>
38
+ {{ fileInfo.created }}
39
+ </v-card-text>
40
+ <v-card-actions>
41
+ <template v-if="!internalValue && !rmAddBtn">
42
+ <v-btn
43
+ tile
44
+ :disabled="readonly"
45
+ @click="editing = true"
46
+ block
47
+ :min-height="minHeight"
48
+ >
49
+ <v-icon size="80"> mdi-plus-circle-outline </v-icon>
50
+ </v-btn>
51
+ </template>
52
+ <template v-else>
53
+ <v-row >
54
+ <v-col align="center">
55
+ <v-btn
56
+ :disabled="readonly"
57
+ @click="editing = true"
58
+ block
59
+ >
60
+ <v-icon>mdi-pencil</v-icon>
61
+ </v-btn>
62
+ </v-col>
63
+ <v-col align="center">
64
+ <v-btn
65
+ :disabled="readonly"
66
+ @click="confirmDelete"
67
+ color="error"
68
+ block
69
+ >
70
+ <v-icon>mdi-delete</v-icon>
71
+ </v-btn>
72
+ </v-col>
73
+ </v-row>
74
+ </template>
75
+ </v-card-actions>
76
+ </v-card>
77
+ <!-- Select media dialog -->
78
+ <media-manager-dialog
79
+ v-model="editing"
80
+ select="single"
81
+ v-on:selectionChange="update"
82
+ v-bind="$attrs"
83
+ >
84
+ </media-manager-dialog>
85
+
86
+ <v-messages v-model="errorMessages" color="error" class="mt-2" />
87
+ </div>
88
+ </template>
89
+
90
+ <style scoped>
91
+ .media-preview {
92
+ cursor: pointer;
93
+ }
94
+ </style>
95
+
96
+ <script>
97
+ export default {
98
+ name: "EnhancedMediaField",
99
+ data() {
100
+ return {
101
+ internalValue: null,
102
+ editing: false,
103
+ childKey: 0,
104
+ };
105
+ },
106
+
107
+ props: {
108
+ value: Object,
109
+ label: String,
110
+ title: {
111
+ type: String,
112
+ default: () => "",
113
+ },
114
+ errorMessages: {
115
+ type: String | Array,
116
+ default: () => [],
117
+ },
118
+ rmAddBtn: {
119
+ type: Boolean,
120
+ default: false,
121
+ },
122
+ //image reflections
123
+ aspectRatio: {
124
+ type: String | Number,
125
+ default: undefined,
126
+ },
127
+ contain: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ height: {
132
+ type: String | Number,
133
+ default: "100%",
134
+ },
135
+ width: {
136
+ type: String | Number,
137
+ default: "100%",
138
+ },
139
+ maxWidth: {
140
+ type: String | Number,
141
+ default: undefined,
142
+ },
143
+ maxHeight: {
144
+ type: String | Number,
145
+ default: undefined,
146
+ },
147
+ minWidth: {
148
+ type: String | Number,
149
+ default: undefined,
150
+ },
151
+ minHeight: {
152
+ type: String | Number,
153
+ default: 300,
154
+ },
155
+ // This set the component status to readonly, stopping the user interaction.
156
+ readonly: {
157
+ type: Boolean,
158
+ default: false,
159
+ },
160
+ },
161
+
162
+ computed: {
163
+ mediaExists() {
164
+ return !!this.internalValue?.file;
165
+ },
166
+ fileInfo() {
167
+ return {
168
+ title: this.internalValue?.title,
169
+ created: new Date(this.internalValue?.created).toLocaleDateString(
170
+ this.internalValue?.language_code
171
+ ),
172
+ };
173
+ },
174
+ fileName() {
175
+ return (
176
+ this.internalValue &&
177
+ this.internalValue.file &&
178
+ this.internalValue.file.split("/").pop()
179
+ );
180
+ },
181
+ },
182
+
183
+ methods: {
184
+ update(val) {
185
+ this.updateChild();
186
+ this.internalValue = val;
187
+ },
188
+ confirmDelete() {
189
+ this.$mapo.$confirm
190
+ .open({
191
+ title: this.$t("mapo.remove"),
192
+ question: this.$t("mapo.mediaField.confirmRemove"),
193
+ approveButton: {
194
+ text: this.$t("mapo.remove"),
195
+ attrs: { color: "red", text: true },
196
+ },
197
+ })
198
+ .then((res) => (res ? (this.internalValue = null) : null));
199
+ },
200
+ updateChild() {
201
+ this.childKey += 1;
202
+ },
203
+ isImage(val) {
204
+ if (!val?.is_image && val?.mime_type.includes("image")) {
205
+ Object.assign(val, { is_image: true });
206
+ }
207
+ },
208
+ },
209
+ watch: {
210
+ value(val) {
211
+ if (val !== this.internalValue) {
212
+ this.internalValue = val;
213
+ }
214
+ },
215
+ internalValue(val) {
216
+ this.isImage(val);
217
+ this.$emit("input", val);
218
+ },
219
+ },
220
+ mounted() {
221
+ this.internalValue = this.value;
222
+ },
223
+ };
224
+ </script>
@@ -16,7 +16,7 @@ export default {
16
16
  data() {
17
17
  return {
18
18
  model: null,
19
- options: [],
19
+ options: this.items || [],
20
20
  loading: false,
21
21
  };
22
22
  },
@@ -224,7 +224,7 @@ export default {
224
224
  },
225
225
  },
226
226
  mounted(){
227
- this.internalValue = this.val
227
+ this.internalValue = this.value
228
228
  }
229
229
  };
230
230
  </script>
@@ -24,7 +24,6 @@
24
24
  .darker__item {
25
25
  &.theme--light {
26
26
  background: #ffffffd6;
27
- filter: invert(1);
28
27
  }
29
28
  &.theme--dark {
30
29
  background: #121212;
@@ -11,6 +11,7 @@
11
11
  }"
12
12
  v-bind="$attrs"
13
13
  v-on="videoListeners"
14
+ :title="media.title || media.name"
14
15
  >
15
16
  <template v-slot:placeholder>
16
17
  <v-row class="fill-height ma-0" align="center" justify="center">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
- "version": "1.0.0-alpha.26",
3
+ "version": "1.0.0-alpha.27",
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>",
@@ -15,5 +15,5 @@
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
18
- "gitHead": "7bb048f2e4b92fa135e3c4738baa0efede92bffc"
18
+ "gitHead": "d028345c7ee4cdf43dac3e68d27d4b9f1ad4198c"
19
19
  }