@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.
@@ -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';
@@ -740,6 +740,11 @@ class GuiInteractiveExecutor {
740
740
  }
741
741
  else if (this.task.isTableControl(this.command.controlName))
742
742
  val = this.task.getValue(this.command.controlName, guiRowId.toString());
743
+ if (this.command._boolVal) {
744
+ const indeterminate = this.task.getProperty(this.command.controlName, HtmlProperties.CheckBoxIndeterminate, guiRowId.toString());
745
+ if (indeterminate)
746
+ val = null;
747
+ }
743
748
  val = this.task.ConvertValToNative(this.command.controlName, guiRowId, val);
744
749
  this.command._mgValue.obj = val;
745
750
  }
@@ -1767,7 +1772,8 @@ class TaskMagicService {
1767
1772
  case CommandType.SET_PROPERTY:
1768
1773
  this.handleSetProperty(command, isTableChild);
1769
1774
  if (command.Operation == HtmlProperties.ReadOnly ||
1770
- command.Operation == HtmlProperties.ItemsList)
1775
+ command.Operation == HtmlProperties.ItemsList ||
1776
+ command.Operation == HtmlProperties.CheckBoxIndeterminate)
1771
1777
  this.refreshDom.next(command);
1772
1778
  break;
1773
1779
  case CommandType.PROP_SET_USER_PROPERTY:
@@ -2007,6 +2013,16 @@ class TaskMagicService {
2007
2013
  if (typeof (event) == 'boolean') {
2008
2014
  guiEvent.Value = event;
2009
2015
  }
2016
+ else if (typeof (event) == 'string') {
2017
+ if (event == "unchecked") {
2018
+ guiEvent.Value = false;
2019
+ }
2020
+ else if (event == 'indeterminate')
2021
+ guiEvent.Value = null;
2022
+ else if (event == 'checked') {
2023
+ guiEvent.Value = true;
2024
+ }
2025
+ }
2010
2026
  else {
2011
2027
  if (typeof event.target === 'undefined')
2012
2028
  guiEvent.Value = (event).checked;
@@ -3874,17 +3890,78 @@ ErrorMagicComponent.ɵcmp = i0.ɵɵdefineComponent({ type: ErrorMagicComponent,
3874
3890
  }] }); })();
3875
3891
 
3876
3892
  class CheckboxMagicDirective {
3877
- constructor(magicDirective) {
3893
+ constructor(magicDirective, el, task) {
3878
3894
  this.magicDirective = magicDirective;
3895
+ this.el = el;
3896
+ this.task = task;
3897
+ this.threeState = false;
3898
+ this.subscribeRefreshDom = null;
3899
+ this.isIndeterminate = false;
3879
3900
  }
3880
3901
  onChange($event) {
3881
- this.magicDirective.task.onCheckChanged($event, this.magicDirective.id, +this.magicDirective.rowId);
3902
+ if (this.threeState) {
3903
+ this.handleThreeState();
3904
+ }
3905
+ else {
3906
+ this.magicDirective.task.onCheckChanged($event, this.magicDirective.id, +this.magicDirective.rowId);
3907
+ }
3908
+ }
3909
+ ngOnInit() {
3910
+ if (this.threeState) {
3911
+ let guiEvent = getGuiEventObj("setAsThreeState", this.magicDirective.id, +this.magicDirective.rowId);
3912
+ this.task.insertEvent(guiEvent);
3913
+ this.regUpdatesUI();
3914
+ }
3915
+ }
3916
+ regUpdatesUI() {
3917
+ this.subscribeRefreshDom = this.task
3918
+ .refreshDom.pipe(filter(c => this.magicDirective.IsSameElement(c)))
3919
+ .subscribe(a => {
3920
+ let command = a;
3921
+ try {
3922
+ this.handleCommand(command);
3923
+ }
3924
+ catch (ex) {
3925
+ console.dir(ex);
3926
+ }
3927
+ });
3928
+ }
3929
+ handleCommand(command) {
3930
+ if (command.CommandType == CommandType.SET_PROPERTY &&
3931
+ command.Operation == HtmlProperties.CheckBoxIndeterminate) {
3932
+ this.isIndeterminate = this.el.nativeElement.indeterminate = command.obj1;
3933
+ }
3934
+ }
3935
+ handleThreeState() {
3936
+ let value = '';
3937
+ let prevCheckedValue = this.task.getValue(this.magicDirective.id, this.magicDirective.rowId);
3938
+ const checkbox = this.el.nativeElement;
3939
+ if (this.isIndeterminate) {
3940
+ checkbox.checked = false;
3941
+ checkbox.indeterminate = false;
3942
+ value = 'unchecked';
3943
+ }
3944
+ else if (prevCheckedValue) {
3945
+ checkbox.checked = false;
3946
+ checkbox.indeterminate = true;
3947
+ value = 'indeterminate';
3948
+ }
3949
+ else if (!prevCheckedValue) {
3950
+ checkbox.checked = true;
3951
+ checkbox.indeterminate = false;
3952
+ value = 'checked';
3953
+ }
3954
+ this.magicDirective.task.onCheckChanged(value, this.magicDirective.id, +this.magicDirective.rowId);
3955
+ }
3956
+ ngOnDestroy() {
3957
+ if (this.subscribeRefreshDom !== null)
3958
+ this.subscribeRefreshDom.unsubscribe();
3882
3959
  }
3883
3960
  }
3884
- CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective)); };
3961
+ CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(TaskMagicService)); };
3885
3962
  CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirective, selectors: [["input", "type", "checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function CheckboxMagicDirective_HostBindings(rf, ctx) { if (rf & 1) {
3886
3963
  i0.ɵɵlistener("change", function CheckboxMagicDirective_change_HostBindingHandler($event) { return ctx.onChange($event); });
3887
- } } });
3964
+ } }, inputs: { threeState: "threeState" } });
3888
3965
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CheckboxMagicDirective, [{
3889
3966
  type: Directive,
3890
3967
  args: [{
@@ -3892,7 +3969,9 @@ CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirec
3892
3969
  input[type=checkbox][magic]:not([noFormControl])
3893
3970
  `,
3894
3971
  }]
3895
- }], function () { return [{ type: MagicDirective }]; }, { onChange: [{
3972
+ }], function () { return [{ type: MagicDirective }, { type: i0.ElementRef }, { type: TaskMagicService }]; }, { threeState: [{
3973
+ type: Input
3974
+ }], onChange: [{
3896
3975
  type: HostListener,
3897
3976
  args: ['change', ['$event']]
3898
3977
  }] }); })();