@geogirafe/lib-geoportal 1.3.0-dev.3060317043 → 1.3.0-dev.3102381424
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/components/edit/component.js +1 -1
- package/components/edit/editform/component.d.ts +0 -1
- package/components/edit/editform/component.js +5 -11
- package/models/oapiflayer.d.ts +4 -0
- package/models/oapiflayer.js +5 -1
- package/package.json +1 -1
- package/templates/public/about.json +1 -1
- package/tools/sw/service-worker-tools.d.ts +4 -3
- package/tools/sw/service-worker-tools.js +16 -17
- package/tools/sw/service-worker.js +17 -11
|
@@ -254,7 +254,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
canDelete() {
|
|
257
|
-
return this.getFeatureId() !== null
|
|
257
|
+
return this.getFeatureId() !== null;
|
|
258
258
|
}
|
|
259
259
|
async onSelectFeature(selectedFeatures) {
|
|
260
260
|
if (this.featureIsModified() && !(await this.confirmDiscardChanges())) {
|
|
@@ -43,7 +43,6 @@ export default class EditFormComponent extends GirafeHTMLElement {
|
|
|
43
43
|
* including loose equality (==) to handle numbers represented as strings.
|
|
44
44
|
*/
|
|
45
45
|
private fuzzyCompareForValueListEntry;
|
|
46
|
-
getFeatureId(): string | null;
|
|
47
46
|
protected connectedCallback(): void;
|
|
48
47
|
}
|
|
49
48
|
export {};
|
|
@@ -150,7 +150,8 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
150
150
|
return rawFormValue === 'true';
|
|
151
151
|
}
|
|
152
152
|
else if (property.isValueListProperty) {
|
|
153
|
-
|
|
153
|
+
// Use loose equality because the dropdown value is always a string but the value in the value list could be a number
|
|
154
|
+
return property.valueListEntries?.find((entry) => entry.value == rawFormValue)?.value ?? null;
|
|
154
155
|
}
|
|
155
156
|
return rawFormValue === '' ? null : rawFormValue;
|
|
156
157
|
}
|
|
@@ -229,6 +230,9 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
229
230
|
}
|
|
230
231
|
getCurrentValue(property) {
|
|
231
232
|
const value = this.feature?.getProperties()[property.name] ?? null;
|
|
233
|
+
if (property.isPrimaryKey) {
|
|
234
|
+
return this.feature?.getId() ?? null;
|
|
235
|
+
}
|
|
232
236
|
if (['datetime', 'date-time'].includes(property.format ?? '')) {
|
|
233
237
|
return DateUtils.fromApiToLocalDateTime(value, 'seconds');
|
|
234
238
|
}
|
|
@@ -248,13 +252,6 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
248
252
|
fuzzyCompareForValueListEntry(property, value) {
|
|
249
253
|
return property.valueListEntries?.find((entry) => entry.title == value || entry.value == value)?.value ?? null;
|
|
250
254
|
}
|
|
251
|
-
getFeatureId() {
|
|
252
|
-
if (this.featureSchema?.pkPropertyName) {
|
|
253
|
-
const featureId = this.feature?.getId();
|
|
254
|
-
return this.isNullOrUndefinedOrBlank(featureId) ? null : `${featureId}`;
|
|
255
|
-
}
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
255
|
connectedCallback() {
|
|
259
256
|
super.connectedCallback();
|
|
260
257
|
this.schemaValidator = new OgcApiFeaturesSchemaValidator(this.context);
|
|
@@ -264,6 +261,3 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
264
261
|
__decorate([
|
|
265
262
|
UsedInTemplateOnly()
|
|
266
263
|
], EditFormComponent.prototype, "getInputType", null);
|
|
267
|
-
__decorate([
|
|
268
|
-
UsedInTemplateOnly()
|
|
269
|
-
], EditFormComponent.prototype, "getFeatureId", null);
|
package/models/oapiflayer.d.ts
CHANGED
|
@@ -21,5 +21,9 @@ export declare class OapifLayer {
|
|
|
21
21
|
* Validity decides if this layer can be used for editing
|
|
22
22
|
*/
|
|
23
23
|
get valid(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* If permissions are undefined, this means the server hasn't specified which CRUD operations are allowed.
|
|
26
|
+
* In this case, all operations are assumed to be allowed.
|
|
27
|
+
*/
|
|
24
28
|
hasPermission(permission: EditingPermission): boolean;
|
|
25
29
|
}
|
package/models/oapiflayer.js
CHANGED
|
@@ -30,7 +30,11 @@ export class OapifLayer {
|
|
|
30
30
|
get valid() {
|
|
31
31
|
return !!this.storageCrs && !!this.schema && !!this.geometryType && !!this.geometryLayout;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* If permissions are undefined, this means the server hasn't specified which CRUD operations are allowed.
|
|
35
|
+
* In this case, all operations are assumed to be allowed.
|
|
36
|
+
*/
|
|
33
37
|
hasPermission(permission) {
|
|
34
|
-
return this.permissions
|
|
38
|
+
return this.permissions === undefined ? true : (this.permissions.includes(permission) ?? false);
|
|
35
39
|
}
|
|
36
40
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.3.0-dev.
|
|
1
|
+
{"version":"1.3.0-dev.3102381424", "build":"3102381424", "date":"23/11/2026"}
|
|
@@ -69,10 +69,11 @@ export declare class CacheHelper {
|
|
|
69
69
|
private readonly maxCacheCount;
|
|
70
70
|
private cacheCount;
|
|
71
71
|
/**
|
|
72
|
-
* Execute a fetch for the query, and cache the result if successful
|
|
73
|
-
*
|
|
72
|
+
* Execute a fetch for the query, and cache the result if successful.
|
|
73
|
+
* Network errors (offline, DNS, CORS...) are propagated to the caller.
|
|
74
|
+
* A failure while caching does not discard the server response.
|
|
74
75
|
*/
|
|
75
|
-
fetchAndCache(state: SwState, request: Request): Promise<Response
|
|
76
|
+
fetchAndCache(state: SwState, request: Request): Promise<Response>;
|
|
76
77
|
/**
|
|
77
78
|
* Try to load this request from local cache.
|
|
78
79
|
* Returns null if unsuccessful
|
|
@@ -277,28 +277,27 @@ export class CacheHelper {
|
|
|
277
277
|
maxCacheCount = 300; // Number of queries that should be cached by the service-worker for offline usage.
|
|
278
278
|
cacheCount = 0; // Counter related to the max value above
|
|
279
279
|
/**
|
|
280
|
-
* Execute a fetch for the query, and cache the result if successful
|
|
281
|
-
*
|
|
280
|
+
* Execute a fetch for the query, and cache the result if successful.
|
|
281
|
+
* Network errors (offline, DNS, CORS...) are propagated to the caller.
|
|
282
|
+
* A failure while caching does not discard the server response.
|
|
282
283
|
*/
|
|
283
284
|
async fetchAndCache(state, request) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
swLog(state, `${this.cacheCount}/${this.maxCacheCount} caching ${request.url} for offline use.`);
|
|
293
|
-
const copy = response.clone();
|
|
285
|
+
const response = await fetch(request);
|
|
286
|
+
if (this.cacheCount < this.maxCacheCount &&
|
|
287
|
+
this.isCacheAllowed(request) &&
|
|
288
|
+
response.ok &&
|
|
289
|
+
response.type !== 'opaque') {
|
|
290
|
+
this.cacheCount++;
|
|
291
|
+
swLog(state, `${this.cacheCount}/${this.maxCacheCount} caching ${request.url} for offline use.`);
|
|
292
|
+
try {
|
|
294
293
|
const cache = await caches.open(this.appCacheName);
|
|
295
|
-
await cache.put(request,
|
|
294
|
+
await cache.put(request, response.clone());
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
swLog(state, `Failed to cache ${request.url}`, error);
|
|
296
298
|
}
|
|
297
|
-
return response;
|
|
298
|
-
}
|
|
299
|
-
catch {
|
|
300
|
-
return null;
|
|
301
299
|
}
|
|
300
|
+
return response;
|
|
302
301
|
}
|
|
303
302
|
/**
|
|
304
303
|
* Try to load this request from local cache.
|
|
@@ -74,19 +74,25 @@ function handleActivate(event) {
|
|
|
74
74
|
async function handleFetchEvent(event) {
|
|
75
75
|
await swHelperReady;
|
|
76
76
|
const newRequest = swHelper.getRequest(event.request);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!response) {
|
|
85
|
-
// Not found in cache. We try to load from IndexedDB.
|
|
86
|
-
response = await indexDbHelper.loadFromIndexedDB(swHelper.State, event.request);
|
|
77
|
+
try {
|
|
78
|
+
return await cacheHelper.fetchAndCache(swHelper.State, newRequest);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const offlineResponse = await loadOfflineResponse(event.request);
|
|
82
|
+
if (offlineResponse) {
|
|
83
|
+
return offlineResponse;
|
|
87
84
|
}
|
|
85
|
+
log(`Fetch failed for ${event.request.method} ${event.request.url}`, error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function loadOfflineResponse(request) {
|
|
90
|
+
// Use cache only for GET queries
|
|
91
|
+
if (!cacheHelper.isCacheAllowed(request)) {
|
|
92
|
+
return null;
|
|
88
93
|
}
|
|
89
|
-
|
|
94
|
+
const cachedResponse = await cacheHelper.loadFromCache(request);
|
|
95
|
+
return cachedResponse ?? (await indexDbHelper.loadFromIndexedDB(swHelper.State, request));
|
|
90
96
|
}
|
|
91
97
|
function log(str, error) {
|
|
92
98
|
swLog(swHelper.State, str, error);
|