Skip to content

Commit

Permalink
create shared assets folder
Browse files Browse the repository at this point in the history
  • Loading branch information
IshavSohal committed Dec 23, 2024
1 parent 2f3e83f commit ff8b2da
Show file tree
Hide file tree
Showing 9 changed files with 529 additions and 54 deletions.
4 changes: 4 additions & 0 deletions src/components/dynamic-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
:centerSlide="centerSlide"
:dynamicSelected="dynamicSelected"
@slide-edit="$emit('slide-edit')"
@shared-asset="(assetName: string) => {
console.log('emitting shared-asset event from dynamic editor');
$emit('shared-asset', assetName);
}"
></component>
</div>
</div>
Expand Down
81 changes: 78 additions & 3 deletions src/components/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@
:slideIndex="slideIndex"
@slide-change="selectSlide"
@slides-updated="updateSlides"
@shared-asset="onSharedAsset"
@process-panel="panelHelper"
:configFileStructure="configFileStructure"
:lang="configLang"
:sourceCounts="sourceCounts"
Expand Down Expand Up @@ -279,6 +281,8 @@
:slideIndex="slideIndex"
@slide-change="selectSlide"
@slides-updated="updateSlides"
@shared-asset="onSharedAsset"
@process-panel="panelHelper"
:configFileStructure="configFileStructure"
:lang="configLang"
:sourceCounts="sourceCounts"
Expand All @@ -298,6 +302,7 @@
:slideIndex="slideIndex"
:isLast="slideIndex === slides.length - 1"
:uid="uuid"
@shared-asset="onSharedAsset"
@slide-change="selectSlide"
@slide-edit="onSlidesEdited"
@custom-slide-updated="updateCustomSlide"
Expand Down Expand Up @@ -332,14 +337,17 @@
<script lang="ts">
import { Options, Prop, Vue, Watch } from 'vue-property-decorator';
import {
BasePanel,
ConfigFileStructure,
HelpSection,
ImagePanel,
MetadataContent,
MultiLanguageSlide,
Slide,
SourceCounts,
StoryRampConfig,
TextPanel
TextPanel,
VideoPanel
} from '@/definitions';
import { VueSpinnerOval } from 'vue3-spinners';
import axios from 'axios';
Expand Down Expand Up @@ -404,9 +412,74 @@ export default class EditorV extends Vue {
@Watch('slides', { deep: true })
onSlidesEdited(): void {
console.log('editor - slide edit event emitted');
this.$emit('save-status', true);
}
/**
* Executes a callback for each ImagePanel/VideoPanel within the provided BasePanel
*
* @param panel The panel which we are processing
* @param callback The callback function that is called on each ImagePanel/VideoPanel in the provided BasePanel
* @param callbackArgs The additional argument(s) for the callback function (can be empty)
*/
panelHelper(panel: BasePanel, callback: (panel: ImagePanel | VideoPanel, ...args) => void, ...callbackArgs): void {
switch (panel.type) {
case 'slideshow':
panel.items.forEach((item) => this.panelHelper(item, callback, ...callbackArgs));
break;
case 'dynamic':
panel.children.forEach((child) => this.panelHelper(child.panel, callback, ...callbackArgs));
break;
case 'image':
case 'video':
callback(panel, ...callbackArgs);
}
}
// move asset from opposite lang's assets folder to shared assets folder
onSharedAsset(assetName: string, oppositeLang: string): void {
console.log('editor - asset to be moved to shared asset folder');
console.log(assetName);
const oppositeConfig = this.configs[oppositeLang];
console.log('opposte lang');
console.log(oppositeLang);
console.log('opposite langs config (before)');
console.log(JSON.parse(JSON.stringify(oppositeConfig)));
console.log('opposite langs slides (before)');
console.log(JSON.parse(JSON.stringify(oppositeConfig?.slides)));
const updateAssetSrc = (panel: ImagePanel | VideoPanel, assetName: string, oppositeLang: string) => {
if (panel.src) {
let assetSrc = panel.src.split('/');
const assetFolder = assetSrc[2];
if (panel.src.includes(assetName) && assetFolder === oppositeLang) {
console.log('need to change to shared');
assetSrc[2] = 'shared';
panel.src = assetSrc.join('/');
}
}
};
oppositeConfig?.slides.forEach((slide) => {
console.log('current slide');
console.log(JSON.parse(JSON.stringify(slide)));
slide.panel.forEach((panel) => {
console.log('current panel');
console.log(JSON.parse(JSON.stringify(panel)));
this.panelHelper(panel, updateAssetSrc, assetName, oppositeLang);
});
});
console.log('opposite langs config (after)');
console.log(JSON.parse(JSON.stringify(oppositeConfig)));
console.log('opposite langs slides (after)');
console.log(JSON.parse(JSON.stringify(oppositeConfig?.slides)));
this.$emit('save-status', true);
console.log(' ');
}
@Watch('metadata', { deep: true })
onMetadataEdited(): void {
this.$emit('save-status', true);
Expand Down Expand Up @@ -467,15 +540,17 @@ export default class EditorV extends Vue {
panel: [{ type: 'loading-page' }, { type: 'loading-page' }]
};
const newLang = lang ? lang : this.configLang ? this.configLang : 'en';
this.$emit('lang-change', newLang);
setTimeout(() => {
if (index === -1 || !this.loadSlides) {
this.currentSlide = '';
} else {
const selectedLang = (lang ?? this.configLang) as keyof MultiLanguageSlide;
const selectedLang = newLang as keyof MultiLanguageSlide;
const selectedSlide = this.loadSlides[index][selectedLang];
this.currentSlide = selectedSlide ?? '';
}
this.slideIndex = index;
(this.$refs.slide as SlideEditorV).panelIndex = 0;
(this.$refs.slide as SlideEditorV).advancedEditorView = false;
Expand Down
1 change: 1 addition & 0 deletions src/components/helpers/custom-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default class CustomEditorV extends Vue {
}
saveChanges(): void {
console.log('customeditor.vue - saving changes after opening advanced editor ');
this.$emit('config-edited', this.updatedConfig);
this.edited = false;
Expand Down
Loading

0 comments on commit ff8b2da

Please sign in to comment.