saasufy-components 7.5.0 → 7.6.0

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.
@@ -4,13 +4,6 @@ class CollectionDeleter extends HTMLElement {
4
4
  this.attachShadow({ mode: 'open' });
5
5
  }
6
6
 
7
- static get observedAttributes() {
8
- return [
9
- 'model-id',
10
- 'confirm-message'
11
- ];
12
- }
13
-
14
7
  connectedCallback() {
15
8
  this.shadowRoot.innerHTML = `
16
9
  <slot></slot>
@@ -24,21 +17,6 @@ class CollectionDeleter extends HTMLElement {
24
17
  );
25
18
  }
26
19
 
27
- confirmDeleteItem() {
28
- let confirmMessage = this.getAttribute('confirm-message');
29
- this.dispatchEvent(
30
- new CustomEvent('showModal', {
31
- detail: {
32
- message: confirmMessage,
33
- callback: () => {
34
- this.deleteItem();
35
- }
36
- },
37
- bubbles: true
38
- })
39
- )
40
- }
41
-
42
20
  deleteItemField() {
43
21
  let modelId = this.getAttribute('model-id');
44
22
  let modelField = this.getAttribute('model-field');
@@ -47,19 +25,37 @@ class CollectionDeleter extends HTMLElement {
47
25
  );
48
26
  }
49
27
 
50
- confirmDeleteItemField() {
51
- let confirmMessage = this.getAttribute('confirm-message');
28
+ showConfirmModal(deleteField) {
29
+ let message = this.getAttribute('confirm-message');
30
+ let title = this.getAttribute('confirm-title');
31
+ let confirmButtonLabel = this.getAttribute('confirm-button-label');
32
+ let cancelButtonLabel = this.getAttribute('cancel-button-label');
52
33
  this.dispatchEvent(
53
34
  new CustomEvent('showModal', {
54
35
  detail: {
55
- message: confirmMessage,
36
+ message,
37
+ title,
38
+ confirmButtonLabel,
39
+ cancelButtonLabel,
56
40
  callback: () => {
57
- this.deleteItemField();
41
+ if (deleteField) {
42
+ this.deleteItemField();
43
+ } else {
44
+ this.deleteItem();
45
+ }
58
46
  }
59
47
  },
60
48
  bubbles: true
61
49
  })
62
- )
50
+ );
51
+ }
52
+
53
+ confirmDeleteItem() {
54
+ this.showConfirmModal();
55
+ }
56
+
57
+ confirmDeleteItemField() {
58
+ this.showConfirmModal(true);
63
59
  }
64
60
  }
65
61
 
@@ -15,7 +15,8 @@ class CollectionViewer extends SocketConsumer {
15
15
  this.handleShowModalEvent = (event) => {
16
16
  event.stopPropagation();
17
17
  let modal = this.shadowRoot.querySelector('slot[name="modal"]').assignedNodes()[0];
18
- modal.show(event.detail.message, event.detail.callback);
18
+ let { callback, ...confirmOptions } = event.detail;
19
+ modal.show(confirmOptions, callback);
19
20
  };
20
21
 
21
22
  this.handleCRUDCreateEvent = async (event) => {
package/confirm-modal.js CHANGED
@@ -21,14 +21,29 @@ class ConfirmModal extends HTMLElement {
21
21
  this.render();
22
22
  }
23
23
 
24
- show(message, confirmCallback) {
24
+ show(options, confirmCallback) {
25
25
  let overlayModal = this.querySelector('overlay-modal');
26
26
  if (overlayModal) {
27
27
  overlayModal.removeAttribute('style');
28
28
  }
29
29
  this.confirmCallback = confirmCallback;
30
30
  this.hidden = false;
31
- this.setAttribute('message', message);
31
+ if (typeof options === 'string') {
32
+ this.setAttribute('message', options);
33
+ } else {
34
+ if (options.title != null) {
35
+ this.setAttribute('title', options.title);
36
+ }
37
+ if (options.confirmButtonLabel != null) {
38
+ this.setAttribute('confirm-button-label', options.confirmButtonLabel);
39
+ }
40
+ if (options.cancelButtonLabel != null) {
41
+ this.setAttribute('cancel-button-label', options.cancelButtonLabel);
42
+ }
43
+ if (options.message != null) {
44
+ this.setAttribute('message', options.message);
45
+ }
46
+ }
32
47
  }
33
48
 
34
49
  render() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "7.5.0",
3
+ "version": "7.6.0",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {