Add new metadata
This commit is contained in:
parent
6aa4c8bd76
commit
61120fef7c
1 changed files with 76 additions and 14 deletions
|
|
@ -65,6 +65,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Metadata modal -->
|
||||||
<div :id="metadataModalID" uk-modal>
|
<div :id="metadataModalID" uk-modal>
|
||||||
<div
|
<div
|
||||||
class="uk-modal-dialog uk-modal-body"
|
class="uk-modal-dialog uk-modal-body"
|
||||||
|
|
@ -80,14 +81,33 @@
|
||||||
<p><b>ID: </b>{{ captureState.metadata.id }}</p>
|
<p><b>ID: </b>{{ captureState.metadata.id }}</p>
|
||||||
<p><b>Format: </b>{{ captureState.metadata.format }}</p>
|
<p><b>Format: </b>{{ captureState.metadata.format }}</p>
|
||||||
|
|
||||||
<div v-for="(value, key) in captureState.metadata.custom" :key="key">
|
<hr />
|
||||||
|
|
||||||
|
<div v-for="(value, key) in customMetadata" :key="key">
|
||||||
<p>
|
<p>
|
||||||
<b>{{ key }}: </b>{{ value }}
|
<b>{{ key }}: </b>{{ value }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div class="uk-flex-bottom" uk-grid>
|
||||||
|
<div class="uk-width-2-3">
|
||||||
|
<keyvalList v-model="newCustomMetadata" />
|
||||||
|
</div>
|
||||||
|
<div class="uk-width-1-3">
|
||||||
|
<button
|
||||||
|
class="uk-button uk-button-primary uk-form-small uk-width-1-1"
|
||||||
|
@click="handleMetadataSubmit()"
|
||||||
|
>
|
||||||
|
Add metadata
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- New tag modal -->
|
||||||
<div :id="tagModalID" uk-modal>
|
<div :id="tagModalID" uk-modal>
|
||||||
<form
|
<form
|
||||||
class="uk-modal-dialog uk-modal-body uk-margin-auto-vertical"
|
class="uk-modal-dialog uk-modal-body uk-margin-auto-vertical"
|
||||||
|
|
@ -100,7 +120,8 @@
|
||||||
<div class="uk-inline">
|
<div class="uk-inline">
|
||||||
<span class="uk-form-icon"><i class="material-icons">label</i></span>
|
<span class="uk-form-icon"><i class="material-icons">label</i></span>
|
||||||
<input
|
<input
|
||||||
v-model="newtag"
|
v-model="newTag"
|
||||||
|
autofocus
|
||||||
class="uk-input uk-form-width-medium uk-form-small"
|
class="uk-input uk-form-width-medium uk-form-small"
|
||||||
type="text"
|
type="text"
|
||||||
name="tagname"
|
name="tagname"
|
||||||
|
|
@ -129,10 +150,16 @@
|
||||||
import UIkit from "uikit";
|
import UIkit from "uikit";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
|
import keyvalList from "../../fieldComponents/keyvalList";
|
||||||
|
|
||||||
// Export main app
|
// Export main app
|
||||||
export default {
|
export default {
|
||||||
name: "CaptureCard",
|
name: "CaptureCard",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
keyvalList
|
||||||
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
captureState: {
|
captureState: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
@ -143,7 +170,9 @@ export default {
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
tags: [],
|
tags: [],
|
||||||
newtag: ""
|
newTag: "",
|
||||||
|
customMetadata: {},
|
||||||
|
newCustomMetadata: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -191,13 +220,21 @@ export default {
|
||||||
|
|
||||||
created: function() {
|
created: function() {
|
||||||
this.getTagRequest();
|
this.getTagRequest();
|
||||||
|
this.getMetadataRequest();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
handleTagSubmit: function(event) {
|
handleTagSubmit: function(event) {
|
||||||
this.newTagRequest(this.newtag);
|
if (this.newTag !== "") {
|
||||||
this.newtag = "";
|
this.newTagRequest(this.newTag);
|
||||||
UIkit.modal(event.target.parentNode).hide(); // TODO: Remove somehow
|
this.newTag = "";
|
||||||
|
}
|
||||||
|
UIkit.modal(event.target.parentNode).hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
handleMetadataSubmit: function() {
|
||||||
|
this.putMetadataRequest(this.newCustomMetadata);
|
||||||
|
this.newCustomMetadata = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
delCaptureConfirm: function() {
|
delCaptureConfirm: function() {
|
||||||
|
|
@ -220,10 +257,10 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
newTagRequest: function(tag_string) {
|
newTagRequest: function(tagString) {
|
||||||
// Send tag PUT request
|
// Send tag PUT request
|
||||||
axios
|
axios
|
||||||
.put(this.tagsURL, [tag_string])
|
.put(this.tagsURL, [tagString])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Update tag array
|
// Update tag array
|
||||||
this.getTagRequest();
|
this.getTagRequest();
|
||||||
|
|
@ -233,18 +270,31 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
delTagConfirm: function(tag_string) {
|
putMetadataRequest: function(metadataObject) {
|
||||||
|
// Send metadata PUT request
|
||||||
|
axios
|
||||||
|
.put(this.captureURL, metadataObject)
|
||||||
|
.then(() => {
|
||||||
|
// Update metadata object
|
||||||
|
this.getMetadataRequest();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.modalError(error); // Let mixin handle error
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
delTagConfirm: function(tagString) {
|
||||||
var context = this;
|
var context = this;
|
||||||
this.modalConfirm(`Remove tag '${tag_string}'?`).then(function() {
|
this.modalConfirm(`Remove tag '${tagString}'?`).then(function() {
|
||||||
context.delTagRequest(tag_string);
|
context.delTagRequest(tagString);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
delTagRequest: function(tag_string) {
|
delTagRequest: function(tagString) {
|
||||||
console.log(tag_string);
|
console.log(tagString);
|
||||||
// Send tag DELETE request
|
// Send tag DELETE request
|
||||||
axios
|
axios
|
||||||
.delete(this.tagsURL, { data: [tag_string] })
|
.delete(this.tagsURL, { data: [tagString] })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Update tag array
|
// Update tag array
|
||||||
this.getTagRequest();
|
this.getTagRequest();
|
||||||
|
|
@ -266,6 +316,18 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getMetadataRequest: function() {
|
||||||
|
// Send tag request
|
||||||
|
axios
|
||||||
|
.get(this.captureURL)
|
||||||
|
.then(response => {
|
||||||
|
this.customMetadata = response.data.metadata.custom;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.modalError(error); // Let mixin handle error
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
makeModalName: function(prefix) {
|
makeModalName: function(prefix) {
|
||||||
return prefix + this.captureState.metadata.id;
|
return prefix + this.captureState.metadata.id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue