-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsol-catalog.js
66 lines (63 loc) · 2.28 KB
/
sol-catalog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {SolCatalogPage} from './sol-catalog-page.js';
import {SolCatalogTabset} from './sol-catalog-tabset.js';
import {SolCatalogSearch} from './sol-catalog-search.js';
import {SolMenu} from './sol-menu.js';
import {SolTabset} from './sol-tabset.js';
import {getDefaults,getLinkFromAttr} from './utils/utils.js';
import {getShacl,catalogMenu} from './utils/catalog-utils.js';
class SolCatalog extends HTMLElement {
constructor() {
super();
getDefaults(this);
this.type="rdf";
this.isCatalog=true
this.classList.add('sol-catalog');
}
async connectedCallback() {
const shape = getLinkFromAttr(this,'shape');
if(!this.wantedProperties)
[this.wantedProperties,this.wantedTypes] = await getShacl(shape);
let menu = await catalogMenu(this,this.wantedProperties,this.wantedTypes);
let title = this.getAttribute('title') || "Catalog";
let logo = getLinkFromAttr(this,'logo');
logo = logo ?`<img src="${logo}" class="logo" />` :"";
this.innerHTML = `
<div class="sol-wrapper">
<div class="sol-header">
${logo}
<span class="sol-header-content">
<span style="display:inline-block;padding-left:1rem;padding-right:1rem;">
${title}
</span>
<sol-catalog-search></sol-catalog-search>
<button class="sol-keywords">keyword index</button>
<button class="about-link" source="./catalog-about.html">about</button>
</span>
</div>
<div class="sol-main">
<div class="left-column">
${menu}
</div>
<div class="sol-display" style="width:100%;"></div>
</div>
</div>
`;
let button = this.querySelector('.sol-keywords');
let self = this;
button.addEventListener('click',(event)=>{
let clicked = event.target;
let element = clicked.closest('.sol-catalog-page') || clicked.closest('.sol-catalog');
element.setAttribute('isIndex',true);
let source = getLinkFromAttr(element,'source');
let displayArea = clicked.closest('.sol-wrapper').querySelector('.sol-display');
let view = getLinkFromAttr(element,'view');
view = view ?`view="${element.view}" ` :"";
displayArea.innerHTML = `<sol-catalog-page wanted="keywordsIndex" ${view} source="${source}"></sol-catalog-page>`;
});
return(true)
}
}
customElements.define("sol-catalog",SolCatalog);
/*
THE END
*/