@zeedhi/common 1.106.1 → 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 +310 -42
- package/dist/zd-common.umd.js +309 -41
- package/package.json +2 -2
- package/types/components/zd-date/date-range.d.ts +6 -0
- package/types/components/zd-grid/grid-editable.d.ts +2 -0
- package/types/components/zd-grid/grid.d.ts +23 -1
- package/types/components/zd-input/input.d.ts +1 -1
- package/types/components/zd-input/interfaces.d.ts +1 -1
- package/types/components/zd-select/interfaces.d.ts +1 -1
- package/types/components/zd-select/select.d.ts +4 -2
- package/types/components/zd-select-multiple/select-multiple.d.ts +3 -0
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';
|
|
@@ -1900,7 +1900,9 @@ class Input extends ComponentRender {
|
|
|
1900
1900
|
/**
|
|
1901
1901
|
* Input validations.
|
|
1902
1902
|
*/
|
|
1903
|
-
this.validations = {
|
|
1903
|
+
this.validations = {
|
|
1904
|
+
required: false,
|
|
1905
|
+
};
|
|
1904
1906
|
/**
|
|
1905
1907
|
* Defines if the input should be automatically registered in the closest parent Form
|
|
1906
1908
|
*/
|
|
@@ -1983,7 +1985,10 @@ class Input extends ComponentRender {
|
|
|
1983
1985
|
* @param validations Field validations
|
|
1984
1986
|
*/
|
|
1985
1987
|
parseValidations(validations) {
|
|
1986
|
-
Object.keys(validations).forEach((name) =>
|
|
1988
|
+
Object.keys(validations).forEach((name) => {
|
|
1989
|
+
if (validations[name])
|
|
1990
|
+
this.addValidation(name, validations[name]);
|
|
1991
|
+
});
|
|
1987
1992
|
}
|
|
1988
1993
|
/**
|
|
1989
1994
|
* Adds input validation.
|
|
@@ -4373,6 +4378,7 @@ class DateRange extends TextInput {
|
|
|
4373
4378
|
this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
|
|
4374
4379
|
this.min = this.getInitValue('min', props.min, this.min);
|
|
4375
4380
|
this.max = this.getInitValue('max', props.max, this.max);
|
|
4381
|
+
this.rules.push(this.dateValidation);
|
|
4376
4382
|
this.createAccessors();
|
|
4377
4383
|
this.unitMask = this.mask;
|
|
4378
4384
|
this.initialMask = this.getInitialMask();
|
|
@@ -4472,8 +4478,14 @@ class DateRange extends TextInput {
|
|
|
4472
4478
|
}
|
|
4473
4479
|
this.value = this.internalValue; // forces value accessor to be called if necessary
|
|
4474
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
|
+
* */
|
|
4475
4487
|
isValidDateArray(format, values) {
|
|
4476
|
-
if (!values || values.length
|
|
4488
|
+
if (!values || values.length < 2)
|
|
4477
4489
|
return false;
|
|
4478
4490
|
return values.every((value) => this.isValidDate(value, format));
|
|
4479
4491
|
}
|
|
@@ -6374,9 +6386,107 @@ class Grid extends Iterable {
|
|
|
6374
6386
|
});
|
|
6375
6387
|
}
|
|
6376
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
|
+
*/
|
|
6377
6487
|
selectAll(isSelected) {
|
|
6378
6488
|
if (!this.selectable)
|
|
6379
|
-
return;
|
|
6489
|
+
return Promise.resolve();
|
|
6380
6490
|
this.selectionState = { allSelected: isSelected, except: [] };
|
|
6381
6491
|
if (!isSelected) {
|
|
6382
6492
|
this.datasource.data.forEach((row) => {
|
|
@@ -6385,15 +6495,23 @@ class Grid extends Iterable {
|
|
|
6385
6495
|
this.selectedRows.splice(index, 1);
|
|
6386
6496
|
}
|
|
6387
6497
|
});
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
if (this.callDisableSelection(row))
|
|
6392
|
-
return;
|
|
6393
|
-
const key = row[this.datasource.uniqueKey];
|
|
6394
|
-
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
6395
|
-
this.selectedRows.push(row);
|
|
6498
|
+
// se ainda existir linhas selecionadas, pergunta se deseja remover tudo.
|
|
6499
|
+
if (this.selectedRows.length) {
|
|
6500
|
+
return this.askToUnselectAll();
|
|
6396
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();
|
|
6397
6515
|
});
|
|
6398
6516
|
}
|
|
6399
6517
|
toggleRow(row) {
|
|
@@ -6602,7 +6720,39 @@ class Grid extends Iterable {
|
|
|
6602
6720
|
getColumn(name) {
|
|
6603
6721
|
return super.getColumn(name);
|
|
6604
6722
|
}
|
|
6605
|
-
}
|
|
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
|
+
});
|
|
6606
6756
|
|
|
6607
6757
|
/**
|
|
6608
6758
|
* Base class for Grid column
|
|
@@ -7099,8 +7249,7 @@ class GridEditable extends Grid {
|
|
|
7099
7249
|
}
|
|
7100
7250
|
cancelAddedRows() {
|
|
7101
7251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7102
|
-
const {
|
|
7103
|
-
const allData = this.datasource.allData || data;
|
|
7252
|
+
const { allData } = this.datasource;
|
|
7104
7253
|
Promise.resolve(allData);
|
|
7105
7254
|
for (let index = allData.length - 1; index >= 0; index -= 1) {
|
|
7106
7255
|
const row = allData[index];
|
|
@@ -7236,29 +7385,36 @@ class GridEditable extends Grid {
|
|
|
7236
7385
|
*/
|
|
7237
7386
|
addNewRow(row, position = 'end') {
|
|
7238
7387
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
data = this.datasource.allData;
|
|
7242
|
-
}
|
|
7243
|
-
else {
|
|
7244
|
-
data = this.datasource.data;
|
|
7245
|
-
}
|
|
7246
|
-
row[this.newRowIdentifier] = true;
|
|
7247
|
-
if (position === 'start') {
|
|
7248
|
-
data.unshift(row);
|
|
7249
|
-
}
|
|
7250
|
-
else {
|
|
7251
|
-
data.push(row);
|
|
7252
|
-
}
|
|
7253
|
-
const id = row[this.datasource.uniqueKey];
|
|
7254
|
-
if (id) {
|
|
7255
|
-
this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
|
|
7256
|
-
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7257
|
-
}
|
|
7388
|
+
const data = this.insertRowInDatasource(row, position);
|
|
7389
|
+
this.saveRowReference(row);
|
|
7258
7390
|
yield this.datasource.updateData(data);
|
|
7259
7391
|
this.editing = true;
|
|
7260
7392
|
});
|
|
7261
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
|
+
}
|
|
7262
7418
|
/**
|
|
7263
7419
|
* Gets the editable component name
|
|
7264
7420
|
* @param key Row unique key
|
|
@@ -9677,7 +9833,7 @@ class Select extends TextInput {
|
|
|
9677
9833
|
/* Defines if should open modal with grid to make the selection */
|
|
9678
9834
|
this.modalSelection = false;
|
|
9679
9835
|
/* Defines fields to show on modal */
|
|
9680
|
-
this.
|
|
9836
|
+
this.modalSelectionColumns = [];
|
|
9681
9837
|
this.dsSearch = {
|
|
9682
9838
|
SEARCH: (value, searchIn) => ({
|
|
9683
9839
|
searchIn: [searchIn],
|
|
@@ -9733,7 +9889,7 @@ class Select extends TextInput {
|
|
|
9733
9889
|
this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
|
|
9734
9890
|
this.closeOnScroll = this.getInitValue('closeOnScroll', props.closeOnScroll, this.closeOnScroll);
|
|
9735
9891
|
this.modalSelection = this.getInitValue('modalSelection', props.modalSelection, this.modalSelection);
|
|
9736
|
-
this.
|
|
9892
|
+
this.modalSelectionColumns = this.getInitValue('modalSelectionColumns', props.modalSelectionColumns, this.modalSelectionColumns);
|
|
9737
9893
|
if (((_a = props.datasource) === null || _a === void 0 ? void 0 : _a.type) === 'simple') {
|
|
9738
9894
|
this.dataValue = 'value';
|
|
9739
9895
|
this.dataText = this.dataText || this.dataValue;
|
|
@@ -9771,7 +9927,7 @@ class Select extends TextInput {
|
|
|
9771
9927
|
}
|
|
9772
9928
|
onMounted(element) {
|
|
9773
9929
|
super.onMounted(element);
|
|
9774
|
-
if (this.modalSelection && this.
|
|
9930
|
+
if (this.modalSelection && this.modalSelectionColumns.length) {
|
|
9775
9931
|
KeyMap.bind({
|
|
9776
9932
|
'shift+enter': {
|
|
9777
9933
|
active: true,
|
|
@@ -9786,12 +9942,14 @@ class Select extends TextInput {
|
|
|
9786
9942
|
onBeforeDestroy() {
|
|
9787
9943
|
super.onBeforeDestroy();
|
|
9788
9944
|
this.datasource.destroy();
|
|
9789
|
-
if (this.modalSelection && this.
|
|
9945
|
+
if (this.modalSelection && this.modalSelectionColumns.length) {
|
|
9790
9946
|
KeyMap.unbind({
|
|
9791
9947
|
'shift+enter': {
|
|
9792
9948
|
event: this.openModalSelection.bind(this),
|
|
9793
9949
|
},
|
|
9794
9950
|
}, this);
|
|
9951
|
+
if (this.modalSelectionObj)
|
|
9952
|
+
this.modalSelectionObj.destroy();
|
|
9795
9953
|
}
|
|
9796
9954
|
}
|
|
9797
9955
|
/**
|
|
@@ -10187,7 +10345,7 @@ class Select extends TextInput {
|
|
|
10187
10345
|
this.viewCloseMenu();
|
|
10188
10346
|
}, 200);
|
|
10189
10347
|
}
|
|
10190
|
-
|
|
10348
|
+
getModalSelectionDef() {
|
|
10191
10349
|
const modalSelectionDef = {
|
|
10192
10350
|
name: `${this.name}-modal-selection`,
|
|
10193
10351
|
persistent: true,
|
|
@@ -10203,7 +10361,7 @@ class Select extends TextInput {
|
|
|
10203
10361
|
name: `${this.name}-modal-selection-grid`,
|
|
10204
10362
|
component: 'ZdGrid',
|
|
10205
10363
|
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
|
|
10206
|
-
columns: this.
|
|
10364
|
+
columns: this.modalSelectionColumns,
|
|
10207
10365
|
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
|
|
10208
10366
|
toolbarSlot: [
|
|
10209
10367
|
{
|
|
@@ -10271,6 +10429,10 @@ class Select extends TextInput {
|
|
|
10271
10429
|
},
|
|
10272
10430
|
},
|
|
10273
10431
|
};
|
|
10432
|
+
return modalSelectionDef;
|
|
10433
|
+
}
|
|
10434
|
+
openModalSelection() {
|
|
10435
|
+
const modalSelectionDef = this.getModalSelectionDef();
|
|
10274
10436
|
if (this.modalSelectionObj)
|
|
10275
10437
|
this.modalSelectionObj.destroy();
|
|
10276
10438
|
ViewService.nextTick(() => {
|
|
@@ -10623,7 +10785,8 @@ class IterableComponentRender extends Iterable {
|
|
|
10623
10785
|
* Returns the iterable component metadata based on row data
|
|
10624
10786
|
*/
|
|
10625
10787
|
getComponentMetadata(row) {
|
|
10626
|
-
const
|
|
10788
|
+
const pattern = `${this.rowPropName}\\.([A-Za-z0-9_.]+?)`;
|
|
10789
|
+
const exp = new RegExp(`<<${pattern}>>|"<<${pattern}>>"`, 'g');
|
|
10627
10790
|
const rowExp = new RegExp(`"<<${this.rowPropName}>>"`, 'g');
|
|
10628
10791
|
const metadata = JSON.stringify(this.componentMetadata)
|
|
10629
10792
|
.replace(rowExp, JSON.stringify(row))
|
|
@@ -10635,6 +10798,8 @@ class IterableComponentRender extends Iterable {
|
|
|
10635
10798
|
return `"${value}"`;
|
|
10636
10799
|
return value;
|
|
10637
10800
|
}
|
|
10801
|
+
if (value === undefined)
|
|
10802
|
+
return '""';
|
|
10638
10803
|
return value;
|
|
10639
10804
|
});
|
|
10640
10805
|
return JSON.parse(metadata);
|
|
@@ -12599,6 +12764,109 @@ class SelectMultiple extends Select {
|
|
|
12599
12764
|
return validation((this.checkboxAll && 'all') || testValue);
|
|
12600
12765
|
});
|
|
12601
12766
|
}
|
|
12767
|
+
confirmModalSelection() {
|
|
12768
|
+
const grid = Metadata.getInstance(`${this.name}-modal-selection-grid`);
|
|
12769
|
+
this.setValue(grid.selectedRows);
|
|
12770
|
+
this.hideModalSelection();
|
|
12771
|
+
setTimeout(() => {
|
|
12772
|
+
if (this.viewCloseMenu)
|
|
12773
|
+
this.viewCloseMenu();
|
|
12774
|
+
}, 200);
|
|
12775
|
+
}
|
|
12776
|
+
getModalSelectionDef() {
|
|
12777
|
+
const modalSelectionDef = {
|
|
12778
|
+
name: `${this.name}-modal-selection`,
|
|
12779
|
+
persistent: true,
|
|
12780
|
+
escKeydownStop: false,
|
|
12781
|
+
children: [
|
|
12782
|
+
{
|
|
12783
|
+
name: `${this.name}-modal-selection-content-container`,
|
|
12784
|
+
component: 'ZdContainer',
|
|
12785
|
+
scrollView: true,
|
|
12786
|
+
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-content-container',
|
|
12787
|
+
children: [
|
|
12788
|
+
{
|
|
12789
|
+
name: `${this.name}-modal-selection-grid`,
|
|
12790
|
+
component: 'ZdGrid',
|
|
12791
|
+
selectable: true,
|
|
12792
|
+
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
|
|
12793
|
+
columns: this.modalSelectionColumns,
|
|
12794
|
+
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
|
|
12795
|
+
toolbarSlot: [
|
|
12796
|
+
{
|
|
12797
|
+
name: `${this.name}-modal-selection-title`,
|
|
12798
|
+
component: 'ZdText',
|
|
12799
|
+
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
12800
|
+
text: this.label,
|
|
12801
|
+
tag: 'h3',
|
|
12802
|
+
},
|
|
12803
|
+
{
|
|
12804
|
+
name: `${this.name}-modal-selection-spacer`,
|
|
12805
|
+
component: 'VSpacer',
|
|
12806
|
+
},
|
|
12807
|
+
{
|
|
12808
|
+
name: `${this.name}-modal-selection_gridSearch`,
|
|
12809
|
+
component: 'ZdSearch',
|
|
12810
|
+
cssClass: 'zd-grid-search',
|
|
12811
|
+
autofocus: true,
|
|
12812
|
+
},
|
|
12813
|
+
],
|
|
12814
|
+
},
|
|
12815
|
+
],
|
|
12816
|
+
},
|
|
12817
|
+
{
|
|
12818
|
+
name: `${this.name}-modal-selection-footer-container`,
|
|
12819
|
+
component: 'ZdContainer',
|
|
12820
|
+
cssClass: 'zd-pa-0',
|
|
12821
|
+
children: [
|
|
12822
|
+
{
|
|
12823
|
+
name: `${this.name}-modal-selection-footer`,
|
|
12824
|
+
component: 'ZdFooter',
|
|
12825
|
+
color: 'transparent',
|
|
12826
|
+
padless: true,
|
|
12827
|
+
rightSlot: [
|
|
12828
|
+
{
|
|
12829
|
+
name: `${this.name}-modal-selection-cancelButton`,
|
|
12830
|
+
component: 'ZdButton',
|
|
12831
|
+
label: 'CANCEL',
|
|
12832
|
+
keyMap: {
|
|
12833
|
+
esc: {
|
|
12834
|
+
event: this.hideModalSelection.bind(this),
|
|
12835
|
+
focus: true,
|
|
12836
|
+
visible: true,
|
|
12837
|
+
input: true,
|
|
12838
|
+
stop: true,
|
|
12839
|
+
},
|
|
12840
|
+
},
|
|
12841
|
+
outline: true,
|
|
12842
|
+
events: {
|
|
12843
|
+
click: this.hideModalSelection.bind(this),
|
|
12844
|
+
},
|
|
12845
|
+
},
|
|
12846
|
+
{
|
|
12847
|
+
name: `${this.name}-modal-selection-confirmButton`,
|
|
12848
|
+
component: 'ZdButton',
|
|
12849
|
+
label: 'OK',
|
|
12850
|
+
outline: false,
|
|
12851
|
+
events: {
|
|
12852
|
+
click: this.confirmModalSelection.bind(this),
|
|
12853
|
+
},
|
|
12854
|
+
},
|
|
12855
|
+
],
|
|
12856
|
+
},
|
|
12857
|
+
],
|
|
12858
|
+
},
|
|
12859
|
+
],
|
|
12860
|
+
events: {
|
|
12861
|
+
onShow: () => {
|
|
12862
|
+
const grid = Metadata.getInstance(`${this.name}-modal-selection-grid`);
|
|
12863
|
+
grid.selectedRows = this.selectedValue;
|
|
12864
|
+
grid.datasource.currentRow = {};
|
|
12865
|
+
},
|
|
12866
|
+
},
|
|
12867
|
+
};
|
|
12868
|
+
return modalSelectionDef;
|
|
12869
|
+
}
|
|
12602
12870
|
}
|
|
12603
12871
|
|
|
12604
12872
|
/**
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -1907,7 +1907,9 @@
|
|
|
1907
1907
|
/**
|
|
1908
1908
|
* Input validations.
|
|
1909
1909
|
*/
|
|
1910
|
-
this.validations = {
|
|
1910
|
+
this.validations = {
|
|
1911
|
+
required: false,
|
|
1912
|
+
};
|
|
1911
1913
|
/**
|
|
1912
1914
|
* Defines if the input should be automatically registered in the closest parent Form
|
|
1913
1915
|
*/
|
|
@@ -1990,7 +1992,10 @@
|
|
|
1990
1992
|
* @param validations Field validations
|
|
1991
1993
|
*/
|
|
1992
1994
|
parseValidations(validations) {
|
|
1993
|
-
Object.keys(validations).forEach((name) =>
|
|
1995
|
+
Object.keys(validations).forEach((name) => {
|
|
1996
|
+
if (validations[name])
|
|
1997
|
+
this.addValidation(name, validations[name]);
|
|
1998
|
+
});
|
|
1994
1999
|
}
|
|
1995
2000
|
/**
|
|
1996
2001
|
* Adds input validation.
|
|
@@ -4380,6 +4385,7 @@
|
|
|
4380
4385
|
this.helperValue = this.getInitValue('helperValue', props.helperValue, this.helperValue);
|
|
4381
4386
|
this.min = this.getInitValue('min', props.min, this.min);
|
|
4382
4387
|
this.max = this.getInitValue('max', props.max, this.max);
|
|
4388
|
+
this.rules.push(this.dateValidation);
|
|
4383
4389
|
this.createAccessors();
|
|
4384
4390
|
this.unitMask = this.mask;
|
|
4385
4391
|
this.initialMask = this.getInitialMask();
|
|
@@ -4479,8 +4485,14 @@
|
|
|
4479
4485
|
}
|
|
4480
4486
|
this.value = this.internalValue; // forces value accessor to be called if necessary
|
|
4481
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
|
+
* */
|
|
4482
4494
|
isValidDateArray(format, values) {
|
|
4483
|
-
if (!values || values.length
|
|
4495
|
+
if (!values || values.length < 2)
|
|
4484
4496
|
return false;
|
|
4485
4497
|
return values.every((value) => this.isValidDate(value, format));
|
|
4486
4498
|
}
|
|
@@ -6381,9 +6393,107 @@
|
|
|
6381
6393
|
});
|
|
6382
6394
|
}
|
|
6383
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
|
+
*/
|
|
6384
6494
|
selectAll(isSelected) {
|
|
6385
6495
|
if (!this.selectable)
|
|
6386
|
-
return;
|
|
6496
|
+
return Promise.resolve();
|
|
6387
6497
|
this.selectionState = { allSelected: isSelected, except: [] };
|
|
6388
6498
|
if (!isSelected) {
|
|
6389
6499
|
this.datasource.data.forEach((row) => {
|
|
@@ -6392,15 +6502,23 @@
|
|
|
6392
6502
|
this.selectedRows.splice(index, 1);
|
|
6393
6503
|
}
|
|
6394
6504
|
});
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
if (this.callDisableSelection(row))
|
|
6399
|
-
return;
|
|
6400
|
-
const key = row[this.datasource.uniqueKey];
|
|
6401
|
-
if (key && this.selectedRows.indexOf(row) === -1) {
|
|
6402
|
-
this.selectedRows.push(row);
|
|
6505
|
+
// se ainda existir linhas selecionadas, pergunta se deseja remover tudo.
|
|
6506
|
+
if (this.selectedRows.length) {
|
|
6507
|
+
return this.askToUnselectAll();
|
|
6403
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();
|
|
6404
6522
|
});
|
|
6405
6523
|
}
|
|
6406
6524
|
toggleRow(row) {
|
|
@@ -6609,7 +6727,39 @@
|
|
|
6609
6727
|
getColumn(name) {
|
|
6610
6728
|
return super.getColumn(name);
|
|
6611
6729
|
}
|
|
6612
|
-
}
|
|
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
|
+
});
|
|
6613
6763
|
|
|
6614
6764
|
/**
|
|
6615
6765
|
* Base class for Grid column
|
|
@@ -7106,8 +7256,7 @@
|
|
|
7106
7256
|
}
|
|
7107
7257
|
cancelAddedRows() {
|
|
7108
7258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7109
|
-
const {
|
|
7110
|
-
const allData = this.datasource.allData || data;
|
|
7259
|
+
const { allData } = this.datasource;
|
|
7111
7260
|
Promise.resolve(allData);
|
|
7112
7261
|
for (let index = allData.length - 1; index >= 0; index -= 1) {
|
|
7113
7262
|
const row = allData[index];
|
|
@@ -7243,29 +7392,36 @@
|
|
|
7243
7392
|
*/
|
|
7244
7393
|
addNewRow(row, position = 'end') {
|
|
7245
7394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
data = this.datasource.allData;
|
|
7249
|
-
}
|
|
7250
|
-
else {
|
|
7251
|
-
data = this.datasource.data;
|
|
7252
|
-
}
|
|
7253
|
-
row[this.newRowIdentifier] = true;
|
|
7254
|
-
if (position === 'start') {
|
|
7255
|
-
data.unshift(row);
|
|
7256
|
-
}
|
|
7257
|
-
else {
|
|
7258
|
-
data.push(row);
|
|
7259
|
-
}
|
|
7260
|
-
const id = row[this.datasource.uniqueKey];
|
|
7261
|
-
if (id) {
|
|
7262
|
-
this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
|
|
7263
|
-
this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
|
|
7264
|
-
}
|
|
7395
|
+
const data = this.insertRowInDatasource(row, position);
|
|
7396
|
+
this.saveRowReference(row);
|
|
7265
7397
|
yield this.datasource.updateData(data);
|
|
7266
7398
|
this.editing = true;
|
|
7267
7399
|
});
|
|
7268
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
|
+
}
|
|
7269
7425
|
/**
|
|
7270
7426
|
* Gets the editable component name
|
|
7271
7427
|
* @param key Row unique key
|
|
@@ -9684,7 +9840,7 @@
|
|
|
9684
9840
|
/* Defines if should open modal with grid to make the selection */
|
|
9685
9841
|
this.modalSelection = false;
|
|
9686
9842
|
/* Defines fields to show on modal */
|
|
9687
|
-
this.
|
|
9843
|
+
this.modalSelectionColumns = [];
|
|
9688
9844
|
this.dsSearch = {
|
|
9689
9845
|
SEARCH: (value, searchIn) => ({
|
|
9690
9846
|
searchIn: [searchIn],
|
|
@@ -9740,7 +9896,7 @@
|
|
|
9740
9896
|
this.dataValueOutFormName = this.getInitValue('dataValueOutFormName', props.dataValueOutFormName, this.dataValueOutFormName);
|
|
9741
9897
|
this.closeOnScroll = this.getInitValue('closeOnScroll', props.closeOnScroll, this.closeOnScroll);
|
|
9742
9898
|
this.modalSelection = this.getInitValue('modalSelection', props.modalSelection, this.modalSelection);
|
|
9743
|
-
this.
|
|
9899
|
+
this.modalSelectionColumns = this.getInitValue('modalSelectionColumns', props.modalSelectionColumns, this.modalSelectionColumns);
|
|
9744
9900
|
if (((_a = props.datasource) === null || _a === void 0 ? void 0 : _a.type) === 'simple') {
|
|
9745
9901
|
this.dataValue = 'value';
|
|
9746
9902
|
this.dataText = this.dataText || this.dataValue;
|
|
@@ -9778,7 +9934,7 @@
|
|
|
9778
9934
|
}
|
|
9779
9935
|
onMounted(element) {
|
|
9780
9936
|
super.onMounted(element);
|
|
9781
|
-
if (this.modalSelection && this.
|
|
9937
|
+
if (this.modalSelection && this.modalSelectionColumns.length) {
|
|
9782
9938
|
core.KeyMap.bind({
|
|
9783
9939
|
'shift+enter': {
|
|
9784
9940
|
active: true,
|
|
@@ -9793,12 +9949,14 @@
|
|
|
9793
9949
|
onBeforeDestroy() {
|
|
9794
9950
|
super.onBeforeDestroy();
|
|
9795
9951
|
this.datasource.destroy();
|
|
9796
|
-
if (this.modalSelection && this.
|
|
9952
|
+
if (this.modalSelection && this.modalSelectionColumns.length) {
|
|
9797
9953
|
core.KeyMap.unbind({
|
|
9798
9954
|
'shift+enter': {
|
|
9799
9955
|
event: this.openModalSelection.bind(this),
|
|
9800
9956
|
},
|
|
9801
9957
|
}, this);
|
|
9958
|
+
if (this.modalSelectionObj)
|
|
9959
|
+
this.modalSelectionObj.destroy();
|
|
9802
9960
|
}
|
|
9803
9961
|
}
|
|
9804
9962
|
/**
|
|
@@ -10194,7 +10352,7 @@
|
|
|
10194
10352
|
this.viewCloseMenu();
|
|
10195
10353
|
}, 200);
|
|
10196
10354
|
}
|
|
10197
|
-
|
|
10355
|
+
getModalSelectionDef() {
|
|
10198
10356
|
const modalSelectionDef = {
|
|
10199
10357
|
name: `${this.name}-modal-selection`,
|
|
10200
10358
|
persistent: true,
|
|
@@ -10210,7 +10368,7 @@
|
|
|
10210
10368
|
name: `${this.name}-modal-selection-grid`,
|
|
10211
10369
|
component: 'ZdGrid',
|
|
10212
10370
|
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
|
|
10213
|
-
columns: this.
|
|
10371
|
+
columns: this.modalSelectionColumns,
|
|
10214
10372
|
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
|
|
10215
10373
|
toolbarSlot: [
|
|
10216
10374
|
{
|
|
@@ -10278,6 +10436,10 @@
|
|
|
10278
10436
|
},
|
|
10279
10437
|
},
|
|
10280
10438
|
};
|
|
10439
|
+
return modalSelectionDef;
|
|
10440
|
+
}
|
|
10441
|
+
openModalSelection() {
|
|
10442
|
+
const modalSelectionDef = this.getModalSelectionDef();
|
|
10281
10443
|
if (this.modalSelectionObj)
|
|
10282
10444
|
this.modalSelectionObj.destroy();
|
|
10283
10445
|
core.ViewService.nextTick(() => {
|
|
@@ -10630,7 +10792,8 @@
|
|
|
10630
10792
|
* Returns the iterable component metadata based on row data
|
|
10631
10793
|
*/
|
|
10632
10794
|
getComponentMetadata(row) {
|
|
10633
|
-
const
|
|
10795
|
+
const pattern = `${this.rowPropName}\\.([A-Za-z0-9_.]+?)`;
|
|
10796
|
+
const exp = new RegExp(`<<${pattern}>>|"<<${pattern}>>"`, 'g');
|
|
10634
10797
|
const rowExp = new RegExp(`"<<${this.rowPropName}>>"`, 'g');
|
|
10635
10798
|
const metadata = JSON.stringify(this.componentMetadata)
|
|
10636
10799
|
.replace(rowExp, JSON.stringify(row))
|
|
@@ -10642,6 +10805,8 @@
|
|
|
10642
10805
|
return `"${value}"`;
|
|
10643
10806
|
return value;
|
|
10644
10807
|
}
|
|
10808
|
+
if (value === undefined)
|
|
10809
|
+
return '""';
|
|
10645
10810
|
return value;
|
|
10646
10811
|
});
|
|
10647
10812
|
return JSON.parse(metadata);
|
|
@@ -12606,6 +12771,109 @@
|
|
|
12606
12771
|
return validation((this.checkboxAll && 'all') || testValue);
|
|
12607
12772
|
});
|
|
12608
12773
|
}
|
|
12774
|
+
confirmModalSelection() {
|
|
12775
|
+
const grid = core.Metadata.getInstance(`${this.name}-modal-selection-grid`);
|
|
12776
|
+
this.setValue(grid.selectedRows);
|
|
12777
|
+
this.hideModalSelection();
|
|
12778
|
+
setTimeout(() => {
|
|
12779
|
+
if (this.viewCloseMenu)
|
|
12780
|
+
this.viewCloseMenu();
|
|
12781
|
+
}, 200);
|
|
12782
|
+
}
|
|
12783
|
+
getModalSelectionDef() {
|
|
12784
|
+
const modalSelectionDef = {
|
|
12785
|
+
name: `${this.name}-modal-selection`,
|
|
12786
|
+
persistent: true,
|
|
12787
|
+
escKeydownStop: false,
|
|
12788
|
+
children: [
|
|
12789
|
+
{
|
|
12790
|
+
name: `${this.name}-modal-selection-content-container`,
|
|
12791
|
+
component: 'ZdContainer',
|
|
12792
|
+
scrollView: true,
|
|
12793
|
+
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-content-container',
|
|
12794
|
+
children: [
|
|
12795
|
+
{
|
|
12796
|
+
name: `${this.name}-modal-selection-grid`,
|
|
12797
|
+
component: 'ZdGrid',
|
|
12798
|
+
selectable: true,
|
|
12799
|
+
cssClass: 'zd-my-2 zd-pa-0 zd-select-modal-selection-grid',
|
|
12800
|
+
columns: this.modalSelectionColumns,
|
|
12801
|
+
datasource: Object.assign(Object.assign({}, this.datasource.clone()), { lazyLoad: false, searchIn: undefined }),
|
|
12802
|
+
toolbarSlot: [
|
|
12803
|
+
{
|
|
12804
|
+
name: `${this.name}-modal-selection-title`,
|
|
12805
|
+
component: 'ZdText',
|
|
12806
|
+
cssStyle: `color: ${'var(--v-primary-base);'}`,
|
|
12807
|
+
text: this.label,
|
|
12808
|
+
tag: 'h3',
|
|
12809
|
+
},
|
|
12810
|
+
{
|
|
12811
|
+
name: `${this.name}-modal-selection-spacer`,
|
|
12812
|
+
component: 'VSpacer',
|
|
12813
|
+
},
|
|
12814
|
+
{
|
|
12815
|
+
name: `${this.name}-modal-selection_gridSearch`,
|
|
12816
|
+
component: 'ZdSearch',
|
|
12817
|
+
cssClass: 'zd-grid-search',
|
|
12818
|
+
autofocus: true,
|
|
12819
|
+
},
|
|
12820
|
+
],
|
|
12821
|
+
},
|
|
12822
|
+
],
|
|
12823
|
+
},
|
|
12824
|
+
{
|
|
12825
|
+
name: `${this.name}-modal-selection-footer-container`,
|
|
12826
|
+
component: 'ZdContainer',
|
|
12827
|
+
cssClass: 'zd-pa-0',
|
|
12828
|
+
children: [
|
|
12829
|
+
{
|
|
12830
|
+
name: `${this.name}-modal-selection-footer`,
|
|
12831
|
+
component: 'ZdFooter',
|
|
12832
|
+
color: 'transparent',
|
|
12833
|
+
padless: true,
|
|
12834
|
+
rightSlot: [
|
|
12835
|
+
{
|
|
12836
|
+
name: `${this.name}-modal-selection-cancelButton`,
|
|
12837
|
+
component: 'ZdButton',
|
|
12838
|
+
label: 'CANCEL',
|
|
12839
|
+
keyMap: {
|
|
12840
|
+
esc: {
|
|
12841
|
+
event: this.hideModalSelection.bind(this),
|
|
12842
|
+
focus: true,
|
|
12843
|
+
visible: true,
|
|
12844
|
+
input: true,
|
|
12845
|
+
stop: true,
|
|
12846
|
+
},
|
|
12847
|
+
},
|
|
12848
|
+
outline: true,
|
|
12849
|
+
events: {
|
|
12850
|
+
click: this.hideModalSelection.bind(this),
|
|
12851
|
+
},
|
|
12852
|
+
},
|
|
12853
|
+
{
|
|
12854
|
+
name: `${this.name}-modal-selection-confirmButton`,
|
|
12855
|
+
component: 'ZdButton',
|
|
12856
|
+
label: 'OK',
|
|
12857
|
+
outline: false,
|
|
12858
|
+
events: {
|
|
12859
|
+
click: this.confirmModalSelection.bind(this),
|
|
12860
|
+
},
|
|
12861
|
+
},
|
|
12862
|
+
],
|
|
12863
|
+
},
|
|
12864
|
+
],
|
|
12865
|
+
},
|
|
12866
|
+
],
|
|
12867
|
+
events: {
|
|
12868
|
+
onShow: () => {
|
|
12869
|
+
const grid = core.Metadata.getInstance(`${this.name}-modal-selection-grid`);
|
|
12870
|
+
grid.selectedRows = this.selectedValue;
|
|
12871
|
+
grid.datasource.currentRow = {};
|
|
12872
|
+
},
|
|
12873
|
+
},
|
|
12874
|
+
};
|
|
12875
|
+
return modalSelectionDef;
|
|
12876
|
+
}
|
|
12609
12877
|
}
|
|
12610
12878
|
|
|
12611
12879
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
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;
|
|
@@ -98,7 +98,7 @@ export declare class Input extends ComponentRender implements IInput {
|
|
|
98
98
|
/**
|
|
99
99
|
* Input validations.
|
|
100
100
|
*/
|
|
101
|
-
validations: IDictionary<IDictionary<string | number
|
|
101
|
+
validations: IDictionary<IDictionary<string | number> | boolean>;
|
|
102
102
|
/**
|
|
103
103
|
* Defines if the input should be automatically registered in the closest parent Form
|
|
104
104
|
*/
|
|
@@ -33,7 +33,7 @@ export interface IInput extends IComponentRender {
|
|
|
33
33
|
showHelper?: boolean;
|
|
34
34
|
showLabel?: boolean;
|
|
35
35
|
storePath?: string;
|
|
36
|
-
validations?: IDictionary<IDictionary<string | number
|
|
36
|
+
validations?: IDictionary<IDictionary<string | number> | boolean>;
|
|
37
37
|
value?: any;
|
|
38
38
|
autoRegister?: boolean;
|
|
39
39
|
}
|
|
@@ -4,6 +4,7 @@ import { ISelect, SearchParam } from './interfaces';
|
|
|
4
4
|
import { TextInput } from '../zd-text-input/text-input';
|
|
5
5
|
import { ISelectDataValueOutItem } from '../../utils';
|
|
6
6
|
import { IColumn } from '../zd-iterable/interfaces';
|
|
7
|
+
import { IModal } from '../zd-modal/interfaces';
|
|
7
8
|
/**
|
|
8
9
|
* Base class for Select component.
|
|
9
10
|
*/
|
|
@@ -94,7 +95,7 @@ export declare class Select extends TextInput implements ISelect {
|
|
|
94
95
|
dataValueOutFormName: string;
|
|
95
96
|
closeOnScroll: boolean;
|
|
96
97
|
modalSelection?: boolean | undefined;
|
|
97
|
-
|
|
98
|
+
modalSelectionColumns: IColumn[];
|
|
98
99
|
protected dsSearch: {
|
|
99
100
|
SEARCH: (value: any, searchIn: string) => {
|
|
100
101
|
searchIn: string[];
|
|
@@ -240,7 +241,8 @@ export declare class Select extends TextInput implements ISelect {
|
|
|
240
241
|
indexOf(search: IDictionary | string | number): number;
|
|
241
242
|
protected isFilledObj(obj: any): number | false;
|
|
242
243
|
private modalSelectionObj?;
|
|
243
|
-
|
|
244
|
+
protected hideModalSelection(): void;
|
|
244
245
|
private modalSelectionGridClick;
|
|
246
|
+
protected getModalSelectionDef(): IModal;
|
|
245
247
|
openModalSelection(): void;
|
|
246
248
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDictionary } from '@zeedhi/core';
|
|
2
2
|
import { ISelectMultiple } from './interfaces';
|
|
3
3
|
import { Select } from '../zd-select/select';
|
|
4
|
+
import { IModal } from '../zd-modal/interfaces';
|
|
4
5
|
export declare class SelectMultiple extends Select implements ISelectMultiple {
|
|
5
6
|
private selectedValue;
|
|
6
7
|
/**
|
|
@@ -112,4 +113,6 @@ export declare class SelectMultiple extends Select implements ISelectMultiple {
|
|
|
112
113
|
* Updates input rules.
|
|
113
114
|
*/
|
|
114
115
|
protected updateRules(): void;
|
|
116
|
+
private confirmModalSelection;
|
|
117
|
+
protected getModalSelectionDef(): IModal;
|
|
115
118
|
}
|