Skip to content

Commit

Permalink
#83
Browse files Browse the repository at this point in the history
Adds Alert when an SVG is uploaded without a domain story attached
  • Loading branch information
AlexanderZellober committed Oct 28, 2020
1 parent 9cc6a4e commit 1828052
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
36 changes: 35 additions & 1 deletion app/domain-story-modeler/features/import/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ let modal = document.getElementById('modal'),
title = document.getElementById('title'),
versionInfo = document.getElementById('versionInfo'),
brokenDSTInfo = document.getElementById('brokenDSTInfo'),
brokenSVGInfo = document.getElementById('brokenSVGInfo'),
importedVersionLabel = document.getElementById('importedVersion'),
modelerVersionLabel = document.getElementById('modelerVersion'),
brokenDSTDialogButtonCancel = document.getElementById(
'brokenDSTDialogButtonCancel'
),
brokenSVGDialogButtonCancel = document.getElementById(
'brokenSVGDialogButtonCancel'
),
versionDialogButtonCancel = document.getElementById('closeVersionDialog');

let titleInputLast = '',
Expand All @@ -59,6 +63,10 @@ if (versionDialogButtonCancel) {
brokenDSTDialogButtonCancel.addEventListener('click', function() {
closeBrokenDSTDialog();
});

brokenSVGDialogButtonCancel.addEventListener('click', function() {
closeBrokenSVGDialog();
});
}

export function getTitleInputLast() {
Expand Down Expand Up @@ -205,9 +213,25 @@ export function readerFunction(text, version, modeler, type) {
} else if (type === DST_TYPE) {
dstText = text;
}

let elements, config;
let configChanged = false;
let dstAndConfig = JSON.parse(dstText);

let dstAndConfig;
try {
dstAndConfig = JSON.parse(dstText);
} catch (e) {
if (type === DST_TYPE) {
showBrokenDSTDialog();
}
else if (type === SVG_TYPE) {
showBrokenSVGDialog();
}
}

if (dstAndConfig == null) {
return;
}

if (dstAndConfig.domain) {
config = dstAndConfig.domain;
Expand Down Expand Up @@ -367,6 +391,16 @@ function showBrokenDSTDialog() {
modal.style.display = 'block';
}

function showBrokenSVGDialog() {
brokenSVGInfo.style.display = 'block';
modal.style.display = 'block';
}

function closeBrokenSVGDialog() {
brokenSVGInfo.style.display = 'none';
modal.style.display = 'none';
}

function closeBrokenDSTDialog() {
brokenDSTInfo.style.display = 'none';
modal.style.display = 'none';
Expand Down
3 changes: 3 additions & 0 deletions app/domain-story.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ input {
#keyboardShortcutInfoDialogButtonCancel,
#downloadDialogCancelButton,
#brokenDSTDialogButtonCancel,
#brokenSVGDialogButtonCancel,
#closeNoContentOnCanvasInfo {
position: absolute;
font-size: 9pt;
Expand Down Expand Up @@ -276,6 +277,7 @@ input {
#dictionaryDialog,
#numberDialog,
#brokenDSTInfo,
#brokenSVGInfo,
#labelDialog,
#wpsLogoInfo,
#dstLogoInfo,
Expand All @@ -295,6 +297,7 @@ input {
#versionInfo,
#keyboardShortcutInfo,
#brokenDSTInfo,
#brokenSVGInfo,
#noContentOnCanvasInfo {
font-size: 11pt;
border: solid 1px #aaaaab;
Expand Down
10 changes: 8 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,14 @@ <h3 id="headline">
<div id="brokenDSTInfo" style="display:none">
<button id="brokenDSTDialogButtonCancel">X</button>
<br>
<text>Your .dst File is incomplete, there most likely was an error during export.</text>
<text>Some of your activities and Domain Elements might be missing.</text>
<text>Your .dst File is corrupted, there most likely was an error during export.</text>
<text>If the domain story was imported, some of your activities and Domain Elements might be missing.</text>
</div>

<div id="brokenSVGInfo" style="display:none">
<button id="brokenSVGDialogButtonCancel">X</button>
<br>
<text>Your .svg File does not contain a Domain Story, there most likely was an error during export.</text>
</div>

<script src="./app.js"></script>
Expand Down

0 comments on commit 1828052

Please sign in to comment.