@windward/core 0.0.1

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 (113) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintrc.js +11 -0
  3. package/.prettierrc +4 -0
  4. package/README.md +86 -0
  5. package/babel.config.js +1 -0
  6. package/components/Content/Blocks/Accordion.vue +133 -0
  7. package/components/Content/Blocks/ClickableIcons.vue +98 -0
  8. package/components/Content/Blocks/Feedback.vue +323 -0
  9. package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionLikert.vue +95 -0
  10. package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionOpenResponse.vue +45 -0
  11. package/components/Content/Blocks/FeedbackTemplates/FeedbackQuestionTrueFalse.vue +55 -0
  12. package/components/Content/Blocks/Image.vue +116 -0
  13. package/components/Content/Blocks/Math.vue +87 -0
  14. package/components/Content/Blocks/Tab.vue +89 -0
  15. package/components/Content/Blocks/Table.vue +68 -0
  16. package/components/Content/Blocks/UserUpload/DisplayUserFilesTable.vue +157 -0
  17. package/components/Content/Blocks/UserUpload/ManageDataTableUserFiles.vue +68 -0
  18. package/components/Content/Blocks/UserUpload.vue +240 -0
  19. package/components/Content/Blocks/Video.vue +245 -0
  20. package/components/Navigation/Items/CourseGlossaryToolNav.vue +39 -0
  21. package/components/Navigation/Items/GlossaryNav.vue +32 -0
  22. package/components/Navigation/Items/UserUploadNav.vue +35 -0
  23. package/components/Settings/AccordionSettings.vue +153 -0
  24. package/components/Settings/ClickableIconsSettings.vue +189 -0
  25. package/components/Settings/FeedbackSettings.vue +92 -0
  26. package/components/Settings/ImageSettings.vue +124 -0
  27. package/components/Settings/MathSettings.vue +81 -0
  28. package/components/Settings/TabSettings.vue +139 -0
  29. package/components/Settings/TextEditorSettings.vue +249 -0
  30. package/components/Settings/UserUploadSettings.vue +151 -0
  31. package/components/Settings/VideoSettings.vue +699 -0
  32. package/components/utils/ContentViewer.vue +69 -0
  33. package/components/utils/MathExpressionEditor.vue +294 -0
  34. package/components/utils/MathLiveWrapper.vue +86 -0
  35. package/components/utils/TinyMCEWrapper.vue +103 -0
  36. package/components/utils/glossary/CourseGlossary.vue +284 -0
  37. package/components/utils/glossary/CourseGlossaryForm.vue +106 -0
  38. package/components/utils/glossary/GlossaryToolTip.vue +87 -0
  39. package/config/tinymce.config.js +136 -0
  40. package/helpers/GlossaryHelper.ts +137 -0
  41. package/helpers/GlossaryTerm.ts +31 -0
  42. package/helpers/MathHelper.ts +236 -0
  43. package/helpers/tinymce/plugin.ts +83 -0
  44. package/i18n/en-US/components/content/blocks/feedback.ts +28 -0
  45. package/i18n/en-US/components/content/blocks/image.ts +5 -0
  46. package/i18n/en-US/components/content/blocks/index.ts +15 -0
  47. package/i18n/en-US/components/content/blocks/tab.ts +4 -0
  48. package/i18n/en-US/components/content/blocks/table.ts +4 -0
  49. package/i18n/en-US/components/content/blocks/user_upload.ts +12 -0
  50. package/i18n/en-US/components/content/blocks/video.ts +53 -0
  51. package/i18n/en-US/components/content/index.ts +5 -0
  52. package/i18n/en-US/components/index.ts +12 -0
  53. package/i18n/en-US/components/navigation/image.ts +4 -0
  54. package/i18n/en-US/components/navigation/index.ts +7 -0
  55. package/i18n/en-US/components/navigation/user_upload.ts +3 -0
  56. package/i18n/en-US/components/settings/clickable_icon.ts +9 -0
  57. package/i18n/en-US/components/settings/image.ts +1 -0
  58. package/i18n/en-US/components/settings/index.ts +13 -0
  59. package/i18n/en-US/components/settings/text_editor.ts +7 -0
  60. package/i18n/en-US/components/settings/user_upload.ts +11 -0
  61. package/i18n/en-US/components/settings/video.ts +13 -0
  62. package/i18n/en-US/components/utils/index.ts +5 -0
  63. package/i18n/en-US/components/utils/tiny_mce_wrapper.ts +7 -0
  64. package/i18n/en-US/index.ts +16 -0
  65. package/i18n/en-US/modules/index.ts +5 -0
  66. package/i18n/en-US/pages/glossary.ts +7 -0
  67. package/i18n/en-US/pages/index.ts +7 -0
  68. package/i18n/en-US/pages/user_upload.ts +3 -0
  69. package/i18n/en-US/shared/content_blocks.ts +20 -0
  70. package/i18n/en-US/shared/index.ts +11 -0
  71. package/i18n/en-US/shared/menu.ts +3 -0
  72. package/i18n/en-US/shared/permission.ts +15 -0
  73. package/i18n/en-US/shared/settings.ts +15 -0
  74. package/index.js +15 -0
  75. package/jest.config.js +15 -0
  76. package/models/SurveyResult.ts +8 -0
  77. package/models/SurveyTemplate.ts +8 -0
  78. package/models/UserFileAsset.ts +12 -0
  79. package/package.json +48 -0
  80. package/pages/glossary.vue +31 -0
  81. package/pages/userUpload.vue +204 -0
  82. package/plugin.js +299 -0
  83. package/test/Components/Content/Blocks/Accordion.spec.js +21 -0
  84. package/test/Components/Content/Blocks/ClickableIcons.spec.js +21 -0
  85. package/test/Components/Content/Blocks/Feedback.spec.js +31 -0
  86. package/test/Components/Content/Blocks/FeedbackTemplates/FeedbackQuestionLikert.spec.js +23 -0
  87. package/test/Components/Content/Blocks/FeedbackTemplates/FeedbackQuestionOpenResponse.spec.js +23 -0
  88. package/test/Components/Content/Blocks/FeedbackTemplates/FeedbackQuestionTrueFalse.spec.js +23 -0
  89. package/test/Components/Content/Blocks/Image.spec.js +34 -0
  90. package/test/Components/Content/Blocks/Math.spec.js +34 -0
  91. package/test/Components/Content/Blocks/Tab.spec.js +20 -0
  92. package/test/Components/Content/Blocks/Table.spec.js +21 -0
  93. package/test/Components/Content/Blocks/UserUpload.spec.js +25 -0
  94. package/test/Components/Content/Blocks/Video.spec.js +112 -0
  95. package/test/Components/Settings/AccordionSettings.spec.js +45 -0
  96. package/test/Components/Settings/ClickableIconsSettings.spec.js +20 -0
  97. package/test/Components/Settings/FeedbackSettings.spec.js +20 -0
  98. package/test/Components/Settings/ImageSettings.spec.js +20 -0
  99. package/test/Components/Settings/MathSettings.spec.js +20 -0
  100. package/test/Components/Settings/TabSettings.spec.js +45 -0
  101. package/test/Components/Settings/UserUploadSettings.spec.js +20 -0
  102. package/test/__mocks__/componentsMock.js +83 -0
  103. package/test/__mocks__/contentBlockMock.js +119 -0
  104. package/test/__mocks__/contentSettingsMock.js +54 -0
  105. package/test/__mocks__/fileMock.js +1 -0
  106. package/test/__mocks__/helpersMock.js +53 -0
  107. package/test/__mocks__/modelMock.js +82 -0
  108. package/test/__mocks__/styleMock.js +1 -0
  109. package/test/helpers/GlossaryHelper.spec.js +227 -0
  110. package/test/helpers/MathHelper.spec.js +128 -0
  111. package/test/mocks.js +140 -0
  112. package/tsconfig.json +15 -0
  113. package/utils/index.js +18 -0
@@ -0,0 +1,699 @@
1
+ <template>
2
+ <div>
3
+ <v-row>
4
+ <v-col cols="12">
5
+ <v-text-field
6
+ v-model="block.metadata.config.title"
7
+ :label="$t('windward.core.components.settings.video.title')"
8
+ ></v-text-field>
9
+ <h1 class="mb-3">
10
+ {{ $t('windward.core.components.settings.video.sources') }}
11
+ </h1>
12
+ <v-tabs v-model="fileTab" fixed-tabs background-color="accent">
13
+ <v-tab>
14
+ {{
15
+ $t(
16
+ 'windward.core.components.content.blocks.video.tabs.video'
17
+ )
18
+ }}
19
+ </v-tab>
20
+ <v-tab>
21
+ {{
22
+ $t(
23
+ 'windward.core.components.content.blocks.video.tabs.poster'
24
+ )
25
+ }}
26
+ </v-tab>
27
+ <v-tab>
28
+ {{
29
+ $t(
30
+ 'windward.core.components.content.blocks.video.tabs.preroll'
31
+ )
32
+ }}
33
+ </v-tab>
34
+ <v-tab>
35
+ {{
36
+ $t(
37
+ 'windward.core.components.content.blocks.video.tabs.postroll'
38
+ )
39
+ }}
40
+ </v-tab>
41
+ </v-tabs>
42
+
43
+ <v-tabs-items v-model="fileTab">
44
+ <v-tab-item class="mb-1">
45
+ <ContentBlockAsset
46
+ v-model="media.source"
47
+ mimes="video/mp4,audio/mpeg,video/webm"
48
+ @click:file="onSourceSelect"
49
+ allow-url
50
+ class="mb-4"
51
+ >
52
+ <template #title>
53
+ {{
54
+ $t(
55
+ 'windward.core.components.content.blocks.video.video.title'
56
+ )
57
+ }}
58
+ </template>
59
+ <template #description>
60
+ {{
61
+ $t(
62
+ 'windward.core.components.content.blocks.video.video.configure_blurb'
63
+ )
64
+ }}
65
+ </template>
66
+ </ContentBlockAsset>
67
+
68
+ <ContentBlockAsset
69
+ v-model="media.track"
70
+ mimes="text/vtt,text/xml"
71
+ @click:file="onTrackSelect"
72
+ allow-url
73
+ class="mb-4"
74
+ >
75
+ <template #title>
76
+ {{
77
+ $t(
78
+ 'windward.core.components.content.blocks.video.caption.title'
79
+ )
80
+ }}
81
+ </template>
82
+ <template #description>
83
+ {{
84
+ $t(
85
+ 'windward.core.components.content.blocks.video.caption.configure_blurb'
86
+ )
87
+ }}
88
+ </template>
89
+ </ContentBlockAsset>
90
+ </v-tab-item>
91
+
92
+ <v-tab-item class="mb-1">
93
+ <ContentBlockAsset
94
+ v-model="media.poster"
95
+ mimes="image/png,image/jpeg"
96
+ @click:file="onPosterSelect"
97
+ allow-url
98
+ >
99
+ <template #title>
100
+ {{
101
+ $t(
102
+ 'windward.core.components.content.blocks.video.poster.title'
103
+ )
104
+ }}
105
+ </template>
106
+ <template #description>
107
+ {{
108
+ $t(
109
+ 'windward.core.components.content.blocks.video.poster.configure_blurb'
110
+ )
111
+ }}
112
+ </template>
113
+ </ContentBlockAsset>
114
+ </v-tab-item>
115
+
116
+ <v-tab-item class="mb-1">
117
+ <ContentBlockAsset
118
+ v-model="media.ads.preroll.source"
119
+ mimes="video/mp4,video/webm"
120
+ @click:file="onAdSourceSelect($event, 0)"
121
+ allow-url
122
+ class="mb-4"
123
+ >
124
+ <template #title>
125
+ {{
126
+ $t(
127
+ 'windward.core.components.content.blocks.video.preroll.title'
128
+ )
129
+ }}
130
+ </template>
131
+ <template #description>
132
+ {{
133
+ $t(
134
+ 'windward.core.components.content.blocks.video.preroll.configure_blurb'
135
+ )
136
+ }}
137
+ </template>
138
+ </ContentBlockAsset>
139
+
140
+ <ContentBlockAsset
141
+ v-model="media.ads.preroll.track"
142
+ mimes="text/vtt,text/xml"
143
+ @click:file="onAdTrackSelect($event, 0)"
144
+ allow-url
145
+ >
146
+ <template #title>
147
+ {{
148
+ $t(
149
+ 'windward.core.components.content.blocks.video.caption.title'
150
+ )
151
+ }}
152
+ </template>
153
+ <template #description>
154
+ {{
155
+ $t(
156
+ 'windward.core.components.content.blocks.video.caption.configure_blurb'
157
+ )
158
+ }}
159
+ </template>
160
+ </ContentBlockAsset>
161
+ </v-tab-item>
162
+
163
+ <v-tab-item class="mb-1">
164
+ <ContentBlockAsset
165
+ v-model="media.ads.postroll.source"
166
+ mimes="video/mp4,video/webm"
167
+ @click:file="onAdSourceSelect($event, 100)"
168
+ allow-url
169
+ class="mb-4"
170
+ >
171
+ <template #title>
172
+ {{
173
+ $t(
174
+ 'windward.core.components.content.blocks.video.postroll.title'
175
+ )
176
+ }}
177
+ </template>
178
+ <template #description>
179
+ {{
180
+ $t(
181
+ 'windward.core.components.content.blocks.video.postroll.configure_blurb'
182
+ )
183
+ }}
184
+ </template>
185
+ </ContentBlockAsset>
186
+
187
+ <ContentBlockAsset
188
+ v-model="media.ads.postroll.track"
189
+ mimes="text/vtt,text/xml"
190
+ @click:file="onAdTrackSelect($event, 100)"
191
+ allow-url
192
+ >
193
+ <template #title>
194
+ {{
195
+ $t(
196
+ 'windward.core.components.content.blocks.video.caption.title'
197
+ )
198
+ }}
199
+ </template>
200
+ <template #description>
201
+ {{
202
+ $t(
203
+ 'windward.core.components.content.blocks.video.caption.configure_blurb'
204
+ )
205
+ }}
206
+ </template>
207
+ </ContentBlockAsset>
208
+ </v-tab-item>
209
+ </v-tabs-items>
210
+ </v-col>
211
+ </v-row>
212
+ <v-row>
213
+ <v-col cols="12">
214
+ <h1 class="mb-3">
215
+ {{ $t('windward.core.components.settings.video.playlist') }}
216
+ </h1>
217
+ <div>
218
+ <strong
219
+ v-if="
220
+ !block.metadata.config.playlist[playlistIndex]
221
+ .sources ||
222
+ !block.metadata.config.playlist[playlistIndex]
223
+ .sources.length > 0
224
+ "
225
+ >
226
+ {{
227
+ $t(
228
+ 'windward.core.components.settings.video.playlist_name_source_required'
229
+ )
230
+ }}
231
+ </strong>
232
+ <v-text-field
233
+ v-model="
234
+ block.metadata.config.playlist[playlistIndex].name
235
+ "
236
+ :label="
237
+ $t(
238
+ 'windward.core.components.settings.video.playlist_name'
239
+ )
240
+ "
241
+ :disabled="
242
+ !block.metadata.config.playlist[playlistIndex]
243
+ .sources ||
244
+ !block.metadata.config.playlist[playlistIndex]
245
+ .sources.length > 0
246
+ "
247
+ />
248
+ </div>
249
+ <v-pagination
250
+ v-model="playlistPaginator"
251
+ :length="block.metadata.config.playlist.length"
252
+ @input="reloadMedia"
253
+ ></v-pagination>
254
+ <div class="d-flex justify-center">
255
+ <v-tooltip top>
256
+ <template #activator="{ on, attrs }">
257
+ <v-btn
258
+ v-bind="attrs"
259
+ v-on="on"
260
+ outlined
261
+ color="error"
262
+ :disabled="
263
+ block.metadata.config.playlist.length <= 1
264
+ "
265
+ @click="onRemovePlaylistItem"
266
+ >
267
+ <v-icon>mdi-delete</v-icon>
268
+ <span class="sr-only">
269
+ {{
270
+ $t(
271
+ 'windward.core.components.settings.video.playlist_remove'
272
+ )
273
+ }}
274
+ </span>
275
+ </v-btn>
276
+ </template>
277
+ <span>{{
278
+ $t(
279
+ 'windward.core.components.settings.video.playlist_remove'
280
+ )
281
+ }}</span>
282
+ </v-tooltip>
283
+
284
+ <v-tooltip top>
285
+ <template #activator="{ on, attrs }">
286
+ <v-btn
287
+ v-bind="attrs"
288
+ v-on="on"
289
+ color="primary"
290
+ outlined
291
+ @click="onAddPlaylistItem"
292
+ >
293
+ <v-icon>mdi-plus</v-icon>
294
+ <span class="sr-only">
295
+ {{
296
+ $t(
297
+ 'windward.core.components.settings.video.playlist_add'
298
+ )
299
+ }}
300
+ </span>
301
+ </v-btn>
302
+ </template>
303
+ <span>{{
304
+ $t(
305
+ 'windward.core.components.settings.video.playlist_add'
306
+ )
307
+ }}</span>
308
+ </v-tooltip>
309
+ </div>
310
+ </v-col>
311
+ </v-row>
312
+ <v-row>
313
+ <v-col cols="12">
314
+ <h1 class="mb-3">
315
+ {{ $t('windward.core.components.settings.video.playback') }}
316
+ </h1>
317
+ <v-card elevation="0">
318
+ <v-card-text>
319
+ <v-row>
320
+ <v-col cols="12">
321
+ <v-select
322
+ v-model="
323
+ block.metadata.config.attributes
324
+ .playbackrates
325
+ "
326
+ :items="playbackRateOptions"
327
+ :label="
328
+ $t(
329
+ 'windward.core.components.content.blocks.video.video.playback_rates'
330
+ )
331
+ "
332
+ multiple
333
+ @change="onPlaybackChange"
334
+ >
335
+ <template #selection="{ item }">
336
+ <v-chip>
337
+ <span>{{ item }}x</span>
338
+ </v-chip>
339
+ </template>
340
+ </v-select>
341
+ </v-col>
342
+ <v-col cols="6">
343
+ <v-switch
344
+ v-model="
345
+ block.metadata.config.attributes
346
+ .controls
347
+ "
348
+ :label="
349
+ $t(
350
+ 'windward.core.components.content.blocks.video.video.controls'
351
+ )
352
+ "
353
+ ></v-switch>
354
+ <v-switch
355
+ v-model="
356
+ block.metadata.config.attributes.rewind
357
+ "
358
+ :label="
359
+ $t(
360
+ 'windward.core.components.content.blocks.video.video.rewind'
361
+ )
362
+ "
363
+ ></v-switch>
364
+ <v-switch
365
+ v-model="
366
+ block.metadata.config.attributes
367
+ .captionsmenu
368
+ "
369
+ :label="
370
+ $t(
371
+ 'windward.core.components.content.blocks.video.video.captionsmenu'
372
+ )
373
+ "
374
+ ></v-switch>
375
+ <v-switch
376
+ v-model="
377
+ block.metadata.config.attributes
378
+ .disablepictureinpicture
379
+ "
380
+ :label="
381
+ $t(
382
+ 'windward.core.components.content.blocks.video.video.disablepictureinpicture'
383
+ )
384
+ "
385
+ ></v-switch>
386
+ <!--
387
+ <v-switch
388
+ v-model="block.metadata.config.attributes.playlistmenu"
389
+ :label="$t('windward.core.components.content.blocks.video.video.attributes.playlistmenu')"
390
+ ></v-switch>
391
+ <v-switch
392
+ v-model="block.metadata.config.attributes.playlistautoadvance"
393
+ :label="$t('windward.core.components.content.blocks.video.video.attributes.playlistautoadvance')"
394
+ ></v-switch>
395
+ -->
396
+ </v-col>
397
+ <v-col cols="6">
398
+ <v-switch
399
+ v-model="
400
+ block.metadata.config.attributes.muted
401
+ "
402
+ :label="
403
+ $t(
404
+ 'windward.core.components.content.blocks.video.video.muted'
405
+ )
406
+ "
407
+ ></v-switch>
408
+ <v-switch
409
+ v-model="
410
+ block.metadata.config.attributes.loop
411
+ "
412
+ :label="
413
+ $t(
414
+ 'windward.core.components.content.blocks.video.video.loop'
415
+ )
416
+ "
417
+ ></v-switch>
418
+ <v-switch
419
+ v-model="
420
+ block.metadata.config.attributes
421
+ .playsinline
422
+ "
423
+ :label="
424
+ $t(
425
+ 'windward.core.components.content.blocks.video.video.playsinline'
426
+ )
427
+ "
428
+ ></v-switch>
429
+ </v-col>
430
+ </v-row>
431
+ </v-card-text>
432
+ </v-card>
433
+ </v-col>
434
+ </v-row>
435
+ </div>
436
+ </template>
437
+ <script>
438
+ import BaseContentSettings from '~/components/Content/Tool/BaseContentSettings.js'
439
+ import Vue from 'vue'
440
+
441
+ export default {
442
+ name: 'VideoSettings',
443
+ extends: BaseContentSettings,
444
+ components: {},
445
+ data() {
446
+ return {
447
+ fileTab: null,
448
+ playbackRateOptions: [0.25, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4],
449
+ playlistPaginator: 1,
450
+ media: {
451
+ source: null,
452
+ track: null,
453
+ poster: null,
454
+ ads: {
455
+ preroll: {
456
+ source: null,
457
+ track: null,
458
+ },
459
+ postroll: {
460
+ source: null,
461
+ track: null,
462
+ },
463
+ },
464
+ },
465
+ }
466
+ },
467
+ computed: {
468
+ playlistIndex() {
469
+ return this.playlistPaginator - 1
470
+ },
471
+ },
472
+ watch: {},
473
+ beforeMount() {
474
+ // Create structure for first playlist source
475
+ if (_.isEmpty(_.get(this.block.metadata.config, `playlist`, null))) {
476
+ this.onAddPlaylistItem()
477
+ this.playlistPaginator = 1
478
+ }
479
+ },
480
+ mounted() {},
481
+ methods: {
482
+ reloadMedia() {
483
+ this.media.source = null
484
+ this.media.track = null
485
+ this.media.poster = null
486
+ this.media.ads = {
487
+ preroll: {
488
+ source: null,
489
+ track: null,
490
+ },
491
+ postroll: {
492
+ source: null,
493
+ track: null,
494
+ },
495
+ }
496
+ },
497
+ reloadVideo() {
498
+ const self = this
499
+
500
+ // Set the config __isDirty so the video component can pick it up on a computed prop
501
+ this.block.metadata.config.__isDirty = true
502
+
503
+ // After .5s delete __isDirty
504
+ setTimeout(() => {
505
+ self.block.metadata.config.__isDirty = false
506
+ delete self.block.metadata.config.__isDirty
507
+ }, 500)
508
+ },
509
+ /**
510
+ * Returns the next array index for an ad slot
511
+ * If a slot is already defined then return that index
512
+ * Eg with array [0: {}, 50: {}, 100: {}]
513
+ * this.getAdSlot(100) -> returns 2
514
+ * this.getAdSlot(75) -> returns 3
515
+ *
516
+ * @param Number|Int Where the ad slot should be placed
517
+ *
518
+ * @return Number the available array slot in this.playlist[0].ads
519
+ */
520
+ getAdSlot(playAtPercent) {
521
+ const ads = _.get(this.block.metadata.config, 'playlist[0].ads', [])
522
+ // No ads defined, 0 slot
523
+ if (ads.length === 0) {
524
+ return 0
525
+ }
526
+ // See if it already exists
527
+ for (let i = 0; i < ads.length; i++) {
528
+ if (ads[i].play_at_percent === playAtPercent) {
529
+ return i
530
+ }
531
+ }
532
+ // Return the length since it's the "next" slot
533
+ return ads.length
534
+ },
535
+ onRemovePlaylistItem() {
536
+ if (this.block.metadata.config.playlist.length > 1) {
537
+ this.block.metadata.config.playlist.splice(
538
+ this.playlistIndex,
539
+ 1
540
+ )
541
+ }
542
+ // Select the first item if we deleted down to the first one
543
+ if (this.block.metadata.config.playlist.length === 1) {
544
+ this.playlistPaginator = 1
545
+ }
546
+ },
547
+ onFirstOrCreateAd(adIndex) {
548
+ // If the ad slot isn't setup yet
549
+ if (
550
+ _.isEmpty(
551
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
552
+ adIndex
553
+ ]
554
+ )
555
+ ) {
556
+ Vue.set(
557
+ this.block.metadata.config.playlist[this.playlistIndex].ads,
558
+ adIndex,
559
+ { sources: [], tracks: [] }
560
+ )
561
+ }
562
+
563
+ return this.block.metadata.config.playlist[this.playlistIndex].ads[
564
+ adIndex
565
+ ]
566
+ },
567
+ onAddPlaylistItem() {
568
+ this.block.metadata.config.playlist.push({
569
+ name: '',
570
+ sources: [],
571
+ tracks: [],
572
+ ads: [],
573
+ })
574
+
575
+ return this.block.metadata.config.playlist.length - 1
576
+ },
577
+ onPosterSelect(file) {
578
+ if (file === null) {
579
+ delete this.block.metadata.config.attributes
580
+ .poster_file_asset_id
581
+ this.block.metadata.config.attributes.poster = ''
582
+ } else {
583
+ this.block.metadata.config.attributes.poster_file_asset_id =
584
+ file.file_asset_id
585
+ this.block.metadata.config.attributes.poster =
586
+ file.asset.public_url
587
+ }
588
+ },
589
+ onSourceSelect(file) {
590
+ this.reloadVideo()
591
+ // No file, clear the selection
592
+ if (_.isEmpty(file)) {
593
+ delete this.block.metadata.config.playlist[this.playlistIndex]
594
+ .name
595
+ this.block.metadata.config.playlist[
596
+ this.playlistIndex
597
+ ].sources = []
598
+
599
+ this.showVideo = false
600
+ } else {
601
+ // Apply an updated name
602
+ this.block.metadata.config.playlist[this.playlistIndex].name =
603
+ file.name ||
604
+ this.$t(
605
+ 'windward.core.components.settings.video.default_filename'
606
+ )
607
+
608
+ // Apply the playlist source video(s)
609
+ this.block.metadata.config.playlist[
610
+ this.playlistIndex
611
+ ].sources = [
612
+ {
613
+ file_asset_id: file.file_asset_id,
614
+ src: file.asset.public_url,
615
+ type: file.asset.metadata.mime,
616
+ },
617
+ ]
618
+
619
+ this.showVideo = true
620
+ }
621
+ },
622
+ onTrackSelect(file) {
623
+ this.reloadVideo()
624
+ if (_.isEmpty(file)) {
625
+ this.block.metadata.config.playlist[this.playlistIndex].tracks =
626
+ []
627
+ this.showVideo = false
628
+ } else {
629
+ this.block.metadata.config.playlist[this.playlistIndex].tracks =
630
+ [
631
+ {
632
+ file_asset_id: file.file_asset_id,
633
+ src: file.asset.public_url,
634
+ kind: 'captions',
635
+ srclang: 'en-US',
636
+ default: true,
637
+ },
638
+ ]
639
+ }
640
+ },
641
+
642
+ onAdSourceSelect(file, playAtPercent) {
643
+ const adIndex = this.getAdSlot(playAtPercent)
644
+
645
+ // Prep in case the ad slot isn't setup yet
646
+ this.onFirstOrCreateAd(adIndex)
647
+
648
+ if (_.isEmpty(file)) {
649
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
650
+ adIndex
651
+ ].sources = []
652
+ } else {
653
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
654
+ adIndex
655
+ ].play_at_percent = playAtPercent
656
+
657
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
658
+ adIndex
659
+ ].sources = [
660
+ {
661
+ file_asset_id: file.file_asset_id,
662
+ src: file.asset.public_url,
663
+ type: file.asset.metadata.mime,
664
+ },
665
+ ]
666
+ }
667
+ },
668
+ onAdTrackSelect(file, playAtPercent) {
669
+ const adIndex = this.getAdSlot(playAtPercent)
670
+
671
+ if (_.isEmpty(file)) {
672
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
673
+ adIndex
674
+ ].tracks = []
675
+ } else {
676
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
677
+ adIndex
678
+ ].play_at_percent = playAtPercent
679
+
680
+ this.block.metadata.config.playlist[this.playlistIndex].ads[
681
+ adIndex
682
+ ].tracks = [
683
+ {
684
+ file_asset_id: file.file_asset_id,
685
+ src: file.asset.public_url,
686
+ kind: 'captions',
687
+ srclang: 'en-US',
688
+ default: true,
689
+ },
690
+ ]
691
+ }
692
+ },
693
+ onPlaybackChange(e) {
694
+ // Sort the list so we don't get instances of 2, 1, 0.25, 3
695
+ this.block.metadata.config.attributes.playbackrates.sort()
696
+ },
697
+ },
698
+ }
699
+ </script>