-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/record group index and seed (#9605)
- [x] [Disable group by on default view Options menu](https://discord.com/channels/1130383047699738754/1328421803399446568) - [x] Add default seed for view group
- Loading branch information
Showing
12 changed files
with
393 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
...rver/src/engine/workspace-manager/standard-objects-prefill-data/create-workspace-views.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { EntityManager } from 'typeorm'; | ||
import { v4 } from 'uuid'; | ||
|
||
import { ViewDefinition } from 'src/engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface'; | ||
|
||
export const createWorkspaceViews = async ( | ||
entityManager: EntityManager, | ||
schemaName: string, | ||
viewDefinitions: ViewDefinition[], | ||
) => { | ||
const viewDefinitionsWithId = viewDefinitions.map((viewDefinition) => ({ | ||
...viewDefinition, | ||
id: v4(), | ||
})); | ||
|
||
await entityManager | ||
.createQueryBuilder() | ||
.insert() | ||
.into(`${schemaName}.view`, [ | ||
'id', | ||
'name', | ||
'objectMetadataId', | ||
'type', | ||
'key', | ||
'position', | ||
'icon', | ||
'kanbanFieldMetadataId', | ||
]) | ||
.values( | ||
viewDefinitionsWithId.map( | ||
({ | ||
id, | ||
name, | ||
objectMetadataId, | ||
type, | ||
key, | ||
position, | ||
icon, | ||
kanbanFieldMetadataId, | ||
}) => ({ | ||
id, | ||
name, | ||
objectMetadataId, | ||
type, | ||
key, | ||
position, | ||
icon, | ||
kanbanFieldMetadataId, | ||
}), | ||
), | ||
) | ||
.returning('*') | ||
.execute(); | ||
|
||
for (const viewDefinition of viewDefinitionsWithId) { | ||
if (viewDefinition.fields && viewDefinition.fields.length > 0) { | ||
await entityManager | ||
.createQueryBuilder() | ||
.insert() | ||
.into(`${schemaName}.viewField`, [ | ||
'fieldMetadataId', | ||
'position', | ||
'isVisible', | ||
'size', | ||
'viewId', | ||
]) | ||
.values( | ||
viewDefinition.fields.map((field) => ({ | ||
fieldMetadataId: field.fieldMetadataId, | ||
position: field.position, | ||
isVisible: field.isVisible, | ||
size: field.size, | ||
viewId: viewDefinition.id, | ||
})), | ||
) | ||
.execute(); | ||
} | ||
|
||
if (viewDefinition.filters && viewDefinition.filters.length > 0) { | ||
await entityManager | ||
.createQueryBuilder() | ||
.insert() | ||
.into(`${schemaName}.viewFilter`, [ | ||
'fieldMetadataId', | ||
'displayValue', | ||
'operand', | ||
'value', | ||
'viewId', | ||
]) | ||
.values( | ||
viewDefinition.filters.map((filter: any) => ({ | ||
fieldMetadataId: filter.fieldMetadataId, | ||
displayValue: filter.displayValue, | ||
operand: filter.operand, | ||
value: filter.value, | ||
viewId: viewDefinition.id, | ||
})), | ||
) | ||
.execute(); | ||
} | ||
|
||
if ( | ||
'groups' in viewDefinition && | ||
viewDefinition.groups && | ||
viewDefinition.groups.length > 0 | ||
) { | ||
await entityManager | ||
.createQueryBuilder() | ||
.insert() | ||
.into(`${schemaName}.viewGroup`, [ | ||
'fieldMetadataId', | ||
'isVisible', | ||
'fieldValue', | ||
'position', | ||
'viewId', | ||
]) | ||
.values( | ||
viewDefinition.groups.map((group: any) => ({ | ||
fieldMetadataId: group.fieldMetadataId, | ||
isVisible: group.isVisible, | ||
fieldValue: group.fieldValue, | ||
position: group.position, | ||
viewId: viewDefinition.id, | ||
})), | ||
) | ||
.execute(); | ||
} | ||
} | ||
|
||
return viewDefinitionsWithId; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...engine/workspace-manager/standard-objects-prefill-data/types/view-definition.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export interface ViewDefinition { | ||
id?: string; | ||
name: string; | ||
objectMetadataId: string; | ||
type: string; | ||
key: string | null; | ||
position: number; | ||
icon?: string; | ||
kanbanFieldMetadataId?: string; | ||
fields?: { | ||
fieldMetadataId: string; | ||
position: number; | ||
isVisible: boolean; | ||
size: number; | ||
}[]; | ||
filters?: { | ||
fieldMetadataId: string; | ||
displayValue: string; | ||
operand: string; | ||
value: string; | ||
}[]; | ||
groups?: { | ||
fieldMetadataId: string; | ||
isVisible: boolean; | ||
fieldValue: string; | ||
position: number; | ||
}[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.