@startinblox/components-ds4go 3.3.0 → 3.3.2
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/index.js +16 -35
- package/package.json +1 -1
- package/src/components/solid-dsp-catalog.ts +16 -71
package/dist/index.js
CHANGED
|
@@ -8972,24 +8972,18 @@ let Ce = class extends re {
|
|
|
8972
8972
|
constructor() {
|
|
8973
8973
|
super(), this.header = "DSP Catalog", this.search = [], this.resultCount = this.objects?.length || 0, this._getResource = new be(this, {
|
|
8974
8974
|
task: async ([t]) => {
|
|
8975
|
-
if (!this.orbit || !this.noRouter && this.route && this.currentRoute && !this.route.startsWith(this.currentRoute))
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
}
|
|
8985
|
-
|
|
8986
|
-
return;
|
|
8975
|
+
if (!(!this.orbit || !this.noRouter && this.route && this.currentRoute && !this.route.startsWith(this.currentRoute))) {
|
|
8976
|
+
if (this.dspConnector?.instance)
|
|
8977
|
+
await this.dspConnector.instance.loadAll(), this.datas = this.dspConnector.instance.datas, this.providers = this.dspConnector.instance.providers;
|
|
8978
|
+
else {
|
|
8979
|
+
const e = () => {
|
|
8980
|
+
this.caching++, this.requestUpdate(), document.removeEventListener("dsp-connector-ready", e);
|
|
8981
|
+
};
|
|
8982
|
+
document.addEventListener("dsp-connector-ready", e);
|
|
8983
|
+
return;
|
|
8984
|
+
}
|
|
8985
|
+
return t ? this.object = this.datas.find((e) => e["@id"] === t) : this.object = void 0, this.datas;
|
|
8987
8986
|
}
|
|
8988
|
-
return e !== void 0 && Array.isArray(e) && (this.datas = await Promise.all(
|
|
8989
|
-
e.map(
|
|
8990
|
-
async (i) => await this._responseAdaptator(i)
|
|
8991
|
-
)
|
|
8992
|
-
)), t ? this.object = this.datas.find((i) => i["@id"] === t) : this.object = void 0, this.datas;
|
|
8993
8987
|
},
|
|
8994
8988
|
args: () => [this.dataSrc, this.caching, this.currentRoute]
|
|
8995
8989
|
}), di(this, {
|
|
@@ -9001,26 +8995,13 @@ let Ce = class extends re {
|
|
|
9001
8995
|
(t) => t.type === "dsp-connector"
|
|
9002
8996
|
), Promise.resolve();
|
|
9003
8997
|
}
|
|
9004
|
-
async _responseAdaptator(t) {
|
|
9005
|
-
return t.images && (Array.isArray(t.images) || (t.images = t.images["ldp:contains"]?.filter(
|
|
9006
|
-
(e) => e
|
|
9007
|
-
) || [t.images])), t.providers ? Array.isArray(t.providers) || (t.providers = [t.providers].filter((e) => e)) : t.provider && (t.providers = [t.provider].filter((e) => e)), t._provider && (t.providers = [
|
|
9008
|
-
{
|
|
9009
|
-
name: t._provider,
|
|
9010
|
-
"@id": t._providerAddress,
|
|
9011
|
-
color: t._providerColor
|
|
9012
|
-
}
|
|
9013
|
-
]), t.categories && (Array.isArray(t.categories) || (t.categories = t.categories["ldp:contains"]?.filter(
|
|
9014
|
-
(e) => e
|
|
9015
|
-
) || [t.categories])), t["dcterms:title"] && !t.name && (t.name = t["dcterms:title"]), t["dcterms:description"] && !t.description && (t.description = t["dcterms:description"]), t;
|
|
9016
|
-
}
|
|
9017
8998
|
_search(t) {
|
|
9018
8999
|
t.preventDefault(), this.search = t.detail, this.filterCount = this.search.filter((e) => e.name !== "search").length;
|
|
9019
9000
|
}
|
|
9020
9001
|
_openModal(t) {
|
|
9021
9002
|
if (t.preventDefault(), this.route)
|
|
9022
9003
|
if ("use-id" in (this.component.routeAttributes || {}))
|
|
9023
|
-
M(this.route, t.detail["@id"]);
|
|
9004
|
+
this.object = t.detail, this.dataSrc = t.detail["@id"], M(this.route, t.detail["@id"]);
|
|
9024
9005
|
else {
|
|
9025
9006
|
const e = t.detail["@type"]?.at(-1) ?? t.detail["@type"];
|
|
9026
9007
|
if (e) {
|
|
@@ -9035,10 +9016,10 @@ let Ce = class extends re {
|
|
|
9035
9016
|
}
|
|
9036
9017
|
}
|
|
9037
9018
|
_closeModal(t) {
|
|
9038
|
-
t.preventDefault(), this.route && M(this.route, this.defaultDataSrc);
|
|
9019
|
+
t.preventDefault(), this.route && (M(this.route, this.defaultDataSrc), this.dataSrc = void 0, this.object = void 0);
|
|
9039
9020
|
}
|
|
9040
9021
|
_closeModalFromBackground(t) {
|
|
9041
|
-
t.preventDefault(), this.route && t.target?.classList.contains("modal") && M(this.route, this.defaultDataSrc);
|
|
9022
|
+
t.preventDefault(), this.route && t.target?.classList.contains("modal") && (M(this.route, this.defaultDataSrc), this.dataSrc = void 0, this.object = void 0);
|
|
9042
9023
|
}
|
|
9043
9024
|
_resultCountUpdate(t) {
|
|
9044
9025
|
this.resultCount = t.detail ?? 0;
|
|
@@ -9100,10 +9081,10 @@ let Ce = class extends re {
|
|
|
9100
9081
|
class="modal"
|
|
9101
9082
|
@click=${this._closeModalFromBackground}
|
|
9102
9083
|
>
|
|
9103
|
-
<ds4go-catalog
|
|
9084
|
+
<ds4go-catalog-modal
|
|
9104
9085
|
.object=${this.object}
|
|
9105
9086
|
@close=${this._closeModal}
|
|
9106
|
-
></ds4go-catalog>
|
|
9087
|
+
></ds4go-catalog-modal>
|
|
9107
9088
|
</div>` : l}
|
|
9108
9089
|
</div>
|
|
9109
9090
|
</tems-viewport>`
|
package/package.json
CHANGED
|
@@ -64,53 +64,6 @@ export class DSPCatalog extends OrbitDSPComponent {
|
|
|
64
64
|
return Promise.resolve();
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
async _responseAdaptator(response: Resource): Promise<Resource> {
|
|
68
|
-
if (response.images) {
|
|
69
|
-
if (!Array.isArray(response.images)) {
|
|
70
|
-
response.images = response.images["ldp:contains"]?.filter(
|
|
71
|
-
(i: any) => i,
|
|
72
|
-
) || [response.images];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (response.providers) {
|
|
77
|
-
if (!Array.isArray(response.providers)) {
|
|
78
|
-
response.providers = [response.providers].filter((i: any) => i);
|
|
79
|
-
}
|
|
80
|
-
} else if (response.provider) {
|
|
81
|
-
response.providers = [response.provider].filter((i: any) => i);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Map DSP provider metadata to standard format
|
|
85
|
-
if (response._provider) {
|
|
86
|
-
response.providers = [
|
|
87
|
-
{
|
|
88
|
-
name: response._provider,
|
|
89
|
-
"@id": response._providerAddress,
|
|
90
|
-
color: response._providerColor,
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (response.categories) {
|
|
96
|
-
if (!Array.isArray(response.categories)) {
|
|
97
|
-
response.categories = response.categories["ldp:contains"]?.filter(
|
|
98
|
-
(i: any) => i,
|
|
99
|
-
) || [response.categories];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Map DSP dataset fields to TEMS format
|
|
104
|
-
if (response["dcterms:title"] && !response.name) {
|
|
105
|
-
response.name = response["dcterms:title"];
|
|
106
|
-
}
|
|
107
|
-
if (response["dcterms:description"] && !response.description) {
|
|
108
|
-
response.description = response["dcterms:description"];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return response;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
67
|
_getResource = new Task(this, {
|
|
115
68
|
task: async ([objSrc]) => {
|
|
116
69
|
if (
|
|
@@ -122,18 +75,10 @@ export class DSPCatalog extends OrbitDSPComponent {
|
|
|
122
75
|
)
|
|
123
76
|
return;
|
|
124
77
|
|
|
125
|
-
// Initialize providers from component parameters if not already set
|
|
126
|
-
if (
|
|
127
|
-
(!this.providers || this.providers.length === 0) &&
|
|
128
|
-
this.component?.parameters?.providers
|
|
129
|
-
) {
|
|
130
|
-
this.providers = this.component.parameters.providers;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
let datasets: Resource[] | undefined;
|
|
134
78
|
if (this.dspConnector?.instance) {
|
|
135
79
|
await this.dspConnector.instance.loadAll();
|
|
136
|
-
|
|
80
|
+
this.datas = this.dspConnector.instance.datas;
|
|
81
|
+
this.providers = this.dspConnector.instance.providers;
|
|
137
82
|
} else {
|
|
138
83
|
const listener = () => {
|
|
139
84
|
this.caching++;
|
|
@@ -141,16 +86,7 @@ export class DSPCatalog extends OrbitDSPComponent {
|
|
|
141
86
|
document.removeEventListener("dsp-connector-ready", listener);
|
|
142
87
|
};
|
|
143
88
|
document.addEventListener("dsp-connector-ready", listener);
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (datasets !== undefined && Array.isArray(datasets)) {
|
|
148
|
-
// Process each dataset through the response adaptator
|
|
149
|
-
this.datas = await Promise.all(
|
|
150
|
-
datasets.map(
|
|
151
|
-
async (dataset) => await this._responseAdaptator(dataset),
|
|
152
|
-
),
|
|
153
|
-
);
|
|
89
|
+
return;
|
|
154
90
|
}
|
|
155
91
|
|
|
156
92
|
if (objSrc) {
|
|
@@ -174,6 +110,8 @@ export class DSPCatalog extends OrbitDSPComponent {
|
|
|
174
110
|
e.preventDefault();
|
|
175
111
|
if (this.route) {
|
|
176
112
|
if ("use-id" in (this.component.routeAttributes || {})) {
|
|
113
|
+
this.object = e.detail;
|
|
114
|
+
this.dataSrc = e.detail["@id"];
|
|
177
115
|
utils.requestNavigation(this.route, e.detail["@id"]);
|
|
178
116
|
} else {
|
|
179
117
|
const rdfType = e.detail["@type"]?.at(-1) ?? e.detail["@type"];
|
|
@@ -195,13 +133,20 @@ export class DSPCatalog extends OrbitDSPComponent {
|
|
|
195
133
|
|
|
196
134
|
_closeModal(e: Event) {
|
|
197
135
|
e.preventDefault();
|
|
198
|
-
if (this.route)
|
|
136
|
+
if (this.route) {
|
|
137
|
+
utils.requestNavigation(this.route, this.defaultDataSrc);
|
|
138
|
+
this.dataSrc = undefined;
|
|
139
|
+
this.object = undefined;
|
|
140
|
+
}
|
|
199
141
|
}
|
|
200
142
|
|
|
201
143
|
_closeModalFromBackground(e: Event) {
|
|
202
144
|
e.preventDefault();
|
|
203
|
-
if (this.route && e.target?.classList.contains("modal"))
|
|
145
|
+
if (this.route && e.target?.classList.contains("modal")) {
|
|
204
146
|
utils.requestNavigation(this.route, this.defaultDataSrc);
|
|
147
|
+
this.dataSrc = undefined;
|
|
148
|
+
this.object = undefined;
|
|
149
|
+
}
|
|
205
150
|
}
|
|
206
151
|
|
|
207
152
|
_resultCountUpdate(e: Event) {
|
|
@@ -284,10 +229,10 @@ export class DSPCatalog extends OrbitDSPComponent {
|
|
|
284
229
|
class="modal"
|
|
285
230
|
@click=${this._closeModalFromBackground}
|
|
286
231
|
>
|
|
287
|
-
<ds4go-catalog
|
|
232
|
+
<ds4go-catalog-modal
|
|
288
233
|
.object=${this.object}
|
|
289
234
|
@close=${this._closeModal}
|
|
290
|
-
></ds4go-catalog>
|
|
235
|
+
></ds4go-catalog-modal>
|
|
291
236
|
</div>`
|
|
292
237
|
: nothing}
|
|
293
238
|
</div>
|