diff --git a/src/App.vue b/src/App.vue index 88c7f4e15d216f706f164b8795eff53f75860668..835ca0dfe019e67b82203489fa1779769df44d92 100644 --- a/src/App.vue +++ b/src/App.vue @@ -125,7 +125,7 @@ </v-toolbar> <v-card-text> <v-layout row> - <ph-d-jsonld :jsonld="displayjsonld" :pid="pid"></ph-d-jsonld> + <ph-d-jsonld :form="form" :jsonld="displayjsonld" :pid="pid"></ph-d-jsonld> </v-layout> </v-card-text> </v-card> @@ -267,8 +267,8 @@ export default { }, members: [], - pid: "o:584804", - + pid: "o:585934", + //"o:584804", piddoc: {}, collection: "", sampleCollection: "", diff --git a/src/components/display/pharma_display/PhDJsonld.vue b/src/components/display/pharma_display/PhDJsonld.vue index 54847575daccbe03b1735fb9bd09b062b9078171..a01d9a62af02f9eea70b189a024f61ead02c2568 100644 --- a/src/components/display/pharma_display/PhDJsonld.vue +++ b/src/components/display/pharma_display/PhDJsonld.vue @@ -289,6 +289,7 @@ </template> <template v-else-if="p==='dcterms:subject'" slot="dcterms:subject"> + <v-btn @click="pharmaStructure()">form</v-btn> <template v-for="(subject, j) in o"> <v-card class="mt-3" @@ -320,7 +321,7 @@ <template v-if="sec.selections"> <v-card v-for="s in sec.selections" :key="s.label+'t'"> - s {{s}} {{sec.type}} {{s.label}} if{{getSelectionElem(sec.type,s.label)}} + s {{s}} type {{sec.type}} label {{s.label}} if {{getSelectionElem(sec.type,s.label)}} <v-layout v-if="getSelectionElem(sec.type,s.label).length>0"> <v-flex xs1 class="subheading"> <a :href="s.id" target="_blank">{{s.label}}</a> @@ -426,20 +427,63 @@ export default { instance: function() { return this.$store.state.settings.instance; }, + s: function() { + return this.form.sections; + }, componentid: function() { return Math.floor(Math.random() * 10000000); }, + pharmaStructure: function() { + var subjectjson = this.jsonld["dcterms:subject"]; + //filter subjects for only the ones with subjects[i]["@type"]=!= "skos:Concept" + //that would be the pharma-related subjects + var pharmajson = subjectjson.filter( + subjectjson => subjectjson["@type"] != "skos:Concept" + ); + console.log("phamra json", pharmajson); + console.log("formCategories", this.s[2].categories); + var formCategories = this.s[2].categories; + var jsonStructured = []; + for (let i = 0; i < formCategories.length; i++) { + //only look at the ones which have not a skos:Concept type + var formFields = formCategories[i].fields; + + jsonStructured.push({ category: formCategories[i].description }); + var formFieldsFiltered = formFields.filter( + formFields => formFields.type != "skos:Concept" + ); + //check which of those filetered fields ffields have a value in subjects + console.log("jsonStructured", jsonStructured, formFieldsFiltered); + for (var j = 0; j < formFieldsFiltered.length; j++) { + // console.log("ffields[j].type", ffields[j].type); + //filter all the elem in subjects which have this type + var jsonTypeArray = pharmajson.filter(function(fs) { + return fs["@type"] == formFieldsFiltered[j].type; + }); + + if (jsonTypeArray.length > 0) { + console.log( + "got those", + jsonTypeArray, + "for", + formFieldsFiltered[j].type + ); + } + } + } + }, pharmaData: function() { var s = this.jsonld["dcterms:subject"]; //filter subjects for only the ones with subjects[i]["@type"]=!= "skos:Concept" //that would be the pharma-related subjects var subjects = s.filter(s => s["@type"] != "skos:Concept"); - + console.log("subject1", subjects); var n_subjects = []; // take all the jsonld["dcterms:subject"] but not the ones which have no skos:prefLabel" for (let i = 0; i < subjects.length; i++) { + console.log("subject", subjects[i]); var subcat = subjects[i]["@type"]; // thuis should be unique to each entry field, comes from "subjectType" in jsonld var categ = this.getCategory(subcat); @@ -457,6 +501,7 @@ export default { n_subjects[i].data = subjects[i]; } console.log("pharmaData", n_subjects); + console.log("pharmaSubjects", this.pharmaSubjects); return n_subjects; } }, @@ -469,7 +514,11 @@ export default { type: Object, default: null }, - pid: String + pid: String, + form: { + type: Object, + default: null + } }, components: { PDTitle, @@ -496,7 +545,7 @@ export default { }, data() { return { - pharmaSubjects: [ + /*pharmaSubjects: [ { type: "biologicalMacromolecule", voc: "biological_macromolecule", @@ -548,7 +597,7 @@ export default { title: "Involved discipline", id: this.getinfoRef("discipline") } - ] + ]*/ }; }, methods: { @@ -563,7 +612,7 @@ export default { return elem; }, getSelectionElem: function(categ, selection) { - console.log("categ", categ, selection); + console.log("categ", categ, "selec", selection); var elem = this.pharmaData.filter( pharmaData => pharmaData.category === categ && pharmaData.selection === selection diff --git a/src/components/display/pharma_display/PhDMetadata.vue b/src/components/display/pharma_display/PhDMetadata.vue index 146c0150db855ccf64ccabd270d00732f8e7cc57..a7bac9ee6ac8196cad4e102d24178e6c595cc286 100644 --- a/src/components/display/pharma_display/PhDMetadata.vue +++ b/src/components/display/pharma_display/PhDMetadata.vue @@ -217,6 +217,11 @@ export default { }) .then(function(body) { self.data = body; + + //if body is empty, then just use whatever was there already in the data getData + if (body.result == "empty") { + self.data = self.getData; + } }) .catch(function(error) { diff --git a/src/components/input/pharma-input-fields/PhInputForm.vue b/src/components/input/pharma-input-fields/PhInputForm.vue index 755c6a7962d82b879f65e8428a24eba0033d8596..fb930c7532ef45431b444605245e8f4a965cee68 100644 --- a/src/components/input/pharma-input-fields/PhInputForm.vue +++ b/src/components/input/pharma-input-fields/PhInputForm.vue @@ -27,7 +27,7 @@ </div> </v-flex> </v-layout> - + <v-flex v-if="n== 'general'"> <v-layout v-for="(f) in s[index].fields" :key="f.id" row wrap fill-height> <v-flex xs12 v-if="f.component === 'text-field'"> diff --git a/src/utils/fields.js b/src/utils/fields.js index d39f7afb1c6b023df6ba94fdaebeabb55ba2b065..339f0d333d835b8aafe67f68961d87a8479d9db5 100644 --- a/src/utils/fields.js +++ b/src/utils/fields.js @@ -1236,7 +1236,7 @@ const fields = [ ontology: "bao", ontClass: "BAO_0000029", topId: "BAO_0000029", - //category: ["assay"], + category: ["assay"], // baseurl: "http://www.bioassayontology.org/bao#", description: "Assay screening campaign stage:", info: @@ -1246,10 +1246,10 @@ const fields = [ { id: "0-Organism", predicate: "dcterms:subject", - type: "pharmaWien:assayOrganism", + type: "pharmaWien:assayOrg", //subjectType: "AssayOrganism:", - label: "Organism", - description: "selection", + label: "Bioassay organism", + //description: "selection", value: "", component: "selection", freefield: false, @@ -1257,11 +1257,13 @@ const fields = [ visible: true, vocabulary: "assay_organism", stateVoc: "assay_organism", - category: ["assayOrganism"], + category: ["assay"], + subcategory: ["assayOrganism"], multiplicable: true, info: "The organism related to the target / meta-target of the bioassay. It includes both bacterium and eukaryote.", - infoRef: "BAO:0000551" + infoRef: "http://www.bioassayontology.org/bao#BAO:0000551", + description: "Bioassay organism:" }, { id: "0-Organism-assayTarget", @@ -1269,7 +1271,7 @@ const fields = [ type: "pharmaWien:assayTarget_organism", //subjectType: "AssayOrganism:", label: "Assay Target Organism", - description: "Organism", + description: "Bioassay Target organism", value: "", component: "selection", freefield: false, @@ -1298,8 +1300,9 @@ const fields = [ ontClass: "NCBITaxon_131567", topId: "NCBITaxon_131567", component: "ext-service", - category: ["assayOrganism"], - description: "Cellular organism", + category: ["assay"], + subcategory: ["assayOrganism"], + description: "Bioassay organism:", info: "" }, { @@ -1316,7 +1319,8 @@ const fields = [ ontClass: "NCBITaxon_10239", topId: "NCBITaxon_10239", component: "ext-service", - category: ["assayOrganism"], + category: ["assay"], + subcategory: ["assayOrganism"], description: "Viruses", info: "" }, @@ -1334,7 +1338,8 @@ const fields = [ ontClass: "NCBITaxon_12884", topId: "NCBITaxon_12884", component: "ext-service", - category: ["assayOrganism"], + category: ["assay"], + subcategory: ["assayOrganism"], description: "Viroids", info: "" },