Merge branch 'master' into 104-focus-point-mutation
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
InteriorsFilter,
|
||||
InteriorType,
|
||||
} from '../types/interior-types';
|
||||
import { Orientation, ProductGroup } from '../types/product-types';
|
||||
import { Orientation } from '../types/product-types';
|
||||
import { Maybe } from '../types/types';
|
||||
import { BaseSQLDataSource } from './BaseSQLDataSource';
|
||||
import { ImageServerApi } from './imageserver-api';
|
||||
@@ -18,22 +18,18 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
this.imageServerApi = imageServerApi;
|
||||
}
|
||||
|
||||
getInteriorType(productGroup: ProductGroup): string {
|
||||
switch (productGroup) {
|
||||
case ProductGroup.DESIGNER_WALLPAPER:
|
||||
case ProductGroup.WALLPAPER:
|
||||
case ProductGroup.PHOTO_WALLPAPER:
|
||||
getInteriorType(roomTypePart: string): string {
|
||||
switch (roomTypePart) {
|
||||
case 'wallpaper':
|
||||
return InteriorType[InteriorType.WALLPAPER];
|
||||
case ProductGroup.CANVAS:
|
||||
case 'painting':
|
||||
return InteriorType[InteriorType.PAINTING];
|
||||
case ProductGroup.POSTER:
|
||||
case 'poster':
|
||||
return InteriorType[InteriorType.POSTER];
|
||||
case ProductGroup.FRAMED_PRINT:
|
||||
case 'framed-print':
|
||||
return InteriorType[InteriorType.FRAMED_PRINT];
|
||||
default:
|
||||
throw new Error(
|
||||
`Could not define interior type from product group [${productGroup}]`,
|
||||
);
|
||||
throw new Error(`Unknown room type: ${roomTypePart}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +51,13 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
}
|
||||
|
||||
decorateRow(row: any): Interior {
|
||||
console.log('row', row);
|
||||
if (row.roomName) {
|
||||
const parts = row.roomName.split('_');
|
||||
row.roomNumber = this.getInteriorRoomNumber(parts[0]);
|
||||
row.type = this.getInteriorType(parts[1]);
|
||||
row.orientation = this.getInteriorOrientation(parts[2]);
|
||||
}
|
||||
row.type = this.getInteriorType(row.productGroup);
|
||||
return row;
|
||||
}
|
||||
|
||||
@@ -78,6 +75,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
...row,
|
||||
roomName: row.name,
|
||||
roomType: row.roomtype,
|
||||
id: row.s3_suffix,
|
||||
};
|
||||
this.decorateRow(res);
|
||||
return res;
|
||||
@@ -118,7 +116,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
return rows.map((row) => {
|
||||
const res = {
|
||||
...row,
|
||||
id: row.interiorId,
|
||||
id: row.uri,
|
||||
};
|
||||
this.decorateRow(res);
|
||||
return res;
|
||||
|
||||
@@ -104,6 +104,8 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
row.fields = this.getProductFields(row);
|
||||
row.designerId = row.designerid;
|
||||
row.orientation = this.getOrientation(row.fields);
|
||||
row.copyright = row.copyright ?? '';
|
||||
row.batch = row.batch ?? '';
|
||||
return row;
|
||||
}
|
||||
|
||||
@@ -170,10 +172,11 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
): Promise<void> {
|
||||
return this.knex.raw(
|
||||
/* sql */ `
|
||||
UPDATE "product-products_fields" SET value = ?
|
||||
WHERE productid = ?
|
||||
AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = ?)`,
|
||||
[value, productId, field],
|
||||
INSERT INTO "product-products_fields" (productid, fieldid, value, inserted, updated)
|
||||
VALUES (?, (SELECT fieldid FROM "product-fields" WHERE field = ?), ?, now(), now())
|
||||
ON CONFLICT (productid, fieldid)
|
||||
DO UPDATE SET "value" = ?`,
|
||||
[productId, field, value, value],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -189,7 +192,7 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
path: info.path,
|
||||
browsable: info.browsable ? 1 : 0,
|
||||
visible: info.visible ? 1 : 0,
|
||||
designerid: info.designerId,
|
||||
designerid: info.designerId ?? null,
|
||||
ref1: info.ref1,
|
||||
ref2: info.ref2,
|
||||
ref3: info.ref3,
|
||||
@@ -199,6 +202,21 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
this.updateProductField(productId, 'name', info.name),
|
||||
this.updateProductField(productId, 'batch', info.batch),
|
||||
this.updateProductField(productId, 'copyright', info.copyright),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'print_file_width',
|
||||
info.printFileWidth.toString(),
|
||||
),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'print_file_height',
|
||||
info.printFileHeight.toString(),
|
||||
),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'print_file_dpi',
|
||||
info.printFileDpi.toString(),
|
||||
),
|
||||
);
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
+6
-3
@@ -262,7 +262,7 @@ type ProductFields {
|
||||
photowallResolution: Int
|
||||
canvasResolution: Int
|
||||
wallpaperResolution: Int
|
||||
copyright: String
|
||||
copyright: String!
|
||||
proportionsWarning: String
|
||||
marginWidthMax: Int
|
||||
marginWidthMin: Int
|
||||
@@ -272,7 +272,7 @@ type ProductFields {
|
||||
focusYpoint: Float
|
||||
focusXpoint2: Float
|
||||
focusYpoint2: Float
|
||||
batch: String
|
||||
batch: String!
|
||||
imageResolution: Int
|
||||
printFileWidth: Int
|
||||
printFileHeight: Int
|
||||
@@ -383,9 +383,12 @@ input ProductInfoInput {
|
||||
ref1: String!
|
||||
ref2: String!
|
||||
ref3: String!
|
||||
designerId: Int!
|
||||
designerId: Int
|
||||
browsable: Boolean!
|
||||
visible: Boolean!
|
||||
printFileWidth: Int!
|
||||
printFileHeight: Int!
|
||||
printFileDpi: Int!
|
||||
}
|
||||
|
||||
input ProductBlacklistingInput {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PaginationInput, PaginationResult } from './types';
|
||||
import { Maybe, PaginationInput, PaginationResult } from './types';
|
||||
|
||||
// Mutation inputs
|
||||
export interface ProductInfoInput {
|
||||
@@ -10,9 +10,12 @@ export interface ProductInfoInput {
|
||||
ref1: string;
|
||||
ref2: string;
|
||||
ref3: string;
|
||||
designerId: number;
|
||||
designerId: Maybe<number>;
|
||||
browsable: boolean;
|
||||
visible: boolean;
|
||||
printFileWidth: number;
|
||||
printFileHeight: number;
|
||||
printFileDpi: number;
|
||||
}
|
||||
|
||||
export interface ProductBlacklistMarketInput {
|
||||
|
||||
Reference in New Issue
Block a user