@ardimedia/angular-portal-azure 0.2.288 → 0.2.290

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.
Files changed (3) hide show
  1. package/apn.d.ts +15 -1
  2. package/apn.js +41 -0
  3. package/package.json +1 -1
package/apn.d.ts CHANGED
@@ -393,7 +393,21 @@ declare namespace angularportalazure {
393
393
  * - set this.isCommandSaveEnabled = true
394
394
  * - call this.setStatusBarException
395
395
  */
396
- saveItem(func: () => (Promise<T> | angular.IHttpPromise<T>), ngForm?: any): (Promise<void | T> | angular.IHttpPromise<void | T>);
396
+ saveItem(func: () => (Promise<T> | angular.IPromise<T>), ngForm?: any): (Promise<void | T> | angular.IPromise<void | T>);
397
+ /**
398
+ * Default behavior for saving any object.
399
+ * - call this.setStatusBarSaveData();
400
+ * - call this.onSaveItem()
401
+ * - validates this.formblade. if not valid, returns without saving
402
+ * - call the provided function
403
+ * THEN
404
+ * - call this.clearStatusBar()
405
+ * - call this.onSavedItem()
406
+ * - returns the saved data
407
+ * CATCH
408
+ * - call this.setStatusBarException
409
+ */
410
+ saveObject(func: () => (Promise<any> | angular.IPromise<any>), ngForm?: any): (Promise<void | any> | angular.IPromise<void | any>);
397
411
  /** Extension point */
398
412
  onSaveItem(): void;
399
413
  /** Extension point */
package/apn.js CHANGED
@@ -1225,6 +1225,47 @@ var angularportalazure;
1225
1225
  _this.setStatusBarException(exception);
1226
1226
  });
1227
1227
  };
1228
+ /**
1229
+ * Default behavior for saving any object.
1230
+ * - call this.setStatusBarSaveData();
1231
+ * - call this.onSaveItem()
1232
+ * - validates this.formblade. if not valid, returns without saving
1233
+ * - call the provided function
1234
+ * THEN
1235
+ * - call this.clearStatusBar()
1236
+ * - call this.onSavedItem()
1237
+ * - returns the saved data
1238
+ * CATCH
1239
+ * - call this.setStatusBarException
1240
+ */
1241
+ BladeDetail.prototype.saveObject = function (func, ngForm) {
1242
+ var _this = this;
1243
+ if (ngForm === void 0) { ngForm = undefined; }
1244
+ this.setStatusBarSaveData();
1245
+ this.onSaveItem();
1246
+ //#region form valid?
1247
+ // angularjs: if form valid
1248
+ if (!this.formblade.$valid) {
1249
+ this.statusBar = 'Speichern nicht möglich! [Console] enthält weitere Informationen.';
1250
+ this.statusBarClass = 'apa-statusbar-error';
1251
+ console.log(this.formblade);
1252
+ return;
1253
+ }
1254
+ // angular: if form valid
1255
+ if (ngForm !== undefined) {
1256
+ if (!ngForm.valid) {
1257
+ return;
1258
+ }
1259
+ }
1260
+ //#endregion
1261
+ return func().then(function (data) {
1262
+ _this.clearStatusBar();
1263
+ _this.onSavedItem();
1264
+ return data;
1265
+ }).catch(function (exception) {
1266
+ _this.setStatusBarException(exception);
1267
+ });
1268
+ };
1228
1269
  /** Extension point */
1229
1270
  BladeDetail.prototype.onSaveItem = function () {
1230
1271
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ardimedia/angular-portal-azure",
3
3
  "description": "Angular Portal Azure - GUI Framework.",
4
4
  "author": "Ardimedia Anstalt <info@ardimedia.com> (http://www.ardimedia.com)",
5
- "version": "0.2.288",
5
+ "version": "0.2.290",
6
6
  "main": "index.js",
7
7
  "typings": "apn.d.ts",
8
8
  "dependencies": {