@dile/crud 0.0.30 → 0.0.32
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.
|
@@ -29,7 +29,6 @@ export class DileCrudInsert extends DileI18nMixin(LitElement) {
|
|
|
29
29
|
constructor() {
|
|
30
30
|
super();
|
|
31
31
|
this.responseAdapter = new ResponseApiAdapter();
|
|
32
|
-
this.actionLabel = 'Insert';
|
|
33
32
|
this.formIdentifier = 'insertform';
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -47,7 +46,7 @@ export class DileCrudInsert extends DileI18nMixin(LitElement) {
|
|
|
47
46
|
<dile-ajax-form
|
|
48
47
|
operation="insert"
|
|
49
48
|
endpoint="${this.endpoint}"
|
|
50
|
-
actionLabel="${this.actionLabel}"
|
|
49
|
+
actionLabel="${this.actionLabelComputed(this.actionLabel, this.translations)}"
|
|
51
50
|
@save-success="${this.doSuccessSave}"
|
|
52
51
|
?buttonSmall="${this.buttonSmall}"
|
|
53
52
|
.responseAdapter="${this.responseAdapter}"
|
|
@@ -77,4 +76,8 @@ export class DileCrudInsert extends DileI18nMixin(LitElement) {
|
|
|
77
76
|
clearFeedback() {
|
|
78
77
|
this.formElement.clearFeedback();
|
|
79
78
|
}
|
|
79
|
+
|
|
80
|
+
actionLabelComputed(label, translations) {
|
|
81
|
+
return label ? label : translations?.insert_label ? translations.insert_label : 'Insert';
|
|
82
|
+
}
|
|
80
83
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import '@dile/ui/components/confirm/confirm';
|
|
3
3
|
import { ResponseApiAdapter } from '../../../lib/ResponseApiAdapter.js';
|
|
4
|
+
import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
|
|
5
|
+
import '../../ajax/ajax.js';
|
|
4
6
|
|
|
5
|
-
export class DileCrudItemDelete extends LitElement {
|
|
7
|
+
export class DileCrudItemDelete extends DileI18nMixin(LitElement) {
|
|
6
8
|
static styles = [
|
|
7
9
|
css`
|
|
8
10
|
:host {
|
|
@@ -40,9 +42,6 @@ export class DileCrudItemDelete extends LitElement {
|
|
|
40
42
|
constructor() {
|
|
41
43
|
super();
|
|
42
44
|
this.responseAdapter = new ResponseApiAdapter();
|
|
43
|
-
this.confirmMessage = 'Are you sure you want to delete this item?';
|
|
44
|
-
this.cancelLabel = 'Cancel';
|
|
45
|
-
this.acceptLabel = 'Delete'
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
firstUpdated() {
|
|
@@ -60,19 +59,23 @@ export class DileCrudItemDelete extends LitElement {
|
|
|
60
59
|
@ajax-error="${this.doErrorDelete}"
|
|
61
60
|
></dile-ajax>
|
|
62
61
|
<dile-confirm
|
|
63
|
-
cancelLabel="${this.cancelLabel}"
|
|
64
|
-
acceptLabel="${this.acceptLabel}"
|
|
62
|
+
cancelLabel="${this.cancelLabelComputed(this.cancelLabel, this.translations)}"
|
|
63
|
+
acceptLabel="${this.acceptLabelComputed(this.acceptLabel, this.translations)}"
|
|
65
64
|
id="elconfirm"
|
|
66
65
|
@dile-confirm-accepted=${this.deleteAccepted}
|
|
67
66
|
>
|
|
68
|
-
<p>${this.confirmMessage}</p>
|
|
67
|
+
<p>${this.confirmMessageComputed(this.confirmMessage, this.translations)}</p>
|
|
69
68
|
</dile-confirm>
|
|
70
69
|
`;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
delete(itemId) {
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
if(itemId != "" && itemId != undefined) {
|
|
74
|
+
this.relatedId = itemId;
|
|
75
|
+
this.elconfirm.open();
|
|
76
|
+
} else {
|
|
77
|
+
throw new Error('Please provide the element id to delete');
|
|
78
|
+
}
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
deleteAccepted() {
|
|
@@ -103,4 +106,16 @@ export class DileCrudItemDelete extends LitElement {
|
|
|
103
106
|
}
|
|
104
107
|
return msg;
|
|
105
108
|
}
|
|
109
|
+
|
|
110
|
+
cancelLabelComputed(label, translations) {
|
|
111
|
+
return label ? label : translations?.cancel_label ? translations.cancel_label : 'Cancel';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
acceptLabelComputed(label, translations) {
|
|
115
|
+
return label ? label : translations?.delete_label ? translations.delete_label : 'Delete';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
confirmMessageComputed(message, translations) {
|
|
119
|
+
return message ? message : translations?.delete_confirm_message ? translations.delete_confirm_message : 'Are you sure?';
|
|
120
|
+
}
|
|
106
121
|
}
|
|
@@ -29,7 +29,6 @@ export class DileCrudUpdate extends DileI18nMixin(LitElement) {
|
|
|
29
29
|
constructor() {
|
|
30
30
|
super();
|
|
31
31
|
this.responseAdapter = new ResponseApiAdapter();
|
|
32
|
-
this.actionLabel = 'Update';
|
|
33
32
|
this.loadOnInit = false;
|
|
34
33
|
this.formIdentifier = 'updateform';
|
|
35
34
|
}
|
|
@@ -48,7 +47,7 @@ export class DileCrudUpdate extends DileI18nMixin(LitElement) {
|
|
|
48
47
|
id="elform"
|
|
49
48
|
operation="update"
|
|
50
49
|
endpoint="${this.endpoint}"
|
|
51
|
-
actionLabel="${this.actionLabel}"
|
|
50
|
+
actionLabel="${this.actionLabelComputed(this.actionLabel, this.translations)}"
|
|
52
51
|
@save-success="${this.doSuccessSave}"
|
|
53
52
|
?buttonSmall="${this.buttonSmall}"
|
|
54
53
|
relatedId="${this.relatedId}"
|
|
@@ -80,4 +79,8 @@ export class DileCrudUpdate extends DileI18nMixin(LitElement) {
|
|
|
80
79
|
clearFeedback() {
|
|
81
80
|
this.formElement.clearFeedback();
|
|
82
81
|
}
|
|
82
|
+
|
|
83
|
+
actionLabelComputed(label, translations) {
|
|
84
|
+
return label ? label : translations?.update_label ? translations.update_label : 'Update';
|
|
85
|
+
}
|
|
83
86
|
}
|
package/lib/i18n/en.js
CHANGED
|
@@ -11,4 +11,9 @@ export const translations = {
|
|
|
11
11
|
ajax_form_not_supported: "Operation not supported in dile-ajax-form use 'insert' or 'update'",
|
|
12
12
|
success_operation: (operation) => operation == 'insert' ? 'The new item has been created' : 'Item updated successfully',
|
|
13
13
|
error_operation: (operation) => `${operation == 'insert' ? 'Insertion' : 'Update'} error`,
|
|
14
|
+
insert_label: "Insert",
|
|
15
|
+
update_label: "Update",
|
|
16
|
+
delete_label: "Delete",
|
|
17
|
+
cancel_label: "Cancel",
|
|
18
|
+
delete_confirm_message: "Are you sure you want to delete this item?",
|
|
14
19
|
};
|
package/lib/i18n/es.js
CHANGED
|
@@ -11,4 +11,9 @@ export const translations = {
|
|
|
11
11
|
ajax_form_not_supported: "Operación no soportada por dile-ajax-form. Elige entre 'insert' o 'update'",
|
|
12
12
|
success_operation: (operation) => `${operation == 'insert' ? 'Inserción' : 'Actualización'} completada con éxito`,
|
|
13
13
|
error_operation: (operation) => `Se ha producido un error en la ${operation == 'insert' ? 'inserción' : 'actualización'}`,
|
|
14
|
+
insert_label: "Insertar",
|
|
15
|
+
update_label: "Actualizar",
|
|
16
|
+
delete_label: "Borrar",
|
|
17
|
+
cancel_label: "Cancelar",
|
|
18
|
+
delete_confirm_message: "¿Estás seguro que quieres borrar este ítem?",
|
|
14
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
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": "
|
|
34
|
+
"gitHead": "817f5102c42848615896580e968fc42d8ee21d66"
|
|
35
35
|
}
|