@colijnit/corecomponents_v12 12.2.5 → 12.2.6
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/bundles/colijnit-corecomponents_v12.umd.js +73 -53
- package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
- package/colijnit-corecomponents_v12.metadata.json +1 -1
- package/esm2015/lib/components/base/base-input.component.js +52 -43
- package/fesm2015/colijnit-corecomponents_v12.js +51 -42
- package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
- package/lib/components/base/base-input.component.d.ts +5 -3
- package/package.json +1 -1
|
@@ -1860,6 +1860,7 @@ class BaseInputComponent {
|
|
|
1860
1860
|
this.forceRequired = false; // a force outside of [cfgName]'s influence
|
|
1861
1861
|
// Goal: ability to emulate the red background of input fields (form-submitted invalid state)
|
|
1862
1862
|
this.redErrorBackground = false;
|
|
1863
|
+
this.commitOnBlur = true;
|
|
1863
1864
|
// @Output()
|
|
1864
1865
|
// public commit: EventEmitter<any> = new EventEmitter<any>();
|
|
1865
1866
|
this.nativeBlur = new EventEmitter();
|
|
@@ -1887,6 +1888,7 @@ class BaseInputComponent {
|
|
|
1887
1888
|
this._markedAsUserTouched = false;
|
|
1888
1889
|
this._destroyed = false;
|
|
1889
1890
|
this._hasOnPushCdStrategy = false;
|
|
1891
|
+
this._modelDirtyForCommit = false;
|
|
1890
1892
|
this._initialModelSet = false;
|
|
1891
1893
|
this._forceReadonly = undefined;
|
|
1892
1894
|
this._validators = [];
|
|
@@ -1919,6 +1921,7 @@ class BaseInputComponent {
|
|
|
1919
1921
|
}
|
|
1920
1922
|
this._model = value;
|
|
1921
1923
|
this.canSaveOrCancel = this._model !== this._initialModel;
|
|
1924
|
+
this._modelDirtyForCommit = this._model !== this._initialModel;
|
|
1922
1925
|
this._clearErrorComponent();
|
|
1923
1926
|
this.modelSet();
|
|
1924
1927
|
}
|
|
@@ -2110,7 +2113,7 @@ class BaseInputComponent {
|
|
|
2110
2113
|
committing: false,
|
|
2111
2114
|
commitFinished: false
|
|
2112
2115
|
}, {
|
|
2113
|
-
commitClick: (event) => this.
|
|
2116
|
+
commitClick: (event) => this._handleCommit(event),
|
|
2114
2117
|
cancelClick: (event) => this.cancelClick(event)
|
|
2115
2118
|
});
|
|
2116
2119
|
}
|
|
@@ -2173,22 +2176,6 @@ class BaseInputComponent {
|
|
|
2173
2176
|
this.changeDetector = undefined;
|
|
2174
2177
|
this.input = undefined;
|
|
2175
2178
|
}
|
|
2176
|
-
commitClick(event) {
|
|
2177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2178
|
-
this.keepFocus = true;
|
|
2179
|
-
if (this._commitButtonsComponentRef) {
|
|
2180
|
-
this._commitButtonsComponentRef.instance.commitFinished = false;
|
|
2181
|
-
this._commitButtonsComponentRef.instance.committing = true;
|
|
2182
|
-
}
|
|
2183
|
-
const success = yield this.commit(this.model);
|
|
2184
|
-
this.keepFocus = false;
|
|
2185
|
-
yield this._commitFinished();
|
|
2186
|
-
if (success) {
|
|
2187
|
-
this.doBlur(event);
|
|
2188
|
-
}
|
|
2189
|
-
return success;
|
|
2190
|
-
});
|
|
2191
|
-
}
|
|
2192
2179
|
cancelClick(event) {
|
|
2193
2180
|
this.keepFocus = true;
|
|
2194
2181
|
if (this._initialModelSet) {
|
|
@@ -2242,23 +2229,28 @@ class BaseInputComponent {
|
|
|
2242
2229
|
}
|
|
2243
2230
|
this.focus.next();
|
|
2244
2231
|
}
|
|
2245
|
-
doBlur(event) {
|
|
2246
|
-
|
|
2247
|
-
if (this.
|
|
2248
|
-
|
|
2249
|
-
event.preventDefault;
|
|
2250
|
-
}
|
|
2251
|
-
return false;
|
|
2252
|
-
}
|
|
2253
|
-
this.focused = false;
|
|
2254
|
-
if (this._hasOnPushCdStrategy) {
|
|
2255
|
-
this.markForCheck();
|
|
2256
|
-
}
|
|
2257
|
-
if (this.input) {
|
|
2258
|
-
this.input.blur();
|
|
2232
|
+
doBlur(event, handleCommit = true) {
|
|
2233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2234
|
+
if (this.showSaveCancel && handleCommit) {
|
|
2235
|
+
yield this._handleCommit(event, false);
|
|
2259
2236
|
}
|
|
2260
|
-
|
|
2261
|
-
|
|
2237
|
+
setTimeout(() => {
|
|
2238
|
+
if (this.keepFocus || this.keepFocussed) {
|
|
2239
|
+
if (event) {
|
|
2240
|
+
event.preventDefault;
|
|
2241
|
+
}
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
this.focused = false;
|
|
2245
|
+
if (this._hasOnPushCdStrategy) {
|
|
2246
|
+
this.markForCheck();
|
|
2247
|
+
}
|
|
2248
|
+
if (this.input) {
|
|
2249
|
+
this.input.blur();
|
|
2250
|
+
}
|
|
2251
|
+
this.blur.next();
|
|
2252
|
+
}, 200);
|
|
2253
|
+
});
|
|
2262
2254
|
}
|
|
2263
2255
|
detectChanges() {
|
|
2264
2256
|
if (!this._destroyed) {
|
|
@@ -2369,6 +2361,26 @@ class BaseInputComponent {
|
|
|
2369
2361
|
this.control.updateValueAndValidity();
|
|
2370
2362
|
}
|
|
2371
2363
|
}
|
|
2364
|
+
_handleCommit(event, doBlur = true) {
|
|
2365
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2366
|
+
if (!this.showSaveCancel || (!this._modelDirtyForCommit)) {
|
|
2367
|
+
return true;
|
|
2368
|
+
}
|
|
2369
|
+
this.keepFocus = true;
|
|
2370
|
+
if (this._commitButtonsComponentRef) {
|
|
2371
|
+
this._commitButtonsComponentRef.instance.commitFinished = false;
|
|
2372
|
+
this._commitButtonsComponentRef.instance.committing = true;
|
|
2373
|
+
}
|
|
2374
|
+
const success = yield this.commit(this.model);
|
|
2375
|
+
this.keepFocus = false;
|
|
2376
|
+
yield this._commitFinished();
|
|
2377
|
+
this._modelDirtyForCommit = false;
|
|
2378
|
+
if (success && doBlur) {
|
|
2379
|
+
this.doBlur(event, false);
|
|
2380
|
+
}
|
|
2381
|
+
return success;
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2372
2384
|
_commitFinished() {
|
|
2373
2385
|
return new Promise((resolve) => {
|
|
2374
2386
|
if (this._commitButtonsComponentRef) {
|
|
@@ -2380,17 +2392,13 @@ class BaseInputComponent {
|
|
|
2380
2392
|
resolve();
|
|
2381
2393
|
}, 800);
|
|
2382
2394
|
}
|
|
2395
|
+
else {
|
|
2396
|
+
resolve();
|
|
2397
|
+
}
|
|
2383
2398
|
});
|
|
2384
2399
|
}
|
|
2385
2400
|
_clearErrorComponent() {
|
|
2386
2401
|
this.overlayService.removeComponent(this._validationComponentRef);
|
|
2387
|
-
// if (this.validationErrorContainer) {
|
|
2388
|
-
// this.validationErrorContainer.clear();
|
|
2389
|
-
// if (this._errorValidationComponent) {
|
|
2390
|
-
// this._errorValidationComponent.destroy();
|
|
2391
|
-
// this._errorValidationComponent = undefined;
|
|
2392
|
-
// }
|
|
2393
|
-
// }
|
|
2394
2402
|
}
|
|
2395
2403
|
// whether this.ngModel.control has safe access
|
|
2396
2404
|
_controlExists() {
|
|
@@ -2487,14 +2495,14 @@ class BaseInputComponent {
|
|
|
2487
2495
|
case 'NumpadEnter':
|
|
2488
2496
|
if (!event.shiftKey) {
|
|
2489
2497
|
event.preventDefault();
|
|
2490
|
-
yield this.
|
|
2498
|
+
yield this._handleCommit();
|
|
2491
2499
|
return false;
|
|
2492
2500
|
}
|
|
2493
2501
|
return true;
|
|
2494
2502
|
case 'Tab':
|
|
2495
2503
|
const nextSiblingToFocus = event.shiftKey ? event.currentTarget.previousSibling : event.currentTarget.nextSibling;
|
|
2496
2504
|
event.preventDefault();
|
|
2497
|
-
const success = yield this.
|
|
2505
|
+
const success = yield this._handleCommit();
|
|
2498
2506
|
if (success) {
|
|
2499
2507
|
if (nextSiblingToFocus) {
|
|
2500
2508
|
try {
|
|
@@ -2580,6 +2588,7 @@ BaseInputComponent.propDecorators = {
|
|
|
2580
2588
|
customCssClass: [{ type: Input }],
|
|
2581
2589
|
redErrorBackground: [{ type: Input }, { type: HostBinding, args: ["class.cc-red-error-background",] }],
|
|
2582
2590
|
myFormInputInstance: [{ type: Input }],
|
|
2591
|
+
commitOnBlur: [{ type: Input }],
|
|
2583
2592
|
nativeBlur: [{ type: Output }],
|
|
2584
2593
|
blur: [{ type: Output }],
|
|
2585
2594
|
enter: [{ type: Output }],
|