@sankhyalabs/ezui 1.1.132 → 1.1.133

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.
@@ -112101,8 +112101,11 @@ class DataSource {
112101
112101
 
112102
112102
  class AgGridController {
112103
112103
  constructor(enterprise) {
112104
+ this.DEFAULT_ROW_HEIGHT = 25;
112104
112105
  this._menuItems = [];
112105
112106
  this._idAttribName = "__record__id__";
112107
+ this._isFirstRecordOfPage = true;
112108
+ this._isLastRecordOfPage = false;
112106
112109
  this._enterprise = enterprise;
112107
112110
  }
112108
112111
  getSort() {
@@ -112130,7 +112133,9 @@ class AgGridController {
112130
112133
  this._pageSize = options.pageSize;
112131
112134
  this._serverURL = options.serverURL;
112132
112135
  this._dataUnit = options.dataUnit;
112133
- this._dataUnit.sortingProvider = this;
112136
+ if (this._dataUnit) {
112137
+ this._dataUnit.sortingProvider = this;
112138
+ }
112134
112139
  this._dataSource = new DataSource(this._dataUnit, this._serverURL);
112135
112140
  this._gridOptions = {
112136
112141
  localeText: gridTerms,
@@ -112139,7 +112144,7 @@ class AgGridController {
112139
112144
  rowSelection: this._multipleSelection ? "multiple" : "single",
112140
112145
  serverSideDatasource: this._dataSource,
112141
112146
  sortingOrder: ['desc', 'asc', null],
112142
- getRowNodeId: (params) => typeof params === "string" ? params : params[this._idAttribName],
112147
+ getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
112143
112148
  getMainMenuItems: (params) => {
112144
112149
  const column = params.column;
112145
112150
  const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
@@ -112149,14 +112154,12 @@ class AgGridController {
112149
112154
  }));
112150
112155
  return items;
112151
112156
  },
112152
- getRowHeight: () => {
112153
- //FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
112154
- //apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
112155
- //dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
112156
- //Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
112157
- //tamanho errado, isso afeta menos o componente.
112158
- return 25;
112159
- }
112157
+ //FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
112158
+ //apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
112159
+ //dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
112160
+ //Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
112161
+ //tamanho errado, isso afeta menos o componente.
112162
+ rowHeight: this.DEFAULT_ROW_HEIGHT
112160
112163
  };
112161
112164
  this.setOptionsEvents(this._gridOptions);
112162
112165
  this.setOptionsPagination(this._gridOptions);
@@ -112179,16 +112182,17 @@ class AgGridController {
112179
112182
  opt.onPaginationChanged = () => this.onPaginationChange();
112180
112183
  opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
112181
112184
  opt.onDragStopped = evt => this.onCallStateChange("columnMovedEnd", evt);
112182
- opt.onViewportChanged = () => {
112183
- if (this._dataUnit) {
112184
- this.selectRows(this._dataUnit.getSelection());
112185
- }
112186
- };
112185
+ }
112186
+ syncSelection() {
112187
+ if (this._dataUnit) {
112188
+ this.selectRows(this._dataUnit.getSelection());
112189
+ }
112187
112190
  }
112188
112191
  setOptionsPagination(opt) {
112189
112192
  opt.pagination = (this._pageSize > -1);
112190
112193
  opt.paginationPageSize = this._pageSize;
112191
112194
  opt.cacheBlockSize = this._pageSize;
112195
+ opt.maxBlocksInCache = 1;
112192
112196
  }
112193
112197
  setOptionsSupress(opt) {
112194
112198
  opt.suppressDragLeaveHidesColumns = true;
@@ -112224,7 +112228,7 @@ class AgGridController {
112224
112228
  if (this._grid === undefined) {
112225
112229
  throw new Error("Erro interno: Grid ainda não inicializado.");
112226
112230
  }
112227
- this._gridOptions.api.refreshServerSideStore({});
112231
+ this._gridOptions.api.refreshServerSideStore({ purge: true });
112228
112232
  }
112229
112233
  changeValues(changes, rowIds) {
112230
112234
  if (this._grid === undefined) {
@@ -112361,6 +112365,75 @@ class AgGridController {
112361
112365
  this.goToPage(0);
112362
112366
  this._gridOptions.api.refreshServerSideStore({ purge: true });
112363
112367
  }
112368
+ isLastOfPage() {
112369
+ return this._isLastRecordOfPage;
112370
+ }
112371
+ isFirstOfPage() {
112372
+ return this._isFirstRecordOfPage;
112373
+ }
112374
+ previousRecord() {
112375
+ const pagination = this.getPaginationStatus();
112376
+ if (this._isFirstRecordOfPage && pagination.hasPrevious) {
112377
+ this.previousPage();
112378
+ }
112379
+ else {
112380
+ if (this._dataUnit) {
112381
+ this._dataUnit.previousRecord();
112382
+ }
112383
+ else {
112384
+ const node = this._gridOptions.api.getSelectedNodes()[0];
112385
+ this.setSelectedIndex(node.rowIndex - 1);
112386
+ }
112387
+ }
112388
+ }
112389
+ nextRecord() {
112390
+ const pagination = this.getPaginationStatus();
112391
+ if (this._isLastRecordOfPage && pagination.hasNext) {
112392
+ this.nextPage();
112393
+ }
112394
+ else {
112395
+ if (this._dataUnit) {
112396
+ this._dataUnit.nextRecord();
112397
+ }
112398
+ else {
112399
+ const node = this._gridOptions.api.getSelectedNodes()[0];
112400
+ this.setSelectedIndex(node.rowIndex + 1);
112401
+ }
112402
+ }
112403
+ }
112404
+ setSelectedIndex(index) {
112405
+ var _a;
112406
+ (_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
112407
+ }
112408
+ hasPreviousRecord() {
112409
+ const pagination = this.getPaginationStatus();
112410
+ if (this._isFirstRecordOfPage) {
112411
+ return pagination.hasPrevious;
112412
+ }
112413
+ else {
112414
+ if (this._dataUnit) {
112415
+ return this._dataUnit.hasPrevious();
112416
+ }
112417
+ else {
112418
+ return pagination.hasPrevious || this._gridOptions.api.getSelectedRows()[0].rowIndex > 0;
112419
+ }
112420
+ }
112421
+ }
112422
+ hasNextRecord() {
112423
+ const pagination = this.getPaginationStatus();
112424
+ if (this._isLastRecordOfPage) {
112425
+ return pagination.hasNext;
112426
+ }
112427
+ else {
112428
+ if (this._dataUnit) {
112429
+ return this._dataUnit.hasNext() || this.getPaginationStatus().hasNext;
112430
+ }
112431
+ else {
112432
+ const api = this._gridOptions.api;
112433
+ return pagination.hasNext || api.getSelectedRows()[0].rowIndex < api.getDisplayedRowCount();
112434
+ }
112435
+ }
112436
+ }
112364
112437
  buildColDef(source) {
112365
112438
  return {
112366
112439
  headerName: source.label,
@@ -112442,31 +112515,44 @@ class AgGridController {
112442
112515
  return false;
112443
112516
  }
112444
112517
  onSelectionChange(e) {
112518
+ const selectedNodes = e.api.getSelectedNodes();
112519
+ if (selectedNodes.length > 0) {
112520
+ this._isFirstRecordOfPage = selectedNodes[0].rowIndex === e.api.getFirstDisplayedRow();
112521
+ this._isLastRecordOfPage = selectedNodes[0].rowIndex === e.api.getLastDisplayedRow();
112522
+ }
112445
112523
  if (this._selectionChangeCallback) {
112446
- this._selectionChangeCallback(e.api.getSelectedRows());
112524
+ this._selectionChangeCallback({
112525
+ selection: e.api.getSelectedRows(),
112526
+ isFirstOfPage: this._isFirstRecordOfPage,
112527
+ isLastOfPage: this._isLastRecordOfPage
112528
+ });
112447
112529
  }
112448
112530
  }
112449
112531
  onPaginationChange() {
112532
+ this.syncSelection();
112450
112533
  if (this._paginationChangeCallback) {
112451
112534
  if (this._gridOptions.api) {
112452
- const api = this._gridOptions.api;
112453
- const currentPage = api.paginationGetCurrentPage();
112454
- const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
112455
- const pageSize = api.paginationGetPageSize();
112456
- const totalRows = api.paginationGetRowCount();
112457
- const pageStart = currentPage * pageSize + 1;
112458
- const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
112459
- this._paginationChangeCallback({
112460
- hasPrevious: currentPage > 0,
112461
- hasNext: !isLastPage,
112462
- currentPage: currentPage + 1,
112463
- pageStart,
112464
- pageEnd,
112465
- totalRows
112466
- });
112535
+ this._paginationChangeCallback(this.getPaginationStatus());
112467
112536
  }
112468
112537
  }
112469
112538
  }
112539
+ getPaginationStatus() {
112540
+ const api = this._gridOptions.api;
112541
+ const currentPage = api.paginationGetCurrentPage();
112542
+ const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
112543
+ const pageSize = api.paginationGetPageSize();
112544
+ const totalRows = api.paginationGetRowCount();
112545
+ const pageStart = currentPage * pageSize + 1;
112546
+ const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
112547
+ return {
112548
+ hasPrevious: currentPage > 0,
112549
+ hasNext: !isLastPage,
112550
+ currentPage: currentPage + 1,
112551
+ pageStart,
112552
+ pageEnd,
112553
+ totalRows
112554
+ };
112555
+ }
112470
112556
  onRowDoubleClick(evt) {
112471
112557
  if (this._doubleClickCallBack) {
112472
112558
  this._doubleClickCallBack(evt.data);
@@ -112490,10 +112576,6 @@ class DataUnitBridge {
112490
112576
  const { records } = action.payload;
112491
112577
  this._gridController.removeRows(records);
112492
112578
  break;
112493
- case Action.RECORDS_ADDED:
112494
- case Action.RECORDS_COPIED:
112495
- this._gridController.addRows(action.payload);
112496
- break;
112497
112579
  case Action.EDITION_CANCELED:
112498
112580
  case Action.DATA_SAVED:
112499
112581
  this._gridController.refresh();
@@ -112502,6 +112584,10 @@ class DataUnitBridge {
112502
112584
  const { selection } = action.payload;
112503
112585
  this._gridController.selectRows(selection);
112504
112586
  break;
112587
+ case Action.NEXT_SELECTED:
112588
+ case Action.PREVIOUS_SELECTED:
112589
+ this._gridController.selectRows(this._dataUnit.getSelection());
112590
+ break;
112505
112591
  case Action.DATA_CHANGED:
112506
112592
  const changes = Object.assign({}, action.payload);
112507
112593
  delete changes.records;
@@ -112607,6 +112693,74 @@ let EzGrid$1 = class extends HTMLElement$1 {
112607
112693
  async quickFilter(term) {
112608
112694
  this._gridController.quickFilter(term);
112609
112695
  }
112696
+ /**
112697
+ * Método para fazer um filtro rápido na grid.
112698
+ */
112699
+ async nextPage() {
112700
+ this._gridController.nextPage();
112701
+ }
112702
+ /**
112703
+ * Método para fazer um filtro rápido na grid.
112704
+ */
112705
+ async previousPage() {
112706
+ this._gridController.previousPage();
112707
+ }
112708
+ /**
112709
+ * Método para fazer um filtro rápido na grid.
112710
+ */
112711
+ async hasNextPage() {
112712
+ return new Promise(resolve => {
112713
+ resolve(this._navigationHasNext);
112714
+ });
112715
+ }
112716
+ /**
112717
+ * Método para fazer um filtro rápido na grid.
112718
+ */
112719
+ async hasPreviousPage() {
112720
+ return new Promise(resolve => {
112721
+ resolve(this._navigationHasPrevious);
112722
+ });
112723
+ }
112724
+ /**
112725
+ * Método para verificar se o registro selecionado é o ultimo da página.
112726
+ */
112727
+ async isLastOfPage() {
112728
+ return new Promise(resolve => {
112729
+ resolve(this._gridController.isLastOfPage());
112730
+ });
112731
+ }
112732
+ /**
112733
+ * Método para verificar se o registro selecionado é o primeiro da página.
112734
+ */
112735
+ async isFirstOfPage() {
112736
+ return new Promise(resolve => {
112737
+ resolve(this._gridController.isFirstOfPage());
112738
+ });
112739
+ }
112740
+ /**
112741
+ * Método para navegar para o proxímo registro da grid.
112742
+ */
112743
+ async nextRecord() {
112744
+ this._gridController.nextRecord();
112745
+ }
112746
+ /**
112747
+ * Método para navegar para o registro anterior da grid.
112748
+ */
112749
+ async previousRecord() {
112750
+ this._gridController.previousRecord();
112751
+ }
112752
+ /**
112753
+ * Método para verificar se existem proximos registros.
112754
+ */
112755
+ async hasNextRecord() {
112756
+ return Promise.resolve(this._gridController.hasNextRecord());
112757
+ }
112758
+ /**
112759
+ * Método para verificar se existem registros anteriores.
112760
+ */
112761
+ async hasPreviousRecord() {
112762
+ return Promise.resolve(this._gridController.hasPreviousRecord());
112763
+ }
112610
112764
  componentWillLoad() {
112611
112765
  if (this.dataUnit) {
112612
112766
  this._dataUnitBridge = new DataUnitBridge(this._gridController, this.dataUnit);
@@ -112679,7 +112833,7 @@ let EzGrid$1 = class extends HTMLElement$1 {
112679
112833
  componentDidLoad() {
112680
112834
  this._gridController.initDatagrid(this._container, {
112681
112835
  onColumnStateChange: (type, state, info) => this.onColumnStateChange(type, state, info),
112682
- onSelectionChange: (selection) => this.ezSelectionChange.emit(selection),
112836
+ onSelectionChange: (state) => this.ezSelectionChange.emit(state.selection),
112683
112837
  onPaginationChange: (status) => {
112684
112838
  this._navigationHasPrevious = status.hasPrevious;
112685
112839
  this._navigationHasNext = status.hasNext;
@@ -112713,8 +112867,8 @@ let EzGrid$1 = class extends HTMLElement$1 {
112713
112867
  }
112714
112868
  return [
112715
112869
  h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium" }, h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, `${this._navigationFirstRow}-${this._navigationLastRow}`), ` de ${this._navigationTotalRows}`),
112716
- h("ez-button", { size: "small", iconName: "chevron-left", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasPrevious, onClick: () => this._gridController.previousPage(), label: "P\u00E1gina anterior" }),
112717
- h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this._gridController.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
112870
+ h("ez-button", { size: "small", iconName: "chevron-left", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasPrevious, onClick: () => this.previousPage(), label: "P\u00E1gina anterior" }),
112871
+ h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
112718
112872
  ];
112719
112873
  }
112720
112874
  applyConfig(config) {
@@ -110059,8 +110059,11 @@ class DataSource {
110059
110059
 
110060
110060
  class AgGridController {
110061
110061
  constructor(enterprise) {
110062
+ this.DEFAULT_ROW_HEIGHT = 25;
110062
110063
  this._menuItems = [];
110063
110064
  this._idAttribName = "__record__id__";
110065
+ this._isFirstRecordOfPage = true;
110066
+ this._isLastRecordOfPage = false;
110064
110067
  this._enterprise = enterprise;
110065
110068
  }
110066
110069
  getSort() {
@@ -110088,7 +110091,9 @@ class AgGridController {
110088
110091
  this._pageSize = options.pageSize;
110089
110092
  this._serverURL = options.serverURL;
110090
110093
  this._dataUnit = options.dataUnit;
110091
- this._dataUnit.sortingProvider = this;
110094
+ if (this._dataUnit) {
110095
+ this._dataUnit.sortingProvider = this;
110096
+ }
110092
110097
  this._dataSource = new DataSource(this._dataUnit, this._serverURL);
110093
110098
  this._gridOptions = {
110094
110099
  localeText: gridTerms,
@@ -110097,7 +110102,7 @@ class AgGridController {
110097
110102
  rowSelection: this._multipleSelection ? "multiple" : "single",
110098
110103
  serverSideDatasource: this._dataSource,
110099
110104
  sortingOrder: ['desc', 'asc', null],
110100
- getRowNodeId: (params) => typeof params === "string" ? params : params[this._idAttribName],
110105
+ getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
110101
110106
  getMainMenuItems: (params) => {
110102
110107
  const column = params.column;
110103
110108
  const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
@@ -110107,14 +110112,12 @@ class AgGridController {
110107
110112
  }));
110108
110113
  return items;
110109
110114
  },
110110
- getRowHeight: () => {
110111
- //FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
110112
- //apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
110113
- //dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
110114
- //Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
110115
- //tamanho errado, isso afeta menos o componente.
110116
- return 25;
110117
- }
110115
+ //FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
110116
+ //apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
110117
+ //dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
110118
+ //Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
110119
+ //tamanho errado, isso afeta menos o componente.
110120
+ rowHeight: this.DEFAULT_ROW_HEIGHT
110118
110121
  };
110119
110122
  this.setOptionsEvents(this._gridOptions);
110120
110123
  this.setOptionsPagination(this._gridOptions);
@@ -110137,16 +110140,17 @@ class AgGridController {
110137
110140
  opt.onPaginationChanged = () => this.onPaginationChange();
110138
110141
  opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
110139
110142
  opt.onDragStopped = evt => this.onCallStateChange("columnMovedEnd", evt);
110140
- opt.onViewportChanged = () => {
110141
- if (this._dataUnit) {
110142
- this.selectRows(this._dataUnit.getSelection());
110143
- }
110144
- };
110143
+ }
110144
+ syncSelection() {
110145
+ if (this._dataUnit) {
110146
+ this.selectRows(this._dataUnit.getSelection());
110147
+ }
110145
110148
  }
110146
110149
  setOptionsPagination(opt) {
110147
110150
  opt.pagination = (this._pageSize > -1);
110148
110151
  opt.paginationPageSize = this._pageSize;
110149
110152
  opt.cacheBlockSize = this._pageSize;
110153
+ opt.maxBlocksInCache = 1;
110150
110154
  }
110151
110155
  setOptionsSupress(opt) {
110152
110156
  opt.suppressDragLeaveHidesColumns = true;
@@ -110182,7 +110186,7 @@ class AgGridController {
110182
110186
  if (this._grid === undefined) {
110183
110187
  throw new Error("Erro interno: Grid ainda não inicializado.");
110184
110188
  }
110185
- this._gridOptions.api.refreshServerSideStore({});
110189
+ this._gridOptions.api.refreshServerSideStore({ purge: true });
110186
110190
  }
110187
110191
  changeValues(changes, rowIds) {
110188
110192
  if (this._grid === undefined) {
@@ -110319,6 +110323,75 @@ class AgGridController {
110319
110323
  this.goToPage(0);
110320
110324
  this._gridOptions.api.refreshServerSideStore({ purge: true });
110321
110325
  }
110326
+ isLastOfPage() {
110327
+ return this._isLastRecordOfPage;
110328
+ }
110329
+ isFirstOfPage() {
110330
+ return this._isFirstRecordOfPage;
110331
+ }
110332
+ previousRecord() {
110333
+ const pagination = this.getPaginationStatus();
110334
+ if (this._isFirstRecordOfPage && pagination.hasPrevious) {
110335
+ this.previousPage();
110336
+ }
110337
+ else {
110338
+ if (this._dataUnit) {
110339
+ this._dataUnit.previousRecord();
110340
+ }
110341
+ else {
110342
+ const node = this._gridOptions.api.getSelectedNodes()[0];
110343
+ this.setSelectedIndex(node.rowIndex - 1);
110344
+ }
110345
+ }
110346
+ }
110347
+ nextRecord() {
110348
+ const pagination = this.getPaginationStatus();
110349
+ if (this._isLastRecordOfPage && pagination.hasNext) {
110350
+ this.nextPage();
110351
+ }
110352
+ else {
110353
+ if (this._dataUnit) {
110354
+ this._dataUnit.nextRecord();
110355
+ }
110356
+ else {
110357
+ const node = this._gridOptions.api.getSelectedNodes()[0];
110358
+ this.setSelectedIndex(node.rowIndex + 1);
110359
+ }
110360
+ }
110361
+ }
110362
+ setSelectedIndex(index) {
110363
+ var _a;
110364
+ (_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
110365
+ }
110366
+ hasPreviousRecord() {
110367
+ const pagination = this.getPaginationStatus();
110368
+ if (this._isFirstRecordOfPage) {
110369
+ return pagination.hasPrevious;
110370
+ }
110371
+ else {
110372
+ if (this._dataUnit) {
110373
+ return this._dataUnit.hasPrevious();
110374
+ }
110375
+ else {
110376
+ return pagination.hasPrevious || this._gridOptions.api.getSelectedRows()[0].rowIndex > 0;
110377
+ }
110378
+ }
110379
+ }
110380
+ hasNextRecord() {
110381
+ const pagination = this.getPaginationStatus();
110382
+ if (this._isLastRecordOfPage) {
110383
+ return pagination.hasNext;
110384
+ }
110385
+ else {
110386
+ if (this._dataUnit) {
110387
+ return this._dataUnit.hasNext() || this.getPaginationStatus().hasNext;
110388
+ }
110389
+ else {
110390
+ const api = this._gridOptions.api;
110391
+ return pagination.hasNext || api.getSelectedRows()[0].rowIndex < api.getDisplayedRowCount();
110392
+ }
110393
+ }
110394
+ }
110322
110395
  buildColDef(source) {
110323
110396
  return {
110324
110397
  headerName: source.label,
@@ -110400,31 +110473,44 @@ class AgGridController {
110400
110473
  return false;
110401
110474
  }
110402
110475
  onSelectionChange(e) {
110476
+ const selectedNodes = e.api.getSelectedNodes();
110477
+ if (selectedNodes.length > 0) {
110478
+ this._isFirstRecordOfPage = selectedNodes[0].rowIndex === e.api.getFirstDisplayedRow();
110479
+ this._isLastRecordOfPage = selectedNodes[0].rowIndex === e.api.getLastDisplayedRow();
110480
+ }
110403
110481
  if (this._selectionChangeCallback) {
110404
- this._selectionChangeCallback(e.api.getSelectedRows());
110482
+ this._selectionChangeCallback({
110483
+ selection: e.api.getSelectedRows(),
110484
+ isFirstOfPage: this._isFirstRecordOfPage,
110485
+ isLastOfPage: this._isLastRecordOfPage
110486
+ });
110405
110487
  }
110406
110488
  }
110407
110489
  onPaginationChange() {
110490
+ this.syncSelection();
110408
110491
  if (this._paginationChangeCallback) {
110409
110492
  if (this._gridOptions.api) {
110410
- const api = this._gridOptions.api;
110411
- const currentPage = api.paginationGetCurrentPage();
110412
- const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
110413
- const pageSize = api.paginationGetPageSize();
110414
- const totalRows = api.paginationGetRowCount();
110415
- const pageStart = currentPage * pageSize + 1;
110416
- const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
110417
- this._paginationChangeCallback({
110418
- hasPrevious: currentPage > 0,
110419
- hasNext: !isLastPage,
110420
- currentPage: currentPage + 1,
110421
- pageStart,
110422
- pageEnd,
110423
- totalRows
110424
- });
110493
+ this._paginationChangeCallback(this.getPaginationStatus());
110425
110494
  }
110426
110495
  }
110427
110496
  }
110497
+ getPaginationStatus() {
110498
+ const api = this._gridOptions.api;
110499
+ const currentPage = api.paginationGetCurrentPage();
110500
+ const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
110501
+ const pageSize = api.paginationGetPageSize();
110502
+ const totalRows = api.paginationGetRowCount();
110503
+ const pageStart = currentPage * pageSize + 1;
110504
+ const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
110505
+ return {
110506
+ hasPrevious: currentPage > 0,
110507
+ hasNext: !isLastPage,
110508
+ currentPage: currentPage + 1,
110509
+ pageStart,
110510
+ pageEnd,
110511
+ totalRows
110512
+ };
110513
+ }
110428
110514
  onRowDoubleClick(evt) {
110429
110515
  if (this._doubleClickCallBack) {
110430
110516
  this._doubleClickCallBack(evt.data);
@@ -110448,10 +110534,6 @@ class DataUnitBridge {
110448
110534
  const { records } = action.payload;
110449
110535
  this._gridController.removeRows(records);
110450
110536
  break;
110451
- case Action.RECORDS_ADDED:
110452
- case Action.RECORDS_COPIED:
110453
- this._gridController.addRows(action.payload);
110454
- break;
110455
110537
  case Action.EDITION_CANCELED:
110456
110538
  case Action.DATA_SAVED:
110457
110539
  this._gridController.refresh();
@@ -110460,6 +110542,10 @@ class DataUnitBridge {
110460
110542
  const { selection } = action.payload;
110461
110543
  this._gridController.selectRows(selection);
110462
110544
  break;
110545
+ case Action.NEXT_SELECTED:
110546
+ case Action.PREVIOUS_SELECTED:
110547
+ this._gridController.selectRows(this._dataUnit.getSelection());
110548
+ break;
110463
110549
  case Action.DATA_CHANGED:
110464
110550
  const changes = Object.assign({}, action.payload);
110465
110551
  delete changes.records;
@@ -110564,6 +110650,74 @@ let EzGrid = class {
110564
110650
  async quickFilter(term) {
110565
110651
  this._gridController.quickFilter(term);
110566
110652
  }
110653
+ /**
110654
+ * Método para fazer um filtro rápido na grid.
110655
+ */
110656
+ async nextPage() {
110657
+ this._gridController.nextPage();
110658
+ }
110659
+ /**
110660
+ * Método para fazer um filtro rápido na grid.
110661
+ */
110662
+ async previousPage() {
110663
+ this._gridController.previousPage();
110664
+ }
110665
+ /**
110666
+ * Método para fazer um filtro rápido na grid.
110667
+ */
110668
+ async hasNextPage() {
110669
+ return new Promise(resolve => {
110670
+ resolve(this._navigationHasNext);
110671
+ });
110672
+ }
110673
+ /**
110674
+ * Método para fazer um filtro rápido na grid.
110675
+ */
110676
+ async hasPreviousPage() {
110677
+ return new Promise(resolve => {
110678
+ resolve(this._navigationHasPrevious);
110679
+ });
110680
+ }
110681
+ /**
110682
+ * Método para verificar se o registro selecionado é o ultimo da página.
110683
+ */
110684
+ async isLastOfPage() {
110685
+ return new Promise(resolve => {
110686
+ resolve(this._gridController.isLastOfPage());
110687
+ });
110688
+ }
110689
+ /**
110690
+ * Método para verificar se o registro selecionado é o primeiro da página.
110691
+ */
110692
+ async isFirstOfPage() {
110693
+ return new Promise(resolve => {
110694
+ resolve(this._gridController.isFirstOfPage());
110695
+ });
110696
+ }
110697
+ /**
110698
+ * Método para navegar para o proxímo registro da grid.
110699
+ */
110700
+ async nextRecord() {
110701
+ this._gridController.nextRecord();
110702
+ }
110703
+ /**
110704
+ * Método para navegar para o registro anterior da grid.
110705
+ */
110706
+ async previousRecord() {
110707
+ this._gridController.previousRecord();
110708
+ }
110709
+ /**
110710
+ * Método para verificar se existem proximos registros.
110711
+ */
110712
+ async hasNextRecord() {
110713
+ return Promise.resolve(this._gridController.hasNextRecord());
110714
+ }
110715
+ /**
110716
+ * Método para verificar se existem registros anteriores.
110717
+ */
110718
+ async hasPreviousRecord() {
110719
+ return Promise.resolve(this._gridController.hasPreviousRecord());
110720
+ }
110567
110721
  componentWillLoad() {
110568
110722
  if (this.dataUnit) {
110569
110723
  this._dataUnitBridge = new DataUnitBridge(this._gridController, this.dataUnit);
@@ -110636,7 +110790,7 @@ let EzGrid = class {
110636
110790
  componentDidLoad() {
110637
110791
  this._gridController.initDatagrid(this._container, {
110638
110792
  onColumnStateChange: (type, state, info) => this.onColumnStateChange(type, state, info),
110639
- onSelectionChange: (selection) => this.ezSelectionChange.emit(selection),
110793
+ onSelectionChange: (state) => this.ezSelectionChange.emit(state.selection),
110640
110794
  onPaginationChange: (status) => {
110641
110795
  this._navigationHasPrevious = status.hasPrevious;
110642
110796
  this._navigationHasNext = status.hasNext;
@@ -110670,8 +110824,8 @@ let EzGrid = class {
110670
110824
  }
110671
110825
  return [
110672
110826
  h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium" }, h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, `${this._navigationFirstRow}-${this._navigationLastRow}`), ` de ${this._navigationTotalRows}`),
110673
- h("ez-button", { size: "small", iconName: "chevron-left", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasPrevious, onClick: () => this._gridController.previousPage(), label: "P\u00E1gina anterior" }),
110674
- h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this._gridController.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
110827
+ h("ez-button", { size: "small", iconName: "chevron-left", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasPrevious, onClick: () => this.previousPage(), label: "P\u00E1gina anterior" }),
110828
+ h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
110675
110829
  ];
110676
110830
  }
110677
110831
  applyConfig(config) {