@trudb/tru-common-lib 0.2.108 → 0.2.110
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.
|
@@ -5952,10 +5952,12 @@ class TruDataGridCellRenderer {
|
|
|
5952
5952
|
|
|
5953
5953
|
class TruDataGridClipboard {
|
|
5954
5954
|
util;
|
|
5955
|
+
uiNotification;
|
|
5955
5956
|
tableName = null;
|
|
5956
5957
|
rowData = [];
|
|
5957
|
-
constructor(util) {
|
|
5958
|
+
constructor(util, uiNotification) {
|
|
5958
5959
|
this.util = util;
|
|
5960
|
+
this.uiNotification = uiNotification;
|
|
5959
5961
|
}
|
|
5960
5962
|
copiedRows = (tableName, rowData) => {
|
|
5961
5963
|
this.tableName = tableName;
|
|
@@ -5964,9 +5966,38 @@ class TruDataGridClipboard {
|
|
|
5964
5966
|
getCopiedRows = () => {
|
|
5965
5967
|
return this.rowData;
|
|
5966
5968
|
};
|
|
5967
|
-
paste = (
|
|
5969
|
+
paste = (config, selectedRoows) => {
|
|
5970
|
+
if (this.tableName !== config.tableName) {
|
|
5971
|
+
this.uiNotification.error('Clipboard data does not match the current table name: ' + this.tableName + ' vs ' + config.tableName);
|
|
5972
|
+
return;
|
|
5973
|
+
}
|
|
5974
|
+
if (selectedRoows && selectedRoows.length !== this.rowData.length) {
|
|
5975
|
+
this.uiNotification.error('Clipboard data does not match the number of selected rows: ' + this.rowData.length + ' vs ' + selectedRoows.length);
|
|
5976
|
+
return;
|
|
5977
|
+
}
|
|
5978
|
+
if (this.rowData.length) {
|
|
5979
|
+
this.rowData.forEach((row, index) => {
|
|
5980
|
+
let newEntity = config.resultConfig.entityType.createEntity();
|
|
5981
|
+
let properties = row.entityType.getPropertyNames();
|
|
5982
|
+
properties
|
|
5983
|
+
.filter((propertyName) => {
|
|
5984
|
+
return propertyName !== 'Ref' &&
|
|
5985
|
+
propertyName !== config.resultConfig.entityType.name + 'Ref' &&
|
|
5986
|
+
!this.util.isLowerCase(propertyName.charAt(0));
|
|
5987
|
+
})
|
|
5988
|
+
.forEach((propertyName) => {
|
|
5989
|
+
if (typeof newEntity.setProperty !== 'undefined')
|
|
5990
|
+
newEntity.setProperty(propertyName, row.getProperty(propertyName));
|
|
5991
|
+
});
|
|
5992
|
+
selectedRoows[index].setData(newEntity);
|
|
5993
|
+
});
|
|
5994
|
+
}
|
|
5968
5995
|
};
|
|
5969
5996
|
insertRowsAtTop = (dataContext, config, addEntity) => {
|
|
5997
|
+
if (this.tableName !== config.tableName) {
|
|
5998
|
+
this.uiNotification.error('Clipboard data does not match the current table name: ' + this.tableName + ' vs ' + config.tableName);
|
|
5999
|
+
return;
|
|
6000
|
+
}
|
|
5970
6001
|
if (this.rowData.length) {
|
|
5971
6002
|
this.rowData.forEach((row) => {
|
|
5972
6003
|
let newEntity = dataContext.entityAccess().add(config.resultConfig.entityType);
|
|
@@ -5985,7 +6016,7 @@ class TruDataGridClipboard {
|
|
|
5985
6016
|
});
|
|
5986
6017
|
}
|
|
5987
6018
|
};
|
|
5988
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, deps: [{ token: TruUtil }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6019
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, deps: [{ token: TruUtil }, { token: TruUiNotification }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5989
6020
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, providedIn: 'root' });
|
|
5990
6021
|
}
|
|
5991
6022
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, decorators: [{
|
|
@@ -5993,7 +6024,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
|
|
|
5993
6024
|
args: [{
|
|
5994
6025
|
providedIn: 'root',
|
|
5995
6026
|
}]
|
|
5996
|
-
}], ctorParameters: () => [{ type: TruUtil }] });
|
|
6027
|
+
}], ctorParameters: () => [{ type: TruUtil }, { type: TruUiNotification }] });
|
|
5997
6028
|
|
|
5998
6029
|
class TruDataGridPkeyCellRenderer {
|
|
5999
6030
|
dataContext;
|
|
@@ -6031,22 +6062,11 @@ class TruDataGridPkeyCellRenderer {
|
|
|
6031
6062
|
let selectedRows = this.params.api.getSelectedRows();
|
|
6032
6063
|
if (selectedRows.length) {
|
|
6033
6064
|
let copiedRowData = selectedRows.map((row) => row.$entity);
|
|
6034
|
-
this.dataGridClipboard.copiedRows(
|
|
6065
|
+
this.dataGridClipboard.copiedRows(this.params.context.grid.config.tableName, copiedRowData);
|
|
6035
6066
|
}
|
|
6036
6067
|
};
|
|
6037
6068
|
onPaste = (event) => {
|
|
6038
|
-
|
|
6039
|
-
copiedRowData.forEach((row) => {
|
|
6040
|
-
let properties = row.entityType.getPropertyNames();
|
|
6041
|
-
properties
|
|
6042
|
-
.filter((propertyName) => {
|
|
6043
|
-
return propertyName !== 'Ref' &&
|
|
6044
|
-
propertyName !== row.entityType.name + 'Ref' &&
|
|
6045
|
-
!this.util.isLowerCase(propertyName.charAt(0));
|
|
6046
|
-
}).forEach((propertyName) => {
|
|
6047
|
-
console.log(propertyName);
|
|
6048
|
-
});
|
|
6049
|
-
});
|
|
6069
|
+
this.dataGridClipboard.paste(this.params.context.grid.config, this.params.api.getSelectedRows());
|
|
6050
6070
|
};
|
|
6051
6071
|
onInsertAtTop = (event) => {
|
|
6052
6072
|
this.dataGridClipboard.insertRowsAtTop(this.dataContext, this.params.context.grid.config, this.params.context.grid.addEntity);
|