@projectcaluma/ember-form 14.7.1 → 14.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.
- package/addon/lib/field.js +31 -0
- package/package.json +5 -5
package/addon/lib/field.js
CHANGED
|
@@ -627,6 +627,8 @@ export default class Field extends Base {
|
|
|
627
627
|
input.dataSourceContext = JSON.stringify(this.document.dataSourceContext);
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
await this.beforeSave();
|
|
631
|
+
|
|
630
632
|
try {
|
|
631
633
|
const response = await this.apollo.mutate(
|
|
632
634
|
{
|
|
@@ -652,12 +654,16 @@ export default class Field extends Base {
|
|
|
652
654
|
this._errors = this._errors.filter(({ type }) => type !== "format");
|
|
653
655
|
}
|
|
654
656
|
|
|
657
|
+
await this.afterSave(response);
|
|
658
|
+
|
|
655
659
|
return response;
|
|
656
660
|
} catch (e) {
|
|
657
661
|
const validationError = e.errors.find(
|
|
658
662
|
(err) => err.extensions?.code === "format_validation_failed",
|
|
659
663
|
);
|
|
660
664
|
|
|
665
|
+
await this.onSaveError(e);
|
|
666
|
+
|
|
661
667
|
if (validationError) {
|
|
662
668
|
this._errors = [
|
|
663
669
|
...this._errors,
|
|
@@ -673,6 +679,31 @@ export default class Field extends Base {
|
|
|
673
679
|
}
|
|
674
680
|
});
|
|
675
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Hook method that can be overridden to add functionality before saving the field.
|
|
684
|
+
*
|
|
685
|
+
* @method beforeSave
|
|
686
|
+
*/
|
|
687
|
+
async beforeSave() {}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Hook method that can be overridden to add functionality after saving the field.
|
|
691
|
+
*
|
|
692
|
+
* @method afterSave
|
|
693
|
+
* @param {Object} response The response from the server
|
|
694
|
+
*/
|
|
695
|
+
// eslint-disable-next-line no-unused-vars
|
|
696
|
+
async afterSave(response) {}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Hook method that can be overridden to add functionality when saving the field fails.
|
|
700
|
+
*
|
|
701
|
+
* @method onSaveError
|
|
702
|
+
* @param {Object} error The error thrown during saving
|
|
703
|
+
*/
|
|
704
|
+
// eslint-disable-next-line no-unused-vars
|
|
705
|
+
async onSaveError(error) {}
|
|
706
|
+
|
|
676
707
|
/**
|
|
677
708
|
* The translated error messages
|
|
678
709
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.8.0",
|
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"luxon": "^3.5.0",
|
|
40
40
|
"reactiveweb": "^1.3.0",
|
|
41
41
|
"tracked-toolbox": "^2.0.0",
|
|
42
|
-
"@projectcaluma/ember-core": "^14.
|
|
42
|
+
"@projectcaluma/ember-core": "^14.8.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@ember/optional-features": "2.3.0",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
"uikit": "3.25.6",
|
|
75
75
|
"uuid": "13.0.0",
|
|
76
76
|
"webpack": "5.104.1",
|
|
77
|
-
"@projectcaluma/ember-
|
|
78
|
-
"@projectcaluma/ember-
|
|
77
|
+
"@projectcaluma/ember-workflow": "14.8.0",
|
|
78
|
+
"@projectcaluma/ember-testing": "14.8.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"ember-source": ">= 4.0.0",
|
|
82
|
-
"@projectcaluma/ember-workflow": "^14.
|
|
82
|
+
"@projectcaluma/ember-workflow": "^14.8.0"
|
|
83
83
|
},
|
|
84
84
|
"dependenciesMeta": {
|
|
85
85
|
"@projectcaluma/ember-core": {
|