@dile/crud 0.2.1 → 0.2.3

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.
@@ -341,6 +341,9 @@ export class DileCrud extends DileI18nMixin(DileCrudMixin(LitElement)) {
341
341
  this.removeActionItems(e.detail.data.delete_elems);
342
342
  }
343
343
  this.refresh();
344
+ if(this.config.onActionListSuccess) {
345
+ this.config.onActionListSuccess(e.detail);
346
+ }
344
347
  }
345
348
 
346
349
  removeActionItems(idsArray) {
@@ -137,6 +137,9 @@ export class DileCrudSingle extends DileI18nMixin(DileCrudMixin(LitElement)) {
137
137
  if(e.detail.action != "DeleteAction") {
138
138
  this.refresh();
139
139
  }
140
+ if(this.config.onActionSingleSuccess) {
141
+ this.config.onActionSingleSuccess(e.detail);
142
+ }
140
143
  }
141
144
 
142
145
  edit() {
@@ -5,86 +5,90 @@ import { ResponseApiAdapter } from '../../../lib/ResponseApiAdapter.js';
5
5
  import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
6
6
 
7
7
  export class DileCrudUpdate extends DileI18nMixin(LitElement) {
8
- static styles = [
9
- formStyles,
10
- css`
8
+ static styles = [
9
+ formStyles,
10
+ css`
11
11
 
12
12
  `
13
- ];
14
-
15
- static get properties() {
16
- return {
17
- title: { type: String },
18
- relatedId: { type: String },
19
- endpoint: { type: String },
20
- actionLabel: { type: String },
21
- loadOnInit: { type: Boolean },
22
- formTemplate: { type: Object },
23
- buttonSmall: { type: Boolean },
24
- responseAdapter: { type: Object },
25
- formIdentifier: { type: String },
26
- sendDataAsFormData: { type: Boolean },
27
- showCancelButton: { type: Boolean },
28
- };
29
- }
13
+ ];
30
14
 
31
- constructor() {
32
- super();
33
- this.responseAdapter = new ResponseApiAdapter();
34
- this.loadOnInit = false;
35
- this.formIdentifier = 'updateform';
36
- }
15
+ static get properties() {
16
+ return {
17
+ title: { type: String },
18
+ relatedId: { type: String },
19
+ endpoint: { type: String },
20
+ actionLabel: { type: String },
21
+ loadOnInit: { type: Boolean },
22
+ formTemplate: { type: Object },
23
+ buttonSmall: { type: Boolean },
24
+ responseAdapter: { type: Object },
25
+ formIdentifier: { type: String },
26
+ sendDataAsFormData: { type: Boolean },
27
+ showCancelButton: { type: Boolean },
28
+ data: { type: Object },
29
+ setDataOnInit: { type: Boolean },
30
+ };
31
+ }
37
32
 
38
- get formElement() {
39
- return this.shadowRoot.getElementById('elform');
40
- }
33
+ constructor() {
34
+ super();
35
+ this.responseAdapter = new ResponseApiAdapter();
36
+ this.loadOnInit = false;
37
+ this.formIdentifier = 'updateform';
38
+ }
41
39
 
42
- render() {
43
- return html`
40
+ get formElement() {
41
+ return this.shadowRoot.getElementById('elform');
42
+ }
43
+
44
+ render() {
45
+ return html`
44
46
  ${this.title
45
- ? html`<h1>${this.title}</h1>`
46
- : ''
47
- }
48
- <dile-ajax-form
49
- id="elform"
50
- operation="update"
51
- endpoint="${this.endpoint}"
52
- actionLabel="${this.actionLabelComputed(this.actionLabel, this.translations)}"
53
- @save-success="${this.doSuccessSave}"
54
- ?buttonSmall="${this.buttonSmall}"
55
- relatedId="${this.relatedId}"
56
- ?loadOnInit="${this.loadOnInit}"
57
- .responseAdapter="${this.responseAdapter}"
58
- formIdentifier="${this.formIdentifier}"
59
- language="${this.language}"
60
- ?sendDataAsFormData=${this.sendDataAsFormData}
61
- ?showCancelButton=${this.showCancelButton}
62
- >
63
- ${this.formTemplate()}
64
- </dile-ajax-form>
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>
65
69
  `;
66
- }
70
+ }
67
71
 
68
- doSuccessSave(e) {
69
- this.dispatchEvent(new CustomEvent('crud-update-success', {
70
- bubbles: true,
71
- composed: true,
72
- detail: e.detail
73
- }));
74
- }
72
+ doSuccessSave(e) {
73
+ this.dispatchEvent(new CustomEvent('crud-update-success', {
74
+ bubbles: true,
75
+ composed: true,
76
+ detail: e.detail
77
+ }));
78
+ }
75
79
 
76
- edit(id) {
77
- this.relatedId = id;
78
- this.updateComplete.then(() => {
79
- this.formElement.loadData();
80
- });
81
- }
80
+ edit(id) {
81
+ this.relatedId = id;
82
+ this.updateComplete.then(() => {
83
+ this.formElement.loadData();
84
+ });
85
+ }
82
86
 
83
- clearFeedback() {
84
- this.formElement.clearFeedback();
85
- }
87
+ clearFeedback() {
88
+ this.formElement.clearFeedback();
89
+ }
86
90
 
87
- actionLabelComputed(label, translations) {
88
- return label ? label : translations?.update_label ? translations.update_label : 'Update';
89
- }
91
+ actionLabelComputed(label, translations) {
92
+ return label ? label : translations?.update_label ? translations.update_label : 'Update';
93
+ }
90
94
  }
@@ -68,16 +68,12 @@ export const defaultConfig = {
68
68
  formSingleActions: () => '',
69
69
  },
70
70
  labels: {
71
- // insertAction: 'Create',
72
- // updateAction: 'Save',
73
- // startUpdateAction: 'Edit',
74
- // insertWindowTitle: 'Create an item',
75
- // updateWindowTitle: 'Update an item',
76
- // helpTitle: 'Help',
77
- // helpButtonLabel: 'Help',
71
+
78
72
  },
79
73
  formIds: {
80
74
  insertForm: 'insertform',
81
75
  updateForm: 'updateform',
82
76
  },
77
+ onActionListSuccess: (actionSuccessDetail) => {},
78
+ onActionSingleSuccess: (actionSuccessDetail) => {},
83
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
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": "5d4e95bced050de218bb3d5a0e489437d9dea8a6"
34
+ "gitHead": "9c6b9c904dc871f0e9067b4e4aeaa101f679c305"
35
35
  }