@zeedhi/common 1.107.0 → 1.107.1
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.
package/dist/zd-common.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, InstanceNotFoundError, ViewService, MemoryDatasource, URL as URL$1, Http,
|
|
1
|
+
import { AccessorManager, Event, KeyMap, MethodNotAssignedError, Metadata, Accessor, I18n, FormatterParserProvider, Validation, Mask, DatasourceFactory, Loader, Config, dayjs, Utils, DateHelper, Router, Messages, InstanceNotFoundError, ViewService, MemoryDatasource, URL as URL$1, Http, Cookie, VersionService } from '@zeedhi/core';
|
|
2
2
|
import merge from 'lodash.merge';
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
4
|
import debounce from 'lodash.debounce';
|
|
@@ -4378,6 +4378,7 @@ class DateRange extends TextInput {
|
|
|
4378
4378
|
this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
|
|
4379
4379
|
this.min = this.getInitValue('min', props.min, this.min);
|
|
4380
4380
|
this.max = this.getInitValue('max', props.max, this.max);
|
|
4381
|
+
this.rules.push(this.dateValidation);
|
|
4381
4382
|
this.createAccessors();
|
|
4382
4383
|
this.unitMask = this.mask;
|
|
4383
4384
|
this.initialMask = this.getInitialMask();
|
|
@@ -4477,8 +4478,14 @@ class DateRange extends TextInput {
|
|
|
4477
4478
|
}
|
|
4478
4479
|
this.value = this.internalValue; // forces value accessor to be called if necessary
|
|
4479
4480
|
}
|
|
4481
|
+
/**
|
|
4482
|
+
* Faz a validação do array de datas
|
|
4483
|
+
* @param format o formato da data
|
|
4484
|
+
* @param values o array de datas
|
|
4485
|
+
* @returns true se todos os valores forem validados
|
|
4486
|
+
* */
|
|
4480
4487
|
isValidDateArray(format, values) {
|
|
4481
|
-
if (!values || values.length
|
|
4488
|
+
if (!values || values.length < 2)
|
|
4482
4489
|
return false;
|
|
4483
4490
|
return values.every((value) => this.isValidDate(value, format));
|
|
4484
4491
|
}
|
|
@@ -6379,9 +6386,107 @@ class Grid extends Iterable {
|
|
|
6379
6386
|
});
|
|
6380
6387
|
}
|
|
6381
6388
|
}
|
|
6389
|
+
/**
|
|
6390
|
+
* Retorna a quantidade total de linhas selecionadas caso exista
|
|
6391
|
+
*/
|
|
6392
|
+
get pageText() {
|
|
6393
|
+
let text = super.pageText;
|
|
6394
|
+
if (this.selectedRows.length) {
|
|
6395
|
+
let translatedText = '';
|
|
6396
|
+
if (this.selectedRows.length === 1) {
|
|
6397
|
+
translatedText = I18n.translate('ROW_SELECTED');
|
|
6398
|
+
}
|
|
6399
|
+
else {
|
|
6400
|
+
translatedText = I18n.translate('ROWS_SELECTEDS');
|
|
6401
|
+
}
|
|
6402
|
+
text = `${this.selectedRows.length} ${translatedText}`;
|
|
6403
|
+
}
|
|
6404
|
+
return text;
|
|
6405
|
+
}
|
|
6406
|
+
/**
|
|
6407
|
+
* Solicita uma confirmação se os registros nas outras páginas devem ser selecionados também.
|
|
6408
|
+
* @private
|
|
6409
|
+
* @returns {Promise<boolean>} Objeto Promise quando a confirmação for feita
|
|
6410
|
+
* com parametro true se confirmado a seleção de todas páginas.
|
|
6411
|
+
*/
|
|
6412
|
+
askToSelectAll() {
|
|
6413
|
+
return new Promise((resolve) => {
|
|
6414
|
+
const buttonClick = (yes) => {
|
|
6415
|
+
DialogService.hide();
|
|
6416
|
+
resolve(yes);
|
|
6417
|
+
};
|
|
6418
|
+
if (this.datasource.allData.length === this.datasource.data.length) {
|
|
6419
|
+
resolve(false);
|
|
6420
|
+
}
|
|
6421
|
+
else {
|
|
6422
|
+
DialogService.show({
|
|
6423
|
+
name: `${this.name}-selectall-dialog`,
|
|
6424
|
+
type: 'warning',
|
|
6425
|
+
title: I18n.translate('SELECTALL'),
|
|
6426
|
+
text: I18n.translate('SELECTALL_TEXT'),
|
|
6427
|
+
buttons: [
|
|
6428
|
+
{
|
|
6429
|
+
name: 'yes',
|
|
6430
|
+
component: 'ZdButton',
|
|
6431
|
+
label: 'YES',
|
|
6432
|
+
events: { click: () => { buttonClick(true); } },
|
|
6433
|
+
outline: true,
|
|
6434
|
+
},
|
|
6435
|
+
{
|
|
6436
|
+
name: 'no',
|
|
6437
|
+
component: 'ZdButton',
|
|
6438
|
+
label: 'NO',
|
|
6439
|
+
events: { click: () => { buttonClick(false); } },
|
|
6440
|
+
},
|
|
6441
|
+
],
|
|
6442
|
+
});
|
|
6443
|
+
}
|
|
6444
|
+
});
|
|
6445
|
+
}
|
|
6446
|
+
/**
|
|
6447
|
+
* Solicita uma confirmação se os registros nas outras páginas precisam ser removidos também.
|
|
6448
|
+
* @private
|
|
6449
|
+
* @returns {Promise<void>} Objeto Promise quando a confirmação for feita.
|
|
6450
|
+
*/
|
|
6451
|
+
askToUnselectAll() {
|
|
6452
|
+
return new Promise((resolve) => {
|
|
6453
|
+
const buttonClick = (yes) => {
|
|
6454
|
+
if (yes)
|
|
6455
|
+
this.selectedRows = [];
|
|
6456
|
+
DialogService.hide();
|
|
6457
|
+
resolve();
|
|
6458
|
+
};
|
|
6459
|
+
DialogService.show({
|
|
6460
|
+
name: `${this.name}-unselectall-dialog`,
|
|
6461
|
+
type: 'warning',
|
|
6462
|
+
title: I18n.translate('UNSELECTALL'),
|
|
6463
|
+
text: I18n.translate('UNSELECTALL_TEXT'),
|
|
6464
|
+
buttons: [
|
|
6465
|
+
{
|
|
6466
|
+
name: 'yes',
|
|
6467
|
+
component: 'ZdButton',
|
|
6468
|
+
label: 'YES',
|
|
6469
|
+
events: { click: () => { buttonClick(true); } },
|
|
6470
|
+
outline: true,
|
|
6471
|
+
},
|
|
6472
|
+
{
|
|
6473
|
+
name: 'no',
|
|
6474
|
+
component: 'ZdButton',
|
|
6475
|
+
label: 'NO',
|
|
6476
|
+
events: { click: () => { buttonClick(false); } },
|
|
6477
|
+
},
|
|
6478
|
+
],
|
|
6479
|
+
});
|
|
6480
|
+
});
|
|
6481
|
+
}
|
|
6482
|
+
/**
|
|
6483
|
+
* Efetua a seleção/desseleção de todas as linhas do grid
|
|
6484
|
+
* @param {boolean} isSelected Indica se as linhas foram selecionadas ou não
|
|
6485
|
+
* @returns {Promise<void>} Objeto Promise quando a seleção/desseleção acabar de ser realizada
|
|
6486
|
+
*/
|
|
6382
6487
|
selectAll(isSelected) {
|
|
6383
6488
|
if (!this.selectable)
|
|
6384
|
-
return;
|
|
6489
|
+
return Promise.resolve();
|
|
6385
6490
|
this.selectionState = { allSelected: isSelected, except: [] };
|
|
6386
6491
|
if (!isSelected) {
|
|
6387
6492
|
this.datasource.data.forEach((row) => {
|
|
@@ -6390,15 +6495,23 @@ class Grid extends Iterable {
|
|
|
6390
6495
|
this.selectedRows.splice(index, 1);
|
|
6391
6496
|
}
|
|
6392
6497
|
});
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
if (this.callDisableSelection(row))
|
|
6397
|
-
return;
|
|
6398
|
-
const key = row[this.datasource.uniqueKey];
|
|
6399
|
-
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
6400
|
-
this.selectedRows.push(row);
|
|
6498
|
+
// se ainda existir linhas selecionadas, pergunta se deseja remover tudo.
|
|
6499
|
+
if (this.selectedRows.length) {
|
|
6500
|
+
return this.askToUnselectAll();
|
|
6401
6501
|
}
|
|
6502
|
+
return Promise.resolve();
|
|
6503
|
+
}
|
|
6504
|
+
return this.askToSelectAll().then((selectAllData) => {
|
|
6505
|
+
const dataArray = selectAllData ? this.datasource.allData : this.datasource.data;
|
|
6506
|
+
dataArray.forEach((row) => {
|
|
6507
|
+
if (this.callDisableSelection(row))
|
|
6508
|
+
return;
|
|
6509
|
+
const key = row[this.datasource.uniqueKey];
|
|
6510
|
+
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
6511
|
+
this.selectedRows.push(row);
|
|
6512
|
+
}
|
|
6513
|
+
});
|
|
6514
|
+
return Promise.resolve();
|
|
6402
6515
|
});
|
|
6403
6516
|
}
|
|
6404
6517
|
toggleRow(row) {
|
|
@@ -6607,7 +6720,39 @@ class Grid extends Iterable {
|
|
|
6607
6720
|
getColumn(name) {
|
|
6608
6721
|
return super.getColumn(name);
|
|
6609
6722
|
}
|
|
6610
|
-
}
|
|
6723
|
+
}
|
|
6724
|
+
Messages.add({
|
|
6725
|
+
'pt-BR': {
|
|
6726
|
+
translation: {
|
|
6727
|
+
ROW_SELECTED: 'linha selecionada',
|
|
6728
|
+
ROWS_SELECTEDS: 'linhas selecionadas',
|
|
6729
|
+
UNSELECTALL: 'Remover seleção',
|
|
6730
|
+
UNSELECTALL_TEXT: 'Existem linhas selecionadas em outras páginas. Deseja removê-las tambem?',
|
|
6731
|
+
SELECTALL: 'Adicionar seleção',
|
|
6732
|
+
SELECTALL_TEXT: 'Existem linhas que podem ser selecionadas em outras páginas. Deseja selecioná-las tambem?',
|
|
6733
|
+
},
|
|
6734
|
+
},
|
|
6735
|
+
'en-US': {
|
|
6736
|
+
translation: {
|
|
6737
|
+
ROW_SELECTED: 'row selected',
|
|
6738
|
+
ROWS_SELECTEDS: 'rows selected',
|
|
6739
|
+
UNSELECTALL: 'Remove selection',
|
|
6740
|
+
UNSELECTALL_TEXT: 'There are selected rows on other pages. Do you want to remove them too?',
|
|
6741
|
+
SELECTALL: 'Add selection',
|
|
6742
|
+
SELECTALL_TEXT: 'There are rows that can be selected on other pages. Do you want to select them too?',
|
|
6743
|
+
},
|
|
6744
|
+
},
|
|
6745
|
+
'es-ES': {
|
|
6746
|
+
translation: {
|
|
6747
|
+
ROW_SELECTED: 'línea seleccionada',
|
|
6748
|
+
ROWS_SELECTEDS: 'líneas seleccionadas',
|
|
6749
|
+
UNSELECTALL: 'Eliminar selección',
|
|
6750
|
+
UNSELECTALL_TEXT: 'Hay líneas seleccionadas en otras páginas. ¿Quieres eliminarlas también?',
|
|
6751
|
+
SELECTALL: 'Añadir selección',
|
|
6752
|
+
SELECTALL_TEXT: 'Hay líneas que se pueden seleccionar en otras páginas. ¿Quieres seleccionarlas también?',
|
|
6753
|
+
},
|
|
6754
|
+
},
|
|
6755
|
+
});
|
|
6611
6756
|
|
|
6612
6757
|
/**
|
|
6613
6758
|
* Base class for Grid column
|
|
@@ -7104,8 +7249,7 @@ class GridEditable extends Grid {
|
|
|
7104
7249
|
}
|
|
7105
7250
|
cancelAddedRows() {
|
|
7106
7251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7107
|
-
const {
|
|
7108
|
-
const allData = this.datasource.allData || data;
|
|
7252
|
+
const { allData } = this.datasource;
|
|
7109
7253
|
Promise.resolve(allData);
|
|
7110
7254
|
for (let index = allData.length - 1; index >= 0; index -= 1) {
|
|
7111
7255
|
const row = allData[index];
|
|
@@ -7241,29 +7385,36 @@ class GridEditable extends Grid {
|
|
|
7241
7385
|
*/
|
|
7242
7386
|
addNewRow(row, position = 'end') {
|
|
7243
7387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
data = this.datasource.allData;
|
|
7247
|
-
}
|
|
7248
|
-
else {
|
|
7249
|
-
data = this.datasource.data;
|
|
7250
|
-
}
|
|
7251
|
-
row[this.newRowIdentifier] = true;
|
|
7252
|
-
if (position === 'start') {
|
|
7253
|
-
data.unshift(row);
|
|
7254
|
-
}
|
|
7255
|
-
else {
|
|
7256
|
-
data.push(row);
|
|
7257
|
-
}
|
|
7258
|
-
const id = row[this.datasource.uniqueKey];
|
|
7259
|
-
if (id) {
|
|
7260
|
-
this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
|
|
7261
|
-
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7262
|
-
}
|
|
7388
|
+
const data = this.insertRowInDatasource(row, position);
|
|
7389
|
+
this.saveRowReference(row);
|
|
7263
7390
|
yield this.datasource.updateData(data);
|
|
7264
7391
|
this.editing = true;
|
|
7265
7392
|
});
|
|
7266
7393
|
}
|
|
7394
|
+
saveRowReference(row) {
|
|
7395
|
+
const id = row[this.datasource.uniqueKey];
|
|
7396
|
+
if (id) {
|
|
7397
|
+
this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
|
|
7398
|
+
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7401
|
+
insertRowInDatasource(row, position) {
|
|
7402
|
+
let data;
|
|
7403
|
+
if (this.datasource instanceof MemoryDatasource) {
|
|
7404
|
+
data = this.datasource.allData;
|
|
7405
|
+
}
|
|
7406
|
+
else {
|
|
7407
|
+
data = this.datasource.data;
|
|
7408
|
+
}
|
|
7409
|
+
row[this.newRowIdentifier] = true;
|
|
7410
|
+
if (position === 'start') {
|
|
7411
|
+
data.unshift(row);
|
|
7412
|
+
}
|
|
7413
|
+
else {
|
|
7414
|
+
data.push(row);
|
|
7415
|
+
}
|
|
7416
|
+
return data;
|
|
7417
|
+
}
|
|
7267
7418
|
/**
|
|
7268
7419
|
* Gets the editable component name
|
|
7269
7420
|
* @param key Row unique key
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -4385,6 +4385,7 @@
|
|
|
4385
4385
|
this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
|
|
4386
4386
|
this.min = this.getInitValue('min', props.min, this.min);
|
|
4387
4387
|
this.max = this.getInitValue('max', props.max, this.max);
|
|
4388
|
+
this.rules.push(this.dateValidation);
|
|
4388
4389
|
this.createAccessors();
|
|
4389
4390
|
this.unitMask = this.mask;
|
|
4390
4391
|
this.initialMask = this.getInitialMask();
|
|
@@ -4484,8 +4485,14 @@
|
|
|
4484
4485
|
}
|
|
4485
4486
|
this.value = this.internalValue; // forces value accessor to be called if necessary
|
|
4486
4487
|
}
|
|
4488
|
+
/**
|
|
4489
|
+
* Faz a validação do array de datas
|
|
4490
|
+
* @param format o formato da data
|
|
4491
|
+
* @param values o array de datas
|
|
4492
|
+
* @returns true se todos os valores forem validados
|
|
4493
|
+
* */
|
|
4487
4494
|
isValidDateArray(format, values) {
|
|
4488
|
-
if (!values || values.length
|
|
4495
|
+
if (!values || values.length < 2)
|
|
4489
4496
|
return false;
|
|
4490
4497
|
return values.every((value) => this.isValidDate(value, format));
|
|
4491
4498
|
}
|
|
@@ -6386,9 +6393,107 @@
|
|
|
6386
6393
|
});
|
|
6387
6394
|
}
|
|
6388
6395
|
}
|
|
6396
|
+
/**
|
|
6397
|
+
* Retorna a quantidade total de linhas selecionadas caso exista
|
|
6398
|
+
*/
|
|
6399
|
+
get pageText() {
|
|
6400
|
+
let text = super.pageText;
|
|
6401
|
+
if (this.selectedRows.length) {
|
|
6402
|
+
let translatedText = '';
|
|
6403
|
+
if (this.selectedRows.length === 1) {
|
|
6404
|
+
translatedText = core.I18n.translate('ROW_SELECTED');
|
|
6405
|
+
}
|
|
6406
|
+
else {
|
|
6407
|
+
translatedText = core.I18n.translate('ROWS_SELECTEDS');
|
|
6408
|
+
}
|
|
6409
|
+
text = `${this.selectedRows.length} ${translatedText}`;
|
|
6410
|
+
}
|
|
6411
|
+
return text;
|
|
6412
|
+
}
|
|
6413
|
+
/**
|
|
6414
|
+
* Solicita uma confirmação se os registros nas outras páginas devem ser selecionados também.
|
|
6415
|
+
* @private
|
|
6416
|
+
* @returns {Promise<boolean>} Objeto Promise quando a confirmação for feita
|
|
6417
|
+
* com parametro true se confirmado a seleção de todas páginas.
|
|
6418
|
+
*/
|
|
6419
|
+
askToSelectAll() {
|
|
6420
|
+
return new Promise((resolve) => {
|
|
6421
|
+
const buttonClick = (yes) => {
|
|
6422
|
+
DialogService.hide();
|
|
6423
|
+
resolve(yes);
|
|
6424
|
+
};
|
|
6425
|
+
if (this.datasource.allData.length === this.datasource.data.length) {
|
|
6426
|
+
resolve(false);
|
|
6427
|
+
}
|
|
6428
|
+
else {
|
|
6429
|
+
DialogService.show({
|
|
6430
|
+
name: `${this.name}-selectall-dialog`,
|
|
6431
|
+
type: 'warning',
|
|
6432
|
+
title: core.I18n.translate('SELECTALL'),
|
|
6433
|
+
text: core.I18n.translate('SELECTALL_TEXT'),
|
|
6434
|
+
buttons: [
|
|
6435
|
+
{
|
|
6436
|
+
name: 'yes',
|
|
6437
|
+
component: 'ZdButton',
|
|
6438
|
+
label: 'YES',
|
|
6439
|
+
events: { click: () => { buttonClick(true); } },
|
|
6440
|
+
outline: true,
|
|
6441
|
+
},
|
|
6442
|
+
{
|
|
6443
|
+
name: 'no',
|
|
6444
|
+
component: 'ZdButton',
|
|
6445
|
+
label: 'NO',
|
|
6446
|
+
events: { click: () => { buttonClick(false); } },
|
|
6447
|
+
},
|
|
6448
|
+
],
|
|
6449
|
+
});
|
|
6450
|
+
}
|
|
6451
|
+
});
|
|
6452
|
+
}
|
|
6453
|
+
/**
|
|
6454
|
+
* Solicita uma confirmação se os registros nas outras páginas precisam ser removidos também.
|
|
6455
|
+
* @private
|
|
6456
|
+
* @returns {Promise<void>} Objeto Promise quando a confirmação for feita.
|
|
6457
|
+
*/
|
|
6458
|
+
askToUnselectAll() {
|
|
6459
|
+
return new Promise((resolve) => {
|
|
6460
|
+
const buttonClick = (yes) => {
|
|
6461
|
+
if (yes)
|
|
6462
|
+
this.selectedRows = [];
|
|
6463
|
+
DialogService.hide();
|
|
6464
|
+
resolve();
|
|
6465
|
+
};
|
|
6466
|
+
DialogService.show({
|
|
6467
|
+
name: `${this.name}-unselectall-dialog`,
|
|
6468
|
+
type: 'warning',
|
|
6469
|
+
title: core.I18n.translate('UNSELECTALL'),
|
|
6470
|
+
text: core.I18n.translate('UNSELECTALL_TEXT'),
|
|
6471
|
+
buttons: [
|
|
6472
|
+
{
|
|
6473
|
+
name: 'yes',
|
|
6474
|
+
component: 'ZdButton',
|
|
6475
|
+
label: 'YES',
|
|
6476
|
+
events: { click: () => { buttonClick(true); } },
|
|
6477
|
+
outline: true,
|
|
6478
|
+
},
|
|
6479
|
+
{
|
|
6480
|
+
name: 'no',
|
|
6481
|
+
component: 'ZdButton',
|
|
6482
|
+
label: 'NO',
|
|
6483
|
+
events: { click: () => { buttonClick(false); } },
|
|
6484
|
+
},
|
|
6485
|
+
],
|
|
6486
|
+
});
|
|
6487
|
+
});
|
|
6488
|
+
}
|
|
6489
|
+
/**
|
|
6490
|
+
* Efetua a seleção/desseleção de todas as linhas do grid
|
|
6491
|
+
* @param {boolean} isSelected Indica se as linhas foram selecionadas ou não
|
|
6492
|
+
* @returns {Promise<void>} Objeto Promise quando a seleção/desseleção acabar de ser realizada
|
|
6493
|
+
*/
|
|
6389
6494
|
selectAll(isSelected) {
|
|
6390
6495
|
if (!this.selectable)
|
|
6391
|
-
return;
|
|
6496
|
+
return Promise.resolve();
|
|
6392
6497
|
this.selectionState = { allSelected: isSelected, except: [] };
|
|
6393
6498
|
if (!isSelected) {
|
|
6394
6499
|
this.datasource.data.forEach((row) => {
|
|
@@ -6397,15 +6502,23 @@
|
|
|
6397
6502
|
this.selectedRows.splice(index, 1);
|
|
6398
6503
|
}
|
|
6399
6504
|
});
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
if (this.callDisableSelection(row))
|
|
6404
|
-
return;
|
|
6405
|
-
const key = row[this.datasource.uniqueKey];
|
|
6406
|
-
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
6407
|
-
this.selectedRows.push(row);
|
|
6505
|
+
// se ainda existir linhas selecionadas, pergunta se deseja remover tudo.
|
|
6506
|
+
if (this.selectedRows.length) {
|
|
6507
|
+
return this.askToUnselectAll();
|
|
6408
6508
|
}
|
|
6509
|
+
return Promise.resolve();
|
|
6510
|
+
}
|
|
6511
|
+
return this.askToSelectAll().then((selectAllData) => {
|
|
6512
|
+
const dataArray = selectAllData ? this.datasource.allData : this.datasource.data;
|
|
6513
|
+
dataArray.forEach((row) => {
|
|
6514
|
+
if (this.callDisableSelection(row))
|
|
6515
|
+
return;
|
|
6516
|
+
const key = row[this.datasource.uniqueKey];
|
|
6517
|
+
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
6518
|
+
this.selectedRows.push(row);
|
|
6519
|
+
}
|
|
6520
|
+
});
|
|
6521
|
+
return Promise.resolve();
|
|
6409
6522
|
});
|
|
6410
6523
|
}
|
|
6411
6524
|
toggleRow(row) {
|
|
@@ -6614,7 +6727,39 @@
|
|
|
6614
6727
|
getColumn(name) {
|
|
6615
6728
|
return super.getColumn(name);
|
|
6616
6729
|
}
|
|
6617
|
-
}
|
|
6730
|
+
}
|
|
6731
|
+
core.Messages.add({
|
|
6732
|
+
'pt-BR': {
|
|
6733
|
+
translation: {
|
|
6734
|
+
ROW_SELECTED: 'linha selecionada',
|
|
6735
|
+
ROWS_SELECTEDS: 'linhas selecionadas',
|
|
6736
|
+
UNSELECTALL: 'Remover seleção',
|
|
6737
|
+
UNSELECTALL_TEXT: 'Existem linhas selecionadas em outras páginas. Deseja removê-las tambem?',
|
|
6738
|
+
SELECTALL: 'Adicionar seleção',
|
|
6739
|
+
SELECTALL_TEXT: 'Existem linhas que podem ser selecionadas em outras páginas. Deseja selecioná-las tambem?',
|
|
6740
|
+
},
|
|
6741
|
+
},
|
|
6742
|
+
'en-US': {
|
|
6743
|
+
translation: {
|
|
6744
|
+
ROW_SELECTED: 'row selected',
|
|
6745
|
+
ROWS_SELECTEDS: 'rows selected',
|
|
6746
|
+
UNSELECTALL: 'Remove selection',
|
|
6747
|
+
UNSELECTALL_TEXT: 'There are selected rows on other pages. Do you want to remove them too?',
|
|
6748
|
+
SELECTALL: 'Add selection',
|
|
6749
|
+
SELECTALL_TEXT: 'There are rows that can be selected on other pages. Do you want to select them too?',
|
|
6750
|
+
},
|
|
6751
|
+
},
|
|
6752
|
+
'es-ES': {
|
|
6753
|
+
translation: {
|
|
6754
|
+
ROW_SELECTED: 'línea seleccionada',
|
|
6755
|
+
ROWS_SELECTEDS: 'líneas seleccionadas',
|
|
6756
|
+
UNSELECTALL: 'Eliminar selección',
|
|
6757
|
+
UNSELECTALL_TEXT: 'Hay líneas seleccionadas en otras páginas. ¿Quieres eliminarlas también?',
|
|
6758
|
+
SELECTALL: 'Añadir selección',
|
|
6759
|
+
SELECTALL_TEXT: 'Hay líneas que se pueden seleccionar en otras páginas. ¿Quieres seleccionarlas también?',
|
|
6760
|
+
},
|
|
6761
|
+
},
|
|
6762
|
+
});
|
|
6618
6763
|
|
|
6619
6764
|
/**
|
|
6620
6765
|
* Base class for Grid column
|
|
@@ -7111,8 +7256,7 @@
|
|
|
7111
7256
|
}
|
|
7112
7257
|
cancelAddedRows() {
|
|
7113
7258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7114
|
-
const {
|
|
7115
|
-
const allData = this.datasource.allData || data;
|
|
7259
|
+
const { allData } = this.datasource;
|
|
7116
7260
|
Promise.resolve(allData);
|
|
7117
7261
|
for (let index = allData.length - 1; index >= 0; index -= 1) {
|
|
7118
7262
|
const row = allData[index];
|
|
@@ -7248,29 +7392,36 @@
|
|
|
7248
7392
|
*/
|
|
7249
7393
|
addNewRow(row, position = 'end') {
|
|
7250
7394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
data = this.datasource.allData;
|
|
7254
|
-
}
|
|
7255
|
-
else {
|
|
7256
|
-
data = this.datasource.data;
|
|
7257
|
-
}
|
|
7258
|
-
row[this.newRowIdentifier] = true;
|
|
7259
|
-
if (position === 'start') {
|
|
7260
|
-
data.unshift(row);
|
|
7261
|
-
}
|
|
7262
|
-
else {
|
|
7263
|
-
data.push(row);
|
|
7264
|
-
}
|
|
7265
|
-
const id = row[this.datasource.uniqueKey];
|
|
7266
|
-
if (id) {
|
|
7267
|
-
this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
|
|
7268
|
-
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7269
|
-
}
|
|
7395
|
+
const data = this.insertRowInDatasource(row, position);
|
|
7396
|
+
this.saveRowReference(row);
|
|
7270
7397
|
yield this.datasource.updateData(data);
|
|
7271
7398
|
this.editing = true;
|
|
7272
7399
|
});
|
|
7273
7400
|
}
|
|
7401
|
+
saveRowReference(row) {
|
|
7402
|
+
const id = row[this.datasource.uniqueKey];
|
|
7403
|
+
if (id) {
|
|
7404
|
+
this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
|
|
7405
|
+
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
insertRowInDatasource(row, position) {
|
|
7409
|
+
let data;
|
|
7410
|
+
if (this.datasource instanceof core.MemoryDatasource) {
|
|
7411
|
+
data = this.datasource.allData;
|
|
7412
|
+
}
|
|
7413
|
+
else {
|
|
7414
|
+
data = this.datasource.data;
|
|
7415
|
+
}
|
|
7416
|
+
row[this.newRowIdentifier] = true;
|
|
7417
|
+
if (position === 'start') {
|
|
7418
|
+
data.unshift(row);
|
|
7419
|
+
}
|
|
7420
|
+
else {
|
|
7421
|
+
data.push(row);
|
|
7422
|
+
}
|
|
7423
|
+
return data;
|
|
7424
|
+
}
|
|
7274
7425
|
/**
|
|
7275
7426
|
* Gets the editable component name
|
|
7276
7427
|
* @param key Row unique key
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.107.
|
|
3
|
+
"version": "1.107.1",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"lodash.times": "4.3.*",
|
|
44
44
|
"mockdate": "3.0.*"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "eb2c40935a4684224e9afc06a250c48955724d7d"
|
|
47
47
|
}
|
|
@@ -100,6 +100,12 @@ export declare class DateRange extends TextInput implements IDateRange {
|
|
|
100
100
|
protected getUpdatedMask(): string | undefined;
|
|
101
101
|
protected maskFormat(format: string): string;
|
|
102
102
|
setDateValue(displayValue: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Faz a validação do array de datas
|
|
105
|
+
* @param format o formato da data
|
|
106
|
+
* @param values o array de datas
|
|
107
|
+
* @returns true se todos os valores forem validados
|
|
108
|
+
* */
|
|
103
109
|
isValidDateArray(format: string, values?: string[]): boolean;
|
|
104
110
|
private splitValues;
|
|
105
111
|
isValidDate(value: string, format: string, strict?: boolean): boolean;
|
|
@@ -205,6 +205,8 @@ export declare class GridEditable extends Grid implements IGridEditable {
|
|
|
205
205
|
* @param position whether the new Row will be inserted at the beginning or end of the data array
|
|
206
206
|
*/
|
|
207
207
|
addNewRow(row: IDictionary, position?: 'end' | 'start'): Promise<void>;
|
|
208
|
+
protected saveRowReference(row: IDictionary<any>): void;
|
|
209
|
+
protected insertRowInDatasource(row: IDictionary<any>, position: 'end' | 'start'): IDictionary<any>[];
|
|
208
210
|
/**
|
|
209
211
|
* Gets the editable component name
|
|
210
212
|
* @param key Row unique key
|
|
@@ -207,7 +207,29 @@ export declare class Grid extends Iterable implements IGrid {
|
|
|
207
207
|
* @param element DOM Element
|
|
208
208
|
*/
|
|
209
209
|
selectAllClick(isSelected: boolean, event: Event, element: any): void;
|
|
210
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Retorna a quantidade total de linhas selecionadas caso exista
|
|
212
|
+
*/
|
|
213
|
+
get pageText(): string;
|
|
214
|
+
/**
|
|
215
|
+
* Solicita uma confirmação se os registros nas outras páginas devem ser selecionados também.
|
|
216
|
+
* @private
|
|
217
|
+
* @returns {Promise<boolean>} Objeto Promise quando a confirmação for feita
|
|
218
|
+
* com parametro true se confirmado a seleção de todas páginas.
|
|
219
|
+
*/
|
|
220
|
+
private askToSelectAll;
|
|
221
|
+
/**
|
|
222
|
+
* Solicita uma confirmação se os registros nas outras páginas precisam ser removidos também.
|
|
223
|
+
* @private
|
|
224
|
+
* @returns {Promise<void>} Objeto Promise quando a confirmação for feita.
|
|
225
|
+
*/
|
|
226
|
+
private askToUnselectAll;
|
|
227
|
+
/**
|
|
228
|
+
* Efetua a seleção/desseleção de todas as linhas do grid
|
|
229
|
+
* @param {boolean} isSelected Indica se as linhas foram selecionadas ou não
|
|
230
|
+
* @returns {Promise<void>} Objeto Promise quando a seleção/desseleção acabar de ser realizada
|
|
231
|
+
*/
|
|
232
|
+
selectAll(isSelected: boolean): Promise<void>;
|
|
211
233
|
toggleRow(row: IDictionary): void;
|
|
212
234
|
selectRow(row: IDictionary, select: boolean): void;
|
|
213
235
|
navigateLeft({ event }: IEventParam<any>): void;
|