mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-17 12:50:43 +00:00
CE-1068 - possible-values working in dynamic form (i think!)
This commit is contained in:
@ -174,7 +174,8 @@ function QDynamicForm({formData, formLabel, bulkEditMode, bulkEditSwitchChangeHa
|
|||||||
<DynamicSelect
|
<DynamicSelect
|
||||||
tableName={field.possibleValueProps.tableName}
|
tableName={field.possibleValueProps.tableName}
|
||||||
processName={field.possibleValueProps.processName}
|
processName={field.possibleValueProps.processName}
|
||||||
fieldName={fieldName}
|
possibleValueSourceName={field.possibleValueProps.possibleValueSourceName}
|
||||||
|
fieldName={field.possibleValueProps.fieldName}
|
||||||
isEditable={field.isEditable}
|
isEditable={field.isEditable}
|
||||||
fieldLabel=""
|
fieldLabel=""
|
||||||
initialValue={values[fieldName]}
|
initialValue={values[fieldName]}
|
||||||
|
@ -172,6 +172,7 @@ class DynamicFormUtils
|
|||||||
{
|
{
|
||||||
isPossibleValue: true,
|
isPossibleValue: true,
|
||||||
tableName: tableName,
|
tableName: tableName,
|
||||||
|
fieldName: field.name,
|
||||||
initialDisplayValue: initialDisplayValue,
|
initialDisplayValue: initialDisplayValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -181,6 +182,7 @@ class DynamicFormUtils
|
|||||||
{
|
{
|
||||||
isPossibleValue: true,
|
isPossibleValue: true,
|
||||||
processName: processName,
|
processName: processName,
|
||||||
|
fieldName: field.name,
|
||||||
initialDisplayValue: initialDisplayValue,
|
initialDisplayValue: initialDisplayValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -190,6 +192,8 @@ class DynamicFormUtils
|
|||||||
{
|
{
|
||||||
isPossibleValue: true,
|
isPossibleValue: true,
|
||||||
initialDisplayValue: initialDisplayValue,
|
initialDisplayValue: initialDisplayValue,
|
||||||
|
fieldName: field.name,
|
||||||
|
possibleValueSourceName: field.possibleValueSourceName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,19 +124,15 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a processName, you must also provide a fieldName");
|
console.log("DynamicSelect - if you provide a processName, you must also provide a fieldName");
|
||||||
}
|
}
|
||||||
if(fieldName && possibleValueSourceName)
|
|
||||||
{
|
|
||||||
console.log("DynamicSelect - if you provide a fieldName and a possibleValueSourceName, the possibleValueSourceName will be ignored");
|
|
||||||
}
|
|
||||||
if(!fieldName && !possibleValueSourceName)
|
if(!fieldName && !possibleValueSourceName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - you must provide either a fieldName (and a tableName or processName) or a possibleValueSourceName");
|
console.log("DynamicSelect - you must provide either a fieldName (and a tableName or processName) or a possibleValueSourceName");
|
||||||
}
|
}
|
||||||
if(fieldName)
|
if(fieldName && !possibleValueSourceName)
|
||||||
{
|
{
|
||||||
if(!tableName || !processName)
|
if(!tableName || !processName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a fieldName, you must also provide a tableName or processName");
|
console.log("DynamicSelect - if you provide a fieldName and not a possibleValueSourceName, then you must also provide a tableName or processName");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(possibleValueSourceName)
|
if(possibleValueSourceName)
|
||||||
@ -198,7 +194,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
(async () =>
|
(async () =>
|
||||||
{
|
{
|
||||||
// console.log(`doing a search with ${searchTerm}`);
|
// console.log(`doing a search with ${searchTerm}`);
|
||||||
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, fieldName ?? possibleValueSourceName, searchTerm ?? "", null, otherValues);
|
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
||||||
|
|
||||||
if(tableMetaData == null && tableName)
|
if(tableMetaData == null && tableName)
|
||||||
{
|
{
|
||||||
@ -231,7 +227,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setOptions([]);
|
setOptions([]);
|
||||||
console.log("Refreshing possible values...");
|
console.log("Refreshing possible values...");
|
||||||
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, fieldName ?? possibleValueSourceName, searchTerm ?? "", null, otherValues);
|
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setOptions([ ...results ]);
|
setOptions([ ...results ]);
|
||||||
setOtherValuesWhenResultsWereLoaded(JSON.stringify(Object.fromEntries(otherValues)));
|
setOtherValuesWhenResultsWereLoaded(JSON.stringify(Object.fromEntries(otherValues)));
|
||||||
|
@ -99,9 +99,10 @@ export default function DynamicFormWidget({isEditable, widgetMetaData, widgetDat
|
|||||||
|
|
||||||
if(newFields.length > 0)
|
if(newFields.length > 0)
|
||||||
{
|
{
|
||||||
|
const recordOfFieldValues = widgetData.recordOfFieldValues ? new QRecord(widgetData.recordOfFieldValues) : null;
|
||||||
const {dynamicFormFields: newDynamicFormFields, formValidations: newFormValidations} = DynamicFormUtils.getFormData(newFields);
|
const {dynamicFormFields: newDynamicFormFields, formValidations: newFormValidations} = DynamicFormUtils.getFormData(newFields);
|
||||||
const defaultDisplayValues = new Map<string,string>(); // todo - seems not right?
|
const defaultDisplayValues = new Map<string,string>(); // todo - seems not right?
|
||||||
DynamicFormUtils.addPossibleValueProps(newDynamicFormFields, newFields, recordValues.tableName, null, record ? record.displayValues : defaultDisplayValues);
|
DynamicFormUtils.addPossibleValueProps(newDynamicFormFields, newFields, recordValues.tableName, null, recordOfFieldValues ? recordOfFieldValues.displayValues : defaultDisplayValues);
|
||||||
setDynamicFormFields(newDynamicFormFields)
|
setDynamicFormFields(newDynamicFormFields)
|
||||||
setFormValidations(newFormValidations)
|
setFormValidations(newFormValidations)
|
||||||
}
|
}
|
||||||
@ -226,7 +227,7 @@ export default function DynamicFormWidget({isEditable, widgetMetaData, widgetDat
|
|||||||
{
|
{
|
||||||
const fieldNames: string[] = [];
|
const fieldNames: string[] = [];
|
||||||
const fieldMap: {[name: string]: QFieldMetaData} = {};
|
const fieldMap: {[name: string]: QFieldMetaData} = {};
|
||||||
const fakeRecord = new QRecord({});
|
const fakeRecord = new QRecord(widgetData.recordOfFieldValues ?? {});
|
||||||
|
|
||||||
const mergedDynamicFormValuesIntoFieldName = widgetData.mergedDynamicFormValuesIntoFieldName;
|
const mergedDynamicFormValuesIntoFieldName = widgetData.mergedDynamicFormValuesIntoFieldName;
|
||||||
|
|
||||||
|
@ -693,6 +693,11 @@ input[type="search"]::-webkit-search-results-decoration
|
|||||||
padding: 24px;
|
padding: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.entityForm .widget
|
||||||
|
{
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.recordView .widget .recordGridWidget
|
.recordView .widget .recordGridWidget
|
||||||
{
|
{
|
||||||
margin: -8px;
|
margin: -8px;
|
||||||
|
Reference in New Issue
Block a user