Merge pull request #236 from SyncrowIOT:bugfix/fix-space-update

fix space
This commit is contained in:
hannathkadher
2025-02-02 23:16:01 +04:00
committed by GitHub
2 changed files with 15 additions and 6 deletions

View File

@ -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();
@ -362,7 +364,7 @@ export class SpaceService {
updateSpaceDto: UpdateSpaceDto,
): Promise<BaseResponseDto> {
const { communityUuid, spaceUuid, projectUuid } = params;
const queryRunner = this.dataSource.createQueryRunner();
try {
@ -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,

View File

@ -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,
);
}