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

Unexpected formatting of results in the search dialog #4844

Open
emenslin opened this issue Apr 26, 2024 · 1 comment
Open

Unexpected formatting of results in the search dialog #4844

emenslin opened this issue Apr 26, 2024 · 1 comment
Labels
1 - Bug Incorrect behavior of the product 2 - App Resources Issues that are related to app resources

Comments

@emenslin
Copy link
Collaborator

Describe the bug
When there is an accession format with no fields defined and then you go to an accession querycombobox and click search it returns different results from the querycombobox itself

To Reproduce
Steps to reproduce the behavior:

  1. Go to table formats-> accession
  2. Remove any mapped fields (or if there isn't one then add accession format with no mapped fields)
  3. Save and clear cache
  4. Go to data entry-> collection object
  5. Use the accession querycombobox (should show <formatter not defined>)
  6. Click search and search for an accession
  7. See error

Expected behavior
The search results should either show <formatter not defined> or just return the accession number as it does in 7.9.3

Screenshots
edge

khEl6w39kn.mp4

7.9.3
Screenshot 2024-04-26 090622

Please, also fill out the following information manually:

@emenslin emenslin added 1 - Bug Incorrect behavior of the product 2 - App Resources Issues that are related to app resources labels Apr 26, 2024
@emenslin emenslin added this to the 7.9.4 milestone Apr 26, 2024
@CarolineDenis CarolineDenis removed this from the 7.9.4 milestone Apr 26, 2024
@melton-jason
Copy link
Contributor

This is the 'expected' behavior for this case currently.

The results in search dialogs do not use the formatting returned from the backend.

.then(async (resources) =>
Promise.all(
filterResults(resources, extraFilters).map(
async (resource) => ({
id: resource.id,
formatted: await format(resource, undefined, true),
resource,
})
)

Instead, they use the frontend formatting code and display those results.
The logic for the formatting in this case is as follows:

  • The fields from the formatter are determined
  • Because there are no fields for the Accession format, the frontend defaults to using a 'naive' formatter
  • This formats the record using Table #ID for existing records or New Table for new records

const fields = await determineFields(definition, resource);
const automaticFormatter = tryBest
? naiveFormatter(resource.specifyTable.label, resource.id)
: undefined;
return Promise.all(
fields.map(async (field) =>
formatField(field, resource, cycleDetection, tryBest)
)
).then((values) => {
const joined = values.reduce<string>(
(result, { formatted, separator = '' }, index) =>
`${result}${
result.length === 0 && index !== 0 ? '' : separator
}${formatted}`,
''
);
return joined.length === 0 ? automaticFormatter : localized(joined);
});

The same formatting logic is used when formatting the table records within a QueryCombobox:

Screenshot 2024-04-26 at 9 53 26 AM

Although directly searching using the QueryComboBox returns <Formatter not defined.> until the page is refreshed, and then the naive formatter is used.

Screenshot 2024-04-26 at 9 54 45 AM

Preferably, all the 'Query Result'-style formatting should be consistent. We should either use the frontend method of creating a naive formatter, or use the backend's <Formatter not defined.>.
Other cases where the formatting is not directly related to 'Query Results' (such as the formatting for dialog titles, or showing the 'preview' of the record when in a QueryComboBox) can be assessed differently.

Regardless, unless others disagree, this is probably something that can be addressed after the v7.9.4 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Bug Incorrect behavior of the product 2 - App Resources Issues that are related to app resources
Projects
None yet
Development

No branches or pull requests

3 participants