feat(product,dashboard): Allow re-ordering images (#10187)

* migration

* fix snapshot

* primarykey

* init work on dnd

* progress

* dnd

* undo changes

* undo changes

* undo changes

* undo changes

* fix firefox issue

* lint

* lint

* lint

* add changeset

* undo changes to product module

* set activator node

* init work on service layer

* alternative

* switch to OneToMany

* add tests

* progress

* update migration

* update approach and remove all references to images in product.ts tests

* handle delete images on empty array

* fix config and order type

* update changeset

* rm flag

* export type and fix type in test

* fix type

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Kasper Fabricius KristensenandOli Juhl authored and GitHub committed 2024-11-25 09:03:10 +01:00
1 parent b12408dbd8
commit 1659c9be5d
32 files changed
+1257 -617

No files matched your search

+6 -1
View File
@@ -49,6 +49,11 @@ export interface SoftDeletableEntity extends BaseEntity {
deleted_at: Date | null
}
/**
* Temporary type fixing to allow any level of orders until we get to properly clean all the types
*/
export type FindConfigOrder = { [Key: string]: "ASC" | "DESC" | string & {} | FindConfigOrder }
/**
* @interface
*
@@ -80,7 +85,7 @@ export interface FindConfig<Entity> {
* An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`
* to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.
*/
order?: Record<string, "ASC" | "DESC" | (string & {})>
order?: FindConfigOrder
/**
* A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the
@@ -290,6 +290,10 @@ export interface BaseProductImage {
* The image's URL.
*/
url: string
/**
* The rank of the product image.
*/
rank: number
/**
* The date the image was created.
*/
@@ -595,6 +595,10 @@ export interface ProductImageDTO {
* The URL of the product image.
*/
url: string
/**
* The rank of the product image.
*/
rank: number
/**
* Holds custom data in key-value pairs.
*/
@@ -1,5 +1,6 @@
import { buildQuery } from "../build-query"
import { FindConfig } from "@medusajs/types"
import { SoftDeletableFilterKey } from "../../dal/mikro-orm/mikro-orm-soft-deletable-filter"
import { buildQuery } from "../build-query"
describe("buildQuery", () => {
test("should return empty where and basic options when no filters or config provided", () => {
@@ -46,7 +47,7 @@ describe("buildQuery", () => {
})
test("should apply config options", () => {
const config = {
const config: FindConfig<any> = {
relations: ["user", "order"],
select: ["id", "name"],
take: 10,