mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Do possible-values before display values, so a rendered possible-value can be part of a record label
This commit is contained in:
@ -95,15 +95,6 @@ public class QueryAction
|
||||
records.replaceAll(t -> postQueryRecordCustomizer.get().apply(t));
|
||||
}
|
||||
|
||||
if(queryInput.getShouldGenerateDisplayValues())
|
||||
{
|
||||
if(qValueFormatter == null)
|
||||
{
|
||||
qValueFormatter = new QValueFormatter();
|
||||
}
|
||||
qValueFormatter.setDisplayValuesInRecords(queryInput.getTable(), records);
|
||||
}
|
||||
|
||||
if(queryInput.getShouldTranslatePossibleValues())
|
||||
{
|
||||
if(qPossibleValueTranslator == null)
|
||||
@ -112,5 +103,14 @@ public class QueryAction
|
||||
}
|
||||
qPossibleValueTranslator.translatePossibleValuesInRecords(queryInput.getTable(), records);
|
||||
}
|
||||
|
||||
if(queryInput.getShouldGenerateDisplayValues())
|
||||
{
|
||||
if(qValueFormatter == null)
|
||||
{
|
||||
qValueFormatter = new QValueFormatter();
|
||||
}
|
||||
qValueFormatter.setDisplayValuesInRecords(queryInput.getTable(), records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class QValueFormatter
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
try
|
||||
{
|
||||
return formatStringWithFields(table.getRecordLabelFormat(), table.getRecordLabelFields(), record.getValues());
|
||||
return formatStringWithFields(table.getRecordLabelFormat(), table.getRecordLabelFields(), record.getDisplayValues(), record.getValues());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@ -177,10 +177,21 @@ public class QValueFormatter
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String formatStringWithFields(String formatString, List<String> formatFields, Map<String, Serializable> valueMap)
|
||||
public String formatStringWithFields(String formatString, List<String> formatFields, Map<String, String> displayValueMap, Map<String, Serializable> rawValueMap)
|
||||
{
|
||||
List<Serializable> values = formatFields.stream()
|
||||
.map(valueMap::get)
|
||||
.map(fieldName ->
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// if there's a display value set, then use it. Else, use the raw value //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
String displayValue = displayValueMap.get(fieldName);
|
||||
if(displayValue != null)
|
||||
{
|
||||
return (displayValue);
|
||||
}
|
||||
return rawValueMap.get(fieldName);
|
||||
})
|
||||
.map(v -> v == null ? "" : v)
|
||||
.toList();
|
||||
return (formatString.formatted(values.toArray()));
|
||||
@ -242,10 +253,13 @@ public class QValueFormatter
|
||||
for(QRecord record : records)
|
||||
{
|
||||
for(QFieldMetaData field : table.getFields().values())
|
||||
{
|
||||
if(record.getDisplayValue(field.getName()) == null)
|
||||
{
|
||||
String formattedValue = formatValue(field, record.getValue(field.getName()));
|
||||
record.setDisplayValue(field.getName(), formattedValue);
|
||||
}
|
||||
}
|
||||
|
||||
record.setRecordLabel(formatRecordLabel(table, record));
|
||||
}
|
||||
|
Reference in New Issue
Block a user