@dile/crud 0.2.0 → 0.2.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.
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Components to create a generic crud system based on Web Components and Lit",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,12 +24,12 @@
24
24
  },
25
25
  "homepage": "https://dile-components.polydile.com/",
26
26
  "dependencies": {
27
- "@dile/ui": "^2.1.39",
27
+ "@dile/ui": "^2.2.0",
28
28
  "axios": "^1.7.2",
29
29
  "lit": "^2.7.0 || ^3.0.0"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "64e0dbe3ac21c7da4edb2150ed32b36ab7cb5d0d"
34
+ "gitHead": "631d93271645e9b413490ab0a9576c5f80026826"
35
35
  }