@zeedhi/teknisa-components-vuetify 1.127.0 → 1.128.0

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.
@@ -4342,10 +4342,81 @@ let TekGridLayoutOptions = class TekGridLayoutOptions extends ZdComponentRender
4342
4342
  constructor() {
4343
4343
  super(...arguments);
4344
4344
  this.instanceType = TekGridLayoutOptions$1;
4345
+ this.updateFilterWatcher = true;
4346
+ this.updateDynamicFilterWatcher = true;
4347
+ this.applying = false;
4345
4348
  }
4346
4349
  created() {
4347
4350
  this.instance.viewApplyLayout = this.applyLayout;
4348
4351
  this.instance.viewGetCurrentLayout = this.getCurrentLayout;
4352
+ this.$nextTick(() => {
4353
+ var _a, _b;
4354
+ if ((_b = (_a = this.instance.grid) === null || _a === void 0 ? void 0 : _a.datasource) === null || _b === void 0 ? void 0 : _b.filter) {
4355
+ this.updateFilterWatcher = false;
4356
+ this.instance.grid.datasource.filter = this.createFilterProxy(this.instance.grid.datasource.filter);
4357
+ this.$nextTick(() => { this.updateFilterWatcher = true; });
4358
+ if (this.instance.grid.datasource instanceof TekRestDatasource) {
4359
+ this.updateDynamicFilterWatcher = false;
4360
+ this.instance.grid.datasource.dynamicFilter = this.createDynamicFilterProxy(this.instance.grid.datasource.dynamicFilter);
4361
+ this.$nextTick(() => { this.updateDynamicFilterWatcher = true; });
4362
+ }
4363
+ }
4364
+ });
4365
+ }
4366
+ createFilterProxy(filter) {
4367
+ const self = this;
4368
+ return new Proxy(filter, {
4369
+ set(target, prop, value) {
4370
+ if (target[prop] !== value) {
4371
+ target[prop] = value;
4372
+ self.checkFilterChanged();
4373
+ }
4374
+ return true;
4375
+ },
4376
+ });
4377
+ }
4378
+ createDynamicFilterProxy(filter) {
4379
+ const self = this;
4380
+ const handler = {
4381
+ set(target, prop, value) {
4382
+ if (target[prop] !== value) {
4383
+ target[prop] = value;
4384
+ self.checkFilterChanged();
4385
+ }
4386
+ return true;
4387
+ },
4388
+ get(target, prop) {
4389
+ const value = target[prop];
4390
+ if (prop !== '__ob__' && typeof value === 'object' && value !== null) {
4391
+ return new Proxy(value, handler);
4392
+ }
4393
+ return value;
4394
+ },
4395
+ };
4396
+ return new Proxy(filter, handler);
4397
+ }
4398
+ checkFilterChanged() {
4399
+ if (!this.applying && this.layoutHasFilter(this.instance.currentLayoutName)) {
4400
+ this.instance.layoutEdited = true;
4401
+ }
4402
+ }
4403
+ datasourceFilterChanged() {
4404
+ if (!this.updateFilterWatcher)
4405
+ return;
4406
+ this.updateFilterWatcher = false;
4407
+ this.checkFilterChanged();
4408
+ this.instance.grid.datasource.filter = this.createFilterProxy(this.instance.grid.datasource.filter);
4409
+ this.$nextTick(() => { this.updateFilterWatcher = true; });
4410
+ }
4411
+ datasourceDynamicFilterChanged() {
4412
+ if (!this.updateDynamicFilterWatcher)
4413
+ return;
4414
+ this.updateDynamicFilterWatcher = false;
4415
+ this.checkFilterChanged();
4416
+ if (this.instance.grid.datasource instanceof TekRestDatasource) {
4417
+ this.instance.grid.datasource.dynamicFilter = this.createDynamicFilterProxy(this.instance.grid.datasource.dynamicFilter);
4418
+ }
4419
+ this.$nextTick(() => { this.updateDynamicFilterWatcher = true; });
4349
4420
  }
4350
4421
  confirmLayoutClick({ component }) {
4351
4422
  const layoutName = component.value;
@@ -4367,6 +4438,7 @@ let TekGridLayoutOptions = class TekGridLayoutOptions extends ZdComponentRender
4367
4438
  const tableElement = this.getParentTable();
4368
4439
  if (!tableElement)
4369
4440
  return;
4441
+ this.applying = true;
4370
4442
  const { grid } = this.instance;
4371
4443
  const gridColumns = {};
4372
4444
  let layoutChanged = false;
@@ -4397,8 +4469,8 @@ let TekGridLayoutOptions = class TekGridLayoutOptions extends ZdComponentRender
4397
4469
  this.instance.updateLayout(layout.name, this.getCurrentLayout(layout.name));
4398
4470
  }
4399
4471
  tableElement.style.width = layout.gridWidth || 'auto';
4400
- grid.datasource.order = layout.order !== undefined ? layout.order : grid.datasource.order;
4401
- grid.datasource.filter = layout.filter !== undefined ? layout.filter : grid.datasource.filter;
4472
+ grid.datasource.order = layout.order !== undefined ? [...layout.order] : grid.datasource.order;
4473
+ grid.datasource.filter = layout.filter !== undefined ? Object.assign({}, layout.filter) : grid.datasource.filter;
4402
4474
  if (grid.datasource instanceof TekRestDatasource
4403
4475
  && layout.dynamicFilter !== undefined) {
4404
4476
  grid.datasource.dynamicFilter = this.getHelperValues(layout.dynamicFilter, layout.columns || grid.columns);
@@ -4475,6 +4547,7 @@ let TekGridLayoutOptions = class TekGridLayoutOptions extends ZdComponentRender
4475
4547
  }
4476
4548
  }
4477
4549
  this.$refs.layoutMenu.isActive = false;
4550
+ this.$nextTick(() => { this.applying = false; });
4478
4551
  }
4479
4552
  setHelperValue(column, value) {
4480
4553
  if (column instanceof TekGridColumn) {
@@ -4562,7 +4635,9 @@ let TekGridLayoutOptions = class TekGridLayoutOptions extends ZdComponentRender
4562
4635
  this.$refs.layoutMenu.isActive = false;
4563
4636
  }
4564
4637
  else {
4638
+ this.applying = true;
4565
4639
  this.instance.applyLayout(layoutName);
4640
+ this.$nextTick(() => { this.applying = false; });
4566
4641
  }
4567
4642
  }
4568
4643
  deleteLayout(event, layoutName) {
@@ -4573,6 +4648,12 @@ let TekGridLayoutOptions = class TekGridLayoutOptions extends ZdComponentRender
4573
4648
  return this.instance.layoutHasFilter(layoutName);
4574
4649
  }
4575
4650
  };
4651
+ __decorate([
4652
+ Watch('instance.grid.datasource.filter')
4653
+ ], TekGridLayoutOptions.prototype, "datasourceFilterChanged", null);
4654
+ __decorate([
4655
+ Watch('instance.grid.datasource.dynamicFilter')
4656
+ ], TekGridLayoutOptions.prototype, "datasourceDynamicFilterChanged", null);
4576
4657
  TekGridLayoutOptions = __decorate([
4577
4658
  Component
4578
4659
  ], TekGridLayoutOptions);
@@ -4342,10 +4342,81 @@
4342
4342
  constructor() {
4343
4343
  super(...arguments);
4344
4344
  this.instanceType = teknisaComponentsCommon.TekGridLayoutOptions;
4345
+ this.updateFilterWatcher = true;
4346
+ this.updateDynamicFilterWatcher = true;
4347
+ this.applying = false;
4345
4348
  }
4346
4349
  created() {
4347
4350
  this.instance.viewApplyLayout = this.applyLayout;
4348
4351
  this.instance.viewGetCurrentLayout = this.getCurrentLayout;
4352
+ this.$nextTick(() => {
4353
+ var _a, _b;
4354
+ if ((_b = (_a = this.instance.grid) === null || _a === void 0 ? void 0 : _a.datasource) === null || _b === void 0 ? void 0 : _b.filter) {
4355
+ this.updateFilterWatcher = false;
4356
+ this.instance.grid.datasource.filter = this.createFilterProxy(this.instance.grid.datasource.filter);
4357
+ this.$nextTick(() => { this.updateFilterWatcher = true; });
4358
+ if (this.instance.grid.datasource instanceof teknisaComponentsCommon.TekRestDatasource) {
4359
+ this.updateDynamicFilterWatcher = false;
4360
+ this.instance.grid.datasource.dynamicFilter = this.createDynamicFilterProxy(this.instance.grid.datasource.dynamicFilter);
4361
+ this.$nextTick(() => { this.updateDynamicFilterWatcher = true; });
4362
+ }
4363
+ }
4364
+ });
4365
+ }
4366
+ createFilterProxy(filter) {
4367
+ const self = this;
4368
+ return new Proxy(filter, {
4369
+ set(target, prop, value) {
4370
+ if (target[prop] !== value) {
4371
+ target[prop] = value;
4372
+ self.checkFilterChanged();
4373
+ }
4374
+ return true;
4375
+ },
4376
+ });
4377
+ }
4378
+ createDynamicFilterProxy(filter) {
4379
+ const self = this;
4380
+ const handler = {
4381
+ set(target, prop, value) {
4382
+ if (target[prop] !== value) {
4383
+ target[prop] = value;
4384
+ self.checkFilterChanged();
4385
+ }
4386
+ return true;
4387
+ },
4388
+ get(target, prop) {
4389
+ const value = target[prop];
4390
+ if (prop !== '__ob__' && typeof value === 'object' && value !== null) {
4391
+ return new Proxy(value, handler);
4392
+ }
4393
+ return value;
4394
+ },
4395
+ };
4396
+ return new Proxy(filter, handler);
4397
+ }
4398
+ checkFilterChanged() {
4399
+ if (!this.applying && this.layoutHasFilter(this.instance.currentLayoutName)) {
4400
+ this.instance.layoutEdited = true;
4401
+ }
4402
+ }
4403
+ datasourceFilterChanged() {
4404
+ if (!this.updateFilterWatcher)
4405
+ return;
4406
+ this.updateFilterWatcher = false;
4407
+ this.checkFilterChanged();
4408
+ this.instance.grid.datasource.filter = this.createFilterProxy(this.instance.grid.datasource.filter);
4409
+ this.$nextTick(() => { this.updateFilterWatcher = true; });
4410
+ }
4411
+ datasourceDynamicFilterChanged() {
4412
+ if (!this.updateDynamicFilterWatcher)
4413
+ return;
4414
+ this.updateDynamicFilterWatcher = false;
4415
+ this.checkFilterChanged();
4416
+ if (this.instance.grid.datasource instanceof teknisaComponentsCommon.TekRestDatasource) {
4417
+ this.instance.grid.datasource.dynamicFilter = this.createDynamicFilterProxy(this.instance.grid.datasource.dynamicFilter);
4418
+ }
4419
+ this.$nextTick(() => { this.updateDynamicFilterWatcher = true; });
4349
4420
  }
4350
4421
  confirmLayoutClick({ component }) {
4351
4422
  const layoutName = component.value;
@@ -4367,6 +4438,7 @@
4367
4438
  const tableElement = this.getParentTable();
4368
4439
  if (!tableElement)
4369
4440
  return;
4441
+ this.applying = true;
4370
4442
  const { grid } = this.instance;
4371
4443
  const gridColumns = {};
4372
4444
  let layoutChanged = false;
@@ -4397,8 +4469,8 @@
4397
4469
  this.instance.updateLayout(layout.name, this.getCurrentLayout(layout.name));
4398
4470
  }
4399
4471
  tableElement.style.width = layout.gridWidth || 'auto';
4400
- grid.datasource.order = layout.order !== undefined ? layout.order : grid.datasource.order;
4401
- grid.datasource.filter = layout.filter !== undefined ? layout.filter : grid.datasource.filter;
4472
+ grid.datasource.order = layout.order !== undefined ? [...layout.order] : grid.datasource.order;
4473
+ grid.datasource.filter = layout.filter !== undefined ? Object.assign({}, layout.filter) : grid.datasource.filter;
4402
4474
  if (grid.datasource instanceof teknisaComponentsCommon.TekRestDatasource
4403
4475
  && layout.dynamicFilter !== undefined) {
4404
4476
  grid.datasource.dynamicFilter = this.getHelperValues(layout.dynamicFilter, layout.columns || grid.columns);
@@ -4475,6 +4547,7 @@
4475
4547
  }
4476
4548
  }
4477
4549
  this.$refs.layoutMenu.isActive = false;
4550
+ this.$nextTick(() => { this.applying = false; });
4478
4551
  }
4479
4552
  setHelperValue(column, value) {
4480
4553
  if (column instanceof teknisaComponentsCommon.TekGridColumn) {
@@ -4562,7 +4635,9 @@
4562
4635
  this.$refs.layoutMenu.isActive = false;
4563
4636
  }
4564
4637
  else {
4638
+ this.applying = true;
4565
4639
  this.instance.applyLayout(layoutName);
4640
+ this.$nextTick(() => { this.applying = false; });
4566
4641
  }
4567
4642
  }
4568
4643
  deleteLayout(event, layoutName) {
@@ -4573,6 +4648,12 @@
4573
4648
  return this.instance.layoutHasFilter(layoutName);
4574
4649
  }
4575
4650
  };
4651
+ __decorate([
4652
+ vuePropertyDecorator.Watch('instance.grid.datasource.filter')
4653
+ ], TekGridLayoutOptions.prototype, "datasourceFilterChanged", null);
4654
+ __decorate([
4655
+ vuePropertyDecorator.Watch('instance.grid.datasource.dynamicFilter')
4656
+ ], TekGridLayoutOptions.prototype, "datasourceDynamicFilterChanged", null);
4576
4657
  TekGridLayoutOptions = __decorate([
4577
4658
  vuePropertyDecorator.Component
4578
4659
  ], TekGridLayoutOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/teknisa-components-vuetify",
3
- "version": "1.127.0",
3
+ "version": "1.128.0",
4
4
  "description": "Teknisa Components based on Vuetify",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -44,5 +44,5 @@
44
44
  "vue": "2.7.*",
45
45
  "vuetify": "2.6.*"
46
46
  },
47
- "gitHead": "c3bd2c897801be9129b637299a244e7a0639607a"
47
+ "gitHead": "a97c1a002d8ab3dc6159e82cb747ae42bcc550bc"
48
48
  }
@@ -6,9 +6,17 @@ import { TekGridLayoutOptions as TekGridLayoutOptionsClass } from '@zeedhi/tekni
6
6
  export default class TekGridLayoutOptions extends ZdComponentRender {
7
7
  instance: TekGridLayoutOptionsClass;
8
8
  instanceType: typeof TekGridLayoutOptionsClass;
9
+ private updateFilterWatcher;
10
+ private updateDynamicFilterWatcher;
9
11
  created(): void;
12
+ private createFilterProxy;
13
+ private createDynamicFilterProxy;
14
+ private checkFilterChanged;
15
+ datasourceFilterChanged(): void;
16
+ datasourceDynamicFilterChanged(): void;
10
17
  confirmLayoutClick({ component }: any): void;
11
18
  private datasourceDynamicFilter;
19
+ private applying;
12
20
  private applyLayout;
13
21
  private setHelperValue;
14
22
  private getHelperValues;