@magic-xpa/angular 4.1000.0-dev4100.400 → 4.1000.0-dev4100.403
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/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 +75 -7
- package/fesm2015/magic-xpa-angular.mjs +86 -7
- package/fesm2015/magic-xpa-angular.mjs.map +1 -1
- package/fesm2020/magic-xpa-angular.mjs +86 -7
- 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
@@ -8,7 +8,7 @@ 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,
|
11
|
+
import { InteractiveCommandType, HtmlProperties, OverlayType, Styles, GuiConstants, CommandType, PIC, GuiEnvironment, Modifiers } from '@magic-xpa/gui';
|
12
12
|
import { MagicBridge, getGuiEventObj, CookieService } 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';
|
@@ -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;
|
@@ -3994,19 +4010,80 @@ ErrorMagicComponent.ɵcmp = i0.ɵɵdefineComponent({ type: ErrorMagicComponent,
|
|
3994
4010
|
})();
|
3995
4011
|
|
3996
4012
|
class CheckboxMagicDirective {
|
3997
|
-
constructor(magicDirective) {
|
4013
|
+
constructor(magicDirective, el, task) {
|
3998
4014
|
this.magicDirective = magicDirective;
|
4015
|
+
this.el = el;
|
4016
|
+
this.task = task;
|
4017
|
+
this.threeState = false;
|
4018
|
+
this.subscribeRefreshDom = null;
|
4019
|
+
this.isIndeterminate = false;
|
3999
4020
|
}
|
4000
4021
|
onChange($event) {
|
4001
|
-
|
4022
|
+
if (this.threeState) {
|
4023
|
+
this.handleThreeState();
|
4024
|
+
}
|
4025
|
+
else {
|
4026
|
+
this.magicDirective.task.onCheckChanged($event, this.magicDirective.id, +this.magicDirective.rowId);
|
4027
|
+
}
|
4028
|
+
}
|
4029
|
+
ngOnInit() {
|
4030
|
+
if (this.threeState) {
|
4031
|
+
let guiEvent = getGuiEventObj("setAsThreeState", this.magicDirective.id, +this.magicDirective.rowId);
|
4032
|
+
this.task.insertEvent(guiEvent);
|
4033
|
+
this.regUpdatesUI();
|
4034
|
+
}
|
4035
|
+
}
|
4036
|
+
regUpdatesUI() {
|
4037
|
+
this.subscribeRefreshDom = this.task
|
4038
|
+
.refreshDom.pipe(filter(c => this.magicDirective.IsSameElement(c)))
|
4039
|
+
.subscribe(a => {
|
4040
|
+
let command = a;
|
4041
|
+
try {
|
4042
|
+
this.handleCommand(command);
|
4043
|
+
}
|
4044
|
+
catch (ex) {
|
4045
|
+
console.dir(ex);
|
4046
|
+
}
|
4047
|
+
});
|
4048
|
+
}
|
4049
|
+
handleCommand(command) {
|
4050
|
+
if (command.CommandType == CommandType.SET_PROPERTY &&
|
4051
|
+
command.Operation == HtmlProperties.CheckBoxIndeterminate) {
|
4052
|
+
this.isIndeterminate = this.el.nativeElement.indeterminate = command.obj1;
|
4053
|
+
}
|
4054
|
+
}
|
4055
|
+
handleThreeState() {
|
4056
|
+
let value = '';
|
4057
|
+
let prevCheckedValue = this.task.getValue(this.magicDirective.id, this.magicDirective.rowId);
|
4058
|
+
const checkbox = this.el.nativeElement;
|
4059
|
+
if (this.isIndeterminate) {
|
4060
|
+
checkbox.checked = false;
|
4061
|
+
checkbox.indeterminate = false;
|
4062
|
+
value = 'unchecked';
|
4063
|
+
}
|
4064
|
+
else if (prevCheckedValue) {
|
4065
|
+
checkbox.checked = false;
|
4066
|
+
checkbox.indeterminate = true;
|
4067
|
+
value = 'indeterminate';
|
4068
|
+
}
|
4069
|
+
else if (!prevCheckedValue) {
|
4070
|
+
checkbox.checked = true;
|
4071
|
+
checkbox.indeterminate = false;
|
4072
|
+
value = 'checked';
|
4073
|
+
}
|
4074
|
+
this.magicDirective.task.onCheckChanged(value, this.magicDirective.id, +this.magicDirective.rowId);
|
4075
|
+
}
|
4076
|
+
ngOnDestroy() {
|
4077
|
+
if (this.subscribeRefreshDom !== null)
|
4078
|
+
this.subscribeRefreshDom.unsubscribe();
|
4002
4079
|
}
|
4003
4080
|
}
|
4004
|
-
CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective)); };
|
4081
|
+
CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(TaskMagicService)); };
|
4005
4082
|
CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirective, selectors: [["input", "type", "checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function CheckboxMagicDirective_HostBindings(rf, ctx) {
|
4006
4083
|
if (rf & 1) {
|
4007
4084
|
i0.ɵɵlistener("change", function CheckboxMagicDirective_change_HostBindingHandler($event) { return ctx.onChange($event); });
|
4008
4085
|
}
|
4009
|
-
} });
|
4086
|
+
}, inputs: { threeState: "threeState" } });
|
4010
4087
|
(function () {
|
4011
4088
|
(typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CheckboxMagicDirective, [{
|
4012
4089
|
type: Directive,
|
@@ -4015,7 +4092,9 @@ CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirec
|
|
4015
4092
|
input[type=checkbox][magic]:not([noFormControl])
|
4016
4093
|
`,
|
4017
4094
|
}]
|
4018
|
-
}], function () { return [{ type: MagicDirective }]; }, {
|
4095
|
+
}], function () { return [{ type: MagicDirective }, { type: i0.ElementRef }, { type: TaskMagicService }]; }, { threeState: [{
|
4096
|
+
type: Input
|
4097
|
+
}], onChange: [{
|
4019
4098
|
type: HostListener,
|
4020
4099
|
args: ['change', ['$event']]
|
4021
4100
|
}] });
|