Skip to content

Commit

Permalink
remove redundant schema file, remove modified panel prop
Browse files Browse the repository at this point in the history
  • Loading branch information
IshavSohal committed Feb 18, 2025
1 parent c4b7ff8 commit 301f51e
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 574 deletions.
493 changes: 0 additions & 493 deletions StorylinesSchema.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"backgroundImage": "00000000-0000-0000-0000-000000000000/assets/en/GettyImages-187242601__1554821467033__w1920.jpg",
"panel": [
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/test-ramp4.json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/OilSandsDeposits.json",
"type": "map",
"scrollguard": true
},
Expand Down Expand Up @@ -89,7 +89,7 @@
{
"id": "panel-4",
"panel": {
"config": "00000000-0000-0000-0000-000000000000/ramp-config/OilSandsFacilityLocations2019.json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/OilSandsFacilityLocations2019.json",
"type": "map",
"scrollguard": true
}
Expand Down Expand Up @@ -156,7 +156,7 @@
"type": "text"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/OilSandsDeposits.json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/OilSandsDeposits.json",
"type": "map",
"scrollguard": true
}
Expand Down Expand Up @@ -203,7 +203,7 @@
"type": "text"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/OilSandsFacilityLocations2019.json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/OilSandsFacilityLocations2019.json",
"type": "map",
"title": "Map Title Test"
}
Expand Down Expand Up @@ -264,7 +264,7 @@
"type": "text"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/ReleasesandDisposalsbyMiningFacilitiesin2019(satellite).json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/ReleasesandDisposalsbyMiningFacilitiesin2019(satellite).json",
"type": "map"
}
]
Expand Down Expand Up @@ -306,7 +306,7 @@
"type": "text"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/ReleasesandDisposalsbyMiningFacilitiesin2019(satellite).json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/ReleasesandDisposalsbyMiningFacilitiesin2019(satellite).json",
"type": "map"
}
],
Expand All @@ -321,7 +321,7 @@
"type": "text"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/TailingsfromMiningFacilities2010to2019(timeslider).json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/TailingsfromMiningFacilities2010to2019(timeslider).json",
"timeSlider": {
"range": [2010, 2019],
"start": [2010, 2010],
Expand Down Expand Up @@ -356,7 +356,7 @@
"type": "text"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/ReleasestoAirbyInSituFacilitiesforAllSubstancesin2019.json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/ReleasestoAirbyInSituFacilitiesforAllSubstancesin2019.json",
"type": "map"
}
],
Expand Down Expand Up @@ -422,7 +422,7 @@
"customStyles": "border: 2px solid black;"
},
{
"config": "00000000-0000-0000-0000-000000000000/ramp-config/ReleasesandDisposalsbyMiningFacilitiesin2019(satellite).json",
"config": "00000000-0000-0000-0000-000000000000/ramp-config/en/ReleasesandDisposalsbyMiningFacilitiesin2019(satellite).json",
"type": "map",
"scrollguard": true
},
Expand Down
32 changes: 0 additions & 32 deletions public/StorylinesSlideSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@
"customStyles": {
"type": "string",
"description": "Additional CSS styles to apply to the panel."
},
"modified": {
"type": "boolean",
"description": "An optional tag that specifies whether the panel has been modified from its default configuration"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -278,10 +274,6 @@
"type": "object",
"description": "A multimedia image component.",
"properties": {
"id": {
"type": "string",
"description": "The image ID."
},
"width": {
"type": "number",
"description": "The image width."
Expand Down Expand Up @@ -370,10 +362,6 @@
"customStyles": {
"type": "string",
"description": "Additional CSS styles to apply to the panel."
},
"modified": {
"type": "boolean",
"description": "An optional tag that specifies whether the panel has been modified from its default configuration"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -419,11 +407,6 @@
"type": "text",
"description": "A caption to display below the slideshow."
},
"userCreated": {
"type": "boolean",
"description": "Specifies whether this slideshow was automatically created from an image panel or if this is actually a slideshow panel.",
"default": false
},
"type": {
"type": "string",
"enum": ["slideshow"]
Expand Down Expand Up @@ -520,21 +503,6 @@
"type": "boolean",
"description": "Optional attribute that indicates whether or not to include slide in table of contents. Defaults to true.",
"default": true
},
"rightOnly": {
"type": "boolean",
"description": "Optional attribute that indicates whether or not the right panel should take up all of the space in the slide. Defaults to false.",
"default": false
},
"centerSlide": {
"type": "boolean",
"description": "Optional attribute that indicates whether or not to center the content of the slide. Defaults to false. Must be false if centerPanel (below) is true",
"default": false
},
"centerPanel": {
"type": "boolean",
"description": "Optional attribute that indicates whether or not to center the content of each panel. Defaults to false. Must be false if centerSlide (above) is true",
"default": false
}

},
Expand Down
1 change: 1 addition & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ app.route(ROUTE_PREFIX + '/retrieve/:id/:hash').get(function (req, res, next) {
// This event listener is fired when the write stream has finished. This means that the
// ZIP file should be correctly populated. Now, we can set the correct headers and send the
// ZIP file to the client.

output.on('close', () => {
// Delete the zip file if the product load was cancelled by the user
if (isRequestAborted) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default class ChartEditorV extends Vue {
onChartsEdited(): void {
this.edited = true;
this.$emit('slide-edit', this.chartConfigs.length !== 0);
this.$emit('slide-edit');
}
}
</script>
Expand Down
5 changes: 3 additions & 2 deletions src/components/image-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,9 @@ export default class ImageEditorV extends Vue {
// Turn each of the image configs into an image panel and add them to the slidesow.
(this.panel as SlideshowPanel).items = this.imagePreviews.map((imageFile: ImageFile) => {
const { id, ...restOfImage } = imageFile; // we don't need the id
return {
...imageFile,
...restOfImage,
src: `${this.configFileStructure.uuid}/assets/${this.lang}/${imageFile.id}`,
type: PanelType.Image
} as ImagePanel;
Expand All @@ -377,7 +378,7 @@ export default class ImageEditorV extends Vue {
onImagesEdited(): void {
this.edited = true;
this.$emit('slide-edit', this.imagePreviews.length !== 0);
this.$emit('slide-edit');
}
}
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/components/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ export default class MetadataEditorV extends Vue {
};
slides: MultiLanguageSlide[] = [];
sourceCounts: SourceCounts = {};
sessionExpired: boolean = false;
sessionExpired = false;
totalTime = import.meta.env.VITE_APP_CURR_ENV ? Number(import.meta.env.VITE_SESSION_END) : 30;
mounted(): void {
Expand Down Expand Up @@ -1349,6 +1349,7 @@ export default class MetadataEditorV extends Vue {
// Update the path to the RAMP config in the product config file.
panel.config = panel.config.replace(`/${prevUuid}-map-`, `/${this.changeUuid}-map-`);
}
break;
default:
// Base case. This is a panel that doesn't have any children (i.e., not dynamic, slideshow).
// Rename the source.
Expand Down
65 changes: 36 additions & 29 deletions src/components/slide-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
id="centerSlide"
class="rounded-none cursor-pointer w-4 h-4"
v-model="centerSlide"
:disabled="centerPanel"
:disabled="centerPanel || onePanelOnly"
@change.stop="toggleCenterSlide()"
/>
<label class="ml-0" for="centerSlide">
Expand Down Expand Up @@ -350,15 +350,7 @@
:sourceCounts="sourceCounts"
:centerSlide="centerSlide"
:dynamicSelected="dynamicSelected"
@slide-edit="(changedFromDefault: boolean = true) => {
$emit('slide-edit');
// changedFromDefault should hold a boolean indicating whether the panel is actually modified
// (different from initial state). Only needed for some multimedia editors; text editors
// write directly to currentSlide constantly, which is handled by panelModified().
currentSlide.panel[panelIndex].modified = changedFromDefault || undefined;
}
"
@slide-edit="$emit('slide-edit')"
v-else
></component>
</div>
Expand Down Expand Up @@ -491,24 +483,33 @@ export default class SlideEditorV extends Vue {
@Watch('currentSlide', { deep: true })
onSlideChange(): void {
// When there is a single panel, centering slide content AND panel content produces the same styling
// ('text-align: center'). So, we just disable the center panel content control upon full screen panel. This
// also clears up confusion, as the user may believe that the two controls produce different results for a
// single panel slide
this.onePanelOnly = this.currentSlide?.panel.length === 1;
const centerPanel = this.currentSlide.panel.reduce(
(panelsCentered, currPanel) => panelsCentered && currPanel.customStyles?.includes('text-align: center'),
true
);
const centerSlide = this.onePanelOnly
? false
: this.currentSlide.panel[0].customStyles?.includes('text-align: right') &&
this.currentSlide.panel[1].customStyles?.includes('text-align: left');
this.langTranslate = this.$t(`editor.lang.${this.lang}`);
this.centerPanel = this.currentSlide.centerPanel ?? false;
this.centerSlide = this.currentSlide.centerSlide ?? false;
this.centerPanel = centerPanel ?? false;
this.centerSlide = centerSlide ?? false;
this.includeInToc = this.currentSlide.includeInToc ?? true;
this.onePanelOnly = this.currentSlide?.rightOnly || this.currentSlide?.panel.length === 1;
}
/**
* Determines whether a given panel has been modified from the default configuration of its type.
* Note that some editors (e.g. text) write directly to currentSlide after each change,
* while other editors (e.g. image) do not. The first type is handled completely in
* panelModified; the second type requires you to set `panel.modified` for the given panel beforehand,
* indicating whether changes have been made from the specific editor sub-component (see
* `<component>`'s `@slide-edit` event handler).
*
* @param {BasePanel} panel The panel to analyze.
* @returns {boolean} Whether panel has been modified.
*/
panelModified(panel: BasePanel): boolean {
this.saveChanges(); // Used to capture unsaved changes before comparing with the corresponding default config
const prevType = this.currentSlide.panel[this.panelIndex].type;
let startingConfig = {
Expand Down Expand Up @@ -537,14 +538,9 @@ export default class SlideEditorV extends Vue {
};
const oldStartingConfig = startingConfig[panel.type as keyof DefaultConfigs];
let newConfig = Object.assign({}, toRaw(panel));
newConfig.customStyles = newConfig.customStyles || undefined;
return (
JSON.stringify(oldStartingConfig) !== JSON.stringify(newConfig) ||
this.currentSlide.panel[this.panelIndex].modified === true
);
return JSON.stringify(oldStartingConfig) !== JSON.stringify(newConfig);
}
changePanelType(prevType: string, newType: string): void {
Expand Down Expand Up @@ -579,8 +575,6 @@ export default class SlideEditorV extends Vue {
// Switching panel type when dynamic panels are not involved.
this.currentSlide.panel[this.panelIndex] = startingConfig[newType as keyof DefaultConfigs];
}
this.currentSlide.rightOnly = this.currentSlide.panel.length === 1;
}
removeSourceCounts(panel: BasePanel): void {
Expand Down Expand Up @@ -690,11 +684,21 @@ export default class SlideEditorV extends Vue {
}
toggleOnePanelOnly(addToWhichSide?: 'left' | 'right'): void {
this.currentSlide.rightOnly = this.onePanelOnly;
this.saveChanges();
if (this.onePanelOnly) {
this.currentSlide['panel'] = [this.currentSlide.panel[this.panelIndex]];
this.panelIndex = 0;
// Since we disable the 'center slide content' control in this case, we need to check if it is
// toggled on. If so, we toggle it off, and toggle on the 'center panel content' control, since they
// are equivalent in the case of a fullscreen panel
if (this.centerSlide) {
this.centerSlide = false;
this.toggleCenterSlide();
this.centerPanel = true;
this.toggleCenterPanel();
}
} else {
this.currentSlide['panel'] = [
...(addToWhichSide === 'right' ? [Object.assign({}, this.currentSlide.panel[0])] : []),
Expand All @@ -709,11 +713,15 @@ export default class SlideEditorV extends Vue {
...(addToWhichSide === 'left' ? [Object.assign({}, this.currentSlide.panel[0])] : [])
];
this.panelIndex = addToWhichSide === 'left' ? 0 : 1;
// Need to apply centering to both panels
if (this.centerPanel) {
this.toggleCenterPanel();
}
}
}
toggleCenterSlide(): void {
this.currentSlide.centerSlide = this.centerSlide;
if (this.determineEditorType(this.currentSlide.panel[this.panelIndex]) === 'dynamic') {
if (this.centerSlide) {
this.currentSlide.panel[0].customStyles = 'text-align: right;';
Expand Down Expand Up @@ -758,7 +766,6 @@ export default class SlideEditorV extends Vue {
}
toggleCenterPanel(): void {
this.currentSlide.centerPanel = this.centerPanel;
if (this.centerPanel) {
for (const p in this.currentSlide.panel) {
this.currentSlide.panel[p].customStyles = 'text-align: center;';
Expand Down
4 changes: 2 additions & 2 deletions src/components/slide-toc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ import {
DynamicPanel,
ImagePanel,
MapPanel,
Slide,
MultiLanguageSlide,
Slide,
SlideshowPanel,
SourceCounts,
TextPanel,
Expand Down Expand Up @@ -405,7 +405,7 @@ export default class SlideTocV extends Vue {
@Prop() configFileStructure!: ConfigFileStructure;
@Prop() lang!: string;
@Prop() sourceCounts!: SourceCounts;
@Prop() closeSidebar!: Function;
@Prop() closeSidebar!: () => void;
@Prop({ default: false }) isMobileSidebar!: boolean;
defaultBlankSlide: Slide = {
Expand Down
5 changes: 4 additions & 1 deletion src/components/slideshow-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export default class SlideshowEditorV extends Vue {
}
saveItem(add = false): void {
console.log('slideshow editor - save item');
let itemConfig;
if (add) {
Expand All @@ -273,7 +274,7 @@ export default class SlideshowEditorV extends Vue {
(this.$refs.slideEditor as ImageEditorV | ChartEditorV).saveChanges();
if (itemConfig.type === PanelType.Map) {
this.$emit('slide-edit', false);
this.$emit('slide-edit');
}
}
}
Expand All @@ -282,6 +283,8 @@ export default class SlideshowEditorV extends Vue {
}
saveChanges(): void {
console.log('slideshow editor - save changes');
delete this.panel.userCreated; // This property is only needed by the editor
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/video-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export default class VideoEditorV extends Vue {
onVideoEdited(): void {
this.edited = true;
this.$emit('slide-edit', this.videoPreview?.videoType || this.videoPreview?.title?.length ? true : false);
this.$emit('slide-edit');
}
}
</script>
Expand Down
Loading

0 comments on commit 301f51e

Please sign in to comment.