Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify header separator in query to avoid issue during export #4678

Merged
merged 8 commits into from
May 21, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,13 @@ export const userPreferenceDefinitions = {
defaultValue: false,
type: 'java.lang.Boolean',
}),
joinHeadersWithSeparator: definePref<boolean>({
CarolineDenis marked this conversation as resolved.
Show resolved Hide resolved
title: preferencesText.joinHeadersWithSeparator(),
requiresReload: false,
visible: true,
defaultValue: true,
type: 'java.lang.Boolean',
}),
},
},
appearance: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,20 @@ function TableHeaderCell({
// TableName refers to the table the field is from, not the base table name of the query
const tableName = fieldSpec?.table?.name;

const [isJoinHeadersWithSeparator] = userPreferences.use(
'queryBuilder',
'behavior',
'joinHeadersWithSeparator'
);

const content =
typeof fieldSpec === 'object' ? (
<>
{tableName && <TableIcon label name={tableName} />}
{generateMappingPathPreview(
fieldSpec.baseTable.name,
fieldSpec.toMappingPath()
fieldSpec.toMappingPath(),
isJoinHeadersWithSeparator
)}
</>
) : undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const mappingPathSubset = <T extends string | undefined>(
*/
export function generateMappingPathPreview(
baseTableName: keyof Tables,
mappingPath: MappingPath
mappingPath: MappingPath,
addSeparator: boolean = true
): string {
if (mappingPath.length === 0) return strictGetTable(baseTableName).label;

Expand Down Expand Up @@ -176,5 +177,5 @@ export function generateMappingPathPreview(
toManyIndexFormatted,
])
.filter(Boolean)
.join(' · ');
.join(addSeparator ? ' · ' : ' ');
grantfitzsimmons marked this conversation as resolved.
Show resolved Hide resolved
CarolineDenis marked this conversation as resolved.
Show resolved Hide resolved
}
3 changes: 3 additions & 0 deletions specifyweb/frontend/js_src/lib/localization/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1979,4 +1979,7 @@ export const preferencesText = createDictionary({
'ru-ru': 'Добавить панель поиска на главную страницу',
'uk-ua': 'Додайте рядок пошуку на головну сторінку',
},
joinHeadersWithSeparator: {
'en-us': 'Join headers with separator',
},
} as const);