From 7b63c2c7c34ed73c4430add9f9dd089ff3ad4359 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 23 Mar 2021 11:28:21 +0100 Subject: [PATCH] Chaging from a DS to a List view also deletes the path parameters now. --- dist/ds-browser.js | 3 ++- dist/ds-browser.min.js | 2 +- src/DSRenderer.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dist/ds-browser.js b/dist/ds-browser.js index dc35bab..032d817 100644 --- a/dist/ds-browser.js +++ b/dist/ds-browser.js @@ -17478,7 +17478,8 @@ class DSRenderer { } var listHtml = this.browser.list ? ' | from List: ' + this.util.createInternalLink({ - dsId: null + dsId: null, + path: null }, this.browser.list['schema:name']) : ''; return "(".concat(shaclLink).concat(listHtml, ")"); } diff --git a/dist/ds-browser.min.js b/dist/ds-browser.min.js index 9e1330f..cf220b7 100644 --- a/dist/ds-browser.min.js +++ b/dist/ds-browser.min.js @@ -245,7 +245,7 @@ var nextTick=require("process/browser.js").nextTick,apply=Function.prototype.app "use strict";class DSHandler{constructor(t){this.browser=t,this.util=t.util}getDSNodeForPath(){var t=this.browser.dsRootNode,e={type:"",node:{}};if(t)if(this.browser.path){for(var r=this.browser.path.split("-"),s=0;st["sh:class"]&&this.rangesToString(t["sh:class"])===e)||null}getProperty(t,e){return t.find(t=>this.rangesToString(t["sh:path"])===e)||null}dataTypeMapperFromSHACL(t){switch(t){case"xsd:string":return"http://schema.org/Text";case"xsd:boolean":return"http://schema.org/Boolean";case"xsd:date":return"http://schema.org/Date";case"xsd:dateTime":return"http://schema.org/DateTime";case"xsd:time":return"http://schema.org/Time";case"xsd:double":return"http://schema.org/Number";case"xsd:float":return"http://schema.org/Float";case"xsd:integer":return"http://schema.org/Integer";case"xsd:anyURI":return"http://schema.org/URL"}return null}rangesToString(t){return Array.isArray(t)?t.map(t=>this.util.prettyPrintIri(t)).join(" + "):this.util.prettyPrintIri(t)}createHtmlCardinality(t,e){var r,s="";return t&&0!==t?e&&0!==e?t!==e?(r="This property is required. It must have between "+t+" and "+e+" value(s).",s=t+".."+e):(r="This property is required. It must have "+t+" value(s).",s=t):(r="This property is required. It must have at least "+t+" value(s).",s=t+"..N"):e&&0!==e?(r="This property is optional. It must have at most "+e+" value(s).",s="0.."+e):(r="This property is optional. It may have any amount of values.",s="0..N"),'').concat(s,"")}generateDsClass(t,e,r){var s,a={},i=t["sh:targetClass"];a.text=i?this.util.prettyPrintClassDefinition(i):this.util.prettyPrintClassDefinition(t["sh:class"]),a.icon="glyphicon glyphicon-list-alt",e||(a.state={opened:!0});try{s=-1===a.text.indexOf(",")?this.browser.sdoAdapter.getClass(a.text).getDescription():"No description found."}catch(t){s="No description found."}return a.data={},a.data.dsDescription=s,t["rdfs:comment"]&&(a.justification=t["rdfs:comment"]),a.children=this.processChildren(t,r),a}processChildren(t,e){var r,s=[],a=t["sh:property"],i=t["sh:node"];return a?r=a:i&&i["sh:property"]&&(r=i["sh:property"]),void 0!==r&&r.forEach(t=>{var r=this.generateDsProperty(t,e);r&&s.push(r)}),s}generateDsProperty(t,e){var r={};return r.justification=t["rdfs:comment"],r.text=this.util.prettyPrintIri(t["sh:path"]),r.data={},r.data.minCount=t["sh:minCount"],r.data.maxCount=t["sh:maxCount"],r.children=[],this.processEnum(r,t["sh:or"][0]),this.processVisibility(r,t["sh:minCount"]),this.processExpectedTypes(r,t["sh:or"],e),e?r:r.data.isOptional?null:r}processEnum(t,e){var r;t.isEnum=!1;try{var s=e["sh:class"];r=this.browser.sdoAdapter.getEnumeration(s),t.isEnum=!0}catch(t){}if(t.isEnum){var a=this.getEnumMemberArray(e["sh:in"],r);a.forEach(t=>{var e=this.browser.sdoAdapter.getEnumerationMember(t.name);t.description=this.util.repairLinksInHTMLCode(e.getDescription())}),t.data.enuMembers=a,t.children=a.map(t=>({children:[],data:{dsRange:"",dsDescription:this.util.repairLinksInHTMLCode(t.description)},icon:"glyphicon glyphicon-chevron-right",text:t.name}))}}getEnumMemberArray(t,e){return t?t.map(t=>{var e=t["@id"];return{name:e=e.replace("schema:","")}}):e.getEnumerationMembers().map(t=>({name:t}))}processVisibility(t,e){t.icon="glyphicon glyphicon-tag",!e>0?(t.icon+=" optional-property",t.data.isOptional=!0):(t.icon+=" mandatory-property",t.data.isOptional=!1)}processExpectedTypes(t,e,r){var s=!1;if(e){var a=this.generateDsRange(e);t.data.dsRange=a.rangeAsString,t.data.rangeJustification=a.rangeJustification;try{var i=this.browser.sdoAdapter.getProperty(t.text).getDescription();t.data.dsDescription=this.util.repairLinksInHTMLCode(i)}catch(e){t.data.dsDescription="No description found."}e.forEach(e=>{if(e["sh:node"]){s=!0;var a=this.generateDsClass(e,!0,r);t.children.push(a)}})}s&&(t.state={opened:!0})}generateDsRange(t){var e={rangeAsString:"",rangeJustification:[]};return e.rangeAsString=t.map(t=>{var r,s,a={},i=t["sh:datatype"],n=t["sh:class"];return s=i?r=this.util.prettyPrintIri(this.dataTypeMapperFromSHACL(i)):t["sh:node"]?""+(r=this.util.prettyPrintClassDefinition(n))+"":r=this.util.prettyPrintClassDefinition(n),a.name=r,a.justification=t["rdfs:comment"],e.rangeJustification.push(a),s}).join(" or "),e}}module.exports=DSHandler; },{}],80:[function(require,module,exports){ -"use strict";function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class DSRenderer{constructor(e){_defineProperty(this,"MODES",{native:"native",tree:"tree",table:"table"}),this.browser=e,this.util=e.util,this.dsHandler=e.dsHandler}createViewModeSelectors(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.MODES.native;return'
'+(e===this.MODES.native?'Native View':this.util.createInternalLink({viewMode:null},"Native View"))+(e===this.MODES.tree?'Tree View':this.util.createInternalLink({viewMode:"tree"},"Tree View"))+(e===this.MODES.table?'Table View':this.util.createInternalLink({viewMode:"table"},"Table View"))+"
"}createHtmlHeader(){this.dsNode=this.browser.dsNode,this.node=this.dsNode.node;var e,t,i="";if(this.browser.path){var r=this.node["sh:class"];e=this.dsHandler.rangesToString(r),t=this.createNodeDescription(r),i=this.createBreadcrumbs()}else{var s=this.browser.ds["@graph"][0];e=s["schema:name"]||"Domain Specification",t=s["schema:description"]||""}return t=this.util.repairLinksInHTMLCode(t),this.createNavigation()+'

'+e+"

"+this.util.createHtmlExternalLinkLegend()+i+'
'+t+"

"}createNodeDescription(e){return this.util.isString(e)?this.browser.sdoAdapter.getTerm(e).getDescription():e.map(e=>""+this.util.prettyPrintIri(e)+": "+this.browser.sdoAdapter.getTerm(e).getDescription()).join("
")}createBreadcrumbs(){var e=this.util.createInternalLink({path:null},this.browser.dsRootNode["schema:name"]||"Domain Specification"),t=this.browser.path.split("-").map((e,t,i)=>{if(t%2==0)return e;var r=i.slice(0,t+1).join("-");return this.util.createInternalLink({path:r},e)}).join(" > ");return'

\n '.concat(e," > ").concat(t,"\n

")}createNavigation(){var e,t=this.browser.dsId;e=this.browser.locationControl?this.util.createInternalLink({format:"shacl"},"SHACL serialization"):'SHACL serialization');var i=this.browser.list?" | from List: "+this.util.createInternalLink({dsId:null},this.browser.list["schema:name"]):"";return'('.concat(e).concat(i,")")}createVisBtnRow(){return'
Show: \n \n optional\n \n \n mandatory\n
'}}module.exports=DSRenderer; +"use strict";function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class DSRenderer{constructor(e){_defineProperty(this,"MODES",{native:"native",tree:"tree",table:"table"}),this.browser=e,this.util=e.util,this.dsHandler=e.dsHandler}createViewModeSelectors(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.MODES.native;return'
'+(e===this.MODES.native?'Native View':this.util.createInternalLink({viewMode:null},"Native View"))+(e===this.MODES.tree?'Tree View':this.util.createInternalLink({viewMode:"tree"},"Tree View"))+(e===this.MODES.table?'Table View':this.util.createInternalLink({viewMode:"table"},"Table View"))+"
"}createHtmlHeader(){this.dsNode=this.browser.dsNode,this.node=this.dsNode.node;var e,t,i="";if(this.browser.path){var r=this.node["sh:class"];e=this.dsHandler.rangesToString(r),t=this.createNodeDescription(r),i=this.createBreadcrumbs()}else{var s=this.browser.ds["@graph"][0];e=s["schema:name"]||"Domain Specification",t=s["schema:description"]||""}return t=this.util.repairLinksInHTMLCode(t),this.createNavigation()+'

'+e+"

"+this.util.createHtmlExternalLinkLegend()+i+'
'+t+"

"}createNodeDescription(e){return this.util.isString(e)?this.browser.sdoAdapter.getTerm(e).getDescription():e.map(e=>""+this.util.prettyPrintIri(e)+": "+this.browser.sdoAdapter.getTerm(e).getDescription()).join("
")}createBreadcrumbs(){var e=this.util.createInternalLink({path:null},this.browser.dsRootNode["schema:name"]||"Domain Specification"),t=this.browser.path.split("-").map((e,t,i)=>{if(t%2==0)return e;var r=i.slice(0,t+1).join("-");return this.util.createInternalLink({path:r},e)}).join(" > ");return'

\n '.concat(e," > ").concat(t,"\n

")}createNavigation(){var e,t=this.browser.dsId;e=this.browser.locationControl?this.util.createInternalLink({format:"shacl"},"SHACL serialization"):'SHACL serialization');var i=this.browser.list?" | from List: "+this.util.createInternalLink({dsId:null,path:null},this.browser.list["schema:name"]):"";return'('.concat(e).concat(i,")")}createVisBtnRow(){return'
Show: \n \n optional\n \n \n mandatory\n
'}}module.exports=DSRenderer; },{}],81:[function(require,module,exports){ "use strict";class ListRenderer{constructor(t){this.browser=t,this.util=t.util}render(){var t=this.createHtmlHeader()+this.createHtmlDsTable();this.browser.targetElement.innerHTML=this.util.createHtmlMainContent("schema:DataSet",t)}createHtmlHeader(){var t=this.browser.list["schema:name"]||"",e=this.util.createHtmlExternalLinkLegend(),r=this.browser.list["schema:description"]||"";return"

".concat(t,"

\n ").concat(e,"\n ").concat(r)}createHtmlDsTable(){return this.util.createHtmlDefinitionTable(["Name","IRI","Description"],this.createHtmlDsTbody(),null,{class:"supertype"})}createHtmlDsTbody(){return this.browser.list["schema:hasPart"].map(t=>this.util.createHtmlTableRow("http://vocab.sti2.at/ds/Domain Specification",t["@id"],"schema:name",this.util.createInternalLink({dsId:t["@id"].split("/").pop()},t["schema:name"]||"No Name"),this.createHtmlDsSideCols(t))).join("")}createHtmlDsSideCols(t){var e=this.util.createLink(t["@id"]),r=t["schema:description"]||"";return''.concat(e,'\n ').concat(r,"")}}module.exports=ListRenderer; diff --git a/src/DSRenderer.js b/src/DSRenderer.js index b768e0c..eb08845 100644 --- a/src/DSRenderer.js +++ b/src/DSRenderer.js @@ -86,7 +86,7 @@ class DSRenderer { } else { shaclLink = `SHACL serialization`; } - const listHtml = this.browser.list ? ' | from List: ' + this.util.createInternalLink({dsId: null}, this.browser.list['schema:name']) : ''; + const listHtml = this.browser.list ? ' | from List: ' + this.util.createInternalLink({dsId: null, path: null}, this.browser.list['schema:name']) : ''; return `(${shaclLink}${listHtml})`; }