@startinblox/core 0.19.0-beta.20 → 0.19.0-beta.21
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as defineComponent, u as uniqID, f as fuzzyCompare, p as parseFieldsString, a as findClosingBracketMatchIndex, c as compare, e as evalTemplateString, s as setDeepProperty, t as transformArrayToContainer } from "./assets/helpers-
|
|
2
|
-
import { h } from "./assets/helpers-
|
|
1
|
+
import { d as defineComponent, u as uniqID, f as fuzzyCompare, p as parseFieldsString, a as findClosingBracketMatchIndex, c as compare, e as evalTemplateString, s as setDeepProperty, t as transformArrayToContainer } from "./assets/helpers-411e08e4.js";
|
|
2
|
+
import { h } from "./assets/helpers-411e08e4.js";
|
|
3
3
|
import PubSub$1 from "https://cdn.skypack.dev/pubsub-js";
|
|
4
4
|
import L from "https://cdn.skypack.dev/leaflet";
|
|
5
5
|
import "https://cdn.skypack.dev/leaflet.markercluster";
|
|
@@ -11738,6 +11738,12 @@ class Store {
|
|
|
11738
11738
|
}
|
|
11739
11739
|
return iri;
|
|
11740
11740
|
}
|
|
11741
|
+
/**
|
|
11742
|
+
* Return the user session information
|
|
11743
|
+
*/
|
|
11744
|
+
async getSession() {
|
|
11745
|
+
return await this.session;
|
|
11746
|
+
}
|
|
11741
11747
|
/**
|
|
11742
11748
|
* Return language of the users
|
|
11743
11749
|
*/
|
|
@@ -53583,7 +53589,7 @@ const SolidAcChecker = {
|
|
|
53583
53589
|
Sib.register(SolidAcChecker);
|
|
53584
53590
|
const SolidDelete = {
|
|
53585
53591
|
name: "solid-delete",
|
|
53586
|
-
use: [NextMixin, ValidationMixin, AttributeBinderMixin],
|
|
53592
|
+
use: [NextMixin, ValidationMixin, AttributeBinderMixin, ContextMixin],
|
|
53587
53593
|
attributes: {
|
|
53588
53594
|
dataSrc: {
|
|
53589
53595
|
type: String,
|
|
@@ -53599,10 +53605,6 @@ const SolidDelete = {
|
|
|
53599
53605
|
if (newValue !== oldValue)
|
|
53600
53606
|
this.planRender();
|
|
53601
53607
|
}
|
|
53602
|
-
},
|
|
53603
|
-
extraContext: {
|
|
53604
|
-
type: String,
|
|
53605
|
-
default: null
|
|
53606
53608
|
}
|
|
53607
53609
|
},
|
|
53608
53610
|
initialState: {
|
|
@@ -53620,16 +53622,6 @@ const SolidDelete = {
|
|
|
53620
53622
|
});
|
|
53621
53623
|
}
|
|
53622
53624
|
},
|
|
53623
|
-
get context() {
|
|
53624
|
-
let extraContextElement = this.extraContext ? document.getElementById(this.extraContext) : (
|
|
53625
|
-
// take element extra context first
|
|
53626
|
-
document.querySelector("[data-default-context]")
|
|
53627
|
-
);
|
|
53628
|
-
let extraContext = {};
|
|
53629
|
-
if (extraContextElement)
|
|
53630
|
-
extraContext = JSON.parse(extraContextElement.textContent || "{}");
|
|
53631
|
-
return { ...base_context, ...extraContext };
|
|
53632
|
-
},
|
|
53633
53625
|
async delete(e) {
|
|
53634
53626
|
e.stopPropagation();
|
|
53635
53627
|
if (!this.dataSrc)
|
|
@@ -54144,6 +54136,279 @@ const SolidMap = {
|
|
|
54144
54136
|
}
|
|
54145
54137
|
};
|
|
54146
54138
|
Sib.register(SolidMap);
|
|
54139
|
+
const SolidMembership = {
|
|
54140
|
+
name: "solid-membership",
|
|
54141
|
+
use: [NextMixin, ValidationMixin, ContextMixin],
|
|
54142
|
+
attributes: {
|
|
54143
|
+
// Data Source being a group URI in that case
|
|
54144
|
+
dataSrc: {
|
|
54145
|
+
type: String,
|
|
54146
|
+
default: null,
|
|
54147
|
+
callback: function() {
|
|
54148
|
+
this.resourceId = this.dataSrc;
|
|
54149
|
+
}
|
|
54150
|
+
},
|
|
54151
|
+
dataLeaveLabel: {
|
|
54152
|
+
type: String,
|
|
54153
|
+
default: null,
|
|
54154
|
+
callback: function(newValue, oldValue) {
|
|
54155
|
+
if (newValue !== oldValue)
|
|
54156
|
+
this.planRender();
|
|
54157
|
+
}
|
|
54158
|
+
},
|
|
54159
|
+
dataJoinLabel: {
|
|
54160
|
+
type: String,
|
|
54161
|
+
default: null,
|
|
54162
|
+
callback: function(newValue, oldValue) {
|
|
54163
|
+
if (newValue !== oldValue)
|
|
54164
|
+
this.planRender();
|
|
54165
|
+
}
|
|
54166
|
+
}
|
|
54167
|
+
},
|
|
54168
|
+
initialState: {
|
|
54169
|
+
renderPlanned: false
|
|
54170
|
+
},
|
|
54171
|
+
created() {
|
|
54172
|
+
this.planRender();
|
|
54173
|
+
},
|
|
54174
|
+
async populate() {
|
|
54175
|
+
if (!store.session)
|
|
54176
|
+
return;
|
|
54177
|
+
let currentUserSession = await store.session;
|
|
54178
|
+
if (!currentUserSession)
|
|
54179
|
+
return;
|
|
54180
|
+
this.userId = await currentUserSession.webId;
|
|
54181
|
+
if (!this.userId)
|
|
54182
|
+
return;
|
|
54183
|
+
this.resource = await store.getData(this.resourceId);
|
|
54184
|
+
if (!this.resource)
|
|
54185
|
+
return;
|
|
54186
|
+
let memberPredicate = store.getExpandedPredicate("user_set", base_context);
|
|
54187
|
+
this.currentMembers = await this.resource[memberPredicate];
|
|
54188
|
+
if (!Array.isArray(this.currentMembers)) {
|
|
54189
|
+
this.currentMembers = [this.currentMembers];
|
|
54190
|
+
}
|
|
54191
|
+
this.isMember = this.currentMembers ? this.currentMembers.some((member) => member["@id"] === this.userId) : false;
|
|
54192
|
+
},
|
|
54193
|
+
planRender() {
|
|
54194
|
+
if (!this.renderPlanned) {
|
|
54195
|
+
this.renderPlanned = true;
|
|
54196
|
+
setTimeout(() => {
|
|
54197
|
+
this.render();
|
|
54198
|
+
this.renderPlanned = false;
|
|
54199
|
+
});
|
|
54200
|
+
}
|
|
54201
|
+
},
|
|
54202
|
+
async changeMembership(e) {
|
|
54203
|
+
e.stopPropagation();
|
|
54204
|
+
if (!this.dataSrc)
|
|
54205
|
+
return;
|
|
54206
|
+
this.performAction();
|
|
54207
|
+
},
|
|
54208
|
+
async joinGroup() {
|
|
54209
|
+
this.currentMembers.push({ "@id": this.userId });
|
|
54210
|
+
let currentRes = {
|
|
54211
|
+
"@context": this.context,
|
|
54212
|
+
"user_set": this.currentMembers
|
|
54213
|
+
};
|
|
54214
|
+
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
54215
|
+
if (!response) {
|
|
54216
|
+
console.warn(`Error while joining group ${this.dataSrc} for user ${this.userId}`);
|
|
54217
|
+
return;
|
|
54218
|
+
}
|
|
54219
|
+
this.goToNext(null);
|
|
54220
|
+
const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true };
|
|
54221
|
+
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
54222
|
+
this.element.dispatchEvent(new CustomEvent("memberAdded", eventData));
|
|
54223
|
+
this.planRender();
|
|
54224
|
+
});
|
|
54225
|
+
},
|
|
54226
|
+
async leaveGroup() {
|
|
54227
|
+
let userSet = this.currentMembers.filter((value) => {
|
|
54228
|
+
const userId = value["@id"];
|
|
54229
|
+
if (userId == this.userId)
|
|
54230
|
+
return false;
|
|
54231
|
+
else
|
|
54232
|
+
return true;
|
|
54233
|
+
});
|
|
54234
|
+
let currentRes = {
|
|
54235
|
+
"@context": this.context,
|
|
54236
|
+
"user_set": userSet
|
|
54237
|
+
};
|
|
54238
|
+
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
54239
|
+
if (!response) {
|
|
54240
|
+
console.warn(`Error while leaving group ${this.dataSrc} for user ${this.userId}`);
|
|
54241
|
+
return;
|
|
54242
|
+
}
|
|
54243
|
+
this.goToNext(null);
|
|
54244
|
+
const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true };
|
|
54245
|
+
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
54246
|
+
this.element.dispatchEvent(new CustomEvent("memberRemoved", eventData));
|
|
54247
|
+
this.planRender();
|
|
54248
|
+
});
|
|
54249
|
+
},
|
|
54250
|
+
switchMembership() {
|
|
54251
|
+
if (this.isMember) {
|
|
54252
|
+
return this.leaveGroup();
|
|
54253
|
+
} else {
|
|
54254
|
+
return this.joinGroup();
|
|
54255
|
+
}
|
|
54256
|
+
},
|
|
54257
|
+
validateModal() {
|
|
54258
|
+
return this.switchMembership();
|
|
54259
|
+
},
|
|
54260
|
+
update() {
|
|
54261
|
+
this.render();
|
|
54262
|
+
},
|
|
54263
|
+
async render() {
|
|
54264
|
+
await this.populate();
|
|
54265
|
+
let button = html$1``;
|
|
54266
|
+
if (this.isMember) {
|
|
54267
|
+
button = html$1`
|
|
54268
|
+
<solid-ac-checker data-src="${this.dataSrc}"
|
|
54269
|
+
permission="acl:Read"
|
|
54270
|
+
>
|
|
54271
|
+
<button @click=${this.changeMembership.bind(this)}>${this.dataLeaveLabel || this.t("solid-leave-group.button")}</button>
|
|
54272
|
+
${this.getModalDialog()}
|
|
54273
|
+
</solid-ac-checker>
|
|
54274
|
+
`;
|
|
54275
|
+
} else {
|
|
54276
|
+
button = html$1`
|
|
54277
|
+
<solid-ac-checker data-src="${this.dataSrc}"
|
|
54278
|
+
permission="acl:Read"
|
|
54279
|
+
>
|
|
54280
|
+
<button @click=${this.changeMembership.bind(this)}>${this.dataJoinLabel || this.t("solid-join-group.button")}</button>
|
|
54281
|
+
${this.getModalDialog()}
|
|
54282
|
+
</solid-ac-checker>
|
|
54283
|
+
`;
|
|
54284
|
+
}
|
|
54285
|
+
render$1(button, this.element);
|
|
54286
|
+
}
|
|
54287
|
+
};
|
|
54288
|
+
Sib.register(SolidMembership);
|
|
54289
|
+
const SolidMemberDelete = {
|
|
54290
|
+
name: "solid-member-delete",
|
|
54291
|
+
use: [NextMixin, ValidationMixin, ContextMixin],
|
|
54292
|
+
attributes: {
|
|
54293
|
+
// Data Source being a group URI in that case
|
|
54294
|
+
dataSrc: {
|
|
54295
|
+
type: String,
|
|
54296
|
+
default: null,
|
|
54297
|
+
callback: function() {
|
|
54298
|
+
this.resourceId = this.dataSrc;
|
|
54299
|
+
}
|
|
54300
|
+
},
|
|
54301
|
+
dataLabel: {
|
|
54302
|
+
type: String,
|
|
54303
|
+
default: null,
|
|
54304
|
+
callback: function(newValue, oldValue) {
|
|
54305
|
+
if (newValue !== oldValue)
|
|
54306
|
+
this.planRender();
|
|
54307
|
+
}
|
|
54308
|
+
},
|
|
54309
|
+
// The user id to remove from the group
|
|
54310
|
+
dataTargetSrc: {
|
|
54311
|
+
type: String,
|
|
54312
|
+
default: null,
|
|
54313
|
+
callback: function(newValue, oldValue) {
|
|
54314
|
+
if (newValue !== oldValue)
|
|
54315
|
+
this.planRender();
|
|
54316
|
+
}
|
|
54317
|
+
},
|
|
54318
|
+
dataUnknownMember: {
|
|
54319
|
+
type: String,
|
|
54320
|
+
default: "Given user is not a member of this group",
|
|
54321
|
+
callback: function(newValue, oldValue) {
|
|
54322
|
+
if (newValue !== oldValue)
|
|
54323
|
+
this.planRender();
|
|
54324
|
+
}
|
|
54325
|
+
}
|
|
54326
|
+
},
|
|
54327
|
+
initialState: {
|
|
54328
|
+
renderPlanned: false
|
|
54329
|
+
},
|
|
54330
|
+
created() {
|
|
54331
|
+
this.planRender();
|
|
54332
|
+
},
|
|
54333
|
+
async populate() {
|
|
54334
|
+
this.resource = await store.getData(this.resourceId);
|
|
54335
|
+
if (!this.resource)
|
|
54336
|
+
return;
|
|
54337
|
+
let memberPredicate = store.getExpandedPredicate("user_set", base_context);
|
|
54338
|
+
this.currentMembers = await this.resource[memberPredicate];
|
|
54339
|
+
if (!Array.isArray(this.currentMembers)) {
|
|
54340
|
+
this.currentMembers = [this.currentMembers];
|
|
54341
|
+
}
|
|
54342
|
+
this.isMember = this.currentMembers ? this.currentMembers.some((member) => member["@id"] === this.dataTargetSrc) : false;
|
|
54343
|
+
console.log("populate", this.dataSrc, this.dataTargetSrc, this.currentMembers, this.isMember);
|
|
54344
|
+
},
|
|
54345
|
+
planRender() {
|
|
54346
|
+
if (!this.renderPlanned) {
|
|
54347
|
+
this.renderPlanned = true;
|
|
54348
|
+
setTimeout(() => {
|
|
54349
|
+
this.render();
|
|
54350
|
+
this.renderPlanned = false;
|
|
54351
|
+
});
|
|
54352
|
+
}
|
|
54353
|
+
},
|
|
54354
|
+
async removeMember(e) {
|
|
54355
|
+
e.stopPropagation();
|
|
54356
|
+
if (!this.dataSrc)
|
|
54357
|
+
return;
|
|
54358
|
+
this.performAction();
|
|
54359
|
+
},
|
|
54360
|
+
async deleteMembership() {
|
|
54361
|
+
console.log("deleteMembership", this.dataSrc, this.dataTargetSrc, this.currentMembers);
|
|
54362
|
+
let userSet = this.currentMembers.filter((value) => {
|
|
54363
|
+
const userId = value["@id"];
|
|
54364
|
+
if (userId == this.dataTargetSrc)
|
|
54365
|
+
return false;
|
|
54366
|
+
else
|
|
54367
|
+
return true;
|
|
54368
|
+
});
|
|
54369
|
+
let currentRes = {
|
|
54370
|
+
"@context": this.context,
|
|
54371
|
+
"user_set": userSet
|
|
54372
|
+
};
|
|
54373
|
+
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
54374
|
+
if (!response) {
|
|
54375
|
+
console.warn(`Error while removing user ${this.dataTargetSrc} from group ${this.dataSrc}`);
|
|
54376
|
+
return;
|
|
54377
|
+
}
|
|
54378
|
+
this.goToNext(null);
|
|
54379
|
+
const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true };
|
|
54380
|
+
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
54381
|
+
this.element.dispatchEvent(new CustomEvent("memberRemoved", eventData));
|
|
54382
|
+
this.planRender();
|
|
54383
|
+
});
|
|
54384
|
+
},
|
|
54385
|
+
validateModal() {
|
|
54386
|
+
return this.deleteMembership();
|
|
54387
|
+
},
|
|
54388
|
+
update() {
|
|
54389
|
+
this.render();
|
|
54390
|
+
},
|
|
54391
|
+
async render() {
|
|
54392
|
+
await this.populate();
|
|
54393
|
+
let button = html$1``;
|
|
54394
|
+
if (this.isMember) {
|
|
54395
|
+
button = html$1`
|
|
54396
|
+
<solid-ac-checker data-src="${this.dataSrc}"
|
|
54397
|
+
permission="acl:Write"
|
|
54398
|
+
>
|
|
54399
|
+
<button @click=${this.removeMember.bind(this)}>${this.dataLabel || this.t("solid-delete-member.button")}</button>
|
|
54400
|
+
${this.getModalDialog()}
|
|
54401
|
+
</solid-ac-checker>
|
|
54402
|
+
`;
|
|
54403
|
+
} else {
|
|
54404
|
+
button = html$1`
|
|
54405
|
+
<span>${this.dataUnknownMember || this.t("solid-member-unknown.span")}</span>
|
|
54406
|
+
`;
|
|
54407
|
+
}
|
|
54408
|
+
render$1(button, this.element);
|
|
54409
|
+
}
|
|
54410
|
+
};
|
|
54411
|
+
Sib.register(SolidMemberDelete);
|
|
54147
54412
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
54148
54413
|
__proto__: null,
|
|
54149
54414
|
AltMixin,
|
|
@@ -54583,6 +54848,8 @@ export {
|
|
|
54583
54848
|
SolidFormSearch,
|
|
54584
54849
|
SolidLang,
|
|
54585
54850
|
SolidMap,
|
|
54851
|
+
SolidMemberDelete,
|
|
54852
|
+
SolidMembership,
|
|
54586
54853
|
SolidTable,
|
|
54587
54854
|
SolidTemplateElement,
|
|
54588
54855
|
SolidWidget,
|