Remove non positive integer constraint on Nav Menu Item (#18081)
To fit with position typed field logic + Ease favorite to nav menu item migration (which have negative and float position)
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
import { type MigrationInterface, type QueryRunner } from 'typeorm';
|
||||
|
||||
export class ChangeNavigationMenuItemPositionToDoublePrecision1771499112046
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'ChangeNavigationMenuItemPositionToDoublePrecision1771499112046';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."navigationMenuItem" ALTER COLUMN "position" TYPE double precision`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."navigationMenuItem" ALTER COLUMN "position" TYPE integer`,
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -97,7 +97,7 @@ export class NavigationMenuItemEntity
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
folderId: string | null;
|
||||
|
||||
@Column({ nullable: false })
|
||||
@Column({ nullable: false, type: 'double precision' })
|
||||
position: number;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
|
||||
+6
-10
@@ -177,13 +177,12 @@ export class FlatNavigationMenuItemValidatorService {
|
||||
|
||||
if (
|
||||
isDefined(flatNavigationMenuItem.position) &&
|
||||
(!Number.isInteger(flatNavigationMenuItem.position) ||
|
||||
flatNavigationMenuItem.position < 0)
|
||||
!Number.isFinite(flatNavigationMenuItem.position)
|
||||
) {
|
||||
validationResult.errors.push({
|
||||
code: NavigationMenuItemExceptionCode.INVALID_NAVIGATION_MENU_ITEM_INPUT,
|
||||
message: t`Position must be a non-negative integer`,
|
||||
userFriendlyMessage: msg`Position must be a non-negative integer`,
|
||||
message: t`Position must be a finite number`,
|
||||
userFriendlyMessage: msg`Position must be a finite number`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -307,14 +306,11 @@ export class FlatNavigationMenuItemValidatorService {
|
||||
|
||||
const positionUpdate = flatEntityUpdate.position;
|
||||
|
||||
if (
|
||||
isDefined(positionUpdate) &&
|
||||
(!Number.isInteger(positionUpdate) || positionUpdate < 0)
|
||||
) {
|
||||
if (isDefined(positionUpdate) && !Number.isFinite(positionUpdate)) {
|
||||
validationResult.errors.push({
|
||||
code: NavigationMenuItemExceptionCode.INVALID_NAVIGATION_MENU_ITEM_INPUT,
|
||||
message: t`Position must be a non-negative integer`,
|
||||
userFriendlyMessage: msg`Position must be a non-negative integer`,
|
||||
message: t`Position must be a finite number`,
|
||||
userFriendlyMessage: msg`Position must be a finite number`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user