Complete Revit object editor assignments
This commit is contained in:
parent
4489cd76f0
commit
77d775fde1
25 changed files with 853 additions and 77 deletions
|
|
@ -11,6 +11,27 @@ export interface ExternalObjectLinkTransition {
|
|||
target: ExternalModelObjectSnapshot;
|
||||
}
|
||||
|
||||
export function captureExternalObjectDetachTransitions(
|
||||
database: AppDatabase,
|
||||
projectId: string,
|
||||
rowIds: string[]
|
||||
): ExternalObjectLinkTransition[] {
|
||||
if (rowIds.length === 0) return [];
|
||||
return database.select().from(externalModelObjects)
|
||||
.where(and(
|
||||
eq(externalModelObjects.projectId, projectId),
|
||||
inArray(externalModelObjects.circuitDeviceRowId, rowIds)
|
||||
)).all()
|
||||
.map(toExternalObjectSnapshot)
|
||||
.map((expected) => ({ expected, target: { ...expected, circuitDeviceRowId: null } }));
|
||||
}
|
||||
|
||||
export function invertExternalObjectLinkTransitions(
|
||||
transitions: ExternalObjectLinkTransition[]
|
||||
): ExternalObjectLinkTransition[] {
|
||||
return transitions.map(({ expected, target }) => ({ expected: target, target: expected }));
|
||||
}
|
||||
|
||||
export function loadExpectedExternalObjectTransitions(
|
||||
database: AppDatabase,
|
||||
projectId: string,
|
||||
|
|
@ -86,7 +107,13 @@ export function applyExternalObjectLinks(
|
|||
) {
|
||||
for (const { expected, target } of transitions) {
|
||||
const updated = database.update(externalModelObjects)
|
||||
.set({ circuitDeviceRowId: target.circuitDeviceRowId })
|
||||
.set({
|
||||
circuitDeviceRowId: target.circuitDeviceRowId,
|
||||
distributionBoardId: target.distributionBoardId,
|
||||
linkedProjectDeviceId: target.linkedProjectDeviceId,
|
||||
planningValues: target.planningValues,
|
||||
overriddenFields: target.overriddenFields,
|
||||
})
|
||||
.where(and(
|
||||
eq(externalModelObjects.id, expected.id),
|
||||
expected.circuitDeviceRowId === null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue