Fix automatic activation of dependent fields in csvxmlV2.js
This commit is contained in:
parent
a817b59b9b
commit
82f01a0961
|
@ -17,12 +17,7 @@ class CsvxmlValidator {
|
||||||
mainImageResource: [],
|
mainImageResource: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
let list = {};
|
this.fieldList = Object.freeze(fieldList);
|
||||||
for (let sectionName in fieldList) {
|
|
||||||
list = Object.assign(list, fieldList[sectionName]);
|
|
||||||
}
|
|
||||||
this.fieldList = Object.freeze(list);
|
|
||||||
console.log(this.fieldList);
|
|
||||||
|
|
||||||
const lines = csvRaw.trim().replace("\r\n", "\n").split("\n");
|
const lines = csvRaw.trim().replace("\r\n", "\n").split("\n");
|
||||||
|
|
||||||
|
@ -376,6 +371,7 @@ class CsvxmlDialogue {
|
||||||
class CsvxmlPage {
|
class CsvxmlPage {
|
||||||
|
|
||||||
fieldList;
|
fieldList;
|
||||||
|
fieldListFlat;
|
||||||
tls;
|
tls;
|
||||||
domUploaderWrapper;
|
domUploaderWrapper;
|
||||||
domMainWrapper;
|
domMainWrapper;
|
||||||
|
@ -386,6 +382,13 @@ class CsvxmlPage {
|
||||||
|
|
||||||
constructor(fieldList) {
|
constructor(fieldList) {
|
||||||
this.fieldList = Object.freeze(fieldList);
|
this.fieldList = Object.freeze(fieldList);
|
||||||
|
|
||||||
|
let list = {};
|
||||||
|
for (let sectionName in fieldList) {
|
||||||
|
list = Object.assign(list, fieldList[sectionName]);
|
||||||
|
}
|
||||||
|
this.fieldListFlat = Object.freeze(list);
|
||||||
|
|
||||||
this.tls = Object.freeze(JSON.parse(document.body.getAttribute("data-tls")));
|
this.tls = Object.freeze(JSON.parse(document.body.getAttribute("data-tls")));
|
||||||
|
|
||||||
let domUploaderWrapper = document.createElement("div");
|
let domUploaderWrapper = document.createElement("div");
|
||||||
|
@ -405,14 +408,12 @@ class CsvxmlPage {
|
||||||
let line2 = [];
|
let line2 = [];
|
||||||
let line3 = [];
|
let line3 = [];
|
||||||
|
|
||||||
for (let sectionName in this.fieldList) {
|
for (let fieldName in this.fieldListFlat) {
|
||||||
const sectionFields = this.fieldList[sectionName];
|
|
||||||
for (let fieldName in sectionFields) {
|
|
||||||
console.log(fieldName);
|
console.log(fieldName);
|
||||||
console.log(selectedFields);
|
console.log(selectedFields);
|
||||||
|
|
||||||
if (selectedFields.length !== 0 && selectedFields.includes(fieldName) === false) continue;
|
if (selectedFields.length !== 0 && selectedFields.includes(fieldName) === false) continue;
|
||||||
const field = sectionFields[fieldName];
|
const field = this.fieldListFlat[fieldName];
|
||||||
|
|
||||||
line1.push(fieldName);
|
line1.push(fieldName);
|
||||||
line2.push(field.name_human_readable);
|
line2.push(field.name_human_readable);
|
||||||
|
@ -426,7 +427,6 @@ class CsvxmlPage {
|
||||||
else line3.push("");
|
else line3.push("");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const csvLine1 = '"' + line1.join('";"') + '"';
|
const csvLine1 = '"' + line1.join('";"') + '"';
|
||||||
const csvLine2 = '"' + line2.join('";"') + '"';
|
const csvLine2 = '"' + line2.join('";"') + '"';
|
||||||
|
@ -551,7 +551,7 @@ class CsvxmlPage {
|
||||||
// On loading success, check if the upload is valid JSON
|
// On loading success, check if the upload is valid JSON
|
||||||
console.log("Read file");
|
console.log("Read file");
|
||||||
// Validate the file
|
// Validate the file
|
||||||
let validator = new CsvxmlValidator(app.fieldList, reader.result);
|
let validator = new CsvxmlValidator(app.fieldListFlat, reader.result);
|
||||||
if (validator.isValid() === true) {
|
if (validator.isValid() === true) {
|
||||||
alert("Document is valid. Press ok to download.");
|
alert("Document is valid. Press ok to download.");
|
||||||
app.zipUploadToXml(validator);
|
app.zipUploadToXml(validator);
|
||||||
|
@ -630,13 +630,13 @@ class CsvxmlPage {
|
||||||
|
|
||||||
if (field.classList.contains("humanTLToggled") === false) return;
|
if (field.classList.contains("humanTLToggled") === false) return;
|
||||||
|
|
||||||
let dependencies = field.getAttribute("data-dependencies");
|
let dependencies = this.fieldListFlat[field.id].dependsOn;
|
||||||
if (dependencies !== undefined && dependencies !== null) {
|
if (dependencies !== undefined && dependencies !== null) {
|
||||||
let linkedFields = dependencies.split(";");
|
let linkedFields = this.fieldListFlat[field.id].dependsOn;
|
||||||
for (let i = 0, max = linkedFields.length; i < max; i++) {
|
for (let i = 0, max = linkedFields.length; i < max; i++) {
|
||||||
let linkedField = document.getElementById(linkedFields[i]);
|
let linkedField = document.getElementById(linkedFields[i]);
|
||||||
if (linkedField.classList.contains("humanTLToggled") === true) continue;
|
if (linkedField.classList.contains("humanTLToggled") === true) continue;
|
||||||
app.toggleListFieldSelectionState(linkedField);
|
this.toggleListFieldSelectionState(linkedField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user