@dile/crud 1.7.6 → 1.8.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.
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { DileAjaxForm } from './src/DileAjaxForm.js';
|
|
1
|
+
export { DileAjaxForm } from './src/DileAjaxForm.js';
|
|
2
|
+
export { DileConfirmedAjaxForm } from './src/DileConfirmedAjaxForm.js';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* # DileConfirmedAjaxForm
|
|
4
|
+
*
|
|
5
|
+
* Ajax form component that requires confirmation before submission
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { LitElement, html } from 'lit';
|
|
10
|
+
import '@dile/ui/components/confirm/confirm.js';
|
|
11
|
+
import { DileAjaxForm } from './DileAjaxForm.js';
|
|
12
|
+
|
|
13
|
+
export class DileConfirmedAjaxForm extends DileAjaxForm {
|
|
14
|
+
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
...super.properties,
|
|
18
|
+
confirmText: { type: String },
|
|
19
|
+
acceptLabel: { type: String },
|
|
20
|
+
cancelLabel: { type: String },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.confirmText = null;
|
|
27
|
+
this.acceptLabel = null;
|
|
28
|
+
this.cancelLabel = null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
return html`
|
|
33
|
+
${super.render()}
|
|
34
|
+
<dile-confirm
|
|
35
|
+
id="confirmDialog"
|
|
36
|
+
@dile-confirm-accepted="${this.onConfirmAccepted}"
|
|
37
|
+
@dile-confirm-cancelled="${this.onConfirmCancelled}"
|
|
38
|
+
.acceptLabel="${this.computeAcceptLabel()}"
|
|
39
|
+
.cancelLabel="${this.computeCancelLabel()}"
|
|
40
|
+
blocking
|
|
41
|
+
>
|
|
42
|
+
<p>${this.computeConfirmText()}</p>
|
|
43
|
+
</dile-confirm>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
firstUpdated() {
|
|
48
|
+
super.firstUpdated();
|
|
49
|
+
this.confirmDialog = this.shadowRoot.getElementById('confirmDialog');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
doAction() {
|
|
53
|
+
this.feedback.clear();
|
|
54
|
+
this.confirmDialog.open();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onConfirmAccepted() {
|
|
58
|
+
// Call the parent's doAction method directly, bypassing our override
|
|
59
|
+
const formData = this.form.getData();
|
|
60
|
+
this.ajaxsave.data = formData;
|
|
61
|
+
this.ajaxsave.generateRequest();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onConfirmCancelled() {
|
|
65
|
+
// Silently cancel, just close the dialog
|
|
66
|
+
// No action needed
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
computeConfirmText() {
|
|
70
|
+
if (this.confirmText) {
|
|
71
|
+
return this.confirmText;
|
|
72
|
+
}
|
|
73
|
+
return this.translations?.confirm_submit_text || 'Are you sure you want to submit this form?';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
computeAcceptLabel() {
|
|
77
|
+
if (this.acceptLabel) {
|
|
78
|
+
return this.acceptLabel;
|
|
79
|
+
}
|
|
80
|
+
return this.translations?.accept_label || 'Accept';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
computeCancelLabel() {
|
|
84
|
+
if (this.cancelLabel) {
|
|
85
|
+
return this.cancelLabel;
|
|
86
|
+
}
|
|
87
|
+
return this.translations?.cancel_label || 'Cancel';
|
|
88
|
+
}
|
|
89
|
+
}
|
package/lib/i18n/en.js
CHANGED
|
@@ -52,4 +52,6 @@ export const translations = {
|
|
|
52
52
|
select_file: "Select file",
|
|
53
53
|
selected_file: "Selected file",
|
|
54
54
|
extension_allowed: "Only this file extensions are allowed: ",
|
|
55
|
+
confirm_submit_title: "Confirm submission",
|
|
56
|
+
confirm_submit_text: "Are you sure you want to submit this form?",
|
|
55
57
|
};
|
package/lib/i18n/es.js
CHANGED
|
@@ -52,4 +52,6 @@ export const translations = {
|
|
|
52
52
|
select_file: "Seleccionar archivo",
|
|
53
53
|
selected_file: "Archivo seleccionado",
|
|
54
54
|
extension_allowed: "Solo se permiten estas extensiones: ",
|
|
55
|
+
confirm_submit_title: "Confirmar envío",
|
|
56
|
+
confirm_submit_text: "¿Estás seguro de que deseas enviar este formulario?",
|
|
55
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.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": {
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://dile-components.com/",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dile/ui": "^2.21.
|
|
27
|
+
"@dile/ui": "^2.21.2",
|
|
28
28
|
"axios": "^1.16.0",
|
|
29
29
|
"lit": "^2.7.0 || ^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "cde235f0d633aac9a2da770248c7301cef99041a"
|
|
35
35
|
}
|