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