@startinblox/core 0.17.21-beta.9 → 0.17.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/solid-ac-checker.js +10 -3
- package/dist/components/solid-ac-checker.js.map +1 -1
- package/dist/components/solid-display.js +1 -1
- package/dist/components/solid-display.js.map +1 -1
- package/dist/components/solid-form-search.js.map +1 -1
- package/dist/components/solid-map.js +2 -2
- package/dist/components/solid-map.js.map +1 -1
- package/dist/libs/interfaces.js.map +1 -1
- package/dist/libs/store/store.js +12 -73
- package/dist/libs/store/store.js.map +1 -1
- package/dist/mixins/filterMixin.js +61 -2
- package/dist/mixins/filterMixin.js.map +1 -1
- package/dist/mixins/widgetMixin.js +2 -2
- package/dist/mixins/widgetMixin.js.map +1 -1
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +3 -4
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +1 -1
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +3 -4
- package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +1 -1
- package/dist/new-widgets/templates/formTemplatesDirectory.js +3 -3
- package/dist/new-widgets/templates/formTemplatesDirectory.js.map +1 -1
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -18
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +1 -1
- package/package.json +4 -4
- package/dist/libs/filter.js +0 -214
- package/dist/libs/filter.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +0 -14
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js.map +0 -1
|
@@ -21,18 +21,25 @@ export const SolidAcChecker = {
|
|
|
21
21
|
const ContextParser = JSONLDContextParser.ContextParser;
|
|
22
22
|
const myParser = new ContextParser();
|
|
23
23
|
const context = await myParser.parse(this.context);
|
|
24
|
-
const permissions = await this.resource.permissions;
|
|
25
24
|
|
|
26
25
|
if (this.permission) {
|
|
27
26
|
// User has permission of ...
|
|
28
|
-
displayElement = permissions.some(p => {
|
|
27
|
+
displayElement = this.resource.permissions.some(p => {
|
|
29
28
|
return ContextParser.compactIri(p, context) === this.permission;
|
|
30
29
|
});
|
|
30
|
+
/* displayElement = await asyncSome(
|
|
31
|
+
(permission: object) => ContextParser.compactIri(permission.toString(), context) === this.permission,
|
|
32
|
+
this.resource.permissions.mode['@type']
|
|
33
|
+
)*/
|
|
31
34
|
} else if (this.noPermission) {
|
|
32
35
|
// User has no permission of ...
|
|
33
|
-
displayElement = permissions.every(p => {
|
|
36
|
+
displayElement = this.resource.permissions.every(p => {
|
|
34
37
|
return ContextParser.compactIri(p, context) !== this.noPermission;
|
|
35
38
|
});
|
|
39
|
+
/*displayElement = await asyncEvery(
|
|
40
|
+
(permission: object) => ContextParser.compactIri(permission.toString(), context) !== this.noPermission,
|
|
41
|
+
this.resource.permissions.mode['@type']
|
|
42
|
+
)*/
|
|
36
43
|
} else {
|
|
37
44
|
// No parameter provided
|
|
38
45
|
console.warn('solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["solid-ac-checker.ts"],"names":["JSONLDContextParser","Sib","StoreMixin","SolidAcChecker","name","use","attributes","permission","type","String","default","noPermission","populate","resource","displayElement","ContextParser","myParser","context","parse","permissions","some","p","compactIri","every","console","warn","element","removeAttribute","empty","setAttribute","register"],"mappings":"AAAA,OAAOA,mBAAP,MAAgC,uBAAhC;AACA,SAASC,GAAT,QAAoB,aAApB;AACA,SAASC,UAAT,QAA2B,sBAA3B;AAEA,OAAO,MAAMC,cAAc,GAAG;AAC5BC,EAAAA,IAAI,EAAE,kBADsB;AAE5BC,EAAAA,GAAG,EAAE,CAACH,UAAD,CAFuB;AAG5BI,EAAAA,UAAU,EAAE;AACVC,IAAAA,UAAU,EAAE;AACVC,MAAAA,IAAI,EAAEC,MADI;AAEVC,MAAAA,OAAO,EAAE;AAFC,KADF;AAKVC,IAAAA,YAAY,EAAE;AACZH,MAAAA,IAAI,EAAEC,MADM;AAEZC,MAAAA,OAAO,EAAE;AAFG;AALJ,GAHgB;;AAc5B,QAAME,QAAN,GAAgC;AAC9B,QAAI,CAAC,KAAKC,QAAV,EAAoB;AACpB,QAAIC,cAAJ;AACA,UAAMC,aAAa,GAAGf,mBAAmB,CAACe,aAA1C;AACA,UAAMC,QAAQ,GAAG,IAAID,aAAJ,EAAjB;AACA,UAAME,OAAO,GAAG,MAAMD,QAAQ,CAACE,KAAT,CAAe,KAAKD,OAApB,CAAtB
|
|
1
|
+
{"version":3,"sources":["solid-ac-checker.ts"],"names":["JSONLDContextParser","Sib","StoreMixin","SolidAcChecker","name","use","attributes","permission","type","String","default","noPermission","populate","resource","displayElement","ContextParser","myParser","context","parse","permissions","some","p","compactIri","every","console","warn","element","removeAttribute","empty","setAttribute","register"],"mappings":"AAAA,OAAOA,mBAAP,MAAgC,uBAAhC;AACA,SAASC,GAAT,QAAoB,aAApB;AACA,SAASC,UAAT,QAA2B,sBAA3B;AAEA,OAAO,MAAMC,cAAc,GAAG;AAC5BC,EAAAA,IAAI,EAAE,kBADsB;AAE5BC,EAAAA,GAAG,EAAE,CAACH,UAAD,CAFuB;AAG5BI,EAAAA,UAAU,EAAE;AACVC,IAAAA,UAAU,EAAE;AACVC,MAAAA,IAAI,EAAEC,MADI;AAEVC,MAAAA,OAAO,EAAE;AAFC,KADF;AAKVC,IAAAA,YAAY,EAAE;AACZH,MAAAA,IAAI,EAAEC,MADM;AAEZC,MAAAA,OAAO,EAAE;AAFG;AALJ,GAHgB;;AAc5B,QAAME,QAAN,GAAgC;AAC9B,QAAI,CAAC,KAAKC,QAAV,EAAoB;AACpB,QAAIC,cAAJ;AACA,UAAMC,aAAa,GAAGf,mBAAmB,CAACe,aAA1C;AACA,UAAMC,QAAQ,GAAG,IAAID,aAAJ,EAAjB;AACA,UAAME,OAAO,GAAG,MAAMD,QAAQ,CAACE,KAAT,CAAe,KAAKD,OAApB,CAAtB;;AAEA,QAAI,KAAKV,UAAT,EAAqB;AAAE;AACrBO,MAAAA,cAAc,GAAG,KAAKD,QAAL,CAAcM,WAAd,CAA0BC,IAA1B,CAAgCC,CAAD,IAAW;AACzD,eAAON,aAAa,CAACO,UAAd,CAAyBD,CAAzB,EAA4BJ,OAA5B,MAAyC,KAAKV,UAArD;AACD,OAFgB,CAAjB;AAGA;AACN;AACA;AACA;AACK,KARD,MAQO,IAAI,KAAKI,YAAT,EAAuB;AAAE;AAC9BG,MAAAA,cAAc,GAAG,KAAKD,QAAL,CAAcM,WAAd,CAA0BI,KAA1B,CAAiCF,CAAD,IAAW;AAC1D,eAAON,aAAa,CAACO,UAAd,CAAyBD,CAAzB,EAA4BJ,OAA5B,MAAyC,KAAKN,YAArD;AACD,OAFgB,CAAjB;AAGA;AACN;AACA;AACA;AACK,KARM,MAQA;AAAE;AACPa,MAAAA,OAAO,CAACC,IAAR,CAAa,gGAAb;AACA;AACD;;AAED,QAAIX,cAAJ,EAAoB,KAAKY,OAAL,CAAaC,eAAb,CAA6B,QAA7B;AACrB,GA3C2B;;AA4C5BC,EAAAA,KAAK,GAAS;AACZ,SAAKF,OAAL,CAAaG,YAAb,CAA0B,QAA1B,EAAoC,EAApC;AACD;;AA9C2B,CAAvB;AAiDP5B,GAAG,CAAC6B,QAAJ,CAAa3B,cAAb","sourcesContent":["import JSONLDContextParser from 'jsonld-context-parser';\nimport { Sib } from '../libs/Sib';\nimport { StoreMixin } from '../mixins/storeMixin';\n\nexport const SolidAcChecker = {\n name: 'solid-ac-checker',\n use: [StoreMixin],\n attributes: {\n permission: {\n type: String,\n default: '',\n },\n noPermission: {\n type: String,\n default: '',\n }\n },\n\n async populate(): Promise<void> {\n if (!this.resource) return;\n let displayElement: boolean;\n const ContextParser = JSONLDContextParser.ContextParser;\n const myParser = new ContextParser();\n const context = await myParser.parse(this.context);\n\n if (this.permission) { // User has permission of ...\n displayElement = this.resource.permissions.some((p:any) => {\n return ContextParser.compactIri(p, context) === this.permission;\n });\n /* displayElement = await asyncSome(\n (permission: object) => ContextParser.compactIri(permission.toString(), context) === this.permission,\n this.resource.permissions.mode['@type']\n )*/\n } else if (this.noPermission) { // User has no permission of ...\n displayElement = this.resource.permissions.every((p:any) => {\n return ContextParser.compactIri(p, context) !== this.noPermission;\n });\n /*displayElement = await asyncEvery(\n (permission: object) => ContextParser.compactIri(permission.toString(), context) !== this.noPermission,\n this.resource.permissions.mode['@type']\n )*/\n } else { // No parameter provided\n console.warn('solid-ac-checker: you should define at least one of \"permission\" or \"no-permission\" attribute.');\n return;\n }\n\n if (displayElement) this.element.removeAttribute('hidden');\n },\n empty(): void {\n this.element.setAttribute('hidden', '');\n }\n};\n\nSib.register(SolidAcChecker);"]}
|
|
@@ -177,7 +177,7 @@ export const SolidDisplay = {
|
|
|
177
177
|
|
|
178
178
|
for (let attr of this.element.attributes) {
|
|
179
179
|
//copy widget and value attributes
|
|
180
|
-
if (attr.name.startsWith('value-') || attr.name.startsWith('label-') || attr.name.startsWith('placeholder-') || attr.name.startsWith('widget-') || attr.name.startsWith('class-') || attr.name.startsWith('multiple-') || attr.name.startsWith('editable-') || attr.name.startsWith('action-') || attr.name.startsWith('default-') || attr.name
|
|
180
|
+
if (attr.name.startsWith('value-') || attr.name.startsWith('label-') || attr.name.startsWith('placeholder-') || attr.name.startsWith('widget-') || attr.name.startsWith('class-') || attr.name.startsWith('multiple-') || attr.name.startsWith('editable-') || attr.name.startsWith('action-') || attr.name.startsWith('default-') || attr.name == 'extra-context') attributes[attr.name] = attr.value;
|
|
181
181
|
if (attr.name.startsWith('child-')) attributes[attr.name.replace(/^child-/, '')] = attr.value;
|
|
182
182
|
|
|
183
183
|
if (attr.name == 'next') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["solid-display.ts"],"names":["Sib","WidgetMixin","ListMixin","StoreMixin","PaginateMixin","FilterMixin","CounterMixin","SorterMixin","GrouperMixin","FederationMixin","HighlighterMixin","NextMixin","RequiredMixin","spread","html","render","ifDefined","SolidDisplay","name","use","attributes","defaultWidget","type","String","default","initialState","activeSubscription","removeActiveSubscription","created","route","document","querySelector","setTimeout","resourceId","addActiveCallback","detached","PubSub","unsubscribe","updateNavigateSubscription","subscribe","bind","element","setAttribute","removeActiveCallback","removeAttribute","childTag","dataset","child","tagName","defaultMultipleWidget","defaultSetWidget","dispatchSelect","event","linkTarget","target","closest","hasAttribute","resource","dispatchEvent","CustomEvent","detail","goToNext","enterKeydownAction","keyCode","getChildTemplate","template","fields","appendSingleElt","parent","getFields","widgetTemplates","Promise","all","map","field","createWidgetTemplate","renderDOM","resources","listPostProcessors","div","context","getChildAttributes","r","nextProcessor","shift","attr","startsWith","value","replace","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,eAAT,QAAgC,2BAAhC;AACA,SAASC,gBAAT,QAAiC,4BAAjC;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,MAAT,QAAuB,qBAAvB;AAEA,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AAEA,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,eADoB;AAE1BC,EAAAA,GAAG,EAAE,CACHlB,WADG,EAEHC,SAFG,EAGHC,UAHG,EAIHC,aAJG,EAKHI,YALG,EAMHF,YANG,EAOHI,gBAPG,EAQHL,WARG,EASHE,WATG,EAUHK,aAVG,EAWHH,eAXG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AV,GAAyB,GAAzB;AACD;AACF;;AACD,WAAOA,UAAP;AACD;;AA/KyB,CAArB;AAkLPpB,GAAG,CAACyF,QAAJ,CAAaxE,YAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { ListMixin } from '../mixins/listMixin';\nimport { StoreMixin } from '../mixins/storeMixin';\nimport { PaginateMixin } from '../mixins/paginateMixin';\nimport { FilterMixin } from '../mixins/filterMixin';\nimport { CounterMixin } from '../mixins/counterMixin';\nimport { SorterMixin } from '../mixins/sorterMixin';\nimport { GrouperMixin } from '../mixins/grouperMixin';\nimport { FederationMixin } from '../mixins/federationMixin';\nimport { HighlighterMixin } from '../mixins/highlighterMixin';\nimport { NextMixin } from '../mixins/nextMixin';\nimport { RequiredMixin } from '../mixins/requiredMixin';\nimport { spread } from '../libs/lit-helpers';\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nexport const SolidDisplay = {\n name: 'solid-display',\n use: [\n WidgetMixin,\n ListMixin,\n StoreMixin,\n PaginateMixin,\n GrouperMixin,\n CounterMixin,\n HighlighterMixin,\n FilterMixin,\n SorterMixin,\n RequiredMixin,\n FederationMixin,\n NextMixin,\n ],\n attributes: {\n defaultWidget: {\n type: String,\n default: 'solid-display-value',\n },\n },\n initialState: {\n activeSubscription: null,\n removeActiveSubscription: null,\n },\n created(): void {\n // Set route active at initialization\n const route = document.querySelector('solid-route[active]') as any;\n if (!route) return;\n setTimeout(() => {\n if (route['resourceId'] === this.resourceId) this.addActiveCallback();\n });\n },\n detached(): void {\n if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);\n if (this.removeActiveSubscription) PubSub.unsubscribe(this.removeActiveSubscription);\n },\n // Update subscription when id changes\n updateNavigateSubscription() {\n if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);\n\n if (this.resourceId) {\n this.activeSubscription = PubSub.subscribe(\n 'enterRoute.' + this.resourceId,\n this.addActiveCallback.bind(this)\n );\n }\n },\n addActiveCallback() {\n this.element.setAttribute('active', '');\n this.removeActiveSubscription = PubSub.subscribe(\n 'leaveRoute',\n this.removeActiveCallback.bind(this)\n );\n },\n removeActiveCallback() {\n this.element.removeAttribute('active');\n PubSub.unsubscribe(this.removeActiveSubscription);\n },\n get childTag(): string {\n return this.element.dataset.child || this.element.tagName;\n },\n get defaultMultipleWidget(): string {\n return 'solid-multiple';\n },\n get defaultSetWidget(): string {\n return 'solid-set-default';\n },\n // Here \"even.target\" points to the content of the widgets of the children of solid-display\n dispatchSelect(event: Event, resourceId: string): void {\n const linkTarget = (event!.target as Element).closest('a');\n if (linkTarget && linkTarget.hasAttribute('href')) return;\n const resource = { \"@id\": resourceId };\n this.element.dispatchEvent(\n new CustomEvent('resourceSelect', { detail: { resource: resource } }),\n );\n this.goToNext(resource);\n },\n \n enterKeydownAction (event, resourceId: string): void {\n if (event.keyCode === 13) {\n const resource = { \"@id\" : resourceId };\n this.goToNext(resource);\n }\n },\n /**\n * Returns template of a child element (resource)\n * @param resourceId\n * @param attributes\n */\n getChildTemplate(resourceId: string, attributes: object) {\n let template = html`\n <solid-display\n data-src=${resourceId}\n @click=${(event: Event) => this.dispatchSelect(event, resourceId)}\n @keydown=${(event: Event) => this.enterKeydownAction(event, resourceId)}\n fields=${ifDefined(this.fields)}\n ...=${spread(attributes)}\n ></solid-display>\n `\n return template;\n },\n\n /**\n * Creates and render the content of a single element (resource)\n * @param parent\n */\n async appendSingleElt(parent: HTMLElement): Promise<void> {\n const fields = await this.getFields();\n const widgetTemplates = await Promise.all( // generate all widget templates\n fields.map((field: string) => this.createWidgetTemplate(field))\n );\n render(html`${widgetTemplates}`, parent);\n },\n\n /**\n * @override listMixin method to use litHtml\n *\n * Render resources from a container\n * @param resources\n * @param listPostProcessors\n * @param div\n * @param context\n */\n async renderDOM(\n resources: object[],\n listPostProcessors: Function[],\n div: HTMLElement,\n context: string,\n ) {\n const attributes = this.getChildAttributes(); // get attributes of children only once\n // and create a child template for each resource\n const template = html`${resources.map(r => r ? this.getChildTemplate(r['@id'], attributes) : null)}`;\n render(template, div);\n\n const nextProcessor = listPostProcessors.shift();\n if (nextProcessor)\n await nextProcessor(\n resources,\n listPostProcessors,\n div,\n context\n );\n },\n\n /**\n * Get attributes to dispatch to children from current element\n */\n getChildAttributes() {\n const attributes:{[key:string]: string} = {};\n for (let attr of this.element.attributes) {\n //copy widget and value attributes\n if (\n attr.name.startsWith('value-') ||\n attr.name.startsWith('label-') ||\n attr.name.startsWith('placeholder-') ||\n attr.name.startsWith('widget-') ||\n attr.name.startsWith('class-') ||\n attr.name.startsWith('multiple-') ||\n attr.name.startsWith('editable-') ||\n attr.name.startsWith('action-') ||\n attr.name.startsWith('default-') ||\n attr.name.startsWith('link-text-') ||\n attr.name == 'extra-context'\n )\n attributes[attr.name] = attr.value;\n if (attr.name.startsWith('child-'))\n attributes[attr.name.replace(/^child-/, '')] = attr.value;\n if (attr.name == 'next') {\n attributes['role'] = 'button';\n attributes['tabindex'] = '0';\n }\n }\n return attributes;\n }\n};\n\nSib.register(SolidDisplay);\n"]}
|
|
1
|
+
{"version":3,"sources":["solid-display.ts"],"names":["Sib","WidgetMixin","ListMixin","StoreMixin","PaginateMixin","FilterMixin","CounterMixin","SorterMixin","GrouperMixin","FederationMixin","HighlighterMixin","NextMixin","RequiredMixin","spread","html","render","ifDefined","SolidDisplay","name","use","attributes","defaultWidget","type","String","default","initialState","activeSubscription","removeActiveSubscription","created","route","document","querySelector","setTimeout","resourceId","addActiveCallback","detached","PubSub","unsubscribe","updateNavigateSubscription","subscribe","bind","element","setAttribute","removeActiveCallback","removeAttribute","childTag","dataset","child","tagName","defaultMultipleWidget","defaultSetWidget","dispatchSelect","event","linkTarget","target","closest","hasAttribute","resource","dispatchEvent","CustomEvent","detail","goToNext","enterKeydownAction","keyCode","getChildTemplate","template","fields","appendSingleElt","parent","getFields","widgetTemplates","Promise","all","map","field","createWidgetTemplate","renderDOM","resources","listPostProcessors","div","context","getChildAttributes","r","nextProcessor","shift","attr","startsWith","value","replace","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,eAAT,QAAgC,2BAAhC;AACA,SAASC,gBAAT,QAAiC,4BAAjC;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,MAAT,QAAuB,qBAAvB;AAEA,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AAEA,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,eADoB;AAE1BC,EAAAA,GAAG,EAAE,CACHlB,WADG,EAEHC,SAFG,EAGHC,UAHG,EAIHC,aAJG,EAKHI,YALG,EAMHF,YANG,EAOHI,gBAPG,EAQHL,WARG,EASHE,WATG,EAUHK,aAVG,EAWHH,eAXG,EAYHE,SAZG,CAFqB;AAgB1BS,EAAAA,UAAU,EAAE;AACVC,IAAAA,aAAa,EAAE;AACbC,MAAAA,IAAI,EAAEC,MADO;AAEbC,MAAAA,OAAO,EAAE;AAFI;AADL,GAhBc;AAsB1BC,EAAAA,YAAY,EAAE;AACZC,IAAAA,kBAAkB,EAAE,IADR;AAEZC,IAAAA,wBAAwB,EAAE;AAFd,GAtBY;;AA0B1BC,EAAAA,OAAO,GAAS;AACd;AACA,UAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAT,CAAuB,qBAAvB,CAAd;AACA,QAAI,CAACF,KAA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A,IAGAD,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,SAArB,CAHA,IAIAD,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,QAArB,CAJA,IAKAD,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,WAArB,CALA,IAMAD,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,WAArB,CANA,IAOAD,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,SAArB,CAPA,IAQAD,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,UAArB,CARA,IASAD,IAAI,CAACnE,IAAL,IAAa,eAVf,EAYEE,UAAU,CAACiE,IAAI,CAACnE,IAAN,CAAV,GAAwBmE,IAAI,CAACE,KAA7B;AACF,UAAIF,IAAI,CAACnE,IAAL,CAAUoE,UAAV,CAAqB,QAArB,CAAJ,EACElE,UAAU,CAACiE,IAAI,CAACnE,IAAL,CAAUsE,OAAV,CAAkB,SAAlB,EAA6B,EAA7B,CAAD,CAAV,GAA+CH,IAAI,CAACE,KAApD;;AACF,UAAIF,IAAI,CAACnE,IAAL,IAAa,MAAjB,EAAyB;AACvBE,QAAAA,UAAU,CAAC,MAAD,CAAV,GAAqB,QAArB;AACAA,QAAAA,UAAU,CAAC,UAAD,CAAV,GAAyB,GAAzB;AACD;AACF;;AACD,WAAOA,UAAP;AACD;;AA9KyB,CAArB;AAiLPpB,GAAG,CAACyF,QAAJ,CAAaxE,YAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { ListMixin } from '../mixins/listMixin';\nimport { StoreMixin } from '../mixins/storeMixin';\nimport { PaginateMixin } from '../mixins/paginateMixin';\nimport { FilterMixin } from '../mixins/filterMixin';\nimport { CounterMixin } from '../mixins/counterMixin';\nimport { SorterMixin } from '../mixins/sorterMixin';\nimport { GrouperMixin } from '../mixins/grouperMixin';\nimport { FederationMixin } from '../mixins/federationMixin';\nimport { HighlighterMixin } from '../mixins/highlighterMixin';\nimport { NextMixin } from '../mixins/nextMixin';\nimport { RequiredMixin } from '../mixins/requiredMixin';\nimport { spread } from '../libs/lit-helpers';\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nexport const SolidDisplay = {\n name: 'solid-display',\n use: [\n WidgetMixin,\n ListMixin,\n StoreMixin,\n PaginateMixin,\n GrouperMixin,\n CounterMixin,\n HighlighterMixin,\n FilterMixin,\n SorterMixin,\n RequiredMixin,\n FederationMixin,\n NextMixin,\n ],\n attributes: {\n defaultWidget: {\n type: String,\n default: 'solid-display-value',\n },\n },\n initialState: {\n activeSubscription: null,\n removeActiveSubscription: null,\n },\n created(): void {\n // Set route active at initialization\n const route = document.querySelector('solid-route[active]') as any;\n if (!route) return;\n setTimeout(() => {\n if (route['resourceId'] === this.resourceId) this.addActiveCallback();\n });\n },\n detached(): void {\n if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);\n if (this.removeActiveSubscription) PubSub.unsubscribe(this.removeActiveSubscription);\n },\n // Update subscription when id changes\n updateNavigateSubscription() {\n if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);\n\n if (this.resourceId) {\n this.activeSubscription = PubSub.subscribe(\n 'enterRoute.' + this.resourceId,\n this.addActiveCallback.bind(this)\n );\n }\n },\n addActiveCallback() {\n this.element.setAttribute('active', '');\n this.removeActiveSubscription = PubSub.subscribe(\n 'leaveRoute',\n this.removeActiveCallback.bind(this)\n );\n },\n removeActiveCallback() {\n this.element.removeAttribute('active');\n PubSub.unsubscribe(this.removeActiveSubscription);\n },\n get childTag(): string {\n return this.element.dataset.child || this.element.tagName;\n },\n get defaultMultipleWidget(): string {\n return 'solid-multiple';\n },\n get defaultSetWidget(): string {\n return 'solid-set-default';\n },\n // Here \"even.target\" points to the content of the widgets of the children of solid-display\n dispatchSelect(event: Event, resourceId: string): void {\n const linkTarget = (event!.target as Element).closest('a');\n if (linkTarget && linkTarget.hasAttribute('href')) return;\n const resource = { \"@id\": resourceId };\n this.element.dispatchEvent(\n new CustomEvent('resourceSelect', { detail: { resource: resource } }),\n );\n this.goToNext(resource);\n },\n \n enterKeydownAction (event, resourceId: string): void {\n if (event.keyCode === 13) {\n const resource = { \"@id\" : resourceId };\n this.goToNext(resource);\n }\n },\n /**\n * Returns template of a child element (resource)\n * @param resourceId\n * @param attributes\n */\n getChildTemplate(resourceId: string, attributes: object) {\n let template = html`\n <solid-display\n data-src=${resourceId}\n @click=${(event: Event) => this.dispatchSelect(event, resourceId)}\n @keydown=${(event: Event) => this.enterKeydownAction(event, resourceId)}\n fields=${ifDefined(this.fields)}\n ...=${spread(attributes)}\n ></solid-display>\n `\n return template;\n },\n\n /**\n * Creates and render the content of a single element (resource)\n * @param parent\n */\n async appendSingleElt(parent: HTMLElement): Promise<void> {\n const fields = await this.getFields();\n const widgetTemplates = await Promise.all( // generate all widget templates\n fields.map((field: string) => this.createWidgetTemplate(field))\n );\n render(html`${widgetTemplates}`, parent);\n },\n\n /**\n * @override listMixin method to use litHtml\n *\n * Render resources from a container\n * @param resources\n * @param listPostProcessors\n * @param div\n * @param context\n */\n async renderDOM(\n resources: object[],\n listPostProcessors: Function[],\n div: HTMLElement,\n context: string,\n ) {\n const attributes = this.getChildAttributes(); // get attributes of children only once\n // and create a child template for each resource\n const template = html`${resources.map(r => r ? this.getChildTemplate(r['@id'], attributes) : null)}`;\n render(template, div);\n\n const nextProcessor = listPostProcessors.shift();\n if (nextProcessor)\n await nextProcessor(\n resources,\n listPostProcessors,\n div,\n context\n );\n },\n\n /**\n * Get attributes to dispatch to children from current element\n */\n getChildAttributes() {\n const attributes:{[key:string]: string} = {};\n for (let attr of this.element.attributes) {\n //copy widget and value attributes\n if (\n attr.name.startsWith('value-') ||\n attr.name.startsWith('label-') ||\n attr.name.startsWith('placeholder-') ||\n attr.name.startsWith('widget-') ||\n attr.name.startsWith('class-') ||\n attr.name.startsWith('multiple-') ||\n attr.name.startsWith('editable-') ||\n attr.name.startsWith('action-') ||\n attr.name.startsWith('default-') ||\n attr.name == 'extra-context'\n )\n attributes[attr.name] = attr.value;\n if (attr.name.startsWith('child-'))\n attributes[attr.name.replace(/^child-/, '')] = attr.value;\n if (attr.name == 'next') {\n attributes['role'] = 'button';\n attributes['tabindex'] = '0';\n }\n }\n return attributes;\n }\n};\n\nSib.register(SolidDisplay);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["solid-form-search.ts"],"names":["Sib","WidgetMixin","AttributeBinderMixin","ContextMixin","newWidgetFactory","html","render","ifDefined","uniqID","SolidFormSearch","name","use","attributes","defaultWidget","type","String","default","submitButton","callback","newValue","oldValue","noRender","populate","submitWidget","undefined","classSubmitButton","value","initialState","error","created","element","closest","autoRangeValues","rangeId","attachedElements","Set","defaultMultipleWidget","defaultSetWidget","values","widgets","forEach","widget","component","getValue","JSON","parse","list","multiple","getWidget","field","isSet","tagName","hasAttribute","idField","setAttribute","widgetAttribute","getAttribute","customElements","get","startsWith","widgetFromTagName","attach","elm","has","add","updateAutoRanges","detach","delete","attr","replace","getValuesOfField","id","ldpContains","Array","from","map","data","context","sibStore","setLocalData","change","resource","dispatchEvent","CustomEvent","bubbles","detail","inputChange","getSubmitTemplate","empty","replaceAttributesData","addEventListener","e","preventDefault","fields","getFields","widgetTemplates","Promise","all","createWidgetTemplate","template","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,SAASC,YAAT,QAA6B,wBAA7B;AAEA,SAASC,gBAAT,QAAiC,mCAAjC;AAEA,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AACA,SAASC,MAAT,QAAuB,iBAAvB;AAGA,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,IAAI,EAAE,mB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in } from '../mixins/attributeBinderMixin';\nimport { ContextMixin } from '../mixins/contextMixin';\nimport type { WidgetInterface } from '../mixins/interfaces';\nimport { newWidgetFactory } from '../new-widgets/new-widget-factory';\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { uniqID } from '../libs/helpers';\nimport type { SearchQuery } from '../libs/interfaces';\n\nexport const SolidFormSearch = {\n name: 'solid-form-search',\n use: [WidgetMixin, AttributeBinderMixin, ContextMixin],\n attributes: {\n defaultWidget: {\n type: String,\n default: 'solid-form-label-text',\n },\n submitButton: {\n type: String,\n default: null,\n callback: function (newValue: string, oldValue: string) {\n if (this.noRender == null && newValue !== oldValue) this.populate();\n },\n },\n submitWidget: {\n type: String,\n default: undefined\n },\n classSubmitButton: {\n type: String,\n default: undefined,\n },\n noRender: {\n type: String,\n default: null,\n callback: function (value: boolean) {\n if (value === null) this.populate()\n }\n },\n },\n initialState: {\n error: '',\n },\n created() {\n if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself\n this.autoRangeValues = {};\n this.rangeId = uniqID();\n this.attachedElements = new Set();\n },\n get defaultMultipleWidget(): string {\n return 'solid-multiple-form';\n },\n get defaultSetWidget(): string {\n return 'solid-set-default';\n },\n\n get value(): SearchQuery {\n const values: SearchQuery = {};\n this.widgets.forEach((widget) => {\n const name = (widget.component || widget).name;\n if (name == null) return;\n let value = widget.component ? widget.component.getValue() : widget.value;\n try {\n value = JSON.parse(value);\n } catch {}\n value = {\n type: widget.component.type,\n list: !!widget.component.multiple,\n value: value,\n }\n values[name] = value;\n });\n return values;\n },\n getWidget(field: string, isSet: boolean = false): WidgetInterface {\n let tagName = '';\n // If auto-range-[field] exists, create range-[field] and sets its value\n if(this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) {\n const idField = `${this.rangeId}_${field}`;\n this.element.setAttribute('range-' + field, 'store://local.' + idField);\n this.populate();\n }\n \n const widgetAttribute = this.element.getAttribute('widget-' + field);\n // Choose widget\n if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) {\n tagName = 'solid-form-dropdown'\n } else {\n tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget);\n }\n // Create widget\n if (!customElements.get(tagName)) { // component does not exist\n if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it\n }\n\n return this.widgetFromTagName(tagName);\n },\n async attach(elm: any) {\n if(this.attachedElements.has(elm)) return;\n this.attachedElements.add(elm);\n await this.updateAutoRanges();\n },\n async detach(elm: any) {\n if(!this.attachedElements.has(elm)) return;\n this.attachedElements.delete(elm);\n await this.updateAutoRanges();\n },\n async updateAutoRanges() {\n for(const attr of (this.element as Element).attributes) {\n if(!attr['name'].startsWith('auto-range-')) continue;\n const field = attr['name'].replace('auto-range-', '');\n const autoRangeValues = new Set();\n for(const elm of this.attachedElements) {\n for(const value of await elm.getValuesOfField(field)) {\n autoRangeValues.add(value);\n }\n }\n const idField = `${this.rangeId}_${field}`;\n const id = `store://local.${idField}`;\n const ldpContains = Array.from(autoRangeValues).map(id => ({'@id' : id}));\n const data = {\n \"@type\": \"ldp:Container\",\n \"@context\": this.context,\n \"ldp:contains\" : ldpContains,\n };\n sibStore.setLocalData(data, id);\n }\n },\n change(resource: object): void {\n this.element.dispatchEvent(\n new CustomEvent('formChange', {\n bubbles: true,\n detail: { resource },\n }),\n );\n },\n async inputChange(): Promise<void> {\n this.change(this.value);\n },\n getSubmitTemplate() {\n return html`\n <div class=${ifDefined(this.classSubmitButton)}>\n ${this.submitWidget === 'button' ? html`\n <button type=\"submit\">${this.submitButton || ''}</button>\n ` : html`\n <input type=\"submit\" value=${ifDefined(this.submitButton || undefined)}>\n `}\n </div>\n ` \n },\n empty(): void {},\n async populate(): Promise<void> {\n await this.replaceAttributesData();\n if(this.submitButton == null) {\n this.element.addEventListener('input', () => this.inputChange());\n } else {\n this.element.addEventListener('submit', (e: Event) => {\n e.preventDefault();\n this.inputChange();\n });\n }\n const fields = await this.getFields();\n const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field)));\n const template = html`\n <form>\n ${widgetTemplates}\n ${this.submitButton == null ? '' : this.getSubmitTemplate()}\n </form>\n `;\n render(template, this.element);\n }\n};\n\nSib.register(SolidFormSearch);"]}
|
|
1
|
+
{"version":3,"sources":["solid-form-search.ts"],"names":["Sib","WidgetMixin","AttributeBinderMixin","ContextMixin","newWidgetFactory","html","render","ifDefined","uniqID","SolidFormSearch","name","use","attributes","defaultWidget","type","String","default","submitButton","callback","newValue","oldValue","noRender","populate","submitWidget","undefined","classSubmitButton","value","initialState","error","created","element","closest","autoRangeValues","rangeId","attachedElements","Set","defaultMultipleWidget","defaultSetWidget","values","widgets","forEach","widget","component","getValue","JSON","parse","list","multiple","getWidget","field","isSet","tagName","hasAttribute","idField","setAttribute","widgetAttribute","getAttribute","customElements","get","startsWith","widgetFromTagName","attach","elm","has","add","updateAutoRanges","detach","delete","attr","replace","getValuesOfField","id","ldpContains","Array","from","map","data","context","sibStore","setLocalData","change","resource","dispatchEvent","CustomEvent","bubbles","detail","inputChange","getSubmitTemplate","empty","replaceAttributesData","addEventListener","e","preventDefault","fields","getFields","widgetTemplates","Promise","all","createWidgetTemplate","template","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,SAASC,YAAT,QAA6B,wBAA7B;AAEA,SAASC,gBAAT,QAAiC,mCAAjC;AAEA,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AACA,SAASC,MAAT,QAAuB,iBAAvB;AAEA,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,IAAI,EAAE,mBADuB;AAE7BC,EAAAA,GAAG,EAAE,CAACV,WAAD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AAG;AAClB,WAAOlF,IAAP,oBACeE,SAAS,CAAC,KAAKkB,iBAAN,CADxB,EAEM,KAAKF,YAAL,KAAsB,QAAtB,GAAiClB,IAAjC,qBACwB,KAAKY,YAAL,IAAqB,EAD7C,IAEEZ,IAFF,qBAG6BE,SAAS,CAAC,KAAKU,YAAL,IAAqBO,SAAtB,CAHtC,CAFN;AASD,GA5I4B;;AA6I7BgE,EAAAA,KAAK,GAAS,CAAE,CA7Ia;;AA8I7B,QAAMlE,QAAN,GAAgC;AAC9B,UAAM,KAAKmE,qBAAL,EAAN;;AACA,QAAG,KAAKxE,YAAL,IAAqB,IAAxB,EAA8B;AAC5B,WAAKa,OAAL,CAAa4D,gBAAb,CAA8B,OAA9B,EAAuC,MAAM,KAAKJ,WAAL,EAA7C;AACD,KAFD,MAEO;AACL,WAAKxD,OAAL,CAAa4D,gBAAb,CAA8B,QAA9B,EAAyCC,CAAD,IAAc;AACpDA,QAAAA,CAAC,CAACC,cAAF;AACA,aAAKN,WAAL;AACD,OAHD;AAID;;AACD,UAAMO,MAAM,GAAG,MAAM,KAAKC,SAAL,EAArB;AACA,UAAMC,eAAe,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYJ,MAAM,CAAClB,GAAP,CAAY1B,KAAD,IAAmB,KAAKiD,oBAAL,CAA0BjD,KAA1B,CAA9B,CAAZ,CAA9B;AACA,UAAMkD,QAAQ,GAAG9F,IAAH,qBAER0F,eAFQ,EAGR,KAAK9E,YAAL,IAAqB,IAArB,GAA4B,EAA5B,GAAiC,KAAKsE,iBAAL,EAHzB,CAAd;AAMAjF,IAAAA,MAAM,CAAC6F,QAAD,EAAW,KAAKrE,OAAhB,CAAN;AACD;;AAjK4B,CAAxB;AAoKP9B,GAAG,CAACoG,QAAJ,CAAa3F,eAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { AttributeBinderMixin } from '../mixins/attributeBinderMixin';\nimport { ContextMixin } from '../mixins/contextMixin';\nimport type { WidgetInterface } from '../mixins/interfaces';\nimport { newWidgetFactory } from '../new-widgets/new-widget-factory';\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { uniqID } from '../libs/helpers';\n\nexport const SolidFormSearch = {\n name: 'solid-form-search',\n use: [WidgetMixin, AttributeBinderMixin, ContextMixin],\n attributes: {\n defaultWidget: {\n type: String,\n default: 'solid-form-label-text',\n },\n submitButton: {\n type: String,\n default: null,\n callback: function (newValue: string, oldValue: string) {\n if (this.noRender == null && newValue !== oldValue) this.populate();\n },\n },\n submitWidget: {\n type: String,\n default: undefined\n },\n classSubmitButton: {\n type: String,\n default: undefined,\n },\n noRender: {\n type: String,\n default: null,\n callback: function (value: boolean) {\n if (value === null) this.populate()\n }\n },\n },\n initialState: {\n error: '',\n },\n created() {\n if (this.element.closest('[no-render]')) this.noRender = ''; // if embedded in no-render, apply no-render to himself\n this.autoRangeValues = {};\n this.rangeId = uniqID();\n this.attachedElements = new Set();\n },\n get defaultMultipleWidget(): string {\n return 'solid-multiple-form';\n },\n get defaultSetWidget(): string {\n return 'solid-set-default';\n },\n\n get value(): object {\n const values = {};\n this.widgets.forEach((widget) => {\n const name = (widget.component || widget).name;\n if (name == null) return;\n let value = widget.component ? widget.component.getValue() : widget.value;\n try {\n value = JSON.parse(value);\n } catch {}\n value = {\n type: widget.component.type,\n list: !!widget.component.multiple,\n value: value,\n }\n values[name] = value;\n });\n return values;\n },\n getWidget(field: string, isSet: boolean = false): WidgetInterface {\n let tagName = '';\n // If auto-range-[field] exists, create range-[field] and sets its value\n if(this.element.hasAttribute('auto-range-' + field) && !this.element.hasAttribute('range-' + field)) {\n const idField = `${this.rangeId}_${field}`;\n this.element.setAttribute('range-' + field, 'store://local.' + idField);\n this.populate();\n }\n \n const widgetAttribute = this.element.getAttribute('widget-' + field);\n // Choose widget\n if (!widgetAttribute && (this.element.hasAttribute('range-' + field) || this.element.hasAttribute('enum-' + field))) {\n tagName = 'solid-form-dropdown'\n } else {\n tagName = widgetAttribute || (!isSet ? this.defaultWidget : this.defaultSetWidget);\n }\n // Create widget\n if (!customElements.get(tagName)) { // component does not exist\n if (tagName.startsWith('solid')) newWidgetFactory(tagName); // solid- -> create it\n }\n\n return this.widgetFromTagName(tagName);\n },\n async attach(elm: any) {\n if(this.attachedElements.has(elm)) return;\n this.attachedElements.add(elm);\n await this.updateAutoRanges();\n },\n async detach(elm: any) {\n if(!this.attachedElements.has(elm)) return;\n this.attachedElements.delete(elm);\n await this.updateAutoRanges();\n },\n async updateAutoRanges() {\n for(const attr of (this.element as Element).attributes) {\n if(!attr['name'].startsWith('auto-range-')) continue;\n const field = attr['name'].replace('auto-range-', '');\n const autoRangeValues = new Set();\n for(const elm of this.attachedElements) {\n for(const value of await elm.getValuesOfField(field)) {\n autoRangeValues.add(value);\n }\n }\n const idField = `${this.rangeId}_${field}`;\n const id = `store://local.${idField}`;\n const ldpContains = Array.from(autoRangeValues).map(id => ({'@id' : id}));\n const data = {\n \"@type\": \"ldp:Container\",\n \"@context\": this.context,\n \"ldp:contains\" : ldpContains,\n };\n sibStore.setLocalData(data, id);\n }\n },\n change(resource: object): void {\n this.element.dispatchEvent(\n new CustomEvent('formChange', {\n bubbles: true,\n detail: { resource },\n }),\n );\n },\n async inputChange(): Promise<void> {\n this.change(this.value);\n },\n getSubmitTemplate() {\n return html`\n <div class=${ifDefined(this.classSubmitButton)}>\n ${this.submitWidget === 'button' ? html`\n <button type=\"submit\">${this.submitButton || ''}</button>\n ` : html`\n <input type=\"submit\" value=${ifDefined(this.submitButton || undefined)}>\n `}\n </div>\n ` \n },\n empty(): void {},\n async populate(): Promise<void> {\n await this.replaceAttributesData();\n if(this.submitButton == null) {\n this.element.addEventListener('input', () => this.inputChange());\n } else {\n this.element.addEventListener('submit', (e: Event) => {\n e.preventDefault();\n this.inputChange();\n });\n }\n const fields = await this.getFields();\n const widgetTemplates = await Promise.all(fields.map((field: string) => this.createWidgetTemplate(field)));\n const template = html`\n <form>\n ${widgetTemplates}\n ${this.submitButton == null ? '' : this.getSubmitTemplate()}\n </form>\n `;\n render(template, this.element);\n }\n};\n\nSib.register(SolidFormSearch);"]}
|
|
@@ -33,9 +33,9 @@ import { store } from '../libs/store/store.js';
|
|
|
33
33
|
import { uniqID } from '../libs/helpers.js';
|
|
34
34
|
import { spread } from '../libs/lit-helpers.js'; //@ts-ignore
|
|
35
35
|
|
|
36
|
-
import L from 'https://cdn.skypack.dev/leaflet'; // TODO : revert to "leaflet" when apps up to date
|
|
36
|
+
import L from 'https://cdn.skypack.dev/leaflet@1.7.1'; // TODO : revert to "leaflet" when apps up to date
|
|
37
37
|
|
|
38
|
-
import 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to "leaflet.markercluster" when apps up to date
|
|
38
|
+
import 'https://cdn.skypack.dev/leaflet.markercluster@1.4.1'; // TODO : revert to "leaflet.markercluster" when apps up to date
|
|
39
39
|
|
|
40
40
|
import { html, render } from '../_snowpack/pkg/lit-html.js';
|
|
41
41
|
import { ifDefined } from '../_snowpack/pkg/lit-html/directives/if-defined.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["solid-map.ts"],"names":["Sib","ListMixin","StoreMixin","WidgetMixin","CounterMixin","FilterMixin","FederationMixin","GrouperMixin","NextMixin","store","uniqID","spread","L","html","render","ifDefined","SolidMap","name","use","attributes","clustering","type","Boolean","default","initialState","markers","subscriptions","resetPlanned","hasBeenResetOnce","created","document","body","addEventListener","setTimeout","isVisible","reset","Map","element","offsetParent","attached","id","template","div","querySelector","map","tileLayer","addTo","markersCluster","markerClusterGroup","addLayer","invalidateSize","length","fitBounds","featureGroup","getBounds","fitWorld","planReset","dispatchSelect","event","target","resource","dispatchEvent","CustomEvent","detail","goToNext","appendChildElt","resourceId","groupClass","getData","context","get","set","PubSub","subscribe","updateDOM","lat","lng","icon","divIcon","className","iconSize","iconAnchor","popupAnchor","marker","toString","on","bind","fields","bindPopup","getPopupContent","minWidth","push","attr","startsWith","value","replace","createElement","empty","removeLayer","renderGroup","groupName","sanitizedGroupName","encodeURIComponent","toLowerCase","dataset","renderDOM","resources","listPostProcessors","Promise","all","nextProcessor","shift","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,UAAT,QAA2B,sBAA3B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,eAAT,QAAgC,2BAAhC;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,MAAT,QAAuB,qBAAvB,C,CAEA;;AACA,OAAOC,CAAP,MAAiC,iCAAjC,C,CAAoE;;AACpE,OAAO,+CAAP,C,CAAwD;;AAExD,SAASC,IAAT,EAAeC,MAAf,QAA6B,UAA7B;AACA,SAASC,SAAT,QAA0B,gCAA1B;AAEA,OAAO,MAAMC,QAAQ,GAAG;AACtBC,EAAAA,IAAI,EAAE,WADgB;AAEtBC,EAAAA,GAAG,EAAE,CACHf,WADG,EAEHF,SAFG,EAGHC,UAHG,EAIHK,YAJG,EAKHH,YALG,EAMHC,WANG,EAOHC,eAPG,EAQHE,SARG,CAFiB;AAYtBW,EAAAA,UAAU,EAAE;AACVC,IAAAA,UAAU,EAAE;AACVC,MAAAA,IAAI,EAAEC,OADI;AAEVC,MAAAA,OAAO,EAAE;AAFC;AADF,GAZU;AAkBtBC,EAAAA,YAAY,EAAE;AACZC,IAAAA,OAAO,EAAE;AACPF,MAAAA,OAAO,EAAE;AADF,KADG;AAIZG,IAAAA,aAAa,EAAE,IAJH;AAKZC,IAAAA,YAAY,EAAE,KALF;AAMZC,IAAAA,gBAAgB,EAAE;AANN,GAlBQ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CAAoBL,QAAQ,CAAC,KAAD,CAA5B,EAAqCO,UAArC,CAA1B,CAAZ,CAAN;AACA,SAAKX,SAAL;AAEA,UAAMsD,aAAa,GAAGH,kBAAkB,CAACI,KAAnB,EAAtB;AACA,QAAGD,aAAH,EAAkB,MAAMA,aAAa,CAACJ,SAAD,EAAYC,kBAAZ,EAAgCjE,GAAhC,EAAqC2B,OAArC,CAAnB;AACnB;;AAjNqB,CAAjB;AAoNPrE,GAAG,CAACgH,QAAJ,CAAahG,QAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { ListMixin } from '../mixins/listMixin';\nimport { StoreMixin } from '../mixins/storeMixin';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { CounterMixin } from '../mixins/counterMixin';\nimport { FilterMixin } from '../mixins/filterMixin';\nimport { FederationMixin } from '../mixins/federationMixin';\nimport { GrouperMixin } from '../mixins/grouperMixin';\nimport { NextMixin } from '../mixins/nextMixin';\nimport { store } from '../libs/store/store';\nimport { uniqID } from '../libs/helpers';\nimport { spread } from '../libs/lit-helpers';\n\n//@ts-ignore\nimport L, { MarkerOptions } from 'https://cdn.skypack.dev/leaflet'; // TODO : revert to \"leaflet\" when apps up to date\nimport 'https://cdn.skypack.dev/leaflet.markercluster'; // TODO : revert to \"leaflet.markercluster\" when apps up to date\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nexport const SolidMap = {\n name: 'solid-map',\n use: [\n WidgetMixin,\n ListMixin,\n StoreMixin,\n GrouperMixin,\n CounterMixin,\n FilterMixin,\n FederationMixin,\n NextMixin,\n ],\n attributes: {\n clustering: {\n type: Boolean,\n default: null\n }\n },\n initialState: {\n markers: {\n default: null\n },\n subscriptions: null,\n resetPlanned: false,\n hasBeenResetOnce: false\n },\n created(): void {\n //@ts-ignore\n import('leaflet/dist/leaflet.css');\n //@ts-ignore\n import('../style/default-theme.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.Default.css');\n\n // reset when it becomes visible to prevent bug https://git.startinblox.com/framework/sib-core/issues/661\n document.body.addEventListener('navigate', () =>\n setTimeout(() => this.isVisible && !this.hasBeenResetOnce && this.reset())\n );\n this.markers = [];\n this.subscriptions = new Map();\n },\n get isVisible() {\n return this.element.offsetParent !== null\n },\n attached(): void {\n const id = uniqID();\n const template = html`\n <div id=${id} style=\"width:100%;height:100%;\"></div>\n `;\n render(template, this.element);\n\n const div = this.element.querySelector(`#${id}`);\n this.map = L.map(div);\n\n L.tileLayer(\n 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'\n ).addTo(this.map);\n\n if (this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n },\n reset() {\n if (this.isVisible) { // reset only if visible\n this.map.invalidateSize();\n\n if (this.markers.length) {\n this.map.fitBounds(L.featureGroup(this.markers).getBounds()); // Center map on markers if some available\n } else {\n this.map.fitWorld(); // ... or on the world if not\n }\n this.hasBeenResetOnce = true;\n }\n },\n /**\n * Execute a reset only if none is planned already\n */\n planReset() {\n if (!this.resetPlanned) {\n this.resetPlanned = true;\n setTimeout(() => {\n this.reset();\n this.resetPlanned = false;\n })\n }\n },\n dispatchSelect(event: CustomEvent): void {\n const target = event.target as Element;\n const resource = target['options'].resource;\n this.element.dispatchEvent(\n new CustomEvent('resourceSelect', { detail: { resource: resource } })\n );\n this.goToNext(resource);\n },\n\n /**\n * Override listMixin method: initialize a marker on the map\n * @param resourceId: id of the resource to display\n * @param groupClass: class of the group of markers\n */\n async appendChildElt(resourceId: string, groupClass: string) {\n const resource = await store.getData(resourceId, this.context);\n if (!this.subscriptions.get(resourceId)) {\n this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM()))\n }\n if (!resource) return;\n const lat = await resource['lat'];\n const lng = await resource['lng'];\n\n if (lat && lng) {\n const icon = L.divIcon({ // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon\n className: 'sib-custom-marker ' + groupClass, // default class used for styling\n iconSize: [8, 8],\n iconAnchor: [12, 34],\n popupAnchor: [0,-34]\n });\n\n // create a marker, doc here: https://leafletjs.com/reference-1.6.0.html#marker\n const marker = L.marker(\n [lat.toString(), lng.toString()], \n {resource, icon} as MarkerOptions\n );\n if(this.clustering === null) marker.addTo(this.map);\n else this.markersCluster.addLayer(marker);\n marker.on('click', this.dispatchSelect.bind(this));\n\n if (this.fields !== null) { // show popups only if fields attribute\n marker.bindPopup(() => this.getPopupContent(resourceId), { minWidth: 150 }) // re-generate popup solid-display\n }\n\n this.markers.push(marker);\n }\n },\n /**\n * Generate the solid-display of the popup\n * @param resourceId: id of the popup clicked\n */\n getPopupContent(resourceId: string) {\n const attributes:{[key:string]: string} = {};\n\n for (let attr of this.element.attributes) {\n //copy widget and value attributes\n if (\n attr.name.startsWith('value-') ||\n attr.name.startsWith('label-') ||\n attr.name.startsWith('widget-') ||\n attr.name.startsWith('class-') ||\n attr.name.startsWith('multiple-') ||\n attr.name.startsWith('editable-') ||\n attr.name.startsWith('action-') ||\n attr.name.startsWith('default-') ||\n attr.name == 'extra-context'\n )\n attributes[attr.name] = attr.value;\n if (attr.name.startsWith('child-'))\n attributes[attr.name.replace(/^child-/, '')] = attr.value;\n }\n\n const div = document.createElement('div');\n const template = html`\n <solid-display\n fields=\"${ifDefined(this.fields)}\"\n data-src=\"${resourceId}\"\n ...=${spread(attributes)}\n ></solid-display>\n `;\n render(template, div);\n return div.querySelector('solid-display');\n },\n /**\n * Override widgetMixin method: empty the map\n */\n empty(): void {\n if (!this.map) return;\n if (this.markersCluster) this.map.removeLayer(this.markersCluster);\n for (let marker of this.markers) this.map.removeLayer(marker);\n if(this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n this.markers = [];\n },\n /**\n * Override groupMixin method\n * @param groupName: value of the group\n */\n renderGroup(groupName: string) {\n const sanitizedGroupName = encodeURIComponent(groupName.toLowerCase()).replace(/%[0-9A-F]{2}/gi, '');\n const div = document.createElement('div'); // used to pass group info to renderDOM\n div.dataset.groupClass = 'group-' + sanitizedGroupName;\n return div;\n },\n /**\n * Override listMixin method: display all the resources\n * @param resources\n * @param listPostProcessors\n * @param div\n * @param context\n */\n async renderDOM(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) {\n const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element\n await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass)))\n this.planReset();\n\n const nextProcessor = listPostProcessors.shift();\n if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);\n }\n};\n\nSib.register(SolidMap);"]}
|
|
1
|
+
{"version":3,"sources":["solid-map.ts"],"names":["Sib","ListMixin","StoreMixin","WidgetMixin","CounterMixin","FilterMixin","FederationMixin","GrouperMixin","NextMixin","store","uniqID","spread","L","html","render","ifDefined","SolidMap","name","use","attributes","clustering","type","Boolean","default","initialState","markers","subscriptions","resetPlanned","hasBeenResetOnce","created","document","body","addEventListener","setTimeout","isVisible","reset","Map","element","offsetParent","attached","id","template","div","querySelector","map","tileLayer","addTo","markersCluster","markerClusterGroup","addLayer","invalidateSize","length","fitBounds","featureGroup","getBounds","fitWorld","planReset","dispatchSelect","event","target","resource","dispatchEvent","CustomEvent","detail","goToNext","appendChildElt","resourceId","groupClass","getData","context","get","set","PubSub","subscribe","updateDOM","lat","lng","icon","divIcon","className","iconSize","iconAnchor","popupAnchor","marker","toString","on","bind","fields","bindPopup","getPopupContent","minWidth","push","attr","startsWith","value","replace","createElement","empty","removeLayer","renderGroup","groupName","sanitizedGroupName","encodeURIComponent","toLowerCase","dataset","renderDOM","resources","listPostProcessors","Promise","all","nextProcessor","shift","register"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,aAApB;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,UAAT,QAA2B,sBAA3B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nB;;AAjNqB,CAAjB;AAoNPrE,GAAG,CAACgH,QAAJ,CAAahG,QAAb","sourcesContent":["import { Sib } from '../libs/Sib';\nimport { ListMixin } from '../mixins/listMixin';\nimport { StoreMixin } from '../mixins/storeMixin';\nimport { WidgetMixin } from '../mixins/widgetMixin';\nimport { CounterMixin } from '../mixins/counterMixin';\nimport { FilterMixin } from '../mixins/filterMixin';\nimport { FederationMixin } from '../mixins/federationMixin';\nimport { GrouperMixin } from '../mixins/grouperMixin';\nimport { NextMixin } from '../mixins/nextMixin';\nimport { store } from '../libs/store/store';\nimport { uniqID } from '../libs/helpers';\nimport { spread } from '../libs/lit-helpers';\n\n//@ts-ignore\nimport L, { MarkerOptions } from 'https://cdn.skypack.dev/leaflet@1.7.1'; // TODO : revert to \"leaflet\" when apps up to date\nimport 'https://cdn.skypack.dev/leaflet.markercluster@1.4.1'; // TODO : revert to \"leaflet.markercluster\" when apps up to date\n\nimport { html, render } from 'lit-html';\nimport { ifDefined } from 'lit-html/directives/if-defined';\n\nexport const SolidMap = {\n name: 'solid-map',\n use: [\n WidgetMixin,\n ListMixin,\n StoreMixin,\n GrouperMixin,\n CounterMixin,\n FilterMixin,\n FederationMixin,\n NextMixin,\n ],\n attributes: {\n clustering: {\n type: Boolean,\n default: null\n }\n },\n initialState: {\n markers: {\n default: null\n },\n subscriptions: null,\n resetPlanned: false,\n hasBeenResetOnce: false\n },\n created(): void {\n //@ts-ignore\n import('leaflet/dist/leaflet.css');\n //@ts-ignore\n import('../style/default-theme.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.css');\n //@ts-ignore\n import('leaflet.markercluster/dist/MarkerCluster.Default.css');\n\n // reset when it becomes visible to prevent bug https://git.startinblox.com/framework/sib-core/issues/661\n document.body.addEventListener('navigate', () =>\n setTimeout(() => this.isVisible && !this.hasBeenResetOnce && this.reset())\n );\n this.markers = [];\n this.subscriptions = new Map();\n },\n get isVisible() {\n return this.element.offsetParent !== null\n },\n attached(): void {\n const id = uniqID();\n const template = html`\n <div id=${id} style=\"width:100%;height:100%;\"></div>\n `;\n render(template, this.element);\n\n const div = this.element.querySelector(`#${id}`);\n this.map = L.map(div);\n\n L.tileLayer(\n 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'\n ).addTo(this.map);\n\n if (this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n },\n reset() {\n if (this.isVisible) { // reset only if visible\n this.map.invalidateSize();\n\n if (this.markers.length) {\n this.map.fitBounds(L.featureGroup(this.markers).getBounds()); // Center map on markers if some available\n } else {\n this.map.fitWorld(); // ... or on the world if not\n }\n this.hasBeenResetOnce = true;\n }\n },\n /**\n * Execute a reset only if none is planned already\n */\n planReset() {\n if (!this.resetPlanned) {\n this.resetPlanned = true;\n setTimeout(() => {\n this.reset();\n this.resetPlanned = false;\n })\n }\n },\n dispatchSelect(event: CustomEvent): void {\n const target = event.target as Element;\n const resource = target['options'].resource;\n this.element.dispatchEvent(\n new CustomEvent('resourceSelect', { detail: { resource: resource } })\n );\n this.goToNext(resource);\n },\n\n /**\n * Override listMixin method: initialize a marker on the map\n * @param resourceId: id of the resource to display\n * @param groupClass: class of the group of markers\n */\n async appendChildElt(resourceId: string, groupClass: string) {\n const resource = await store.getData(resourceId, this.context);\n if (!this.subscriptions.get(resourceId)) {\n this.subscriptions.set(resourceId, PubSub.subscribe(resourceId, () => this.updateDOM()))\n }\n if (!resource) return;\n const lat = await resource['lat'];\n const lng = await resource['lng'];\n\n if (lat && lng) {\n const icon = L.divIcon({ // create the icon, doc here: https://leafletjs.com/reference-1.6.0.html#icon\n className: 'sib-custom-marker ' + groupClass, // default class used for styling\n iconSize: [8, 8],\n iconAnchor: [12, 34],\n popupAnchor: [0,-34]\n });\n\n // create a marker, doc here: https://leafletjs.com/reference-1.6.0.html#marker\n const marker = L.marker(\n [lat.toString(), lng.toString()], \n {resource, icon} as MarkerOptions\n );\n if(this.clustering === null) marker.addTo(this.map);\n else this.markersCluster.addLayer(marker);\n marker.on('click', this.dispatchSelect.bind(this));\n\n if (this.fields !== null) { // show popups only if fields attribute\n marker.bindPopup(() => this.getPopupContent(resourceId), { minWidth: 150 }) // re-generate popup solid-display\n }\n\n this.markers.push(marker);\n }\n },\n /**\n * Generate the solid-display of the popup\n * @param resourceId: id of the popup clicked\n */\n getPopupContent(resourceId: string) {\n const attributes:{[key:string]: string} = {};\n\n for (let attr of this.element.attributes) {\n //copy widget and value attributes\n if (\n attr.name.startsWith('value-') ||\n attr.name.startsWith('label-') ||\n attr.name.startsWith('widget-') ||\n attr.name.startsWith('class-') ||\n attr.name.startsWith('multiple-') ||\n attr.name.startsWith('editable-') ||\n attr.name.startsWith('action-') ||\n attr.name.startsWith('default-') ||\n attr.name == 'extra-context'\n )\n attributes[attr.name] = attr.value;\n if (attr.name.startsWith('child-'))\n attributes[attr.name.replace(/^child-/, '')] = attr.value;\n }\n\n const div = document.createElement('div');\n const template = html`\n <solid-display\n fields=\"${ifDefined(this.fields)}\"\n data-src=\"${resourceId}\"\n ...=${spread(attributes)}\n ></solid-display>\n `;\n render(template, div);\n return div.querySelector('solid-display');\n },\n /**\n * Override widgetMixin method: empty the map\n */\n empty(): void {\n if (!this.map) return;\n if (this.markersCluster) this.map.removeLayer(this.markersCluster);\n for (let marker of this.markers) this.map.removeLayer(marker);\n if(this.clustering !== null) {\n this.markersCluster = L.markerClusterGroup();\n this.map.addLayer(this.markersCluster);\n }\n this.markers = [];\n },\n /**\n * Override groupMixin method\n * @param groupName: value of the group\n */\n renderGroup(groupName: string) {\n const sanitizedGroupName = encodeURIComponent(groupName.toLowerCase()).replace(/%[0-9A-F]{2}/gi, '');\n const div = document.createElement('div'); // used to pass group info to renderDOM\n div.dataset.groupClass = 'group-' + sanitizedGroupName;\n return div;\n },\n /**\n * Override listMixin method: display all the resources\n * @param resources\n * @param listPostProcessors\n * @param div\n * @param context\n */\n async renderDOM(resources: object[], listPostProcessors: Function[], div: HTMLElement, context: string) {\n const groupClass = div.dataset.groupClass || ''; // get the group class from the useless div element\n await Promise.all(resources.map(resource => this.appendChildElt(resource['@id'], groupClass)))\n this.planReset();\n\n const nextProcessor = listPostProcessors.shift();\n if(nextProcessor) await nextProcessor(resources, listPostProcessors, div, context);\n }\n};\n\nSib.register(SolidMap);"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["interfaces.ts"],"names":[],"mappings":"AAKC;AAUA;AA8BA;AAsBA;AAIA","sourcesContent":["export interface AccessorStaticInterface {\n [key: string]: {\n get: Function;\n set: Function;\n }\n};\n\nexport interface ArrayOfHooksInterface {\n created: HookInterface[];\n attached: HookInterface[];\n detached: HookInterface[];\n}\n\nexport interface AttributeChangedCallbackInterface {\n (newValue: any, oldValue: any): void;\n};\n\nexport interface AttributeDefinitionInterface {\n type?: any;\n default?: any;\n required?: boolean;\n callback?: AttributeChangedCallbackInterface;\n}\n\nexport interface AttributesDefinitionInterface {\n [key: string]: AttributeDefinitionInterface;\n}\n\nexport type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface;\n\nexport interface ComponentInterface {\n element: HTMLElement;\n created():void;\n attached():void;\n detached():void;\n\n attributesCallback(key: string, value: any, oldValue: any):void;\n}\n\nexport interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface {\n name: String;\n\n hooks: ArrayOfHooksInterface;\n methods: Map<string, Function>;\n accessors: AccessorStaticInterface;\n};\n\nexport interface HasAttributesDefinitionInterface {\n attributes?: AttributesDefinitionInterface | undefined;\n}\n\nexport interface HasHooksInterface {\n created?: HookInterface;\n attached?: HookInterface;\n detached?: HookInterface;\n}\n\nexport interface HasInitialStateInterface {\n initialState?: object | undefined;\n}\n\nexport interface HasMixinsInterface {\n use?: MixinStaticInterface[] | undefined;\n}\n\nexport interface HookInterface {\n (): void;\n};\n\nexport interface MixinStaticInterface extends HasAttributesDefinitionInterface, HasMixinsInterface, HasInitialStateInterface, HasHooksInterface {\n name: String;\n};\n\nexport interface LocationResourceInterface {\n lat?: HookInterface;\n lng?: HookInterface;\n}\
|
|
1
|
+
{"version":3,"sources":["interfaces.ts"],"names":[],"mappings":"AAKC;AAUA;AA8BA;AAsBA;AAIA","sourcesContent":["export interface AccessorStaticInterface {\n [key: string]: {\n get: Function;\n set: Function;\n }\n};\n\nexport interface ArrayOfHooksInterface {\n created: HookInterface[];\n attached: HookInterface[];\n detached: HookInterface[];\n}\n\nexport interface AttributeChangedCallbackInterface {\n (newValue: any, oldValue: any): void;\n};\n\nexport interface AttributeDefinitionInterface {\n type?: any;\n default?: any;\n required?: boolean;\n callback?: AttributeChangedCallbackInterface;\n}\n\nexport interface AttributesDefinitionInterface {\n [key: string]: AttributeDefinitionInterface;\n}\n\nexport type ComponentConstructorInterface = new (element: HTMLElement) => ComponentInterface;\n\nexport interface ComponentInterface {\n element: HTMLElement;\n created():void;\n attached():void;\n detached():void;\n\n attributesCallback(key: string, value: any, oldValue: any):void;\n}\n\nexport interface ComponentStaticInterface extends HasAttributesDefinitionInterface, HasInitialStateInterface {\n name: String;\n\n hooks: ArrayOfHooksInterface;\n methods: Map<string, Function>;\n accessors: AccessorStaticInterface;\n};\n\nexport interface HasAttributesDefinitionInterface {\n attributes?: AttributesDefinitionInterface | undefined;\n}\n\nexport interface HasHooksInterface {\n created?: HookInterface;\n attached?: HookInterface;\n detached?: HookInterface;\n}\n\nexport interface HasInitialStateInterface {\n initialState?: object | undefined;\n}\n\nexport interface HasMixinsInterface {\n use?: MixinStaticInterface[] | undefined;\n}\n\nexport interface HookInterface {\n (): void;\n};\n\nexport interface MixinStaticInterface extends HasAttributesDefinitionInterface, HasMixinsInterface, HasInitialStateInterface, HasHooksInterface {\n name: String;\n};\n\nexport interface LocationResourceInterface {\n lat?: HookInterface;\n lng?: HookInterface;\n}\n"]}
|
package/dist/libs/store/store.js
CHANGED
|
@@ -59,8 +59,7 @@ class Store {
|
|
|
59
59
|
this.subscriptionVirtualContainersIndex = new Map();
|
|
60
60
|
this.loadingList = new Set();
|
|
61
61
|
this.headers = {
|
|
62
|
-
'Content-Type': 'application/ld+json'
|
|
63
|
-
'Cache-Control': 'must-revalidate'
|
|
62
|
+
'Content-Type': 'application/ld+json'
|
|
64
63
|
};
|
|
65
64
|
this.fetch = this.storeOptions.fetchMethod;
|
|
66
65
|
this.session = this.storeOptions.session;
|
|
@@ -70,8 +69,6 @@ class Store {
|
|
|
70
69
|
* @param id - uri of the resource to fetch
|
|
71
70
|
* @param context - context used to expand id and predicates when accessing the resource
|
|
72
71
|
* @param idParent - uri of the parent caller used to expand uri for local files
|
|
73
|
-
* @param localData - data to put in cache
|
|
74
|
-
* @param forceFetch - force the fetch of data
|
|
75
72
|
*
|
|
76
73
|
* @returns The fetched resource
|
|
77
74
|
*
|
|
@@ -79,10 +76,10 @@ class Store {
|
|
|
79
76
|
*/
|
|
80
77
|
|
|
81
78
|
|
|
82
|
-
async getData(id, context = {}, idParent = "", localData
|
|
79
|
+
async getData(id, context = {}, idParent = "", localData) {
|
|
83
80
|
if (localData == null && this.cache.has(id) && !this.loadingList.has(id)) {
|
|
84
81
|
const resource = this.get(id);
|
|
85
|
-
if (resource && resource.isFullResource()
|
|
82
|
+
if (resource && resource.isFullResource()) return resource; // if resource is not complete, re-fetch it
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
return new Promise(async resolve => {
|
|
@@ -133,14 +130,7 @@ class Store {
|
|
|
133
130
|
} else {
|
|
134
131
|
// anonymous
|
|
135
132
|
if (options.headers) options.headers = this._convertHeaders(options.headers);
|
|
136
|
-
return fetch(iri, options)
|
|
137
|
-
if (options.method === "PURGE" && !response.ok && response.status === 404) {
|
|
138
|
-
const err = new Error("PURGE call is returning 404");
|
|
139
|
-
throw err;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return response;
|
|
143
|
-
});
|
|
133
|
+
return fetch(iri, options);
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
136
|
|
|
@@ -150,7 +140,6 @@ class Store {
|
|
|
150
140
|
const headers = { ...this.headers,
|
|
151
141
|
'accept-language': this._getLanguage()
|
|
152
142
|
};
|
|
153
|
-
console.log("Request Headers:", headers);
|
|
154
143
|
return this.fetchAuthn(iri, {
|
|
155
144
|
method: 'GET',
|
|
156
145
|
headers: headers,
|
|
@@ -247,15 +236,11 @@ class Store {
|
|
|
247
236
|
|
|
248
237
|
const expandedId = this._getExpandedId(id, context);
|
|
249
238
|
|
|
250
|
-
return this._fetch(method, resource, id).then(
|
|
239
|
+
return this._fetch(method, resource, id).then(response => {
|
|
251
240
|
if (response.ok) {
|
|
252
241
|
var _response$headers;
|
|
253
242
|
|
|
254
|
-
if (method !== '_LOCAL')
|
|
255
|
-
await this.purge(id);
|
|
256
|
-
this.clearCache(expandedId);
|
|
257
|
-
} // clear cache
|
|
258
|
-
|
|
243
|
+
if (method !== '_LOCAL') this.clearCache(expandedId); // clear cache
|
|
259
244
|
|
|
260
245
|
this.getData(expandedId, resource['@context']).then(async () => {
|
|
261
246
|
// re-fetch data
|
|
@@ -411,41 +396,6 @@ class Store {
|
|
|
411
396
|
async patch(resource, id) {
|
|
412
397
|
return this._updateResource('PATCH', resource, id);
|
|
413
398
|
}
|
|
414
|
-
/**
|
|
415
|
-
* Send a PURGE request to remove a resource from REDIS AD cache
|
|
416
|
-
* @param id - uri of the resource to patch
|
|
417
|
-
*
|
|
418
|
-
* @returns id of the edited resource
|
|
419
|
-
*/
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
async purge(id) {
|
|
423
|
-
console.log('Purging resource ' + id);
|
|
424
|
-
await this.fetchAuthn(id, {
|
|
425
|
-
method: "PURGE",
|
|
426
|
-
headers: this.headers
|
|
427
|
-
}).catch(function (error) {
|
|
428
|
-
console.warn('No purge method allowed: ' + error);
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
try {
|
|
432
|
-
const fullURL = new URL(id);
|
|
433
|
-
var pathArray = fullURL.pathname.split('/');
|
|
434
|
-
var containerUrl = fullURL.origin + '/' + pathArray[1] + '/';
|
|
435
|
-
const headers = { ...this.headers,
|
|
436
|
-
'X-Cache-Purge-Match': 'startswith'
|
|
437
|
-
};
|
|
438
|
-
await this.fetchAuthn(containerUrl, {
|
|
439
|
-
method: "PURGE",
|
|
440
|
-
headers: headers
|
|
441
|
-
}).catch(function (error) {
|
|
442
|
-
console.warn('No purge method allowed: ' + error);
|
|
443
|
-
});
|
|
444
|
-
} catch (error) {
|
|
445
|
-
console.warn('The resource ID is not a complete URL: ' + error);
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
399
|
/**
|
|
450
400
|
* Send a DELETE request to delete a resource
|
|
451
401
|
* @param id - uri of the resource to delete
|
|
@@ -463,7 +413,6 @@ class Store {
|
|
|
463
413
|
headers: this.headers,
|
|
464
414
|
credentials: 'include'
|
|
465
415
|
});
|
|
466
|
-
await this.purge(id);
|
|
467
416
|
const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
|
|
468
417
|
const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
|
|
469
418
|
this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(resourceIds => this.notifyResources(resourceIds));
|
|
@@ -685,12 +634,11 @@ class CustomGetter {
|
|
|
685
634
|
* @param id
|
|
686
635
|
* @param context
|
|
687
636
|
* @param iriParent
|
|
688
|
-
* @param forceFetch
|
|
689
637
|
*/
|
|
690
638
|
|
|
691
639
|
|
|
692
|
-
async getResource(id, context, iriParent
|
|
693
|
-
return store.getData(id, context, iriParent
|
|
640
|
+
async getResource(id, context, iriParent) {
|
|
641
|
+
return store.getData(id, context, iriParent);
|
|
694
642
|
}
|
|
695
643
|
/**
|
|
696
644
|
* Return true if the resource is a container
|
|
@@ -773,16 +721,8 @@ class CustomGetter {
|
|
|
773
721
|
return Object.keys(this.resource).filter(p => !p.startsWith('@')).length > 0;
|
|
774
722
|
}
|
|
775
723
|
|
|
776
|
-
|
|
777
|
-
const
|
|
778
|
-
let permissions = this.resource[permissionPredicate];
|
|
779
|
-
|
|
780
|
-
if (!permissions) {
|
|
781
|
-
// if no permission, re-fetch data
|
|
782
|
-
await this.getResource(this.resourceId, this.clientContext, this.parentId, true);
|
|
783
|
-
permissions = this.resource[permissionPredicate];
|
|
784
|
-
}
|
|
785
|
-
|
|
724
|
+
getPermissions() {
|
|
725
|
+
const permissions = this.resource[this.getExpandedPredicate("permissions")];
|
|
786
726
|
return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];
|
|
787
727
|
}
|
|
788
728
|
/**
|
|
@@ -826,9 +766,8 @@ class CustomGetter {
|
|
|
826
766
|
|
|
827
767
|
switch (property) {
|
|
828
768
|
case '@id':
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
return;
|
|
769
|
+
return this.getCompactedIri(this.resource['@id']);
|
|
770
|
+
// Compact @id if possible
|
|
832
771
|
|
|
833
772
|
case '@type':
|
|
834
773
|
return this.resource['@type'];
|