Fix domain objects ids selector (#98)

This commit is contained in:
Rinat Arsaev 2022-06-29 22:11:53 +03:00 committed by GitHub
parent b8d7b8059f
commit b31a564493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -15,21 +15,18 @@ export function createDomainObjectExtension(
determinant: (data) =>
of(
isTypeWithAliases(data?.trueParent, refType, 'domain') &&
isTypeWithAliases(data, 'ObjectID', 'domain')
(isTypeWithAliases(data, 'ObjectID', 'domain') ||
// TODO: 'field.name' must be passed as an argument
['id', 'symbolic_code'].includes(data.field?.name))
),
extension: () =>
options().pipe(
map((objects) => ({
options: objects
.sort((a, b) =>
typeof a.value === 'number' && typeof b.value === 'number'
? a.value - b.value
: 0
)
.map((o) => ({
details: o,
...o,
})),
options: objects.sort((a, b) =>
typeof a.value === 'number' && typeof b.value === 'number'
? a.value - b.value
: 0
),
isIdentifier: true,
}))
),

View File

@ -15,11 +15,11 @@ export const DOMAIN_OBJECTS_TO_OPTIONS: {
[N in keyof OtherDomainObjects]-?: (o: OtherDomainObjects[N]) => MetadataFormExtensionOption;
} = {
/* eslint-disable @typescript-eslint/naming-convention */
currency: (o) => ({ value: o.ref.symbolic_code, label: o.data.name }),
currency: (o) => ({ value: o.ref.symbolic_code, label: o.data.name, details: o }),
payment_method: null,
globals: null,
identity_provider: (o) => ({ value: o.ref.id }),
dummy_link: (o) => ({ value: o.ref.id, label: o.data.link.id }),
identity_provider: (o) => ({ value: o.ref.id, details: o }),
dummy_link: (o) => ({ value: o.ref.id, label: o.data.link.id, details: o }),
/* eslint-enable @typescript-eslint/naming-convention */
};
@ -27,5 +27,5 @@ export function defaultDomainObjectToOption(o: DomainRefDataObjects[keyof Domain
let label: string;
if ('name' in o.data) label = o.data.name;
if ('id' in o.data && !label) label = o.data.id;
return { value: o.ref.id, label };
return { value: o.ref.id, label, details: o };
}