@mapomodule/uikit 1.0.0-alpha.32 → 1.0.0-alpha.34

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,40 @@
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.34](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.33...v1.0.0-alpha.34) (2022-11-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix media dialog reset and selected visualization ([d04e6f2](https://github.com/lotrekagency/mapo/commit/d04e6f2269c059f083a84920befec35e52087857))
12
+ * fix repeater width ([f210aff](https://github.com/lotrekagency/mapo/commit/f210aff38bdd576eb1c7dfa07a1c6a8d0efc5a0d))
13
+ * fix some graphic issues in new media dialogue ([6895dab](https://github.com/lotrekagency/mapo/commit/6895dab303466cbf419a4500dd9fb432997e4c4b))
14
+ * fixed some interface glitch in media manager ([317f550](https://github.com/lotrekagency/mapo/commit/317f55087a741aada769304025294f46cc2a7044))
15
+ * little media manager graphic fixs ([9f9df7e](https://github.com/lotrekagency/mapo/commit/9f9df7e18429ba7905b3d64cfa2ea4dca9827680))
16
+
17
+
18
+ ### Features
19
+
20
+ * completely rewritten mediaField ([4b17d18](https://github.com/lotrekagency/mapo/commit/4b17d18c836608eb5f07ed0b42f45bb18cf8b30d))
21
+ * new m2m media field and moved media selection logic to store ([8094375](https://github.com/lotrekagency/mapo/commit/8094375712b7ad7bc10caeec71d8d5e5bca43edc))
22
+ * rewreitten media grids ([3818ca1](https://github.com/lotrekagency/mapo/commit/3818ca17dead56367e21edcf01f6910cb80cee25))
23
+ * rewritten media manager ([de18547](https://github.com/lotrekagency/mapo/commit/de185479bada77ee41786f9925681cdc5630e7fa))
24
+
25
+
26
+
27
+
28
+
29
+ # [1.0.0-alpha.33](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.32...v1.0.0-alpha.33) (2022-10-14)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * **repeater:** keep cloned array in repeater ([2d9254c](https://github.com/lotrekagency/mapo/commit/2d9254cef9a9ac17b488d3bac440dbde9bfc60cf))
35
+
36
+
37
+
38
+
39
+
6
40
  # [1.0.0-alpha.32](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.31...v1.0.0-alpha.32) (2022-09-28)
7
41
 
8
42
 
@@ -22,9 +22,6 @@ const props = {
22
22
  itemText: "text",
23
23
  itemValue: "value"
24
24
  },
25
- MediaField: {
26
- outlined: false
27
- },
28
25
  EnhancedMediaField: {
29
26
  outlined: false
30
27
  },
@@ -1,177 +1,125 @@
1
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
- <v-hover v-model="isHovered">
12
- <div style="position: relative">
13
- <v-img
14
- v-if="mediaExists"
15
- :src="internalValue.is_image && internalValue.file || null"
16
- :lazy-src="internalValue.is_image && internalValue.thumbnail || null"
17
- :class="{'grey lighten-2': !internalValue.is_image}"
18
- v-bind="{
19
- aspectRatio,
20
- contain,
21
- height,
22
- width,
23
- maxWidth,
24
- maxHeight,
25
- minWidth,
26
- minHeight,
27
- }"
28
- >
29
- <template v-slot:placeholder>
30
- <v-row
31
- v-if="internalValue"
32
- class="fill-height ma-0"
33
- align="center"
34
- justify="center"
35
- >
36
- <v-progress-circular
37
- v-if="internalValue.is_image"
38
- indeterminate
39
- color="grey"
40
- ></v-progress-circular>
41
- <div class="d-flex flex-column align-center justify-space-between fill-height" style="width: 100%" v-else>
42
- <div></div>
43
- <v-icon size="70px" color="grey">mdi-file</v-icon>
44
- <span class="grey--text text--darken-3 text-truncate pl-1 pr-8" style="width: 100%">{{fileName}}</span>
45
- </div>
46
- </v-row>
47
- </template>
48
- </v-img>
49
-
50
- <!-- If the media is not avaible, it shows a btn to add new media -->
51
- <v-card
52
- v-else-if="!rmAddBtn"
53
- class="rounded-0"
54
- v-bind="{
55
- height,
56
- width,
57
- maxWidth,
58
- maxHeight,
59
- minWidth,
60
- minHeight,
61
- ...$attrs,
62
- }"
63
- >
64
- <v-card-title>{{ label }}</v-card-title>
65
-
66
- <v-card-actions>
67
- <v-btn tile :disabled="readonly" @click="editing = true" block :min-height="minHeight">
68
- <v-icon size="80"> mdi-plus-circle-outline </v-icon>
69
- </v-btn>
70
- </v-card-actions>
71
- </v-card>
72
-
73
- <!-- Shows darkening overlay on image with buttons on top while hovered -->
74
- <v-overlay opacity="0.3" absolute :value="overlay">
75
- <v-row>
76
- <v-col cols="12">
77
- <h3>{{ label }}</h3>
78
- </v-col>
79
- </v-row>
80
- <v-row>
81
- <v-col cols="6">
82
- <v-btn :disabled="readonly" @click="editing = true" fab v-bind="$attrs">
83
- <v-icon>mdi-pencil</v-icon>
84
- </v-btn>
85
- </v-col>
86
-
87
- <v-col cols="6">
88
- <v-btn :disabled="readonly" @click="confirmDelete" fab v-bind="$attrs">
89
- <v-icon>mdi-delete</v-icon>
90
- </v-btn>
91
- </v-col>
92
- </v-row>
93
- </v-overlay>
94
-
95
- <!-- Select media dialog -->
96
- <media-manager-dialog
97
- v-model="editing"
98
- select="single"
99
- v-on:selectionChange="update"
100
- v-bind="$attrs"
101
- >
102
- </media-manager-dialog>
103
-
104
- </div>
105
- </v-hover>
106
- <v-messages
107
- v-model="errorMessages"
108
- color="error"
109
- class="mt-2"
110
- />
111
- </div>
2
+ <media-manager-dialog
3
+ select="single"
4
+ :selected.sync="model"
5
+ v-bind="$attrs"
6
+ >
7
+ <template v-slot:activator="{ on, attrs }">
8
+ <v-text-field
9
+ readonly
10
+ v-bind="{ ...$attrs, ...attrs }"
11
+ v-on="readonly ? undefined : on"
12
+ class="media-field--card rounded-0"
13
+ :class="{ 'media-field--selected': !!model }"
14
+ :value="model ? ' ' : ''"
15
+ >
16
+ <template v-if="model" v-slot:append>
17
+ <MediaPreview
18
+ v-if="model"
19
+ :media="model"
20
+ :video-preview="!model.is_image"
21
+ class="media-field--preview"
22
+ />
23
+ <div class="media-field--info caption text--secondary">
24
+ <p>
25
+ <b>{{ $t("mapo.fileName") }}:</b> {{ fileName }}
26
+ </p>
27
+ <p>
28
+ <b>{{ $t("mapo.size") }}:</b> {{ fileSize }}
29
+ </p>
30
+ <p>
31
+ <b>{{ $t("mapo.mime") }}:</b> {{ model.mime_type }}
32
+ </p>
33
+ <p>
34
+ <b>{{ $t("mapo.altTag") }}:</b> {{ model.alt_text }}
35
+ </p>
36
+ </div>
37
+ <v-btn
38
+ @click.native="clear"
39
+ class="media-field--info-btn"
40
+ tile
41
+ small
42
+ icon
43
+ ><v-icon>mdi-close</v-icon></v-btn
44
+ >
45
+ </template>
46
+ </v-text-field>
47
+ </template>
48
+ </media-manager-dialog>
112
49
  </template>
50
+ <style lang="scss">
51
+ .media-field--card.v-text-field > .v-input__control > .v-input__slot {
52
+ input {
53
+ cursor: pointer;
54
+ }
55
+ }
56
+ .media-field--selected {
57
+ .v-text-field__slot {
58
+ position: absolute !important;
59
+ width: 100%;
60
+ height: 100%;
61
+ }
62
+ .v-input__append-inner {
63
+ margin-left: 0 !important;
64
+ width: 100%;
65
+ }
66
+ &.media-field--card.v-text-field > .v-input__control > .v-input__slot {
67
+ cursor: pointer;
68
+ input {
69
+ position: absolute;
70
+ cursor: pointer;
71
+ width: 100%;
72
+ min-height: 100%;
73
+ }
74
+ }
75
+ }
113
76
 
114
- <style scoped>
77
+ .media-field--preview {
78
+ width: 100px;
79
+ height: 100px;
80
+ border: 1px solid;
81
+ border-color: inherit;
82
+ margin-bottom: 10px;
83
+ margin-right: 12px;
84
+ }
85
+ .media-field--info {
86
+ width: 100%;
87
+ max-width: calc(100% - 112px);
88
+ p {
89
+ margin-bottom: 0;
90
+ overflow: hidden;
91
+ text-overflow: ellipsis;
92
+ white-space: nowrap;
93
+ }
94
+ &-btn {
95
+ position: absolute;
96
+ top: 0;
97
+ right: 0;
98
+ }
99
+ }
100
+ .media-field--add {
101
+ width: 100px;
102
+ margin-bottom: 10px;
103
+ }
115
104
  </style>
116
105
 
117
106
  <script>
107
+ import { humanFileSize } from "@mapomodule/utils/helpers/formatters";
108
+
109
+ /**
110
+ * This component is made to manage media fields for single selection.
111
+ */
118
112
  export default {
119
- name: "MediaField",
113
+ name: "MultimediaField",
120
114
  data() {
121
115
  return {
122
- internalValue: null,
123
- editing: false,
124
- isHovered: false,
116
+ model: this.value,
125
117
  };
126
118
  },
127
-
128
119
  props: {
129
- value: Object,
130
- label: String,
131
- title: {
132
- type: String,
133
- default: () => "",
134
- },
135
- errorMessages: {
136
- type: String | Array,
137
- default: () => []
138
- },
139
- rmAddBtn: {
140
- type: Boolean,
141
- default: false,
142
- },
143
- //image reflections
144
- aspectRatio: {
145
- type: String | Number,
146
- default: undefined,
147
- },
148
- contain: {
149
- type: Boolean,
150
- default: false,
151
- },
152
- height: {
153
- type: String | Number,
154
- default: "100%",
155
- },
156
- width: {
157
- type: String | Number,
158
- default: "100%",
159
- },
160
- maxWidth: {
161
- type: String | Number,
162
- default: undefined,
163
- },
164
- maxHeight: {
165
- type: String | Number,
166
- default: undefined,
167
- },
168
- minWidth: {
169
- type: String | Number,
170
- default: undefined,
171
- },
172
- minHeight: {
173
- type: String | Number,
174
- default: 300,
120
+ // V-model property. Color must be hex codified.
121
+ value: {
122
+ type: Object | null,
175
123
  },
176
124
  // This set the component status to readonly, stopping the user interaction.
177
125
  readonly: {
@@ -179,52 +127,30 @@ export default {
179
127
  default: false,
180
128
  },
181
129
  },
182
-
183
130
  computed: {
184
- mediaExists() {
185
- return !!this.internalValue?.file;
186
- },
187
- overlay() {
188
- return this.isHovered && this.mediaExists;
189
- },
190
131
  fileName() {
191
- return this.internalValue && this.internalValue.file && this.internalValue.file.split("/").pop();
132
+ return this.model && this.model.file && this.model.file.split("/").pop();
192
133
  },
193
- },
194
-
195
- methods: {
196
- update(val) {
197
- this.internalValue = val;
134
+ dateCreated() {
135
+ return this.model && new Date(this.model.created).toLocaleString();
198
136
  },
199
- confirmDelete() {
200
- this.$mapo.$confirm
201
- .open({
202
- title: this.$t("mapo.remove"),
203
- question: this.$t("mapo.mediaField.confirmRemove"),
204
- approveButton: { text: this.$t("mapo.remove"), attrs: { color: "red", text: true } }
205
- })
206
- .then((res) => (res ? (this.internalValue = null) : null));
207
- },
208
- isImage(val) {
209
- if (!val?.is_image && val?.mime_type.includes("image")) {
210
- Object.assign(val, { is_image: true });
211
- }
137
+ fileSize() {
138
+ return this.model && humanFileSize(this.model.size);
212
139
  },
213
140
  },
214
-
141
+ methods:{
142
+ clear(event){
143
+ event.stopPropagation();
144
+ this.model = null;
145
+ }
146
+ },
215
147
  watch: {
216
148
  value(val) {
217
- if (val !== this.internalValue) {
218
- this.internalValue = val;
219
- }
149
+ this.model = val;
220
150
  },
221
- internalValue(val) {
222
- this.isImage(val)
151
+ model(val) {
223
152
  this.$emit("input", val);
224
153
  },
225
154
  },
226
- mounted(){
227
- this.internalValue = this.value
228
- }
229
155
  };
230
156
  </script>