@dile/crud 0.4.3 → 0.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.
@@ -245,7 +245,7 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
245
245
  let msg = this._customSuccessMessage();
246
246
  this.feedback.positiveFeedbackWithDelay(msg, 5000);
247
247
  if(this.operation == 'insert') {
248
- this.form.clearData();
248
+ this.clearForm();
249
249
  }
250
250
  this.dispatchEvent(new CustomEvent('save-success', {
251
251
  bubbles: true,
@@ -316,5 +316,9 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
316
316
  }
317
317
  }));
318
318
  }
319
+
320
+ clearForm() {
321
+ this.form.clearData();
322
+ }
319
323
  }
320
324
 
@@ -0,0 +1,2 @@
1
+ import { DileModalCrudInsert } from './src/DileModalCrudInsert';
2
+ customElements.define('dile-modal-crud-insert', DileModalCrudInsert);
@@ -39,12 +39,23 @@ export class DileCrudInsert extends DileI18nMixin(LitElement) {
39
39
  }
40
40
 
41
41
  render() {
42
+ return html`
43
+ ${this.titleTemplate}
44
+ ${this.ajaxFormTemplate}
45
+ `;
46
+ }
47
+
48
+ get titleTemplate() {
42
49
  return html`
43
50
  ${this.title
44
51
  ? html`<h1>${this.title}</h1>`
45
52
  : ''
46
- }
47
-
53
+ }
54
+ `;
55
+ }
56
+
57
+ get ajaxFormTemplate() {
58
+ return html`
48
59
  <dile-ajax-form
49
60
  operation="insert"
50
61
  endpoint="${this.endpoint}"
@@ -0,0 +1,6 @@
1
+ import { DileCrudInsert } from './DileCrudInsert.js';
2
+ import { DileModalCrudOperationsMixin } from '../../../lib/DileModalCrudOperationsMixin.js';
3
+
4
+ export class DileModalCrudInsert extends DileModalCrudOperationsMixin(DileCrudInsert) {
5
+
6
+ }
@@ -65,6 +65,7 @@ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
65
65
  filters: { type: Array },
66
66
  belongsTo: { type: String },
67
67
  relationId: { type: String },
68
+ disableLoadOnStart: { type: Boolean },
68
69
  };
69
70
  }
70
71
 
@@ -80,14 +81,16 @@ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
80
81
  this.delayTimer = null;
81
82
  this.isSelectAllActive = false;
82
83
  this.loading = true;
84
+ this.disableLoadOnStart = false;
83
85
  }
84
86
 
85
87
  firstUpdated() {
86
88
  this.pageSize = this.config.pageSize?.initial ?? this.pageSize;
87
89
  this.elservice = this.shadowRoot.getElementById('elservice');
88
90
  this.ajaxgetallids = this.shadowRoot.getElementById('ajaxgetallids');
89
- this.updateComplete.then( () => this.refresh());
90
-
91
+ if(!this.disableLoadOnStart) {
92
+ this.updateComplete.then( () => this.refresh());
93
+ }
91
94
  }
92
95
 
93
96
  render() {
@@ -0,0 +1,2 @@
1
+ import { DileModalCrudUpdate } from "./src/DileModalCrudUpdate";
2
+ customElements.define('dile-modal-crud-update', DileModalCrudUpdate);
@@ -43,30 +43,42 @@ export class DileCrudUpdate extends DileI18nMixin(LitElement) {
43
43
 
44
44
  render() {
45
45
  return html`
46
- ${this.title
47
- ? html`<h1>${this.title}</h1>`
48
- : ''
49
- }
50
- <dile-ajax-form
51
- id="elform"
52
- operation="update"
53
- endpoint="${this.endpoint}"
54
- actionLabel="${this.actionLabelComputed(this.actionLabel, this.translations)}"
55
- @save-success="${this.doSuccessSave}"
56
- ?buttonSmall="${this.buttonSmall}"
57
- relatedId="${this.relatedId}"
58
- ?loadOnInit="${this.loadOnInit}"
59
- .responseAdapter="${this.responseAdapter}"
60
- formIdentifier="${this.formIdentifier}"
61
- language="${this.language}"
62
- ?sendDataAsFormData=${this.sendDataAsFormData}
63
- ?showCancelButton=${this.showCancelButton}
64
- ?setDataOnInit=${this.setDataOnInit}
65
- .data=${this.data}
66
- >
67
- ${this.formTemplate()}
68
- </dile-ajax-form>
69
- `;
46
+ ${this.titleTemplate}
47
+ ${this.ajaxFormTemplate}
48
+ `;
49
+ }
50
+
51
+ get titleTemplate() {
52
+ return html`
53
+ ${this.title
54
+ ? html`<h1>${this.title}</h1>`
55
+ : ''
56
+ }
57
+ `;
58
+ }
59
+
60
+ get ajaxFormTemplate() {
61
+ return html`
62
+ <dile-ajax-form
63
+ id="elform"
64
+ operation="update"
65
+ endpoint="${this.endpoint}"
66
+ actionLabel="${this.actionLabelComputed(this.actionLabel, this.translations)}"
67
+ @save-success="${this.doSuccessSave}"
68
+ ?buttonSmall="${this.buttonSmall}"
69
+ relatedId="${this.relatedId}"
70
+ ?loadOnInit="${this.loadOnInit}"
71
+ .responseAdapter="${this.responseAdapter}"
72
+ formIdentifier="${this.formIdentifier}"
73
+ language="${this.language}"
74
+ ?sendDataAsFormData=${this.sendDataAsFormData}
75
+ ?showCancelButton=${this.showCancelButton}
76
+ ?setDataOnInit=${this.setDataOnInit}
77
+ .data=${this.data}
78
+ >
79
+ ${this.formTemplate()}
80
+ </dile-ajax-form>
81
+ `;
70
82
  }
71
83
 
72
84
  doSuccessSave(e) {
@@ -0,0 +1,7 @@
1
+ import { DileCrudUpdate } from './DileCrudUpdate.js';
2
+ import { DileModalCrudOperationsMixin } from '../../../lib/DileModalCrudOperationsMixin.js';
3
+
4
+ export class DileModalCrudUpdate extends DileModalCrudOperationsMixin(DileCrudUpdate) {
5
+
6
+ }
7
+
@@ -0,0 +1,71 @@
1
+ import { css, html } from 'lit';
2
+ import { formStyles } from '../styles/form-styles.js';
3
+ import '@dile/ui/components/modal/modal.js';
4
+ import '@dile/ui/components/button/button.js';
5
+ import '@dile/ui/components/button/button-icon.js';
6
+
7
+ export const DileModalCrudOperationsMixin = (superclass) => class extends superclass {
8
+
9
+ static styles = [
10
+ formStyles,
11
+ css`
12
+ section {
13
+ padding: var(--dile-modal-crud-extra-padding, 3px);
14
+ }
15
+ `
16
+ ];
17
+
18
+ static get properties() {
19
+ return {
20
+ openModalLabel: { type: String },
21
+ openModalIcon: { type: Object },
22
+ closeOnSuccess: { type: Boolean },
23
+ };
24
+ }
25
+
26
+ get modalElement() {
27
+ return this.shadowRoot.getElementById('modalElement')
28
+ }
29
+
30
+ constructor() {
31
+ super();
32
+ this.openModalLabel = "Open"
33
+ }
34
+
35
+ render() {
36
+ return html`
37
+ <dile-modal
38
+ id="modalElement"
39
+ blocking
40
+ showCloseIcon
41
+ @save-success=${this.doSuccessActions}
42
+ >
43
+ ${this.titleTemplate}
44
+ <section>
45
+ ${this.ajaxFormTemplate}
46
+ </section>
47
+ </dile-modal>
48
+ ${this.openModalTrigger}
49
+ `;
50
+ }
51
+
52
+ get openModalTrigger() {
53
+ return html`
54
+ ${this.openModalIcon
55
+ ? html`<dile-button-icon @click=${this.openModal} .icon=${this.openModalIcon}>${this.openModalLabel}</dile-button-icon>`
56
+ : html`<dile-button @click=${this.openModal}>${this.openModalLabel}</dile-button>`
57
+ }
58
+ `
59
+ }
60
+
61
+ openModal() {
62
+ this.modalElement.open();
63
+ }
64
+
65
+ doSuccessActions() {
66
+ if(this.closeOnSuccess) {
67
+ this.modalElement.close();
68
+ }
69
+ }
70
+
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.4.3",
3
+ "version": "0.6.0",
4
4
  "description": "Components to create a generic crud system based on Web Components and Lit",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "1ba8c7a0a7f28812a2a5b461a197f8e3ea050f4c"
34
+ "gitHead": "1421edd8c9a2e0ec6657ff291d58d0b249f0c99d"
35
35
  }