@visns-studio/visns-components 5.15.17 → 5.15.18
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/package.json
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
96
|
"name": "@visns-studio/visns-components",
|
|
97
|
-
"version": "5.15.
|
|
97
|
+
"version": "5.15.18",
|
|
98
98
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
99
99
|
"main": "src/index.js",
|
|
100
100
|
"files": [
|
|
@@ -287,6 +287,45 @@ const formatName = (name) => {
|
|
|
287
287
|
.join(' ');
|
|
288
288
|
};
|
|
289
289
|
|
|
290
|
+
// Enhanced function to format pivot field names with context from end table
|
|
291
|
+
const formatPivotFieldName = (fieldName, pivotTableName, joins, definition = null) => {
|
|
292
|
+
if (!fieldName || !pivotTableName) return formatName(fieldName);
|
|
293
|
+
|
|
294
|
+
// Find if this pivot table has an associated end table through joins
|
|
295
|
+
const pivotJoin = joins.find(join =>
|
|
296
|
+
join.targetTable === pivotTableName && join.autoIncludeEndTable
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
if (pivotJoin && pivotJoin.endTable) {
|
|
300
|
+
// Get a user-friendly name for the end table
|
|
301
|
+
const endTableDisplay = getTableDisplayName(pivotJoin.endTable, definition);
|
|
302
|
+
|
|
303
|
+
// Create contextual field names for common pivot fields
|
|
304
|
+
const contextualMappings = {
|
|
305
|
+
'area': `${endTableDisplay} Area`,
|
|
306
|
+
'duration': `${endTableDisplay} Duration`,
|
|
307
|
+
'qty': `${endTableDisplay} Quantity`,
|
|
308
|
+
'quantity': `${endTableDisplay} Quantity`,
|
|
309
|
+
'start_date': `${endTableDisplay} Start Date`,
|
|
310
|
+
'end_date': `${endTableDisplay} End Date`,
|
|
311
|
+
'detail': `${endTableDisplay} Details`,
|
|
312
|
+
'notes': `${endTableDisplay} Notes`,
|
|
313
|
+
'status': `${endTableDisplay} Status`,
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const lowercaseField = fieldName.toLowerCase();
|
|
317
|
+
if (contextualMappings[lowercaseField]) {
|
|
318
|
+
return contextualMappings[lowercaseField];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// For other fields, just prefix with end table name
|
|
322
|
+
return `${endTableDisplay} ${formatName(fieldName)}`;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Fallback to regular formatting
|
|
326
|
+
return formatName(fieldName);
|
|
327
|
+
};
|
|
328
|
+
|
|
290
329
|
// User-friendly terminology mapping
|
|
291
330
|
const friendlyTerms = {
|
|
292
331
|
// Database terms
|
|
@@ -1942,11 +1981,32 @@ const GenericReportImproved = ({
|
|
|
1942
1981
|
// Add join relationship
|
|
1943
1982
|
const addJoin = (joinData) => {
|
|
1944
1983
|
const newJoin = { ...joinData, availableColumns: [] };
|
|
1945
|
-
|
|
1984
|
+
const joinsToAdd = [newJoin];
|
|
1985
|
+
|
|
1986
|
+
// If this is a pivot relationship with auto-include end table, add both joins automatically
|
|
1987
|
+
if (joinData.autoIncludeEndTable && joinData.secondJoin) {
|
|
1988
|
+
const endTableJoin = {
|
|
1989
|
+
...joinData.secondJoin,
|
|
1990
|
+
availableColumns: [],
|
|
1991
|
+
isAutoIncludedEndTable: true
|
|
1992
|
+
};
|
|
1993
|
+
joinsToAdd.push(endTableJoin);
|
|
1994
|
+
|
|
1995
|
+
// Add end table to available tables list
|
|
1996
|
+
if (!availableTables.includes(joinData.secondJoin.targetTable)) {
|
|
1997
|
+
setAvailableTables(prev => [...prev, joinData.secondJoin.targetTable]);
|
|
1998
|
+
// Fetch columns for the end table as well
|
|
1999
|
+
setTimeout(() => {
|
|
2000
|
+
fetchJoinColumns(joinData.secondJoin.targetTable, joins.length + 1);
|
|
2001
|
+
}, 100);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
setJoins([...joins, ...joinsToAdd]);
|
|
1946
2006
|
|
|
1947
|
-
// Fetch columns for the
|
|
2007
|
+
// Fetch columns for the pivot table if not already available
|
|
1948
2008
|
if (!availableTables.includes(joinData.targetTable)) {
|
|
1949
|
-
setAvailableTables([...
|
|
2009
|
+
setAvailableTables(prev => [...prev, joinData.targetTable]);
|
|
1950
2010
|
fetchJoinColumns(joinData.targetTable, joins.length); // Use current joins.length as index
|
|
1951
2011
|
}
|
|
1952
2012
|
};
|
|
@@ -5279,6 +5339,11 @@ const GenericReportImproved = ({
|
|
|
5279
5339
|
joins.forEach((join) => {
|
|
5280
5340
|
if (join.availableColumns) {
|
|
5281
5341
|
join.availableColumns.forEach((col) => {
|
|
5342
|
+
// Use enhanced pivot field naming for pivot tables
|
|
5343
|
+
const columnName = join.isPivotRelationship
|
|
5344
|
+
? formatPivotFieldName(col.name, join.targetTable, joins, definition)
|
|
5345
|
+
: formatName(col.name);
|
|
5346
|
+
|
|
5282
5347
|
allColumns.push({
|
|
5283
5348
|
table: join.targetTable,
|
|
5284
5349
|
tableName: getTableDisplayName(
|
|
@@ -5286,7 +5351,7 @@ const GenericReportImproved = ({
|
|
|
5286
5351
|
definition
|
|
5287
5352
|
),
|
|
5288
5353
|
column: col.name,
|
|
5289
|
-
columnName:
|
|
5354
|
+
columnName: columnName,
|
|
5290
5355
|
type: col.type,
|
|
5291
5356
|
});
|
|
5292
5357
|
});
|
|
@@ -5341,6 +5406,11 @@ const GenericReportImproved = ({
|
|
|
5341
5406
|
if (join.availableColumns) {
|
|
5342
5407
|
join.availableColumns.forEach((col) => {
|
|
5343
5408
|
if (!shouldHideField(col.name, col.type)) {
|
|
5409
|
+
// Use enhanced pivot field naming for pivot tables
|
|
5410
|
+
const columnName = join.isPivotRelationship
|
|
5411
|
+
? formatPivotFieldName(col.name, join.targetTable, joins, definition)
|
|
5412
|
+
: formatName(col.name);
|
|
5413
|
+
|
|
5344
5414
|
allColumns.push({
|
|
5345
5415
|
table: join.targetTable,
|
|
5346
5416
|
tableName: getTableDisplayName(
|
|
@@ -5348,7 +5418,7 @@ const GenericReportImproved = ({
|
|
|
5348
5418
|
definition
|
|
5349
5419
|
),
|
|
5350
5420
|
column: col.name,
|
|
5351
|
-
columnName:
|
|
5421
|
+
columnName: columnName,
|
|
5352
5422
|
type: col.type,
|
|
5353
5423
|
});
|
|
5354
5424
|
}
|