@dile/crud 0.0.51 → 0.0.53

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.
@@ -131,12 +131,16 @@ export class DileCrudActions extends DileI18nMixin(LitElement) {
131
131
  @dile-confirm-accepted=${this.doAction}
132
132
  >
133
133
  <div class="modalcontainer">
134
- ${this.formActionsTemplate(this.selection)}
134
+ ${this.actionsTemplateRunner}
135
135
  </div>
136
136
  </dile-confirm>
137
137
  `;
138
138
  }
139
139
 
140
+ get actionsTemplateRunner() {
141
+ return this.formActionsTemplate(this.selection, this.actionIds);
142
+ }
143
+
140
144
  setActionIds(items) {
141
145
  this.actionIds = items;
142
146
  }
@@ -37,6 +37,7 @@ export class DileCrudSingleActions extends DileCrudActions {
37
37
  static get properties() {
38
38
  return {
39
39
  actions: { type: Array },
40
+ element: { type: Object },
40
41
  };
41
42
  }
42
43
 
@@ -69,7 +70,9 @@ export class DileCrudSingleActions extends DileCrudActions {
69
70
  `;
70
71
  }
71
72
 
72
-
73
+ get actionsTemplateRunner() {
74
+ return html`${this.formActionsTemplate(this.selection, this.element)}`;
75
+ }
73
76
 
74
77
  onActionSelected(e) {
75
78
  this.selection = e.detail.selected;
@@ -98,6 +98,9 @@ export class DileAjax extends DileAxios(DileI18nMixin(LitElement)) {
98
98
  case 405:
99
99
  this.dispatchError(this.translations.http_405);
100
100
  break;
101
+ case 413:
102
+ this.dispatchError(this.translations.http_413);
103
+ break;
101
104
  case 419:
102
105
  this.dispatchError(this.translations.http_419);
103
106
  break;
@@ -20,6 +20,17 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
20
20
  .actions {
21
21
  margin-top: var(--dile-ajax-form-actions-margin-top, 1rem);
22
22
  padding-left: 3px;
23
+ display: flex;
24
+ gap: var(--dile-form-actions-gap, 1.2rem);
25
+ justify-content: var(--dile-form-actions-justify-content, flex-start);
26
+ }
27
+ .cancel_button {
28
+ --dile-primary-color: var(--dile-ajax-form-cancel-button-background-color, transparent);
29
+ --dile-on-primary-color: var(--dile-ajax-form-cancel-button-text-color, #303030);
30
+ --dile-primary-dark-color: var(--dile-ajax-form-cancel-button-border-color, transparent);
31
+ --dile-button-hover-background-color: var(--dile-ajax-form-cancel-button-hover-background-color, transparent);
32
+ --dile-button-hover-text-color: var(--dile-ajax-form-cancel-button-hover-text-color, #303030);
33
+ --dile-button-hover-border-color: var(--dile-ajax-form-cancel-button-hover-border-color, #303030);
23
34
  }
24
35
  `
25
36
  ];
@@ -29,6 +40,7 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
29
40
  operation: { type: String },
30
41
  endpoint: { type: String },
31
42
  actionLabel: { type: String },
43
+ cancelLabel: { type: String },
32
44
  data: { type: Object },
33
45
  relatedId: { type: String },
34
46
  loadOnInit: { type: Boolean },
@@ -37,6 +49,7 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
37
49
  setDataOnInit: { type: Boolean },
38
50
  responseAdapter: { type: Object },
39
51
  sendDataAsFormData: { type: Boolean },
52
+ showCancelButton: { type: Boolean },
40
53
  };
41
54
  }
42
55
 
@@ -71,13 +84,24 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
71
84
  return this.querySelector('#' + this.formIdentifier);
72
85
  }
73
86
 
87
+ actionLabelComputed(label, translations, operation) {
88
+ if(operation == 'insert') {
89
+ return label ? label : translations?.insert_label ? translations.insert_label : 'Insert';
90
+ }
91
+ if(operation == 'update') {
92
+ return label ? label : translations?.update_label ? translations.update_label : 'Update';
93
+ }
94
+ return translations.send_label;
95
+ }
96
+
74
97
  render() {
75
98
  return html`
76
99
  ${this.ajaxComponents}
77
100
  <slot></slot>
78
101
  <dile-inline-feedback id="feedback"></dile-inline-feedback>
79
102
  <div class="actions">
80
- <dile-button @click=${this.doAction}>${this.actionLabel}</dile-button>
103
+ <dile-button @click=${this.doAction}>${this.actionLabelComputed(this.actionLabel, this.translations, this.operation)}</dile-button>
104
+ ${this.showCancelButton ? html`<dile-button class="cancel_button" @click=${this.doCancel}>${this.translations.cancel_label}</dile-button>` : ''}
81
105
  </div>
82
106
  `;
83
107
  }
@@ -229,5 +253,15 @@ export class DileAjaxForm extends DileI18nMixin(LitElement) {
229
253
  }
230
254
  return this.translations.error_operation(this.operation);
231
255
  }
256
+
257
+ doCancel() {
258
+ this.dispatchEvent(new CustomEvent('form-canceled', {
259
+ bubbles: true,
260
+ composed: true,
261
+ detail: {
262
+ data: this.form.getData()
263
+ }
264
+ }));
265
+ }
232
266
  }
233
267
 
@@ -14,7 +14,7 @@ export class DileCrudDetail extends DileLoading(LitElement) {
14
14
  margin-bottom: 0;
15
15
  }
16
16
  .detail-data {
17
- background-color: #f5f5f5;
17
+ background-color: var(--dile-crud-detail-data-background-color, #f5f5f5);
18
18
  padding: 1rem;
19
19
  border-top-left-radius: 0.6rem;
20
20
  border-top-right-radius: 0.6rem;
@@ -24,6 +24,7 @@ export class DileCrudInsert extends DileI18nMixin(LitElement) {
24
24
  responseAdapter: { type: Object},
25
25
  formIdentifier: { type: String },
26
26
  sendDataAsFormData: { type: Boolean },
27
+ showCancelButton: { type: Boolean },
27
28
  };
28
29
  }
29
30
 
@@ -54,6 +55,7 @@ export class DileCrudInsert extends DileI18nMixin(LitElement) {
54
55
  formIdentifier="${this.formIdentifier}"
55
56
  language="${this.language}"
56
57
  ?sendDataAsFormData=${this.sendDataAsFormData}
58
+ ?showCancelButton=${this.showCancelButton}
57
59
  >
58
60
  ${this.formTemplate(this.belongsTo, this.relationId)}
59
61
  </dile-ajax-form>
@@ -90,7 +90,7 @@ export class DileCrudSingle extends DileI18nMixin(DileCrudMixin(LitElement)) {
90
90
  ${this.updateTemplate}
91
91
  ${this.singleActionsTemplate}
92
92
 
93
- ${this.config.templates.relations(this.element)}
93
+ ${this.element ? this.config.templates.relations(this.element) : ''}
94
94
  `;
95
95
  }
96
96
 
@@ -115,6 +115,7 @@ export class DileCrudSingle extends DileI18nMixin(DileCrudMixin(LitElement)) {
115
115
  endpoint=${this.config.endpoint}
116
116
  @crud-action-success=${this.actionSuccess}
117
117
  language="${this.language}"
118
+ .element=${this.element}
118
119
  ></dile-crud-single-actions>
119
120
  `
120
121
  }
@@ -24,6 +24,7 @@ export class DileCrudUpdate extends DileI18nMixin(LitElement) {
24
24
  responseAdapter: { type: Object },
25
25
  formIdentifier: { type: String },
26
26
  sendDataAsFormData: { type: Boolean },
27
+ showCancelButton: { type: Boolean },
27
28
  };
28
29
  }
29
30
 
@@ -57,6 +58,7 @@ export class DileCrudUpdate extends DileI18nMixin(LitElement) {
57
58
  formIdentifier="${this.formIdentifier}"
58
59
  language="${this.language}"
59
60
  ?sendDataAsFormData=${this.sendDataAsFormData}
61
+ ?showCancelButton=${this.showCancelButton}
60
62
  >
61
63
  ${this.formTemplate()}
62
64
  </dile-ajax-form>
package/lib/i18n/en.js CHANGED
@@ -3,6 +3,7 @@ export const translations = {
3
3
  http_404: "Not found error",
4
4
  http_401: "Unauthorized",
5
5
  http_405: "Method Not Allowed",
6
+ http_413: "Content Too Large",
6
7
  http_419: "Your session has expired. Please refresh the page",
7
8
  http_502: "Connection error, invalid gateway",
8
9
  http_504: "Connection timeout with the gateway",
@@ -11,6 +12,7 @@ export const translations = {
11
12
  ajax_form_not_supported: "Operation not supported in dile-ajax-form use 'insert' or 'update'",
12
13
  success_operation: (operation) => operation == 'insert' ? 'The new item has been created' : 'Item updated successfully',
13
14
  error_operation: (operation) => `${operation == 'insert' ? 'Insertion' : 'Update'} error`,
15
+ send_label: "Send",
14
16
  insert_label: "Create",
15
17
  update_label: "Update",
16
18
  start_update_label: "Edit",
package/lib/i18n/es.js CHANGED
@@ -3,6 +3,7 @@ export const translations = {
3
3
  http_404: "Recurso inexistente",
4
4
  http_401: "No autorizado",
5
5
  http_405: "Método HTTP no permitido",
6
+ http_413: "Contenido enviado al servidor demasiado largo",
6
7
  http_419: "La sesión ha expirado. Refresca la página.",
7
8
  http_502: "Error de conexión, gateway no válido",
8
9
  http_504: "Error de timeout con el gateway",
@@ -11,6 +12,7 @@ export const translations = {
11
12
  ajax_form_not_supported: "Operación no soportada por dile-ajax-form. Elige entre 'insert' o 'update'",
12
13
  success_operation: (operation) => `${operation == 'insert' ? 'Inserción' : 'Actualización'} completada con éxito`,
13
14
  error_operation: (operation) => `Se ha producido un error en la ${operation == 'insert' ? 'inserción' : 'actualización'}`,
15
+ send_label: "Enviar",
14
16
  insert_label: "Insertar",
15
17
  update_label: "Actualizar",
16
18
  start_update_label: "Editar",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
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.27",
27
+ "@dile/ui": "^2.1.29",
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": "252763ee699b898671883ea5c67f4207488ea472"
34
+ "gitHead": "ae6bb276e5139b7924bb81e4235d0745a59057b8"
35
35
  }