mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
chore: Rimossa valutazione automatica della relationship
This commit is contained in:
@@ -239,31 +239,12 @@ export default class RecordsTable<M extends Model<any, any>, A extends RecordsTa
|
|||||||
|
|
||||||
protected getModelValue(record: M, attribute: string, vnode: Vnode<A>): unknown {
|
protected getModelValue(record: M, attribute: string, vnode: Vnode<A>): unknown {
|
||||||
// Check if is a relation
|
// Check if is a relation
|
||||||
let value: unknown = this.getModelRelationValue(record, attribute);
|
let value: unknown = record.getAttribute(attribute);
|
||||||
|
|
||||||
if (!value) {
|
|
||||||
value = record.getAttribute(attribute);
|
|
||||||
}
|
|
||||||
if (attribute === 'id') {
|
if (attribute === 'id') {
|
||||||
value = record.getId()!;
|
value = record.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
let fallback = value;
|
return vnode.attrs.valueModifier?.(value, attribute, record) ?? value;
|
||||||
if (value instanceof ToOneRelation || value instanceof ToManyRelation) {
|
|
||||||
fallback = value.getReferringObject().getApiId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return vnode.attrs.valueModifier?.(value, attribute, record) ?? fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected getModelRelationValue(record: M, attribute: string) {
|
|
||||||
const relation = Reflect.get(record, attribute) as unknown;
|
|
||||||
if (relation && typeof relation === 'function') {
|
|
||||||
const relationship = relation() as unknown;
|
|
||||||
if (relationship instanceof ToOneRelation || relationship instanceof ToManyRelation) {
|
|
||||||
return relationship;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static isRecordTableColumnAttributes(column: Children | RecordsTableColumnAttributes): column is RecordsTableColumnAttributes {
|
private static isRecordTableColumnAttributes(column: Children | RecordsTableColumnAttributes): column is RecordsTableColumnAttributes {
|
||||||
|
Reference in New Issue
Block a user