Skip to content
Snippets Groups Projects
Commit ef8884ab authored by Isa H's avatar Isa H
Browse files

last tab submission, license for each file

parent 69ac53c9
No related branches found
No related tags found
1 merge request!2Dev2
......@@ -675,7 +675,8 @@ export default {
this.form.sections[0].fields.push(fields.getField("date"));
this.form.sections[0].fields.push(fields.getField("contributors"));
this.form.sections[0].fields.push(fields.getField("projects"));
this.form.sections[0].fields.push(fields.getField("license"));
//this is moved to file section now
//this.form.sections[0].fields.push(fields.getField("license"));
this.form.sections[1].fields.push(fields.getField("file"));
......
......@@ -228,6 +228,7 @@ export default {
},
getMetadata: function() {
let jsonlds;
console.log("this.form", this.form);
if (!this.targetpid && this.submittype === "container") {
jsonlds = jsonLd.containerForm2json(this.form);
} else {
......@@ -266,6 +267,7 @@ export default {
if (this.owner) {
md["metadata"]["ownerid"] = this.owner;
}
console.log("md", md);
return md;
},
......@@ -285,11 +287,13 @@ export default {
return "unknown";
}
},
submit: function() {
submit: async function() {
var self = this;
this.loading = true;
var httpFormData = new FormData();
httpFormData.append("metadata", JSON.stringify(self.getMetadata()));
console.log("httpFormData", self.getMetadata());
if (this.submittype === "container") {
for (var i = 0; i < this.form.sections.length; i++) {
var s = this.form.sections[i];
......@@ -327,6 +331,14 @@ export default {
}
}
}
console.log(
"posting",
self.$store.state.settings.instance.api +
"/" +
this.submittype +
"/create",
httpFormData
);
fetch(
self.$store.state.settings.instance.api +
"/" +
......@@ -344,6 +356,7 @@ export default {
)
.then(response => response.json())
.then(function(json) {
console.log("failed 1", json);
if (json.alerts && json.alerts.length > 0) {
self.$store.commit("setAlerts", json.alerts);
}
......@@ -356,6 +369,7 @@ export default {
self.$vuetify.goTo(0);
})
.catch(function(error) {
console.log("failed 2", error);
self.$store.commit("setAlerts", [{ type: "danger", msg: error }]);
self.loading = false;
self.$vuetify.goTo(0);
......@@ -409,8 +423,8 @@ export default {
console.log("in check warning", this.s);
var self = this;
let missingF = [];
for (var section in self.s) {
this.submit();
/* for (var section in self.s) {
let fields = self.s[section].fields;
for (var f in fields) {
......@@ -434,7 +448,7 @@ export default {
self.loading = false;
self.$store.commit("setAlerts", []);
this.submit();
}
}*/
}
},
mounted: function() {
......
......@@ -99,7 +99,7 @@ export default {
} else {
this.validationWarning = false;
}
console.log("validationWarning", this.validationWarningI);
// console.log("validationWarning", this.validationWarningI);
}
},
mounted: function() {
......
......@@ -80,10 +80,26 @@
v-on:input="setArray(itemsDesc,i-1,$event);$emit('input-description', itemsDesc)"
></v-text-field>
</v-flex>
<v-flex xs12>
<v-layout row wrap justify-end>
<v-flex xs4>
<p-i-select
vocabulary="licenses"
label="License"
:value="itemsLicense[i-1]"
:warning="true"
definition="The value will indicate the copyright, usage and access rights that apply to this digital representation."
v-on:input="setArray(itemsLicense,i-1,selectId($event));$emit('input-license', itemsLicense)"
v-on:validation="setArray(itemsWarning,i-1,$event); $emit('input-warning', itemsWarning)"
></p-i-select>
</v-flex>
<v-btn outline color="indigo" small icon @click="removeOneItem(i-1)">
<icon name="material-content-remove" width="12px" height="12px"></icon>
</v-btn>
</v-layout>
</v-flex>
</v-layout>
<v-layout row wrap>
<v-flex>
<v-card flat>
......@@ -111,11 +127,13 @@ import "@/compiled-icons/material-content-remove";
import "@/compiled-icons/material-hardware-arrow-down";
import "@/compiled-icons/material-hardware-arrow-up";
import PhTextselected from "./PhTextselected";
import PISelect from "./PISelect";
export default {
name: "ph-files",
components: {
PhTextselected
PhTextselected,
PISelect
},
computed: {
vocabularies: function() {
......@@ -153,7 +171,9 @@ export default {
itemsType: [],
itemsExt: [],
itemsDesc: [],
itemsLicense: [],
itemsSizes: [],
itemsWarning: [],
readonly: true,
itemsTotalSize: "",
//successMsg: '',
......@@ -165,8 +185,10 @@ export default {
},
methods: {
validate: function() {
//just check if there is at least one file
selectId: function(event) {
if (event) {
return event["@id"];
} else return "";
},
setArray: function(array, index, val) {
array.splice(index, 1, val);
......@@ -185,8 +207,6 @@ export default {
},
setFilename(e) {
this.loaderVisible = false;
//this.successMsg = ''
//this.errorMsg = ''
let files = e.target.files;
......@@ -220,32 +240,29 @@ export default {
var fileSizes = 0;
for (var i = 0; i < this.items.length; i++) {
this.itemsNames[i] = this.items[i].name;
this.itemsExt[i] = this.items[i].type;
this.itemsType[i] = "";
this.itemsDesc[i] = "";
//this.itemsExt[i] = this.items[i].type;
//this.itemsType[i] = ;
//this.itemsDesc[i] = "";
//this.itemsLicense[i] = "";
this.itemsWarning[i] = true;
this.itemsSizes[i] = this.bytesToSize(this.items[i].size);
fileSizes += this.items[i].size;
}
this.itemsTotalSize = this.bytesToSize(fileSizes);
this.itemsAdded = this.items.length;
// console.log(
// "files",
// this.items,
// "names",
// this.itemsNames,
// "exten",
// this.itemsExt
// );
this.$emit("input-file", this.items);
if (this.items.length > 0) {
this.$emit("validation", false);
} else {
this.$emit("validation", true);
}
this.$store.commit("setFiles", this.itemsNames);
//this.$store.commit("setFiles", this.itemsNames);
this.$emit("input-numberFiles", this.items.length);
this.$emit("input-name", this.itemsNames);
this.$emit("input-extension", this.itemsExt);
this.$emit("input-license", this.itemsLicense);
this.$emit("input-warning", this.itemsWarning);
},
removeItems() {
this.items = [];
......@@ -255,6 +272,8 @@ export default {
this.itemsType = [];
this.itemsDesc = [];
this.itemsSizes = [];
this.itemsLicense = [];
this.itemsWarning = [];
this.itemsTotalSize = "";
this.loaderVisible = true;
if (this.items.length > 0) {
......@@ -262,13 +281,15 @@ export default {
} else {
this.$emit("validation", true);
}
this.$store.commit("setFiles", this.itemsNames);
//this.$store.commit("setFiles", this.itemsNames);
this.$emit("input-numberFiles", 0);
this.$emit("input-file", this.items);
this.$emit("input-name", this.itemsNames);
this.$emit("input-extension", this.itemsExt);
this.$emit("input-type", this.itemsType);
this.$emit("input-description", this.itemsDesc);
this.$emit("input-license", this.itemsLicense);
this.$emit("input-warning", this.itemsWarning);
//this.dragging = false
},
removeOneItem(i) {
......@@ -286,6 +307,8 @@ export default {
this.itemsType.splice(i, 1);
this.itemsDesc.splice(i, 1);
this.itemsSizes.splice(i, 1);
this.itemsLicense.splice(i, 1);
this.itemsWarning.splice(i, 1);
for (var i = 0; i < this.items.length; i++) {
fileSizes += this.items[i].size;
}
......@@ -296,11 +319,13 @@ export default {
this.$emit("input-file", this.items);
this.$emit("input-numberFiles", this.items.length);
this.$store.commit("setFiles", this.itemsNames);
//this.$store.commit("setFiles", this.itemsNames);
this.$emit("input-name", this.itemsNames);
this.$emit("input-extension", this.itemsExt);
this.$emit("input-type", this.itemsType);
this.$emit("input-description", this.itemsDesc);
this.$emit("input-license", this.itemsLicense);
this.$emit("input-warning", this.itemsWarning);
//this.dragging = false;
}
}
......
......@@ -108,6 +108,7 @@
<v-card-text>
<v-layout v-for="(f) in s[index].fields" :key="f.id" row wrap>
<v-flex v-if="f.component == 'files'">
hallo{{f}}
<ph-files
v-bind.sync="f"
v-on:input-numberFiles="f.nfile=$event"
......@@ -116,6 +117,8 @@
v-on:input-type="f.fileFormat=$event"
v-on:input-extension="f.fileExtension=$event"
v-on:input-description="f.fileDescription=$event"
v-on:input-license="f.fileLicense=$event"
v-on:input-warning="f.licenseWarning=$event"
v-on:validation="f.warning=$event"
></ph-files>
</v-flex>
......
......@@ -124,7 +124,7 @@ const fields = [
value: "",
definition: "File input."
},*/
{
/* {
id: "license",
fieldname: "License",
predicate: "edm:rights",
......@@ -136,7 +136,7 @@ const fields = [
"skos:prefLabel": [],
definition:
"The value will indicate the copyright, usage and access rights that apply to this digital representation."
},
},*/
{
id: "file",
label: "Files",
......@@ -147,6 +147,8 @@ const fields = [
fileFormat: "",
fileDescription: "",
fileExtension: "",
fileLicense: "",
licenseWarning: true,
formValidation: true,
warning: true
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment