@magic-xpa/angular 4.1000.0-dev4100.401 → 4.1000.0-dev4100.404

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.
@@ -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, HtmlProperties, GuiConstants, CommandType, PIC, GuiEnvironment, Modifiers } from '@magic-xpa/gui';
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,81 @@ 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
- this.magicDirective.task.onCheckChanged($event, this.magicDirective.id, +this.magicDirective.rowId);
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.el.nativeElement.indeterminate = this.isIndeterminate = this.task.getProperty(this.magicDirective.id, HtmlProperties.CheckBoxIndeterminate, this.magicDirective.rowId);
4034
+ this.regUpdatesUI();
4035
+ }
4036
+ }
4037
+ regUpdatesUI() {
4038
+ this.subscribeRefreshDom = this.task
4039
+ .refreshDom.pipe(filter(c => this.magicDirective.IsSameElement(c)))
4040
+ .subscribe(a => {
4041
+ let command = a;
4042
+ try {
4043
+ this.handleCommand(command);
4044
+ }
4045
+ catch (ex) {
4046
+ console.dir(ex);
4047
+ }
4048
+ });
4049
+ }
4050
+ handleCommand(command) {
4051
+ if (command.CommandType == CommandType.SET_PROPERTY &&
4052
+ command.Operation == HtmlProperties.CheckBoxIndeterminate) {
4053
+ this.isIndeterminate = this.el.nativeElement.indeterminate = command.obj1;
4054
+ }
4055
+ }
4056
+ handleThreeState() {
4057
+ let value = '';
4058
+ let prevCheckedValue = this.task.getValue(this.magicDirective.id, this.magicDirective.rowId);
4059
+ const checkbox = this.el.nativeElement;
4060
+ if (this.isIndeterminate) {
4061
+ checkbox.checked = false;
4062
+ checkbox.indeterminate = false;
4063
+ value = 'unchecked';
4064
+ }
4065
+ else if (prevCheckedValue) {
4066
+ checkbox.checked = false;
4067
+ checkbox.indeterminate = true;
4068
+ value = 'indeterminate';
4069
+ }
4070
+ else if (!prevCheckedValue) {
4071
+ checkbox.checked = true;
4072
+ checkbox.indeterminate = false;
4073
+ value = 'checked';
4074
+ }
4075
+ this.magicDirective.task.onCheckChanged(value, this.magicDirective.id, +this.magicDirective.rowId);
4076
+ }
4077
+ ngOnDestroy() {
4078
+ if (this.subscribeRefreshDom !== null)
4079
+ this.subscribeRefreshDom.unsubscribe();
4002
4080
  }
4003
4081
  }
4004
- CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective)); };
4082
+ CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(TaskMagicService)); };
4005
4083
  CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirective, selectors: [["input", "type", "checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function CheckboxMagicDirective_HostBindings(rf, ctx) {
4006
4084
  if (rf & 1) {
4007
4085
  i0.ɵɵlistener("change", function CheckboxMagicDirective_change_HostBindingHandler($event) { return ctx.onChange($event); });
4008
4086
  }
4009
- } });
4087
+ }, inputs: { threeState: "threeState" } });
4010
4088
  (function () {
4011
4089
  (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CheckboxMagicDirective, [{
4012
4090
  type: Directive,
@@ -4015,7 +4093,9 @@ CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirec
4015
4093
  input[type=checkbox][magic]:not([noFormControl])
4016
4094
  `,
4017
4095
  }]
4018
- }], function () { return [{ type: MagicDirective }]; }, { onChange: [{
4096
+ }], function () { return [{ type: MagicDirective }, { type: i0.ElementRef }, { type: TaskMagicService }]; }, { threeState: [{
4097
+ type: Input
4098
+ }], onChange: [{
4019
4099
  type: HostListener,
4020
4100
  args: ['change', ['$event']]
4021
4101
  }] });