@energycap/components 0.32.28 → 0.32.29-ECAP-17287-Add-Save-Without-Validate.20230407-0819

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.
@@ -10326,18 +10326,7 @@ class PageBaseComponent {
10326
10326
  async onSave(event) {
10327
10327
  this.formGroup.markAllAsTouched();
10328
10328
  if (this.formGroup.valid) {
10329
- this.showStatus(PageStatus.Saving);
10330
- try {
10331
- await this.applyModelUpdates();
10332
- let entityId = await this.saveToApi() || -1;
10333
- this._errors = '';
10334
- this.onSaveComplete(entityId);
10335
- }
10336
- catch (error) {
10337
- //clear the "saving" overlay and show the message at the top of the view through the errors property
10338
- this.showErrorBanner(error, this.defaultUnknownSaveError);
10339
- this.splashService.hideSplash();
10340
- }
10329
+ await this.save();
10341
10330
  }
10342
10331
  else {
10343
10332
  // Only show the banner with the generic message if the parent component hasn't already set one
@@ -10352,6 +10341,15 @@ class PageBaseComponent {
10352
10341
  }
10353
10342
  }
10354
10343
  }
10344
+ /**
10345
+ * Function available to trigger a save and bypass the form validation checks.
10346
+ * This is useful if the user chooses a remove action from within an edit dialog. If the dialog form is invalid
10347
+ * that is no concern to the user if they wish to remove the item they are editing.
10348
+ * @param event
10349
+ */
10350
+ async onSaveWithoutValidate(event) {
10351
+ await this.save();
10352
+ }
10355
10353
  /**
10356
10354
  * Function called when the component is destroyed
10357
10355
  */
@@ -10452,6 +10450,23 @@ class PageBaseComponent {
10452
10450
  this.breadcrumbs = result.breadcrumbs;
10453
10451
  this.help = result.help;
10454
10452
  }
10453
+ /**
10454
+ * Controls the page status and triggers the save action. If there is an error banner will be shown.
10455
+ */
10456
+ async save() {
10457
+ this.showStatus(PageStatus.Saving);
10458
+ try {
10459
+ await this.applyModelUpdates();
10460
+ let entityId = await this.saveToApi() || -1;
10461
+ this._errors = '';
10462
+ this.onSaveComplete(entityId);
10463
+ }
10464
+ catch (error) {
10465
+ //clear the "saving" overlay and show the message at the top of the view through the errors property
10466
+ this.showErrorBanner(error, this.defaultUnknownSaveError);
10467
+ this.splashService.hideSplash();
10468
+ }
10469
+ }
10455
10470
  /**
10456
10471
  * Sets up the router event subscriptions
10457
10472
  */
@@ -10561,6 +10576,14 @@ class PageBaseComponentTestHelper {
10561
10576
  async clickSave() {
10562
10577
  await this._component.onSave(clickEvent);
10563
10578
  }
10579
+ /**
10580
+ * Simulate saving without validate
10581
+ *
10582
+ * @returns {Promise<void>}
10583
+ */
10584
+ async clickSaveWithoutValidate() {
10585
+ await this._component.onSaveWithoutValidate(clickEvent);
10586
+ }
10564
10587
  }
10565
10588
 
10566
10589
  /**