@startinblox/core 0.19.0 → 0.19.1-beta.1
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 +119 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -54370,6 +54370,124 @@ const SolidMemberDelete = {
|
|
|
54370
54370
|
}
|
|
54371
54371
|
};
|
|
54372
54372
|
Sib.register(SolidMemberDelete);
|
|
54373
|
+
const SolidMemberAdd = {
|
|
54374
|
+
name: "solid-member-add",
|
|
54375
|
+
use: [NextMixin, ValidationMixin, ContextMixin],
|
|
54376
|
+
attributes: {
|
|
54377
|
+
// Data Source being a group URI in that case
|
|
54378
|
+
dataSrc: {
|
|
54379
|
+
type: String,
|
|
54380
|
+
default: null,
|
|
54381
|
+
callback: function() {
|
|
54382
|
+
this.resourceId = this.dataSrc;
|
|
54383
|
+
}
|
|
54384
|
+
},
|
|
54385
|
+
// The list of users to load
|
|
54386
|
+
rangeUsers: {
|
|
54387
|
+
type: String,
|
|
54388
|
+
default: null,
|
|
54389
|
+
callback: function(newValue, oldValue) {
|
|
54390
|
+
if (newValue !== oldValue)
|
|
54391
|
+
this.planRender();
|
|
54392
|
+
}
|
|
54393
|
+
},
|
|
54394
|
+
addMemberLabel: {
|
|
54395
|
+
type: String,
|
|
54396
|
+
default: "Add a member",
|
|
54397
|
+
callback: function(newValue, oldValue) {
|
|
54398
|
+
if (newValue !== oldValue)
|
|
54399
|
+
this.planRender();
|
|
54400
|
+
}
|
|
54401
|
+
}
|
|
54402
|
+
},
|
|
54403
|
+
initialState: {
|
|
54404
|
+
renderPlanned: false
|
|
54405
|
+
},
|
|
54406
|
+
created() {
|
|
54407
|
+
this.planRender();
|
|
54408
|
+
},
|
|
54409
|
+
async populate() {
|
|
54410
|
+
newWidgetFactory("solid-form-dropdown-autocompletion");
|
|
54411
|
+
this.resource = await store.getData(this.resourceId);
|
|
54412
|
+
if (!this.resource)
|
|
54413
|
+
return;
|
|
54414
|
+
let memberPredicate = store.getExpandedPredicate("user_set", base_context);
|
|
54415
|
+
this.currentMembers = await this.resource[memberPredicate];
|
|
54416
|
+
if (!Array.isArray(this.currentMembers)) {
|
|
54417
|
+
this.currentMembers = [this.currentMembers];
|
|
54418
|
+
}
|
|
54419
|
+
},
|
|
54420
|
+
planRender() {
|
|
54421
|
+
if (!this.renderPlanned) {
|
|
54422
|
+
this.renderPlanned = true;
|
|
54423
|
+
setTimeout(() => {
|
|
54424
|
+
this.render();
|
|
54425
|
+
this.renderPlanned = false;
|
|
54426
|
+
});
|
|
54427
|
+
}
|
|
54428
|
+
},
|
|
54429
|
+
async addMember(e) {
|
|
54430
|
+
if (!this.dataSrc)
|
|
54431
|
+
return;
|
|
54432
|
+
e.preventDefault();
|
|
54433
|
+
this.performAction();
|
|
54434
|
+
},
|
|
54435
|
+
async addMembership() {
|
|
54436
|
+
this.currentMembers.push(JSON.parse(this.dataTargetSrc));
|
|
54437
|
+
let currentRes = {
|
|
54438
|
+
"@context": this.context,
|
|
54439
|
+
"user_set": this.currentMembers
|
|
54440
|
+
};
|
|
54441
|
+
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
54442
|
+
if (!response) {
|
|
54443
|
+
console.warn(`Error while adding user ${this.dataTargetSrc} to group ${this.dataSrc}`);
|
|
54444
|
+
return;
|
|
54445
|
+
}
|
|
54446
|
+
this.goToNext(null);
|
|
54447
|
+
const eventData = { detail: { resource: { "@id": this.dataSrc } }, bubbles: true };
|
|
54448
|
+
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
54449
|
+
this.element.dispatchEvent(new CustomEvent("memberAdded", eventData));
|
|
54450
|
+
this.planRender();
|
|
54451
|
+
});
|
|
54452
|
+
},
|
|
54453
|
+
validateModal() {
|
|
54454
|
+
return this.addMembership();
|
|
54455
|
+
},
|
|
54456
|
+
update() {
|
|
54457
|
+
this.render();
|
|
54458
|
+
},
|
|
54459
|
+
changeSelectedUser(e) {
|
|
54460
|
+
var _a;
|
|
54461
|
+
if (!e.target || !e.target.firstElementChild)
|
|
54462
|
+
return;
|
|
54463
|
+
this.dataTargetSrc = (_a = e.target.firstElementChild) == null ? void 0 : _a.value;
|
|
54464
|
+
},
|
|
54465
|
+
async render() {
|
|
54466
|
+
await this.populate();
|
|
54467
|
+
let button = html$1`
|
|
54468
|
+
<solid-ac-checker data-src="${this.dataSrc}"
|
|
54469
|
+
permission="acl:Write"
|
|
54470
|
+
>
|
|
54471
|
+
<form
|
|
54472
|
+
src="${this.dataSrc}"
|
|
54473
|
+
@submit="${this.addMember.bind(this)}"
|
|
54474
|
+
>
|
|
54475
|
+
<solid-form-dropdown-autocompletion
|
|
54476
|
+
range="${this.rangeUsers}"
|
|
54477
|
+
data-src="${this.rangeUsers}"
|
|
54478
|
+
name="users"
|
|
54479
|
+
@change="${this.changeSelectedUser.bind(this)}"
|
|
54480
|
+
></solid-form-dropdown-autocompletion>
|
|
54481
|
+
<button type="submit">${this.addMemberLabel}</button>
|
|
54482
|
+
</form>
|
|
54483
|
+
|
|
54484
|
+
${this.getModalDialog()}
|
|
54485
|
+
</solid-ac-checker>
|
|
54486
|
+
`;
|
|
54487
|
+
render$1(button, this.element);
|
|
54488
|
+
}
|
|
54489
|
+
};
|
|
54490
|
+
Sib.register(SolidMemberAdd);
|
|
54373
54491
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
54374
54492
|
__proto__: null,
|
|
54375
54493
|
AltMixin,
|
|
@@ -54809,6 +54927,7 @@ export {
|
|
|
54809
54927
|
SolidFormSearch,
|
|
54810
54928
|
SolidLang,
|
|
54811
54929
|
SolidMap,
|
|
54930
|
+
SolidMemberAdd,
|
|
54812
54931
|
SolidMemberDelete,
|
|
54813
54932
|
SolidMembership,
|
|
54814
54933
|
SolidTable,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1-beta.1",
|
|
4
4
|
"description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|