diff --git a/server/src/api/controllers/ItemCategories.ts b/server/src/api/controllers/ItemCategories.ts index d36d75643..6bdd272e9 100644 --- a/server/src/api/controllers/ItemCategories.ts +++ b/server/src/api/controllers/ItemCategories.ts @@ -84,10 +84,6 @@ export default class ItemsCategoriesController extends BaseController { .trim() .escape() .isLength({ min: 0, max: DATATYPES_LENGTH.STRING }), - check('parent_category_id') - .optional({ nullable: true }) - .isInt({ min: 0, max: DATATYPES_LENGTH.INT_10 }) - .toInt(), check('description') .optional({ nullable: true }) .isString() diff --git a/server/src/database/migrations/20190822214304_create_items_categories_table.js b/server/src/database/migrations/20190822214304_create_items_categories_table.js index c807352f5..2fe1ec9ef 100644 --- a/server/src/database/migrations/20190822214304_create_items_categories_table.js +++ b/server/src/database/migrations/20190822214304_create_items_categories_table.js @@ -3,7 +3,7 @@ exports.up = function (knex) { return knex.schema.createTable('items_categories', (table) => { table.increments(); table.string('name').index(); - table.integer('parent_category_id').unsigned().references('id').inTable('items_categories'); + table.text('description'); table.integer('user_id').unsigned().index(); diff --git a/server/src/interfaces/ItemCategory.ts b/server/src/interfaces/ItemCategory.ts index 6da3f1ce4..9742d6e51 100644 --- a/server/src/interfaces/ItemCategory.ts +++ b/server/src/interfaces/ItemCategory.ts @@ -4,8 +4,6 @@ import { ISystemUser } from "./User"; export interface IItemCategory { id: number, name: string, - - parentCategoryId?: number, description?: string, userId: number, @@ -19,7 +17,6 @@ export interface IItemCategory { export interface IItemCategoryOTD { name: string, - parentCategoryId?: number, description?: string, userId: number, diff --git a/server/src/models/ItemCategory.js b/server/src/models/ItemCategory.js index 8eda86284..2741c5174 100644 --- a/server/src/models/ItemCategory.js +++ b/server/src/models/ItemCategory.js @@ -57,13 +57,6 @@ export default class ItemCategory extends TenantModel { column: 'description', columnType: 'string' }, - parent_category_id: { - label: 'Parent category', - column: 'parent_category_id', - relation: 'items_categories.id', - relationColumn: 'items_categories.id', - optionsResource: 'item_category', - }, user: { label: 'User', column: 'user_id', diff --git a/server/src/services/ItemCategories/ItemCategoriesService.ts b/server/src/services/ItemCategories/ItemCategoriesService.ts index d7e9e73b2..893381135 100644 --- a/server/src/services/ItemCategories/ItemCategoriesService.ts +++ b/server/src/services/ItemCategories/ItemCategoriesService.ts @@ -99,9 +99,6 @@ export default class ItemCategoriesService implements IItemCategoriesService { if (itemCategoryOTD.inventoryAccountId) { await this.validateInventoryAccount(tenantId, itemCategoryOTD.inventoryAccountId); } - if (itemCategoryOTD.parentCategoryId) { - await this.getItemCategoryOrThrowError(tenantId, itemCategoryOTD.parentCategoryId); - } const itemCategoryObj = this.transformOTDToObject(itemCategoryOTD, authorizedUser); const itemCategory = await ItemCategory.query().insert({ ...itemCategoryObj }); @@ -203,10 +200,6 @@ export default class ItemCategoriesService implements IItemCategoriesService { if (itemCategoryOTD.inventoryAccountId) { await this.validateInventoryAccount(tenantId, itemCategoryOTD.inventoryAccountId); } - if (itemCategoryOTD.parentCategoryId) { - await this.getItemCategoryOrThrowError(tenantId, itemCategoryOTD.parentCategoryId); - } - const itemCategoryObj = this.transformOTDToObject(itemCategoryOTD, authorizedUser); const itemCategory = await ItemCategory.query().patchAndFetchById(itemCategoryId, { ...itemCategoryObj });