Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat(#408): clean only in case of split and load vertical from db in …
Browse files Browse the repository at this point in the history
…case of split
  • Loading branch information
peterpeterparker committed Oct 21, 2019
1 parent c1e57bc commit 71d2514
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
28 changes: 21 additions & 7 deletions studio/src/app/handlers/editor/events/deck/deck-events.handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,35 @@ export class DeckEventsHandler {
if ((slide as any).imgAlt) {
attributes.imgAlt = (slide as any).imgAlt;
}


const qrCodeAttributes: SlideAttributes = await this.getSlideAttributesQRCode(slide, cleanFields);
const chartAttributes: SlideAttributes = await this.getSlideAttributesChart(slide, cleanFields);
const splitAttributes: SlideAttributes = await this.getSlideAttributesSplit(slide, cleanFields);

attributes = {...attributes, ...qrCodeAttributes, ...chartAttributes, ...splitAttributes};

resolve(attributes);
})
}

private getSlideAttributesSplit(slide: HTMLElement, cleanFields: boolean): Promise<SlideAttributes> {
return new Promise<SlideAttributes>((resolve) => {
if (!slide || !slide.nodeName || slide.nodeName.toLowerCase() !== 'deckgo-slide-split') {
resolve({});
return;
}

let attributes: SlideAttributes = {};

if ((slide as any).vertical) {
attributes.vertical = true;
} else if (cleanFields) {
// @ts-ignore
attributes.vertical = firebase.firestore.FieldValue.delete();
}

const qrCodeAttributes: SlideAttributes = await this.getSlideAttributesQRCode(slide, cleanFields);
const chartAttributes: SlideAttributes = await this.getSlideAttributesChart(slide, cleanFields);

attributes = {...attributes, ...qrCodeAttributes, ...chartAttributes};

resolve(attributes);
})
});
}

private getSlideAttributesQRCode(slide: HTMLElement, cleanFields: boolean): Promise<SlideAttributes> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class AppCreateSlide {

private async addSlideSplit(template: SlideTemplate, attributes: SlideAttributes = undefined) {
const slide: JSX.IntrinsicElements = await CreateSlidesUtils.createSlideSplit(attributes);
await this.closePopover(template, slide, attributes);
await this.closePopover(template, slide);
}

private addSlideQRCode() {
Expand Down
3 changes: 3 additions & 0 deletions studio/src/app/utils/editor/parse-slides.utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class ParseSlidesUtils {
attributes['ticks'] = slide.data.attributes && slide.data.attributes.ticks ? slide.data.attributes.ticks : undefined;
attributes['grid'] = slide.data.attributes && slide.data.attributes.grid ? 'true' : undefined;
attributes['separator'] = slide.data.attributes && slide.data.attributes.separator ? slide.data.attributes.separator : undefined;
}

if (slide.data.template === SlideTemplate.SPLIT) {
attributes['vertical'] = slide.data.attributes && slide.data.attributes.vertical ? 'true' : undefined;
}

Expand Down

0 comments on commit 71d2514

Please sign in to comment.