added comments in code (#81)

This commit is contained in:
Arwid Thornström
2021-10-29 07:22:42 +02:00
committed by GitHub
parent ee16ff44c6
commit 48972d7090
2 changed files with 134 additions and 1 deletions
+54 -1
View File
@@ -243,9 +243,11 @@ export class ProductAPI extends BaseSQLDataSource {
async searchByBatch(name: string): Promise<Array<Batch>> {
return this.searchByFieldValue<Batch>(name, 36, 'batch');
}
async searchByCopyright(name: string): Promise<Array<Copyright>> {
return this.searchByFieldValue<Copyright>(name, 25, 'copyright');
}
async searchByFieldValue<T>(
name: string,
fieldNo: number,
@@ -307,6 +309,11 @@ export class ProductAPI extends BaseSQLDataSource {
);
}
/**
* @function getUniqueProductPath
* @description Returns a unique product path, ex if foggy-forest is take it will return foggy-forest-1
* foggy-forest-2 and so on.
*/
async getUniqueProductPath(
path: string,
productId?: number,
@@ -359,6 +366,11 @@ export class ProductAPI extends BaseSQLDataSource {
return newPath;
}
/**
* @function addProduct
* @description Adds a new product to system, will use batchname and name to
* set a unique path, artNo is the productId with e infront.
*/
async addProduct(name: string, batch: string): Promise<number> {
const path = batch ? batch + ' ' + name : name;
const productPath = slug(path);
@@ -379,6 +391,10 @@ export class ProductAPI extends BaseSQLDataSource {
return id;
}
/**
* @function updateProductInfo
* @description Update base info for a product
*/
async updateProductInfo(
productId: number,
info: ProductInfoInput,
@@ -436,6 +452,10 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(promises);
}
/**
* @function updateFocusPoint
* @description Updates the focus point on a motif
*/
async updateFocusPoint(
productId: number,
focusXpoint2: number,
@@ -461,6 +481,10 @@ export class ProductAPI extends BaseSQLDataSource {
return this.updateProductField(productId, 'comments', comments);
}
/**
* @function updateBlacklisting
* @description Updates the blacklisted countries and sections
*/
async updateBlacklisting(
productId: number,
markets: Array<ProductBlacklistMarketInput>,
@@ -488,6 +512,11 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(insertsPromises);
}
/**
* @function setWallpaperTypes
* @description Sets what wallpaper type a product is sold as, meaning the sections on site
* like wallpaper or design-wallpaper
*/
async setWallpaperTypes(
productId: number,
wallpaperTypes: Array<ProductWallpaperType>,
@@ -506,6 +535,11 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(promises);
}
/**
* @function updateGroups
* @description Updates the groups that a product is sold in, like wallpaper, canvas or
* poster. Note that group 3 is repeating wallpapers.
*/
async updateGroups(productId: number, groupIds: number[]): Promise<any[]> {
// Fetch the current state
const allPrintProducts = await this.knex.raw(
@@ -627,6 +661,7 @@ export class ProductAPI extends BaseSQLDataSource {
/**
* @func productGroupInteriors
* @description Sets interiors to a product and product group
*
* @param productId The product id for the targeted product
* @param groupId The targeted group id, if product does not have group it will be created
@@ -728,6 +763,10 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(insertPromises);
}
/**
* @function setProportionsWarning
* @description Sets propotion warning-values to a product
*/
async setProportionsWarning(
productId: number,
proportions: ProductProportionsInput,
@@ -764,6 +803,11 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(promises);
}
/**
* @function addRelatedProducts
* @description Adds a related product to a product, when settings a related product
* the target product will get the same related connection.
*/
async addRelatedProducts(
productId: number,
articleNumbers: Array<string>,
@@ -802,7 +846,8 @@ export class ProductAPI extends BaseSQLDataSource {
}
/**
* Removes variant products from productid as well as the sent in
* @function removeRelatedProducts
* @description Removes variant products from productid as well as the sent in
* productid from its variants
*/
async removeRelatedProducts(
@@ -825,6 +870,10 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(promises);
}
/**
* @function addCategoriesToProduct
* @description Adds a list of categories to a product
*/
async addCategoriesToProduct(
productId,
categoryIds,
@@ -838,6 +887,10 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(promises);
}
/**
* @function removeCategoriesFromProduct
* @description Removes list of categories from a product
*/
async removeCategoriesFromProduct(
productId,
categoryIds,