Skip to content

Commit

Permalink
put quotes around elements, need to fix attach files
Browse files Browse the repository at this point in the history
  • Loading branch information
judithweng committed Aug 13, 2024
1 parent 54d4d17 commit f22923c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/frontend/components/Forms/CreateContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default {
description: this.description,
tags: tag_set,
children_key: [],
children_name: [],
hasParent: true,
isReportingKey: true,
}, this.pictures || [])
Expand Down Expand Up @@ -202,7 +203,8 @@ export default {
deviceName: childName,
description: this.description, // need to see if we want a special description when making a child
tags:this.tags,
children_key: '',
children_key: [],
children_name: [],
hasParent: true,
isReportingKey: false
}, this.pictures || [])
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/components/Forms/CreateDevice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default {
description: '',
tags: [] as string[],
children_key: [] as string[],
children_name: [] as string[],
hasParent: false, // states whether a device is contained within a box/container
pictures: [] as File[] | null,
}
Expand All @@ -84,6 +85,7 @@ export default {
description: this.description,
tags: this.tags,
children_key: [],
children_name: [],
hasParent: false,
isReportingKey: false,
}, this.pictures || [])
Expand Down
31 changes: 19 additions & 12 deletions packages/frontend/components/Provenance/CreateRecord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. -->
<label>Container Key (optional): </label>
<input type="text" class="form-control" name="container-key" id="container-key" v-model="containerKey" />
<label>Contained Devices Keys (optional, separated with a coma): </label>
<input type="text" class="form-control" name="children-key" id="children-key" v-model="childrenKey" />
<input type="text" class="form-control" name="children-key" id="children-key" v-model="enteredChildKeys" />
<div>
<span v-for="(childkey1, index) in childrenKey" :key="childkey1">
{{ childkey1 }}{{ index !== childrenKey.length - 1 && childkey1.endsWith(',') ? ' ' : ''}}
<span v-for="(childkey1, index) in enteredChildKeys" :key="childkey1">
{{ childkey1 }}{{ index !== enteredChildKeys.length - 1 && childkey1.endsWith(',') ? ' ' : ''}}
</span>
</div>
<div class="mt-1">
Expand All @@ -70,7 +70,7 @@ export default {
pictures: [] as File[] | null,
tags: [] as string[],
containerKey: '',
childrenKey: [] as string[],
enteredChildKeys: [] as string[],
hasParent: false,
isReportingKey: false,
}
Expand All @@ -89,7 +89,7 @@ export default {
},
computed: {
uniqueChildrenKeys() {
const uniqueValues = [...new Set(this.childrenKey)];
const uniqueValues = [...new Set(this.enteredChildKeys)];
return uniqueValues.filter(childKey => childKey); // Filter out empty strings if any
}
},
Expand All @@ -111,7 +111,7 @@ export default {
this.pictures = null;
this.tags = [];
this.containerKey = '';
this.childrenKey = [];
this.enteredChildKeys = [];
this.hasParent = false;
this.isReportingKey = false;
},
Expand All @@ -125,7 +125,8 @@ export default {
postProvenance(key, {
blobType: 'deviceRecord',
description: recallReason,
children_key: '',
children_key: [],
children_name: [],
tags: tags,
}, this.pictures || [])
}
Expand All @@ -140,6 +141,7 @@ export default {
this.hasParent = local_deviceRecord.hasParent;
this.isReportingKey = local_deviceRecord.isReportingKey;
let descendantsList = await getAllDescendants(this.deviceKey);
let enteredChildNames:string[] = [];
//here we post provenance if a container (parent) key was entered
if (this.containerKey != '') {
Expand All @@ -161,6 +163,7 @@ export default {
description: this.description, // keep the same description?
tags: [],
children_key: [this.deviceKey],
children_name: response[response.length - 1].record.deviceName,
hasParent: true,
}, this.pictures || [])
Expand All @@ -169,8 +172,8 @@ export default {
}
}
if (this.childrenKey.length > 1) { // if user want to add children keys
let string_children = this.childrenKey.toString();
if (this.enteredChildKeys.length > 1) { // if user want to add children keys
let string_children = this.enteredChildKeys.toString();
let entered_children = string_children.split(",");
entered_children = [...new Set(entered_children)]; //removing any duplicates
let new_children_list = entered_children.slice(0); //copy this exact array
Expand Down Expand Up @@ -206,20 +209,23 @@ export default {
console.log("This device key is among descendants.");
this.description = this.description + `\nError: Child device could not be added.`;
new_children_list.splice(index, 1);
} else {
} else { // Here we finally add the child as it has passed all the requirements
enteredChildNames = enteredChildNames.concat(child_prov[child_prov.length-1].record.deviceName);
postProvenance(i, {
blobType: 'deviceRecord',
description: "Added parent", // need to discuss whether we want to have a unique description
tags: [],
children_key: [],
children_name: [],
hasParent: true, // make sure the child has parent = true
}, this.pictures || [])
}
}
}
}
this.childrenKey = new_children_list;
this.enteredChildKeys = new_children_list;
}
const recall = this.tags.indexOf("recall", 0);
Expand Down Expand Up @@ -253,7 +259,8 @@ export default {
blobType: 'deviceRecord',
description: this.description,
tags: this.tags,
children_key: this.childrenKey,
children_key: this.enteredChildKeys,
children_name: enteredChildNames,
hasParent: this.hasParent,
}, this.pictures || [])
.then(response => {
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend/components/csvProvenance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export default {
let fileNames = await Promise.all(provenance.map( x => getAttachmentName(x, this.deviceKey)));
let data = provenance.map( (x, index) =>
([new Date(x.timestamp)]).concat(x.record.description,
JSON.stringify(x.record.tags),
JSON.stringify(fileNames[index]),
JSON.stringify(x.record.children_name),
JSON.stringify(x.record.children_key) )).join("\n");
([new Date(x.timestamp)]).concat(String('"' + x.record.description + '"'),
String('"'+ x.record.tags + '"'),
String('"'+fileNames[index]+'"'),
String('"'+x.record.children_name+'"'),
String('"'+x.record.children_key+'"') )).join("\n");
data = data.replaceAll('[]','') //removes any empty arrays []
Expand Down

0 comments on commit f22923c

Please sign in to comment.