comand-component-library 3.3.84 → 3.3.86

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 (38) hide show
  1. package/dist/comand-component-library.js +5623 -3929
  2. package/dist/comand-component-library.umd.cjs +4 -4
  3. package/dist/style.css +1 -1
  4. package/package.json +2 -2
  5. package/src/App.vue +215 -112
  6. package/src/assets/data/component-structure.json +228 -0
  7. package/src/assets/data/form-elements.json +156 -0
  8. package/src/assets/data/opening-hours.json +79 -37
  9. package/src/components/CmdAddressData.vue +187 -201
  10. package/src/components/CmdAddressDataItem.vue +306 -0
  11. package/src/components/CmdBox.vue +1 -0
  12. package/src/components/CmdBoxWrapper.vue +53 -5
  13. package/src/components/CmdFancyBox.vue +31 -4
  14. package/src/components/CmdForm.vue +98 -4
  15. package/src/components/CmdFormElement.vue +5 -1
  16. package/src/components/CmdHeadline.vue +179 -52
  17. package/src/components/CmdImage.vue +205 -76
  18. package/src/components/CmdImageGallery.vue +88 -85
  19. package/src/components/CmdListOfLinks.vue +63 -43
  20. package/src/components/CmdListOfLinksItem.vue +97 -0
  21. package/src/components/CmdLoginForm.vue +3 -6
  22. package/src/components/CmdMultistepFormProgressBar.vue +37 -8
  23. package/src/components/CmdOpeningHours.vue +280 -63
  24. package/src/components/CmdOpeningHoursItem.vue +264 -0
  25. package/src/components/{CmdPager.vue → CmdPagination.vue} +2 -2
  26. package/src/components/CmdSlideshow.vue +137 -10
  27. package/src/components/CmdSocialNetworks.vue +115 -28
  28. package/src/components/CmdSocialNetworksItem.vue +184 -0
  29. package/src/components/CmdTable.vue +0 -1
  30. package/src/components/CmdTextImageBlock.vue +158 -0
  31. package/src/components/CmdThumbnailScroller.vue +132 -12
  32. package/src/components/CmdToggleDarkMode.vue +58 -1
  33. package/src/components/EditComponentWrapper.vue +553 -0
  34. package/src/index.js +2 -2
  35. package/src/mixins/EditMode.vue +28 -9
  36. package/src/utils/editmode.js +30 -5
  37. package/src/components/CmdTextBlock.vue +0 -73
  38. package/src/editmode/editModeContext.js +0 -50
@@ -1,42 +1,129 @@
1
1
  <template>
2
2
  <div class="cmd-opening-hours">
3
- <!-- begin cmd-custom-headline -->
4
- <CmdHeadline v-if="cmdHeadline" v-bind="cmdHeadline" />
5
- <!-- end cmd-custom-headline -->
3
+ <!-- begin cmd-headline -->
4
+ <CmdHeadline
5
+ v-if="cmdHeadline?.headlineText || editModeContext"
6
+ v-bind="cmdHeadline"
7
+ />
8
+ <!-- end cmd-headline -->
6
9
 
7
10
  <!-- begin opening-status with link to detail-page -->
8
- <template v-if="link && link?.path && link?.show">
9
- <a v-if="link.type === 'href'" :href="link.path" :class="{closed: isClosed}">{{ textOpenClosed }}</a>
10
- <router-link v-if="link.type === 'router'" :to="link.path" :class="{closed: isClosed}">{{ textOpenClosed }}</router-link>
11
- <button v-if="link.type === 'button'" :class="['button', {closed: isClosed}]">{{ textOpenClosed }}</button>
11
+ <template v-if="!editing">
12
+ <template v-if="link && link?.path && link?.show">
13
+ <a v-if="link.type === 'href'" :href="link.path" :class="{closed: isClosed}">{{ textOpenClosed }}</a>
14
+ <router-link v-if="link.type === 'router'" :to="link.path" :class="{closed: isClosed}">{{
15
+ textOpenClosed
16
+ }}
17
+ </router-link>
18
+ <button v-if="link.type === 'button'" :class="['button', {closed: isClosed}]">{{
19
+ textOpenClosed
20
+ }}
21
+ </button>
22
+ </template>
23
+ <!-- end opening-status with link to detail-page -->
24
+
25
+ <!-- begin opening-status (without link) -->
26
+ <span v-else :class="{'closed': isClosed}">{{ textOpenClosed }}</span>
27
+ <!-- end opening-status (without link) -->
12
28
  </template>
13
- <!-- end opening-status with link to detail-page -->
14
29
 
15
- <!-- begin opening-status (without link) -->
16
- <span v-else :class="{'closed': isClosed}">{{ textOpenClosed }}</span>
17
- <!-- end opening-status (without link) -->
30
+ <!-- begin edit-mode -->
31
+ <div v-else class="flex-container">
32
+ <CmdFormElement
33
+ element="input"
34
+ type="text"
35
+ :showLabel="false"
36
+ labelText="Text for 'open'"
37
+ placeholder="Text for 'open'"
38
+ v-model="textOpenModel"
39
+ />
40
+ <CmdFormElement
41
+ element="input"
42
+ type="text"
43
+ :showLabel="false"
44
+ labelText="Text for 'closed'"
45
+ placeholder="Text for 'closed'"
46
+ v-model="textClosedModel"
47
+ />
48
+ </div>
49
+ <!-- end edit-mode -->
18
50
 
19
- <!-- begin opening-days and -hours -->
20
- <dl>
21
- <template v-for="day in openingHoursFormatted" :key="day.day">
22
- <dt>{{ day.day }}:</dt>
23
- <dd>{{ getTime(day.fromTime)}}&ndash;{{ getTime(day.tillTime)}}</dd>
24
- </template>
51
+ <!-- begin default view -->
52
+ <dl v-if="!editModeContext">
53
+ <CmdOpeningHoursItem
54
+ v-for="(day, index) in openingHoursFormatted"
55
+ :key="index"
56
+ :day="day"
57
+ :separator="separator"
58
+ :abbreviationText="abbreviationText"
59
+ />
25
60
  </dl>
26
- <!-- end opening-days and -hours -->
61
+ <!-- end default view -->
62
+
63
+ <!-- begin edit-mode -->
64
+ <button v-if="openingHoursFormatted.length === 0" type="button" class="button confirm small" @click="onAddItem">
65
+ <span class="icon-plus"></span>
66
+ <span>Add new entry</span>
67
+ </button>
68
+
69
+ <EditComponentWrapper
70
+ v-else
71
+ v-for="(day, index) in openingHoursFormatted"
72
+ :key="'x' + index"
73
+ class="edit-items"
74
+ :showComponentName="false"
75
+ componentName="CmdOpeningHoursItem"
76
+ :componentProps="day"
77
+ :allowedComponentTypes="[]"
78
+ :componentPath="['props', 'openingHours', index]"
79
+ :itemProvider="itemProvider"
80
+ >
81
+ <dl class="edit-mode-opening-hours-item">
82
+ <CmdOpeningHoursItem
83
+ :day="day"
84
+ :separator="separator"
85
+ :abbreviationText="abbreviationText"
86
+ />
87
+ </dl>
88
+ </EditComponentWrapper>
89
+ <!-- end edit-mode -->
27
90
 
28
91
  <!-- begin holiday-closes-text and miscellaneous information -->
29
- <div v-if="textHolidaysClosed || textMiscInfo">
30
- <p v-if="textHolidaysClosed">
31
- <strong>{{ textHolidaysClosed }}</strong>
92
+ <div v-if="!editing && (textHolidays || textMiscInfo)">
93
+ <p v-if="textHolidays">
94
+ <strong>{{ textHolidays }}</strong>
32
95
  </p>
33
96
  <p v-if="textMiscInfo">{{ textMiscInfo }}</p>
34
97
  </div>
35
98
  <!-- end holiday-closes-text and miscellaneous information -->
99
+
100
+ <!-- begin edit-mode -->
101
+ <div v-if="editing" class="flex-container vertical">
102
+ <CmdFormElement
103
+ element="input"
104
+ type="text"
105
+ :showLabel="false"
106
+ labelText="Text for 'holidays'"
107
+ placeholder="Text for 'holidays'"
108
+ v-model="textHolidaysModel"
109
+ />
110
+ <CmdFormElement
111
+ element="input"
112
+ type="text"
113
+ :showLabel="false"
114
+ labelText="Miscellaneous information"
115
+ placeholder="Miscellaneous information"
116
+ v-model="textMiscInfoModel"
117
+ />
118
+ </div>
119
+ <!-- end edit-mode -->
36
120
  </div>
37
121
  </template>
38
122
 
39
123
  <script>
124
+ import EditMode from "../mixins/EditMode.vue"
125
+ import {buildComponentPath, updateHandlerProvider} from "../utils/editmode.js"
126
+
40
127
  export function localizedTime(language) {
41
128
  return (hour, minute) => {
42
129
  const now = new Date()
@@ -47,17 +134,17 @@ export function localizedTime(language) {
47
134
 
48
135
  export function timeFormatting(separator, suffix1, suffix2, hoursLeadingZero = true) {
49
136
  function addLeadingZero(time, addLeadingZero) {
50
- if(addLeadingZero && time < 10) {
137
+ if (addLeadingZero && time < 10) {
51
138
  return "0" + time
52
139
  }
53
140
  return time
54
141
  }
55
142
 
56
143
  return (hour, minute) => {
57
- if(suffix2) {
144
+ if (suffix2) {
58
145
  let hour12 = hour
59
146
  let currentSuffix = suffix1
60
- if(hour12 > 12) {
147
+ if (hour12 > 12) {
61
148
  hour12 -= 12
62
149
  currentSuffix = suffix2
63
150
  }
@@ -69,6 +156,17 @@ export function timeFormatting(separator, suffix1, suffix2, hoursLeadingZero = t
69
156
 
70
157
  export default {
71
158
  name: "CmdOpeningHours",
159
+ mixins: [EditMode],
160
+ data() {
161
+ return {
162
+ currentTime: new Date(),
163
+ editableOpeningHours: [],
164
+ editableTextOpen: null,
165
+ editableTextClosed: null,
166
+ editableTextHolidays: null,
167
+ editableTextMiscInfo: null
168
+ }
169
+ },
72
170
  props: {
73
171
  /**
74
172
  * set a link to a detail page
@@ -100,6 +198,14 @@ export default {
100
198
  type: String,
101
199
  default: "Closed right now!"
102
200
  },
201
+ separator: {
202
+ type: String,
203
+ default: "–"
204
+ },
205
+ abbreviationText: {
206
+ type: String,
207
+ default: "h"
208
+ },
103
209
  /**
104
210
  * list of opening-hours
105
211
  */
@@ -108,9 +214,9 @@ export default {
108
214
  required: true
109
215
  },
110
216
  /**
111
- * text to show if holidays closed (shown below opening-hours)
217
+ * text to show for holidays (shown below opening-hours)
112
218
  */
113
- textHolidaysClosed: {
219
+ textHolidays: {
114
220
  type: String,
115
221
  required: false
116
222
  },
@@ -151,7 +257,7 @@ export default {
151
257
  }
152
258
  },
153
259
  mounted() {
154
- if(this.componentHandlesClosedStatus && this.checkInterval > 0) {
260
+ if (this.componentHandlesClosedStatus && this.checkInterval > 0) {
155
261
  // create new property on component by 'this.property-name' and assign value (id) from setInterval (so it can be cleared in unmount)
156
262
  this.$_CmdOpeningHours_intervalId = setInterval(() => {
157
263
  // use arrow-function to assure that 'this' is the component
@@ -159,44 +265,95 @@ export default {
159
265
  }, this.checkInterval)
160
266
  }
161
267
  },
162
- data() {
163
- return {
164
- currentTime: new Date()
268
+ beforeUnmount() {
269
+ if (this.$_CmdOpeningHours_intervalId) {
270
+ // remove interval
271
+ clearInterval(this.$_CmdOpeningHours_intervalId)
272
+
273
+ // clear interval-id
274
+ this.$_CmdOpeningHours_intervalId = null
165
275
  }
166
276
  },
167
277
  computed: {
168
- textOpenClosed() {
169
- return this.isClosed ? this.textClosed : this.textOpen
170
- },
171
278
  openingHoursFormatted() {
172
279
  const weekdays = []
173
- for(let i = 0; i < this.openingHours.length; i++) {
280
+ for (let i = 0; i < this.openingHours.length; i++) {
174
281
  const openingHours = {}
175
- const splitFromTime = this.openingHours[i].fromTime.split(/[:.]/)
176
- const splitTillTime = this.openingHours[i].tillTime.split(/[:.]/)
282
+ const splitAmFromTime = this.openingHours[i].am.fromTime.split(/[:.]/)
283
+ const splitAmTillTime = this.openingHours[i].am.tillTime.split(/[:.]/)
284
+ const splitPmFromTime = this.openingHours[i].pm.fromTime.split(/[:.]/)
285
+ const splitPmTillTime = this.openingHours[i].pm.tillTime.split(/[:.]/)
177
286
 
178
287
  openingHours.day = this.openingHours[i].day
179
- openingHours.fromTime = {
180
- hours: parseInt(splitFromTime[0]),
181
- mins: parseInt(splitFromTime[1])
288
+
289
+ openingHours.am = {...this.openingHours[i].am}
290
+ openingHours.am.fromTime = {
291
+ hours: parseInt(splitAmFromTime[0]),
292
+ mins: parseInt(splitAmFromTime[1])
293
+ }
294
+ openingHours.am.tillTime = {
295
+ hours: parseInt(splitAmTillTime[0]),
296
+ mins: parseInt(splitAmTillTime[1])
297
+ }
298
+
299
+ openingHours.pm = {...this.openingHours[i].pm}
300
+ openingHours.pm.fromTime = {
301
+ hours: parseInt(splitPmFromTime[0]),
302
+ mins: parseInt(splitPmFromTime[1])
182
303
  }
183
- openingHours.tillTime = {
184
- hours: parseInt(splitTillTime[0]),
185
- mins: parseInt(splitTillTime[1])
304
+ openingHours.pm.tillTime = {
305
+ hours: parseInt(splitPmTillTime[0]),
306
+ mins: parseInt(splitPmTillTime[1])
186
307
  }
308
+
187
309
  weekdays.push(openingHours)
188
310
  }
189
311
  return weekdays
190
312
  },
313
+ textOpenModel: {
314
+ get() {
315
+ return this.editableTextOpen == null ? this.textOpen : this.editableTextOpen
316
+ },
317
+ set(value) {
318
+ this.editableTextOpen = value
319
+ }
320
+ },
321
+ textClosedModel: {
322
+ get() {
323
+ return this.editableTextClosed == null ? this.textClosed : this.editableTextClosed
324
+ },
325
+ set(value) {
326
+ this.editableTextClosed = value
327
+ }
328
+ },
329
+ textHolidaysModel: {
330
+ get() {
331
+ return this.editableTextHolidays == null ? this.textHolidays : this.editableTextHolidays
332
+ },
333
+ set(value) {
334
+ this.editableTextHolidays = value
335
+ }
336
+ },
337
+ textMiscInfoModel: {
338
+ get() {
339
+ return this.editableTextMiscInfo == null ? this.textMiscInfo : this.editableTextMiscInfo
340
+ },
341
+ set(value) {
342
+ this.editableTextMiscInfo = value
343
+ }
344
+ },
345
+ textOpenClosed() {
346
+ return this.isClosed ? this.textClosed : this.textOpen
347
+ },
191
348
  isClosed() {
192
- if(!this.componentHandlesClosedStatus) {
349
+ if (!this.componentHandlesClosedStatus) {
193
350
  return this.closed
194
351
  }
195
352
 
196
353
  let currentDay = this.currentTime.getDay()
197
354
 
198
355
  // fix order and check if currentDay equals 0 === sunday. Data are expected to start with monday
199
- if (currentDay === 0){
356
+ if (currentDay === 0) {
200
357
  currentDay = 6
201
358
  } else {
202
359
  currentDay -= 1
@@ -204,14 +361,23 @@ export default {
204
361
 
205
362
  const openingHours = this.openingHoursFormatted[currentDay]
206
363
 
207
- if(this.openingHoursFormatted[currentDay]) {
208
- const openingHoursFrom = new Date()
209
- openingHoursFrom.setHours(openingHours.fromTime.hours, openingHours.fromTime.mins)
364
+ if (this.openingHoursFormatted[currentDay]) {
365
+ // set hours for AM
366
+ const openingHoursAmFrom = new Date()
367
+ openingHoursAmFrom.setHours(openingHours.am.fromTime.hours, openingHours.am.fromTime.mins)
210
368
 
211
- const openingHoursTill = new Date()
212
- openingHoursTill.setHours(openingHours.tillTime.hours, openingHours.tillTime.mins)
369
+ const openingHoursAmTill = new Date()
370
+ openingHoursAmTill.setHours(openingHours.am.tillTime.hours, openingHours.am.tillTime.mins)
213
371
 
214
- if (openingHoursFrom <= this.currentTime && this.currentTime <= openingHoursTill) {
372
+ // set hours for PM
373
+ const openingHoursPmFrom = new Date()
374
+ openingHoursPmFrom.setHours(openingHours.pm.fromTime.hours, openingHours.pm.fromTime.mins)
375
+
376
+ const openingHoursPmTill = new Date()
377
+ openingHoursPmTill.setHours(openingHours.pm.tillTime.hours, openingHours.pm.tillTime.mins)
378
+
379
+ // compare am/pm times with current time to determine if closed/open-text will be displayed
380
+ if ((openingHoursAmFrom <= this.currentTime && this.currentTime <= openingHoursAmTill) && (openingHoursPmFrom <= this.currentTime && this.currentTime <= openingHoursPmTill)) {
215
381
  return false
216
382
  }
217
383
  }
@@ -219,20 +385,50 @@ export default {
219
385
  }
220
386
  },
221
387
  methods: {
388
+ onAddItem() {
389
+ this.editModeContext.content.addContent(
390
+ buildComponentPath(this, 'props', 'openingHours', -1),
391
+ this.itemProvider)
392
+ },
393
+ itemProvider() {
394
+ return {
395
+ "day": "Weekday",
396
+ "am": {
397
+ "fromTime": "00:00",
398
+ "tillTime": "00:00"
399
+ },
400
+ "pm": {
401
+ "fromTime": "00:00",
402
+ "tillTime": "00:00"
403
+ }
404
+ }
405
+ },
222
406
  getTime(time) {
223
- if(this.timeFormatter) {
407
+ if (this.timeFormatter) {
224
408
  return this.timeFormatter(time.hours, time.mins)
225
409
  }
226
- return timeFormatting(":", " hrs", "", false)(time.hours, time.mins)
227
- }
228
- },
229
- beforeUnmount() {
230
- if(this.$_CmdOpeningHours_intervalId) {
231
- // remove interval
232
- clearInterval(this.$_CmdOpeningHours_intervalId)
233
-
234
- // clear interval-id
235
- this.$_CmdOpeningHours_intervalId = null
410
+ return timeFormatting(":", " hrs", "", false)(time.hours, time.mins)
411
+ },
412
+ updateHandlerProvider() {
413
+ const openingHours = this.editableOpeningHours
414
+ const textOpen = this.editableTextOpen
415
+ const textClosed = this.editableTextClosed
416
+ const textHolidays = this.editableTextHolidays
417
+ const textMiscInfo = this.editableTextMiscInfo
418
+ return updateHandlerProvider(this, {
419
+ update(props, childUpdateHandlers) {
420
+ props.openingHours = openingHours
421
+ props.textOpen = textOpen
422
+ props.textClosed = textClosed
423
+ props.textHolidays = textHolidays
424
+ props.textMiscInfo = textMiscInfo
425
+ const cmdHeadlineUpdateHandler = childUpdateHandlers?.find(handler => handler.name === "CmdHeadline")
426
+ if (cmdHeadlineUpdateHandler) {
427
+ props.cmdHeadline = props.cmdHeadline || {}
428
+ cmdHeadlineUpdateHandler.update(props.cmdHeadline)
429
+ }
430
+ }
431
+ })
236
432
  }
237
433
  }
238
434
  }
@@ -247,10 +443,10 @@ export default {
247
443
  display: table;
248
444
  margin-bottom: var(--default-margin);
249
445
  color: var(--pure-white);
250
- background: #0b0;
446
+ background: var(--success-color);
251
447
 
252
448
  &.closed {
253
- background: #b00;
449
+ background: var(--error-color);
254
450
  }
255
451
  }
256
452
 
@@ -261,9 +457,30 @@ export default {
261
457
  }
262
458
  }
263
459
 
460
+ span.pm {
461
+ margin-left: var(--default-margin);
462
+ }
463
+
264
464
  p:last-child {
265
465
  margin: 0;
266
466
  }
467
+
468
+ .edit-component-wrapper {
469
+ dl {
470
+ margin-bottom: 0;
471
+ }
472
+ }
473
+ }
474
+
475
+ .edit-component-wrapper .cmd-opening-hours {
476
+ display: flex;
477
+ flex-direction: column;
478
+ align-items: flex-start;
479
+ gap: calc(var(--default-gap) / 2);
480
+
481
+ dt {
482
+ min-width: 2.5rem;
483
+ }
267
484
  }
268
485
 
269
486
  /* end cmd-opening-hours ------------------------------------------------------------------------------------------ */