diff --git a/src/App.vue b/src/App.vue index fa794b4b6f36a00f83270d340f19fa892d3f2b0a..a43c972f1542ce9085b4fab6f9e9fb42d3f0f9c1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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")); diff --git a/src/components/input/PhSubmit.vue b/src/components/input/PhSubmit.vue index 3920a926494145f52704b04e9727c02909ddfaa4..919eb6e646128306b5d44860982449432448820e 100644 --- a/src/components/input/PhSubmit.vue +++ b/src/components/input/PhSubmit.vue @@ -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() { diff --git a/src/components/input/pharma-input-fields/PISelect.vue b/src/components/input/pharma-input-fields/PISelect.vue index dc0312bc94974811a6b3ad934e90e2468dbeb0d5..381199f72cee2ce7b1fcb1620bcfa4d071fa994f 100644 --- a/src/components/input/pharma-input-fields/PISelect.vue +++ b/src/components/input/pharma-input-fields/PISelect.vue @@ -99,7 +99,7 @@ export default { } else { this.validationWarning = false; } - console.log("validationWarning", this.validationWarningI); + // console.log("validationWarning", this.validationWarningI); } }, mounted: function() { diff --git a/src/components/input/pharma-input-fields/PhFiles.vue b/src/components/input/pharma-input-fields/PhFiles.vue index 6ab701e2fa6017bc6d3ff83fbf28bd36202deb78..c018d0f508f216af7c3a26cc3fd06a383ae17406 100644 --- a/src/components/input/pharma-input-fields/PhFiles.vue +++ b/src/components/input/pharma-input-fields/PhFiles.vue @@ -80,9 +80,25 @@ v-on:input="setArray(itemsDesc,i-1,$event);$emit('input-description', itemsDesc)" ></v-text-field> </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-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> @@ -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; } } diff --git a/src/components/input/pharma-input-fields/PhInputForm.vue b/src/components/input/pharma-input-fields/PhInputForm.vue index 768844d8d2890e4df2f8d03e9fe5b9becbb3f645..a1791a52b0863a90d6d820352dd03bc61952eaec 100644 --- a/src/components/input/pharma-input-fields/PhInputForm.vue +++ b/src/components/input/pharma-input-fields/PhInputForm.vue @@ -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> diff --git a/src/utils/fields.js b/src/utils/fields.js index cd468f50bc475545da21f610dd4db997241c54ef..f4faae0ce9ddc5104a210be8ccf09f6653c76d23 100644 --- a/src/utils/fields.js +++ b/src/utils/fields.js @@ -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 },