mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
CE-1115 pre-QA commit on saved report UI, including:
- redo pivots so editing is in a modal - add form validations - field rules for clearing one field when another changes
This commit is contained in:
50
src/qqq/models/fields/FieldRules.ts
Normal file
50
src/qqq/models/fields/FieldRules.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* QQQ - Low-code Application Framework for Engineers.
|
||||
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
* contact@kingsrook.com
|
||||
* https://github.com/Kingsrook/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
export interface FieldRule
|
||||
{
|
||||
trigger: FieldRuleTrigger;
|
||||
sourceField: string;
|
||||
action: FieldRuleAction;
|
||||
targetField: string;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
export enum FieldRuleTrigger
|
||||
{
|
||||
ON_CHANGE = "ON_CHANGE"
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
export enum FieldRuleAction
|
||||
{
|
||||
CLEAR_TARGET_FIELD = "CLEAR_TARGET_FIELD"
|
||||
}
|
@ -19,6 +19,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** put a unique key value in all the pivot table group-by and value objects,
|
||||
@ -30,7 +32,7 @@ export class PivotObjectKey
|
||||
|
||||
static next(): number
|
||||
{
|
||||
return PivotObjectKey.value++
|
||||
return PivotObjectKey.value++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +58,7 @@ export class PivotTableGroupBy
|
||||
|
||||
constructor()
|
||||
{
|
||||
this.key = PivotObjectKey.next()
|
||||
this.key = PivotObjectKey.next();
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,43 +75,85 @@ export class PivotTableValue
|
||||
|
||||
constructor()
|
||||
{
|
||||
this.key = PivotObjectKey.next()
|
||||
this.key = PivotObjectKey.next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Functions that can be appplied to pivot table values
|
||||
** Functions that can be applied to pivot table values
|
||||
*******************************************************************************/
|
||||
export enum PivotTableFunction
|
||||
{
|
||||
AVERAGE = "AVERAGE",
|
||||
SUM = "SUM",
|
||||
COUNT = "COUNT",
|
||||
COUNT_NUMS = "COUNT_NUMS",
|
||||
AVERAGE = "AVERAGE",
|
||||
MAX = "MAX",
|
||||
MIN = "MIN",
|
||||
PRODUCT = "PRODUCT",
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// i don't think we have a useful version of count-nums --unless we allowed //
|
||||
// it on string fields, and counted if they looked like numbers? is that //
|
||||
// what we should do? ... leave here as zombie in case that request comes in //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// COUNT_NUMS = "COUNT_NUMS",
|
||||
|
||||
STD_DEV = "STD_DEV",
|
||||
STD_DEVP = "STD_DEVP",
|
||||
SUM = "SUM",
|
||||
VAR = "VAR",
|
||||
VARP = "VARP",
|
||||
}
|
||||
|
||||
const allFunctions = [
|
||||
PivotTableFunction.SUM,
|
||||
PivotTableFunction.COUNT,
|
||||
PivotTableFunction.AVERAGE,
|
||||
PivotTableFunction.MAX,
|
||||
PivotTableFunction.MIN,
|
||||
PivotTableFunction.PRODUCT,
|
||||
// PivotTableFunction.COUNT_NUMS,
|
||||
PivotTableFunction.STD_DEV,
|
||||
PivotTableFunction.STD_DEVP,
|
||||
PivotTableFunction.VAR,
|
||||
PivotTableFunction.VARP
|
||||
];
|
||||
|
||||
const onlyCount = [PivotTableFunction.COUNT];
|
||||
|
||||
const functionsForDates = [PivotTableFunction.COUNT, PivotTableFunction.AVERAGE, PivotTableFunction.MAX, PivotTableFunction.MIN];
|
||||
|
||||
export const functionsPerFieldType: { [type: string]: PivotTableFunction[] } = {};
|
||||
functionsPerFieldType[QFieldType.STRING] = onlyCount;
|
||||
functionsPerFieldType[QFieldType.BOOLEAN] = onlyCount;
|
||||
functionsPerFieldType[QFieldType.BLOB] = onlyCount;
|
||||
functionsPerFieldType[QFieldType.HTML] = onlyCount;
|
||||
functionsPerFieldType[QFieldType.PASSWORD] = onlyCount;
|
||||
functionsPerFieldType[QFieldType.TEXT] = onlyCount;
|
||||
functionsPerFieldType[QFieldType.TIME] = onlyCount;
|
||||
|
||||
functionsPerFieldType[QFieldType.INTEGER] = allFunctions;
|
||||
functionsPerFieldType[QFieldType.DECIMAL] = allFunctions;
|
||||
// functionsPerFieldType[QFieldType.LONG] = allFunctions;
|
||||
|
||||
functionsPerFieldType[QFieldType.DATE] = functionsForDates;
|
||||
functionsPerFieldType[QFieldType.DATE_TIME] = functionsForDates;
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
// labels for pivot table functions //
|
||||
//////////////////////////////////////
|
||||
export const pivotTableFunctionLabels =
|
||||
{
|
||||
"SUM": "Sum",
|
||||
"COUNT": "Count",
|
||||
"AVERAGE": "Average",
|
||||
"COUNT": "Count Values (COUNTA)",
|
||||
"COUNT_NUMS": "Count Numbers (COUNT)",
|
||||
"MAX": "Max",
|
||||
"MIN": "Min",
|
||||
"PRODUCT": "Product",
|
||||
// "COUNT_NUMS": "Count Numbers",
|
||||
"STD_DEV": "StdDev",
|
||||
"STD_DEVP": "StdDevp",
|
||||
"SUM": "Sum",
|
||||
"VAR": "Var",
|
||||
"VARP": "Varp"
|
||||
};
|
||||
|
@ -80,11 +80,19 @@ export default class QQueryColumns
|
||||
fields.forEach((field) =>
|
||||
{
|
||||
const column: Column = {name: field.name, isVisible: true, width: DataGridUtils.getColumnWidthForField(field, table)};
|
||||
queryColumns.columns.push(column);
|
||||
|
||||
if (field.name == table.primaryKeyField)
|
||||
{
|
||||
column.pinned = "left";
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// insert the primary key field after __check__ //
|
||||
//////////////////////////////////////////////////
|
||||
queryColumns.columns.splice(1, 0, column);
|
||||
}
|
||||
else
|
||||
{
|
||||
queryColumns.columns.push(column);
|
||||
}
|
||||
});
|
||||
|
||||
@ -392,6 +400,42 @@ export default class QQueryColumns
|
||||
return columnVisibilityModel;
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** sort the columns list, so that pinned columns go to the front (left) or back
|
||||
** (right) of the list.
|
||||
*******************************************************************************/
|
||||
public sortColumnsFixingPinPositions = (): void =>
|
||||
{
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// do a sort to push pinned-left columns to the start, and pinned-right columns to the end //
|
||||
// and otherwise, leave everything alone //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
this.columns = this.columns.sort((a: Column, b: Column) =>
|
||||
{
|
||||
if(a.pinned == "left" && b.pinned != "left")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if(b.pinned == "left" && a.pinned != "left")
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(a.pinned == "right" && b.pinned != "right")
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(b.pinned == "right" && a.pinned != "right")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user