Skip to content

Commit 0308534

Browse files
committed
Fix index
1 parent 0351de2 commit 0308534

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

templates/index.html

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,21 @@ <h5 class="modal-title">Condition editor</h5>
5252
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
5353
</div>
5454
<div class="modal-body">
55-
<div v-for="(item, i) in conditions">
5655
<div v-for="(item, i) in conditions">
5756
<div class="row no-gutters">
5857
<div class="col-sm-2">Condition path-value:</div>
5958
<div class="col-sm-7">
6059
<input class="form-control" type="text" v-model="item.xpath">
61-
<input class="form-control" type="text" v-model="item.xpath">
6260
</div>
6361
<div class="col-sm-2">
6462
<input class="form-control" type="text" v-model="item.value">
65-
<input class="form-control" type="text" v-model="item.value">
6663
</div>
6764
<div class="col-sm-1">
6865
<button type="button" class="btn btn-primary btn-sm" @click="conditions.splice(i, 1)">Delete</button>
69-
<button type="button" class="btn btn-primary btn-sm" @click="conditions.splice(i, 1)">Delete</button>
7066
</div>
7167
</div>
7268
</div>
7369
<button type="button" class="btn btn-primary btn-sm" onclick="addCondition(app.conditions)">Add condition</button>
74-
<button type="button" class="btn btn-primary btn-sm" onclick="addCondition(app.conditions)">Add condition</button>
7570
</div>
7671
<div class="modal-footer">
7772
<button type="button" class="btn btn-primary btn-sm" data-bs-dismiss="modal">Dimiss</button>
@@ -273,7 +268,20 @@ <h2 class="accordion-header" :id="'L' + j">
273268
}
274269
var app = Vue.createApp({
275270
data() {
276-
return { x3ml: {}, lido: '', x3file: null, lidoURL: null, activeM: -1, activeL: -1, conditions: [], mode: '' }
271+
return {
272+
x3ml: {},
273+
lido: '',
274+
x3file: null,
275+
lidoURL: null,
276+
activeM: -1,
277+
activeL: -1,
278+
conditions: [],
279+
mode: '',
280+
modeFormatKeys: new Map(),
281+
tmp: ["abc", "abcd", "xxxx"],
282+
formatKey: 'n3',
283+
useBlankNode: false
284+
}
277285
},
278286
delimiters: ["${", "}$"], // for global
279287
compilerOptions: { delimiters: ["${", "}$"] }, // for standalone
@@ -308,7 +316,7 @@ <h2 class="accordion-header" :id="'L' + j">
308316
});
309317
}
310318
},
311-
applyConditionChanges() {
319+
applyConditionChanges() {
312320
if (this.mode == 'map') {
313321
// Applies condition changes for a mapping
314322
domain = this.x3ml.mappings[this.activeM].domain
@@ -319,11 +327,29 @@ <h2 class="accordion-header" :id="'L' + j">
319327
link = this.x3ml.mappings[this.activeM].links[this.activeL]
320328
link.path.targetRelation.conditions = this.conditions;
321329
}
330+
rdfEditor.setValue('', -1);
322331
this.mode = ''
323332
this.activeL = -1;
324333
this.activeM = -1;
325334
this.conditions = [];
326335
},
336+
337+
downloadMappings() {
338+
post('json_to_x3ml', { x3ml: this.x3ml })
339+
.then(res => res.json())
340+
.then(json => {
341+
x3ml_str = json.x3ml;
342+
const url = window.URL.createObjectURL(new Blob([x3ml_str]));
343+
const link = document.createElement('a');
344+
link.href = url;
345+
link.setAttribute('download', 'mapping.x3ml');
346+
document.body.appendChild(link);
347+
link.click();
348+
link.parentNode.removeChild(link);
349+
})
350+
.catch(() => alert('An error occurred while downloading the mapping file.'));
351+
},
352+
327353
resetMappings() {
328354
rdfEditor.setValue('', -1);
329355
this.getDfltX3ml();
@@ -379,7 +405,6 @@ <h2 class="accordion-header" :id="'L' + j">
379405
this.activeL = parseInt(attrs.iL.value);
380406
link = this.x3ml.mappings[this.activeM].links[this.activeL]
381407
this.conditions = clone(link.path.targetRelation.conditions);
382-
this.conditions = clone(link.path.targetRelation.conditions);
383408
$('#conditionEditor').modal('show');
384409
}
385410
},
@@ -391,7 +416,6 @@ <h2 class="accordion-header" :id="'L' + j">
391416
this.activeM = parseInt(attrs.iM.value);
392417
domain = this.x3ml.mappings[this.activeM].domain
393418
this.conditions = clone(domain.targetNode.conditions);
394-
this.conditions = clone(domain.targetNode.conditions);
395419
$('#conditionEditor').modal('show');
396420
}
397421
},
@@ -491,7 +515,8 @@ <h2 class="accordion-header" :id="'L' + j">
491515
conditions.push(clone(conditions.at(-1)));
492516
}
493517
else {
494-
conditions.push({ attributes: {}, tag: "equals", value: "a value", xpath: "a path" } );
518+
// Create a default condition
519+
conditions.push({ attributes: {}, tag: "equals", value: "a value", xpath: "a path" });
495520
}
496521
}
497522

0 commit comments

Comments
 (0)