@magic-xpa/angular 4.1000.0 → 4.1000.410-0.428
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/esm2020/index.mjs +1 -1
- package/esm2020/src/services/task.magics.service.mjs +13 -2
- package/esm2020/src/ui/GuiInteractiveExecutor.mjs +7 -2
- package/esm2020/src/ui/directives/magic/checkbox.magic.directive.mjs +76 -7
- package/esm2020/src/ui/directives/magic/form-controls/control-value-accessors/date.cva.directive.mjs +34 -5
- package/esm2020/src/ui/directives/mgformat.magic.directive.mjs +170 -2
- package/fesm2015/magic-xpa-angular.mjs +284 -13
- package/fesm2015/magic-xpa-angular.mjs.map +1 -1
- package/fesm2020/magic-xpa-angular.mjs +284 -13
- package/fesm2020/magic-xpa-angular.mjs.map +1 -1
- package/package.json +3 -3
- package/src/ui/directives/magic/checkbox.magic.directive.d.ts +15 -2
- package/src/ui/directives/magic/form-controls/control-value-accessors/date.cva.directive.d.ts +8 -2
- package/src/ui/directives/mgformat.magic.directive.d.ts +7 -0
@@ -8,8 +8,8 @@ import { RouterModule } from '@angular/router';
|
|
8
8
|
import { FormGroup, FormControl, Validators, NG_VALIDATORS, NG_VALUE_ACCESSOR, CheckboxControlValueAccessor, DefaultValueAccessor, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
9
9
|
import * as i3 from 'ng-dynamic-component';
|
10
10
|
import { DynamicModule } from 'ng-dynamic-component';
|
11
|
-
import { InteractiveCommandType, OverlayType, Styles,
|
12
|
-
import { MagicBridge, getGuiEventObj, CookieService } from '@magic-xpa/engine';
|
11
|
+
import { InteractiveCommandType, HtmlProperties, OverlayType, Styles, GuiConstants, CommandType, PIC, GuiEnvironment, Modifiers } from '@magic-xpa/gui';
|
12
|
+
import { MagicBridge, getGuiEventObj, CookieService, Environment, LastFocusedManager } from '@magic-xpa/engine';
|
13
13
|
import { MagicProperties, Logger, StrUtil, StorageAttribute, PICInterface, BindingLevel, StorageAttributeType, MgControlType } from '@magic-xpa/utils';
|
14
14
|
import { filter, map, debounceTime } from 'rxjs/operators';
|
15
15
|
import { Subject, fromEvent } from 'rxjs';
|
@@ -756,6 +756,11 @@ class GuiInteractiveExecutor {
|
|
756
756
|
}
|
757
757
|
else if (this.task.isTableControl(this.command.controlName))
|
758
758
|
val = this.task.getValue(this.command.controlName, guiRowId.toString());
|
759
|
+
if (this.command._boolVal) {
|
760
|
+
const indeterminate = this.task.getProperty(this.command.controlName, HtmlProperties.CheckBoxIndeterminate, guiRowId.toString());
|
761
|
+
if (indeterminate)
|
762
|
+
val = null;
|
763
|
+
}
|
759
764
|
val = this.task.ConvertValToNative(this.command.controlName, guiRowId, val);
|
760
765
|
this.command._mgValue.obj = val;
|
761
766
|
}
|
@@ -1827,7 +1832,8 @@ class TaskMagicService {
|
|
1827
1832
|
case CommandType.SET_PROPERTY:
|
1828
1833
|
this.handleSetProperty(command, isTableChild);
|
1829
1834
|
if (command.Operation == HtmlProperties.ReadOnly ||
|
1830
|
-
command.Operation == HtmlProperties.ItemsList
|
1835
|
+
command.Operation == HtmlProperties.ItemsList ||
|
1836
|
+
command.Operation == HtmlProperties.CheckBoxIndeterminate)
|
1831
1837
|
this.refreshDom.next(command);
|
1832
1838
|
break;
|
1833
1839
|
case CommandType.PROP_SET_USER_PROPERTY:
|
@@ -2067,6 +2073,16 @@ class TaskMagicService {
|
|
2067
2073
|
if (typeof (event) == 'boolean') {
|
2068
2074
|
guiEvent.Value = event;
|
2069
2075
|
}
|
2076
|
+
else if (typeof (event) == 'string') {
|
2077
|
+
if (event == "unchecked") {
|
2078
|
+
guiEvent.Value = false;
|
2079
|
+
}
|
2080
|
+
else if (event == 'indeterminate')
|
2081
|
+
guiEvent.Value = null;
|
2082
|
+
else if (event == 'checked') {
|
2083
|
+
guiEvent.Value = true;
|
2084
|
+
}
|
2085
|
+
}
|
2070
2086
|
else {
|
2071
2087
|
if (typeof event.target === 'undefined')
|
2072
2088
|
guiEvent.Value = (event).checked;
|
@@ -3508,6 +3524,170 @@ class MgformatMagicDirective {
|
|
3508
3524
|
break;
|
3509
3525
|
}
|
3510
3526
|
}
|
3527
|
+
onBlurEvent(event) {
|
3528
|
+
let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
|
3529
|
+
let attr = this._task.Records.list[0].getControlMetadata(this.magicDir.id).dataType;
|
3530
|
+
const century = Environment.Instance.GetCentury(LastFocusedManager.Instance.getCurrTask().getCompIdx());
|
3531
|
+
if (attr == StorageAttribute.DATE)
|
3532
|
+
this.formatDateWithCentury(event.target.value, century, control);
|
3533
|
+
}
|
3534
|
+
formatDateWithCentury(userInput, century, control) {
|
3535
|
+
const dateFormat = this._task.mgInputDateFormat;
|
3536
|
+
const separator = userInput.includes('/') ? '/' : "-";
|
3537
|
+
let centuryVal = parseInt(century.toString().slice(0, 2));
|
3538
|
+
if (userInput.length == 0)
|
3539
|
+
return;
|
3540
|
+
if ((dateFormat == 'dd/MMM/yyyy' || dateFormat == 'dd-MMM-yyyy')) {
|
3541
|
+
const dateArray = userInput.split(separator);
|
3542
|
+
const [day, month, year] = this.getDateSegments1(dateArray);
|
3543
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3544
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3545
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3546
|
+
}
|
3547
|
+
}
|
3548
|
+
else if ((dateFormat == 'dd/MM/yyyy' || dateFormat == 'dd-MM-yyyy' || dateFormat == 'd/M/yyyy' || dateFormat == 'd-M-yyyy')) {
|
3549
|
+
const dateArray = userInput.split(separator);
|
3550
|
+
const [day, month, year] = this.getDateSegments1(dateArray);
|
3551
|
+
if ((day < 32 && month < 13)) {
|
3552
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3553
|
+
}
|
3554
|
+
}
|
3555
|
+
else if ((dateFormat == 'MM/dd/yyyy' || dateFormat == 'MM-dd-yyyy' || dateFormat == 'M/d/yyyy' || dateFormat == 'M-d-yyyy')) {
|
3556
|
+
const dateArray = userInput.split(separator);
|
3557
|
+
const [day, month, year] = this.getDateSegments2(dateArray);
|
3558
|
+
if ((day < 32 && month < 13)) {
|
3559
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3560
|
+
}
|
3561
|
+
}
|
3562
|
+
else if ((dateFormat == 'MMM/dd/yyyy' || dateFormat == 'MMM-dd-yyyy')) {
|
3563
|
+
const dateArray = userInput.split(separator);
|
3564
|
+
const [day, month, year] = this.getDateSegments2(dateArray);
|
3565
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3566
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3567
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3568
|
+
}
|
3569
|
+
}
|
3570
|
+
else if ((dateFormat == 'yyyy/MM/dd' || dateFormat == 'yyyy-MM-dd')) {
|
3571
|
+
const dateArray = userInput.split(separator);
|
3572
|
+
const [day, month, year] = this.getDateSegments3(dateArray);
|
3573
|
+
if ((day < 32 && month < 13)) {
|
3574
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3575
|
+
}
|
3576
|
+
}
|
3577
|
+
else if ((dateFormat == 'yyyy/dd/MM' || dateFormat == 'yyyy-dd-MM')) {
|
3578
|
+
const dateArray = userInput.split(separator);
|
3579
|
+
const [day, month, year] = this.getDateSegments4(dateArray);
|
3580
|
+
if ((day < 32 && month < 13)) {
|
3581
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3582
|
+
}
|
3583
|
+
}
|
3584
|
+
else if ((dateFormat == 'yyyy/dd/MMM' || dateFormat == 'yyyy-dd-MMM')) {
|
3585
|
+
const dateArray = userInput.split(separator);
|
3586
|
+
const [day, month, year] = this.getDateSegments4(dateArray);
|
3587
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3588
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3589
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3590
|
+
}
|
3591
|
+
}
|
3592
|
+
else if ((dateFormat == 'dd/MM/yy' || dateFormat == 'dd-MM-yy' || dateFormat == 'd/M/yy' || dateFormat == 'd-M-yy')) {
|
3593
|
+
const dateArray = userInput.split(separator);
|
3594
|
+
const [day, month, year] = this.getDateSegments1(dateArray);
|
3595
|
+
if ((day < 32 && month < 13)) {
|
3596
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3597
|
+
}
|
3598
|
+
}
|
3599
|
+
else if ((dateFormat == 'MM/dd/yy' || dateFormat == 'MM-dd-yy' || dateFormat == 'M/d/yy' || dateFormat == 'M-d-yy')) {
|
3600
|
+
const dateArray = userInput.split(separator);
|
3601
|
+
const [day, month, year] = this.getDateSegments2(dateArray);
|
3602
|
+
if ((day < 32 && month < 13)) {
|
3603
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3604
|
+
}
|
3605
|
+
}
|
3606
|
+
else if ((dateFormat == 'yy/MM/dd' || dateFormat == 'yy-MM-dd')) {
|
3607
|
+
const dateArray = userInput.split(separator);
|
3608
|
+
const [day, month, year] = this.getDateSegments3(dateArray);
|
3609
|
+
if ((day < 32 && month < 13)) {
|
3610
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3611
|
+
}
|
3612
|
+
}
|
3613
|
+
else if ((dateFormat == 'yy/dd/MM' || dateFormat == 'yy-dd-MM')) {
|
3614
|
+
const dateArray = userInput.split(separator);
|
3615
|
+
const [day, month, year] = this.getDateSegments4(dateArray);
|
3616
|
+
if ((day < 32 && month < 13)) {
|
3617
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3618
|
+
}
|
3619
|
+
}
|
3620
|
+
else if ((dateFormat == 'dd/MMM/yy' || dateFormat == 'dd-MMM-yy')) {
|
3621
|
+
const dateArray = userInput.split(separator);
|
3622
|
+
const [day, month, year] = this.getDateSegments1(dateArray);
|
3623
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3624
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3625
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3626
|
+
}
|
3627
|
+
}
|
3628
|
+
else if ((dateFormat == 'yy/dd/MMM' || dateFormat == 'yy-dd-MMM')) {
|
3629
|
+
const dateArray = userInput.split(separator);
|
3630
|
+
const [day, month, year] = this.getDateSegments4(dateArray);
|
3631
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3632
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3633
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3634
|
+
}
|
3635
|
+
}
|
3636
|
+
else if ((dateFormat == 'MMM/dd/yy' || dateFormat == 'MMM-dd-yy')) {
|
3637
|
+
const dateArray = userInput.split(separator);
|
3638
|
+
const [day, month, year] = this.getDateSegments2(dateArray);
|
3639
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3640
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3641
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3642
|
+
}
|
3643
|
+
}
|
3644
|
+
else if ((dateFormat == 'yyyy/MMM/dd' || dateFormat == 'yyyy-MMM-dd' || dateFormat == 'yy/MMM/dd' || dateFormat == 'yy-MMM-dd')) {
|
3645
|
+
const dateArray = userInput.split(separator);
|
3646
|
+
const [day, month, year] = this.getDateSegments3(dateArray);
|
3647
|
+
const isMonthInNumber = !isNaN(Number(month));
|
3648
|
+
if ((isMonthInNumber && day < 32 && Number(month) < 13) || (!isMonthInNumber && day < 32)) {
|
3649
|
+
this.updateYear(day, month, year, separator, century, centuryVal, control);
|
3650
|
+
}
|
3651
|
+
}
|
3652
|
+
else if (dateFormat == 'yyyy/MM' || dateFormat == 'yyyy-MM') {
|
3653
|
+
const dateArray = userInput.split(separator);
|
3654
|
+
const month = dateArray[1];
|
3655
|
+
const year = Number(dateArray[0]);
|
3656
|
+
if (Number(month) < 13) {
|
3657
|
+
this.updateYear(1, month, year, separator, century, centuryVal, control);
|
3658
|
+
}
|
3659
|
+
}
|
3660
|
+
}
|
3661
|
+
updateYear(day, month, year, separator, century, centuryVal, control) {
|
3662
|
+
let updatedYear = year.toString().length === 2 ? (year < century % 100 ? centuryVal + 1 : centuryVal) + '' + year :
|
3663
|
+
year.toString().length === 1 ? (year < century % 100 ? centuryVal + 1 : centuryVal) + '0' + year :
|
3664
|
+
year;
|
3665
|
+
control.setValue(new Date(`${updatedYear}${separator}${month}${separator}${day}`));
|
3666
|
+
}
|
3667
|
+
getDateSegments1(dateArray) {
|
3668
|
+
const day = Number(dateArray[0]);
|
3669
|
+
const month = dateArray[1];
|
3670
|
+
const year = Number(dateArray[2]);
|
3671
|
+
return [day, month, year];
|
3672
|
+
}
|
3673
|
+
getDateSegments2(dateArray) {
|
3674
|
+
const day = Number(dateArray[1]);
|
3675
|
+
const month = dateArray[0];
|
3676
|
+
const year = Number(dateArray[2]);
|
3677
|
+
return [day, month, year];
|
3678
|
+
}
|
3679
|
+
getDateSegments3(dateArray) {
|
3680
|
+
const day = Number(dateArray[2]);
|
3681
|
+
const month = dateArray[1];
|
3682
|
+
const year = Number(dateArray[0]);
|
3683
|
+
return [day, month, year];
|
3684
|
+
}
|
3685
|
+
getDateSegments4(dateArray) {
|
3686
|
+
const day = Number(dateArray[1]);
|
3687
|
+
const month = dateArray[2];
|
3688
|
+
const year = Number(dateArray[0]);
|
3689
|
+
return [day, month, year];
|
3690
|
+
}
|
3511
3691
|
calculatePattern() {
|
3512
3692
|
let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
|
3513
3693
|
if (control != null) {
|
@@ -3690,7 +3870,7 @@ class MgformatMagicDirective {
|
|
3690
3870
|
MgformatMagicDirective.ɵfac = function MgformatMagicDirective_Factory(t) { return new (t || MgformatMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(TaskMagicService)); };
|
3691
3871
|
MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirective, selectors: [["", "mgFormat", ""]], hostBindings: function MgformatMagicDirective_HostBindings(rf, ctx) {
|
3692
3872
|
if (rf & 1) {
|
3693
|
-
i0.ɵɵlistener("focus", function MgformatMagicDirective_focus_HostBindingHandler($event) { return ctx.onFocusEvent($event); })("paste", function MgformatMagicDirective_paste_HostBindingHandler($event) { return ctx.onPaste($event); })("input", function MgformatMagicDirective_input_HostBindingHandler($event) { return ctx.onInputEvent($event); })("change", function MgformatMagicDirective_change_HostBindingHandler($event) { return ctx.onChangeEvent($event); });
|
3873
|
+
i0.ɵɵlistener("focus", function MgformatMagicDirective_focus_HostBindingHandler($event) { return ctx.onFocusEvent($event); })("paste", function MgformatMagicDirective_paste_HostBindingHandler($event) { return ctx.onPaste($event); })("input", function MgformatMagicDirective_input_HostBindingHandler($event) { return ctx.onInputEvent($event); })("change", function MgformatMagicDirective_change_HostBindingHandler($event) { return ctx.onChangeEvent($event); })("blur", function MgformatMagicDirective_blur_HostBindingHandler($event) { return ctx.onBlurEvent($event); });
|
3694
3874
|
}
|
3695
3875
|
} });
|
3696
3876
|
(function () {
|
@@ -3711,6 +3891,9 @@ MgformatMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: MgformatMagicDirec
|
|
3711
3891
|
}], onChangeEvent: [{
|
3712
3892
|
type: HostListener,
|
3713
3893
|
args: ['change', ['$event']]
|
3894
|
+
}], onBlurEvent: [{
|
3895
|
+
type: HostListener,
|
3896
|
+
args: ['blur', ['$event']]
|
3714
3897
|
}] });
|
3715
3898
|
})();
|
3716
3899
|
|
@@ -3994,19 +4177,81 @@ ErrorMagicComponent.ɵcmp = i0.ɵɵdefineComponent({ type: ErrorMagicComponent,
|
|
3994
4177
|
})();
|
3995
4178
|
|
3996
4179
|
class CheckboxMagicDirective {
|
3997
|
-
constructor(magicDirective) {
|
4180
|
+
constructor(magicDirective, el, task) {
|
3998
4181
|
this.magicDirective = magicDirective;
|
4182
|
+
this.el = el;
|
4183
|
+
this.task = task;
|
4184
|
+
this.threeState = false;
|
4185
|
+
this.subscribeRefreshDom = null;
|
4186
|
+
this.isIndeterminate = false;
|
3999
4187
|
}
|
4000
4188
|
onChange($event) {
|
4001
|
-
|
4189
|
+
if (this.threeState) {
|
4190
|
+
this.handleThreeState();
|
4191
|
+
}
|
4192
|
+
else {
|
4193
|
+
this.magicDirective.task.onCheckChanged($event, this.magicDirective.id, +this.magicDirective.rowId);
|
4194
|
+
}
|
4195
|
+
}
|
4196
|
+
ngOnInit() {
|
4197
|
+
if (this.threeState) {
|
4198
|
+
let guiEvent = getGuiEventObj("setAsThreeState", this.magicDirective.id, +this.magicDirective.rowId);
|
4199
|
+
this.task.insertEvent(guiEvent);
|
4200
|
+
this.el.nativeElement.indeterminate = this.isIndeterminate = this.task.getProperty(this.magicDirective.id, HtmlProperties.CheckBoxIndeterminate, this.magicDirective.rowId);
|
4201
|
+
this.regUpdatesUI();
|
4202
|
+
}
|
4203
|
+
}
|
4204
|
+
regUpdatesUI() {
|
4205
|
+
this.subscribeRefreshDom = this.task
|
4206
|
+
.refreshDom.pipe(filter(c => this.magicDirective.IsSameElement(c)))
|
4207
|
+
.subscribe(a => {
|
4208
|
+
let command = a;
|
4209
|
+
try {
|
4210
|
+
this.handleCommand(command);
|
4211
|
+
}
|
4212
|
+
catch (ex) {
|
4213
|
+
console.dir(ex);
|
4214
|
+
}
|
4215
|
+
});
|
4216
|
+
}
|
4217
|
+
handleCommand(command) {
|
4218
|
+
if (command.CommandType == CommandType.SET_PROPERTY &&
|
4219
|
+
command.Operation == HtmlProperties.CheckBoxIndeterminate) {
|
4220
|
+
this.isIndeterminate = this.el.nativeElement.indeterminate = command.obj1;
|
4221
|
+
}
|
4222
|
+
}
|
4223
|
+
handleThreeState() {
|
4224
|
+
let value = '';
|
4225
|
+
let prevCheckedValue = this.task.getValue(this.magicDirective.id, this.magicDirective.rowId);
|
4226
|
+
const checkbox = this.el.nativeElement;
|
4227
|
+
if (this.isIndeterminate) {
|
4228
|
+
checkbox.checked = false;
|
4229
|
+
checkbox.indeterminate = false;
|
4230
|
+
value = 'unchecked';
|
4231
|
+
}
|
4232
|
+
else if (prevCheckedValue) {
|
4233
|
+
checkbox.checked = false;
|
4234
|
+
checkbox.indeterminate = true;
|
4235
|
+
value = 'indeterminate';
|
4236
|
+
}
|
4237
|
+
else if (!prevCheckedValue) {
|
4238
|
+
checkbox.checked = true;
|
4239
|
+
checkbox.indeterminate = false;
|
4240
|
+
value = 'checked';
|
4241
|
+
}
|
4242
|
+
this.magicDirective.task.onCheckChanged(value, this.magicDirective.id, +this.magicDirective.rowId);
|
4243
|
+
}
|
4244
|
+
ngOnDestroy() {
|
4245
|
+
if (this.subscribeRefreshDom !== null)
|
4246
|
+
this.subscribeRefreshDom.unsubscribe();
|
4002
4247
|
}
|
4003
4248
|
}
|
4004
|
-
CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective)); };
|
4249
|
+
CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(TaskMagicService)); };
|
4005
4250
|
CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirective, selectors: [["input", "type", "checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function CheckboxMagicDirective_HostBindings(rf, ctx) {
|
4006
4251
|
if (rf & 1) {
|
4007
4252
|
i0.ɵɵlistener("change", function CheckboxMagicDirective_change_HostBindingHandler($event) { return ctx.onChange($event); });
|
4008
4253
|
}
|
4009
|
-
} });
|
4254
|
+
}, inputs: { threeState: "threeState" } });
|
4010
4255
|
(function () {
|
4011
4256
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CheckboxMagicDirective, [{
|
4012
4257
|
type: Directive,
|
@@ -4015,7 +4260,9 @@ CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirec
|
|
4015
4260
|
input[type=checkbox][magic]:not([noFormControl])
|
4016
4261
|
`,
|
4017
4262
|
}]
|
4018
|
-
}], function () { return [{ type: MagicDirective }]; }, {
|
4263
|
+
}], function () { return [{ type: MagicDirective }, { type: i0.ElementRef }, { type: TaskMagicService }]; }, { threeState: [{
|
4264
|
+
type: Input
|
4265
|
+
}], onChange: [{
|
4019
4266
|
type: HostListener,
|
4020
4267
|
args: ['change', ['$event']]
|
4021
4268
|
}] });
|
@@ -4391,12 +4638,33 @@ const DATE_VALUE_ACCESSOR = {
|
|
4391
4638
|
multi: true
|
4392
4639
|
};
|
4393
4640
|
class DateValueAccessor {
|
4394
|
-
|
4641
|
+
onBlurEvent(event) {
|
4642
|
+
const century = Environment.Instance.GetCentury(LastFocusedManager.Instance.getCurrTask().getCompIdx());
|
4643
|
+
let control = this._task.getFormControl(this.magicDir.rowId, this.magicDir.id);
|
4644
|
+
this.formatDateWithCentury(event.target.value, century, control);
|
4645
|
+
}
|
4646
|
+
constructor(renderer, elementRef, magicDir, _task) {
|
4395
4647
|
this.renderer = renderer;
|
4396
4648
|
this.elementRef = elementRef;
|
4649
|
+
this.magicDir = magicDir;
|
4650
|
+
this._task = _task;
|
4397
4651
|
this.onChange = (_) => { };
|
4398
4652
|
this.onTouched = () => { };
|
4399
4653
|
}
|
4654
|
+
formatDateWithCentury(userInput, century, control) {
|
4655
|
+
const separator = userInput.includes('/') ? '/' : "-";
|
4656
|
+
let centuryVal = parseInt(century.toString().slice(0, 2));
|
4657
|
+
if (userInput.length == 0)
|
4658
|
+
return;
|
4659
|
+
const dateArray = userInput.split(separator);
|
4660
|
+
const day = Number(dateArray[2]);
|
4661
|
+
const month = Number(dateArray[1]);
|
4662
|
+
const year = Number(dateArray[0]);
|
4663
|
+
let updatedYear = year.toString().length === 2 ? (year < century % 100 ? centuryVal + 1 : centuryVal) + '' + year :
|
4664
|
+
year.toString().length === 1 ? (year < century % 100 ? centuryVal + 1 : centuryVal) + '0' + year :
|
4665
|
+
year;
|
4666
|
+
control.setValue(new Date(`${updatedYear}${separator}${month}${separator}${day}`));
|
4667
|
+
}
|
4400
4668
|
writeValue(value) {
|
4401
4669
|
if (!value) {
|
4402
4670
|
this.renderer.setProperty(this.elementRef.nativeElement, "value", null);
|
@@ -4416,10 +4684,10 @@ class DateValueAccessor {
|
|
4416
4684
|
this.renderer.setProperty(this.elementRef.nativeElement, "disabled", isDisabled);
|
4417
4685
|
}
|
4418
4686
|
}
|
4419
|
-
DateValueAccessor.ɵfac = function DateValueAccessor_Factory(t) { return new (t || DateValueAccessor)(i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.ElementRef)); };
|
4687
|
+
DateValueAccessor.ɵfac = function DateValueAccessor_Factory(t) { return new (t || DateValueAccessor)(i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(TaskMagicService)); };
|
4420
4688
|
DateValueAccessor.ɵdir = i0.ɵɵdefineDirective({ type: DateValueAccessor, selectors: [["", "dateInput", ""]], hostBindings: function DateValueAccessor_HostBindings(rf, ctx) {
|
4421
4689
|
if (rf & 1) {
|
4422
|
-
i0.ɵɵlistener("input", function DateValueAccessor_input_HostBindingHandler($event) { return ctx.onChange($event.target.valueAsDate); })("blur", function DateValueAccessor_blur_HostBindingHandler() { return ctx.
|
4690
|
+
i0.ɵɵlistener("input", function DateValueAccessor_input_HostBindingHandler($event) { return ctx.onChange($event.target.valueAsDate); })("blur", function DateValueAccessor_blur_HostBindingHandler($event) { return ctx.onBlurEvent($event); });
|
4423
4691
|
}
|
4424
4692
|
}, features: [i0.ɵɵProvidersFeature([DATE_VALUE_ACCESSOR])] });
|
4425
4693
|
(function () {
|
@@ -4429,12 +4697,15 @@ DateValueAccessor.ɵdir = i0.ɵɵdefineDirective({ type: DateValueAccessor, sele
|
|
4429
4697
|
selector: "[dateInput]",
|
4430
4698
|
providers: [DATE_VALUE_ACCESSOR]
|
4431
4699
|
}]
|
4432
|
-
}], function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, { onChange: [{
|
4700
|
+
}], function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: MagicDirective }, { type: TaskMagicService }]; }, { onChange: [{
|
4433
4701
|
type: HostListener,
|
4434
4702
|
args: ["input", ["$event.target.valueAsDate"]]
|
4435
4703
|
}], onTouched: [{
|
4436
4704
|
type: HostListener,
|
4437
4705
|
args: ["blur", []]
|
4706
|
+
}], onBlurEvent: [{
|
4707
|
+
type: HostListener,
|
4708
|
+
args: ['blur', ['$event']]
|
4438
4709
|
}] });
|
4439
4710
|
})();
|
4440
4711
|
|