@visns-studio/visns-components 5.15.17 → 5.15.19

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
@@ -24,7 +24,7 @@
24
24
  "array-move": "^4.0.0",
25
25
  "awesome-debounce-promise": "^2.1.0",
26
26
  "browser-image-compression": "^2.0.2",
27
- "dayjs": "^1.11.14",
27
+ "dayjs": "^1.11.15",
28
28
  "fabric": "^6.7.1",
29
29
  "file-saver": "^2.0.5",
30
30
  "framer-motion": "^12.23.12",
@@ -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.17",
97
+ "version": "5.15.19",
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
@@ -711,8 +750,8 @@ const shouldHideField = (fieldName, fieldType) => {
711
750
  const name = fieldName.toLowerCase();
712
751
  const type = fieldType.toLowerCase();
713
752
 
714
- // Hide foreign keys (except main 'id')
715
- if (name.endsWith('_id') && name !== 'id') return true;
753
+ // Hide foreign keys and primary key IDs (confusing for non-dev users)
754
+ if (name.endsWith('_id') || name === 'id') return true;
716
755
 
717
756
  // Hide UUIDs
718
757
  if (name.includes('uuid') || type.includes('uuid')) return true;
@@ -1942,11 +1981,32 @@ const GenericReportImproved = ({
1942
1981
  // Add join relationship
1943
1982
  const addJoin = (joinData) => {
1944
1983
  const newJoin = { ...joinData, availableColumns: [] };
1945
- setJoins([...joins, newJoin]);
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 joined table if not already available
2007
+ // Fetch columns for the pivot table if not already available
1948
2008
  if (!availableTables.includes(joinData.targetTable)) {
1949
- setAvailableTables([...availableTables, joinData.targetTable]);
2009
+ setAvailableTables(prev => [...prev, joinData.targetTable]);
1950
2010
  fetchJoinColumns(joinData.targetTable, joins.length); // Use current joins.length as index
1951
2011
  }
1952
2012
  };
@@ -4033,7 +4093,17 @@ const GenericReportImproved = ({
4033
4093
  </div>
4034
4094
 
4035
4095
  <div className={styles.tableColumnSections}>
4036
- {allAvailableColumns.map((tableData) => (
4096
+ {allAvailableColumns
4097
+ .filter((tableData) => {
4098
+ // Hide table sections with 0 visible fields
4099
+ const visibleFieldsCount = tableData.columns.filter((col) =>
4100
+ tableData.isMainTable
4101
+ ? !shouldHideField(col.name, col.type) || showHiddenFields
4102
+ : !shouldHideField(col.name, col.type)
4103
+ ).length;
4104
+ return visibleFieldsCount > 0;
4105
+ })
4106
+ .map((tableData) => (
4037
4107
  <div
4038
4108
  key={tableData.tableName}
4039
4109
  className={styles.tableSection}
@@ -5279,6 +5349,11 @@ const GenericReportImproved = ({
5279
5349
  joins.forEach((join) => {
5280
5350
  if (join.availableColumns) {
5281
5351
  join.availableColumns.forEach((col) => {
5352
+ // Use enhanced pivot field naming for pivot tables
5353
+ const columnName = join.isPivotRelationship
5354
+ ? formatPivotFieldName(col.name, join.targetTable, joins, definition)
5355
+ : formatName(col.name);
5356
+
5282
5357
  allColumns.push({
5283
5358
  table: join.targetTable,
5284
5359
  tableName: getTableDisplayName(
@@ -5286,7 +5361,7 @@ const GenericReportImproved = ({
5286
5361
  definition
5287
5362
  ),
5288
5363
  column: col.name,
5289
- columnName: formatName(col.name),
5364
+ columnName: columnName,
5290
5365
  type: col.type,
5291
5366
  });
5292
5367
  });
@@ -5341,6 +5416,11 @@ const GenericReportImproved = ({
5341
5416
  if (join.availableColumns) {
5342
5417
  join.availableColumns.forEach((col) => {
5343
5418
  if (!shouldHideField(col.name, col.type)) {
5419
+ // Use enhanced pivot field naming for pivot tables
5420
+ const columnName = join.isPivotRelationship
5421
+ ? formatPivotFieldName(col.name, join.targetTable, joins, definition)
5422
+ : formatName(col.name);
5423
+
5344
5424
  allColumns.push({
5345
5425
  table: join.targetTable,
5346
5426
  tableName: getTableDisplayName(
@@ -5348,7 +5428,7 @@ const GenericReportImproved = ({
5348
5428
  definition
5349
5429
  ),
5350
5430
  column: col.name,
5351
- columnName: formatName(col.name),
5431
+ columnName: columnName,
5352
5432
  type: col.type,
5353
5433
  });
5354
5434
  }
@@ -759,7 +759,7 @@ select:not(:placeholder-shown) + .fi__span {
759
759
  bottom: 20px;
760
760
  right: 20px;
761
761
  width: auto;
762
- z-index: 5;
762
+ z-index: 50;
763
763
 
764
764
  button {
765
765
  display: block;