fix(f6.1): derive creation operator from active area relation
This commit is contained in:
@@ -144,7 +144,6 @@ export function AssetEditorPage() {
|
||||
const parentType = types.find((type) => type.id === parent.type.id);
|
||||
if (parentType?.operationalRole === 'AREA') setOperationalAreaId(parent.id);
|
||||
else if (parent.operationalArea) setOperationalAreaId(parent.operationalArea.id);
|
||||
if (parent.operatorCompany) setOperatorCompanyId(parent.operatorCompany.id);
|
||||
}
|
||||
}).catch((requestError) => setError(errorMessage(requestError)));
|
||||
}, [editing, contextParentId, types]);
|
||||
@@ -175,7 +174,16 @@ export function AssetEditorPage() {
|
||||
setOperationalCompanies([]);
|
||||
return;
|
||||
}
|
||||
listCompaniesForArea(operationalAreaId).then(setOperationalCompanies).catch((requestError) => setError(errorMessage(requestError)));
|
||||
listCompaniesForArea(operationalAreaId).then((loadedCompanies) => {
|
||||
setOperationalCompanies(loadedCompanies);
|
||||
setOperatorCompanyId((current) => loadedCompanies.some((company) => company.id === current)
|
||||
? current
|
||||
: loadedCompanies.length === 1 ? loadedCompanies[0].id : '');
|
||||
}).catch((requestError) => {
|
||||
setOperationalCompanies([]);
|
||||
setOperatorCompanyId('');
|
||||
setError(errorMessage(requestError));
|
||||
});
|
||||
}, [editing, canReadRelations, operationalAreaId, selectedType?.operationalRole]);
|
||||
|
||||
const changeType = (nextTypeId: string) => { setTypeId(nextTypeId); setParentId(''); setOperationalAreaId(''); if (!editing) setOperatorCompanyId(''); setAttributeValues({}); setParentSearch(''); };
|
||||
|
||||
Reference in New Issue
Block a user