mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 10:46:17 +00:00
Merge pull request #236 from SyncrowIOT:bugfix/fix-space-update
fix space
This commit is contained in:
@ -212,6 +212,7 @@ export class SpaceService {
|
||||
{ subspaceTagsDisabled: false },
|
||||
)
|
||||
.leftJoinAndSelect('subspaceTags.product', 'subspaceTagProduct')
|
||||
.leftJoinAndSelect('space.spaceModel', 'spaceModel')
|
||||
.where('space.community_id = :communityUuid', { communityUuid })
|
||||
.andWhere('space.spaceName != :orphanSpaceName', {
|
||||
orphanSpaceName: ORPHAN_SPACE_NAME,
|
||||
@ -286,6 +287,7 @@ export class SpaceService {
|
||||
.andWhere('space.spaceName != :orphanSpaceName', {
|
||||
orphanSpaceName: ORPHAN_SPACE_NAME,
|
||||
})
|
||||
.andWhere('space.uuid = :spaceUuid', { spaceUuid })
|
||||
.andWhere('space.disabled = :disabled', { disabled: false });
|
||||
|
||||
const space = await queryBuilder.getOne();
|
||||
@ -584,7 +586,11 @@ export class SpaceService {
|
||||
addSpaceDto: AddSpaceDto,
|
||||
spaceModelUuid?: string,
|
||||
) {
|
||||
if (spaceModelUuid && (addSpaceDto.tags || addSpaceDto.subspaces)) {
|
||||
const hasTagsOrSubspaces =
|
||||
(addSpaceDto.tags && addSpaceDto.tags.length > 0) ||
|
||||
(addSpaceDto.subspaces && addSpaceDto.subspaces.length > 0);
|
||||
|
||||
if (spaceModelUuid && hasTagsOrSubspaces) {
|
||||
throw new HttpException(
|
||||
'For space creation choose either space model or products and subspace',
|
||||
HttpStatus.CONFLICT,
|
||||
|
@ -387,6 +387,7 @@ export class SubSpaceService {
|
||||
const createTagDtos: CreateTagDto[] =
|
||||
subspace.tags?.map((tag) => ({
|
||||
tag: tag.tag as string,
|
||||
uuid: tag.uuid,
|
||||
productUuid: tag.productUuid as string,
|
||||
})) || [];
|
||||
const subSpace = await this.createSubspacesFromDto(
|
||||
@ -441,15 +442,17 @@ export class SubSpaceService {
|
||||
);
|
||||
|
||||
if (subspace.tags?.length) {
|
||||
const modifyTagDtos = subspace.tags.map((tag) => ({
|
||||
const modifyTagDtos: CreateTagDto[] = subspace.tags.map((tag) => ({
|
||||
uuid: tag.uuid,
|
||||
action: ModifyAction.DELETE,
|
||||
action: ModifyAction.ADD,
|
||||
tag: tag.tag,
|
||||
productUuid: tag.product.uuid,
|
||||
}));
|
||||
await this.tagService.modifyTags(
|
||||
await this.tagService.moveTags(
|
||||
modifyTagDtos,
|
||||
queryRunner,
|
||||
subspace.space,
|
||||
null,
|
||||
subspace,
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user