@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';
@@ -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,79 @@ 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.el.nativeElement.indeterminate = this.isIndeterminate = this.task.getProperty(this.magicDirective.id, HtmlProperties.CheckBoxIndeterminate, this.magicDirective.rowId);
3914
+ this.regUpdatesUI();
3915
+ }
3916
+ }
3917
+ regUpdatesUI() {
3918
+ this.subscribeRefreshDom = this.task
3919
+ .refreshDom.pipe(filter(c => this.magicDirective.IsSameElement(c)))
3920
+ .subscribe(a => {
3921
+ let command = a;
3922
+ try {
3923
+ this.handleCommand(command);
3924
+ }
3925
+ catch (ex) {
3926
+ console.dir(ex);
3927
+ }
3928
+ });
3929
+ }
3930
+ handleCommand(command) {
3931
+ if (command.CommandType == CommandType.SET_PROPERTY &&
3932
+ command.Operation == HtmlProperties.CheckBoxIndeterminate) {
3933
+ this.isIndeterminate = this.el.nativeElement.indeterminate = command.obj1;
3934
+ }
3935
+ }
3936
+ handleThreeState() {
3937
+ let value = '';
3938
+ let prevCheckedValue = this.task.getValue(this.magicDirective.id, this.magicDirective.rowId);
3939
+ const checkbox = this.el.nativeElement;
3940
+ if (this.isIndeterminate) {
3941
+ checkbox.checked = false;
3942
+ checkbox.indeterminate = false;
3943
+ value = 'unchecked';
3944
+ }
3945
+ else if (prevCheckedValue) {
3946
+ checkbox.checked = false;
3947
+ checkbox.indeterminate = true;
3948
+ value = 'indeterminate';
3949
+ }
3950
+ else if (!prevCheckedValue) {
3951
+ checkbox.checked = true;
3952
+ checkbox.indeterminate = false;
3953
+ value = 'checked';
3954
+ }
3955
+ this.magicDirective.task.onCheckChanged(value, this.magicDirective.id, +this.magicDirective.rowId);
3956
+ }
3957
+ ngOnDestroy() {
3958
+ if (this.subscribeRefreshDom !== null)
3959
+ this.subscribeRefreshDom.unsubscribe();
3882
3960
  }
3883
3961
  }
3884
- CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective)); };
3962
+ CheckboxMagicDirective.ɵfac = function CheckboxMagicDirective_Factory(t) { return new (t || CheckboxMagicDirective)(i0.ɵɵdirectiveInject(MagicDirective), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(TaskMagicService)); };
3885
3963
  CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirective, selectors: [["input", "type", "checkbox", "magic", "", 3, "noFormControl", ""]], hostBindings: function CheckboxMagicDirective_HostBindings(rf, ctx) { if (rf & 1) {
3886
3964
  i0.ɵɵlistener("change", function CheckboxMagicDirective_change_HostBindingHandler($event) { return ctx.onChange($event); });
3887
- } } });
3965
+ } }, inputs: { threeState: "threeState" } });
3888
3966
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CheckboxMagicDirective, [{
3889
3967
  type: Directive,
3890
3968
  args: [{
@@ -3892,7 +3970,9 @@ CheckboxMagicDirective.ɵdir = i0.ɵɵdefineDirective({ type: CheckboxMagicDirec
3892
3970
  input[type=checkbox][magic]:not([noFormControl])
3893
3971
  `,
3894
3972
  }]
3895
- }], function () { return [{ type: MagicDirective }]; }, { onChange: [{
3973
+ }], function () { return [{ type: MagicDirective }, { type: i0.ElementRef }, { type: TaskMagicService }]; }, { threeState: [{
3974
+ type: Input
3975
+ }], onChange: [{
3896
3976
  type: HostListener,
3897
3977
  args: ['change', ['$event']]
3898
3978
  }] }); })();