diff --git a/codbex-products/codbex-products.edm b/codbex-products/codbex-products.edm index af9c23e..9a126bb 100644 --- a/codbex-products/codbex-products.edm +++ b/codbex-products/codbex-products.edm @@ -45,7 +45,7 @@ - + @@ -127,6 +127,13 @@ + + + + + + + Productsproducts-navigation-group/services/web/resources/unicons/cube.svg100 @@ -135,5 +142,5 @@ - + \ No newline at end of file diff --git a/codbex-products/codbex-products.gen b/codbex-products/codbex-products.gen index 43c7469..be2faca 100644 --- a/codbex-products/codbex-products.gen +++ b/codbex-products/codbex-products.gen @@ -63,6 +63,7 @@ "ProductPackaging", "ProductImage", "CampaignEntry", + "ProductLeaflet", "Product-details", "Product-details", "Product-details", @@ -1789,7 +1790,7 @@ "inputRule": "" }, { - "dataLength": "2000", + "dataLength": "3000", "dataName": "PRODUCTATTRIBUTE_VALUE", "dataNullable": true, "dataType": "VARCHAR", @@ -3373,6 +3374,125 @@ "masterEntity": "Product", "masterEntityId": "Product", "hasDropdowns": true + }, + { + "properties": [ + { + "dataAutoIncrement": true, + "dataName": "PRODUCTLEAFLET_ID", + "dataNullable": true, + "dataPrimaryKey": true, + "dataType": "INTEGER", + "description": "", + "name": "Id", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "20", + "widgetSize": "", + "widgetType": "TEXTBOX", + "dataNotNull": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "widgetLabel": "Id", + "widgetDropdownUrl": "", + "dataTypeJava": "int", + "dataTypeTypescript": "number", + "inputRule": "" + }, + { + "dataName": "PRODUCTLEAFLET_TITLE", + "dataNullable": true, + "dataType": "INTEGER", + "description": "", + "name": "Title", + "relationshipCardinality": "1_n", + "relationshipName": "ProductLeaflet_Product", + "relationshipType": "COMPOSITION", + "tooltip": "", + "widgetDropDownKey": "Id", + "widgetDropDownValue": "Name", + "widgetIsMajor": false, + "widgetLength": "20", + "widgetSize": "", + "widgetType": "DROPDOWN", + "relationshipEntityName": "Product", + "relationshipEntityPerspectiveName": "Products", + "relationshipEntityPerspectiveLabel": "Entities", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "widgetLabel": "Title", + "widgetDropdownUrl": "/services/ts/codbex-products/gen/codbex-products/api/Products/ProductService.ts", + "dataTypeJava": "int", + "dataTypeTypescript": "number", + "inputRule": "" + }, + { + "dataLength": "500", + "dataName": "PRODUCTLEAFLET_LEAFLETLINK", + "dataNullable": true, + "dataType": "VARCHAR", + "description": "", + "name": "LeafletLink", + "tooltip": "", + "widgetIsMajor": true, + "widgetLength": "500", + "widgetSize": "", + "widgetType": "URL", + "dataNotNull": false, + "dataAutoIncrement": false, + "dataPrimaryKey": false, + "dataUnique": false, + "isRequiredProperty": false, + "isCalculatedProperty": false, + "widgetLabel": "LeafletLink", + "widgetDropdownUrl": "", + "dataTypeJava": "string", + "dataTypeTypescript": "string", + "minLength": 0, + "maxLength": 500, + "inputRule": "" + } + ], + "caption": "Manage entity ProductLeaflet", + "dataCount": "SELECT COUNT(*) AS COUNT FROM \"CODBEX_PRODUCTLEAFLET\"", + "dataName": "PRODUCTLEAFLET", + "dataQuery": "", + "description": "Manage entity ProductLeaflet", + "feedPassword": "YWRtaW4=", + "feedUsername": "YWRtaW4=", + "generateDefaultRoles": "false", + "generateReport": "false", + "icon": "/services/web/resources/unicons/file.svg", + "layoutType": "MANAGE_DETAILS", + "menuIndex": "100", + "menuKey": "productleaflet", + "menuLabel": "ProductLeaflet", + "multilingual": "false", + "name": "ProductLeaflet", + "perspectiveHeader": "", + "perspectiveIcon": "/services/web/resources/unicons/cube.svg", + "perspectiveLabel": "Products", + "perspectiveName": "Products", + "perspectiveNavId": "products-navigation-group", + "perspectiveOrder": "100", + "perspectiveRole": "", + "title": "ProductLeaflet", + "tooltip": "ProductLeaflet", + "type": "DEPENDENT", + "dataSource": "DefaultDB", + "referencedProjections": [], + "primaryKeys": [ + "Id" + ], + "primaryKeysString": "Id", + "masterEntity": "Product", + "masterEntityId": "Title", + "hasDropdowns": true } ] } \ No newline at end of file diff --git a/codbex-products/codbex-products.model b/codbex-products/codbex-products.model index e35f653..4a18d6d 100644 --- a/codbex-products/codbex-products.model +++ b/codbex-products/codbex-products.model @@ -576,7 +576,7 @@ "widgetType": "TEXTBOX" }, { - "dataLength": "2000", + "dataLength": "3000", "dataName": "PRODUCTATTRIBUTE_VALUE", "dataNullable": "true", "dataType": "VARCHAR", @@ -1516,6 +1516,83 @@ "title": "CampaignEntry", "tooltip": "CampaignEntry", "type": "DEPENDENT" + }, + { + "properties": [ + { + "dataAutoIncrement": "true", + "dataName": "PRODUCTLEAFLET_ID", + "dataNullable": "true", + "dataPrimaryKey": "true", + "dataType": "INTEGER", + "description": "", + "name": "Id", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "", + "widgetType": "TEXTBOX" + }, + { + "dataName": "PRODUCTLEAFLET_TITLE", + "dataNullable": "true", + "dataType": "INTEGER", + "description": "", + "name": "Title", + "relationshipCardinality": "1_n", + "relationshipName": "ProductLeaflet_Product", + "relationshipType": "COMPOSITION", + "tooltip": "", + "widgetDropDownKey": "Id", + "widgetDropDownValue": "Name", + "widgetIsMajor": "true", + "widgetLength": "20", + "widgetSize": "", + "widgetType": "DROPDOWN", + "relationshipEntityName": "Product", + "relationshipEntityPerspectiveName": "Products", + "relationshipEntityPerspectiveLabel": "Entities" + }, + { + "dataLength": "500", + "dataName": "PRODUCTLEAFLET_LEAFLETLINK", + "dataNullable": "true", + "dataType": "VARCHAR", + "description": "", + "name": "LeafletLink", + "tooltip": "", + "widgetIsMajor": "true", + "widgetLength": "500", + "widgetSize": "", + "widgetType": "URL" + } + ], + "caption": "Manage entity ProductLeaflet", + "dataCount": "SELECT COUNT(*) AS COUNT FROM \"${tablePrefix}PRODUCTLEAFLET\"", + "dataName": "PRODUCTLEAFLET", + "dataQuery": "", + "description": "Manage entity ProductLeaflet", + "feedPassword": "YWRtaW4=", + "feedUsername": "YWRtaW4=", + "generateDefaultRoles": "false", + "generateReport": "false", + "icon": "/services/web/resources/unicons/file.svg", + "layoutType": "MANAGE_DETAILS", + "menuIndex": "100", + "menuKey": "productleaflet", + "menuLabel": "ProductLeaflet", + "multilingual": "false", + "name": "ProductLeaflet", + "perspectiveHeader": "", + "perspectiveIcon": "/services/web/resources/unicons/cube.svg", + "perspectiveLabel": "Products", + "perspectiveName": "Products", + "perspectiveNavId": "products-navigation-group", + "perspectiveOrder": "100", + "perspectiveRole": "", + "title": "ProductLeaflet", + "tooltip": "ProductLeaflet", + "type": "DEPENDENT" } ], "perspectives": [ diff --git a/codbex-products/gen/codbex-products/api/Products/ProductAttributeService.ts b/codbex-products/gen/codbex-products/api/Products/ProductAttributeService.ts index 33efa97..8598c76 100644 --- a/codbex-products/gen/codbex-products/api/Products/ProductAttributeService.ts +++ b/codbex-products/gen/codbex-products/api/Products/ProductAttributeService.ts @@ -156,8 +156,8 @@ class ProductAttributeService { if (entity.Name?.length > 200) { throw new ValidationError(`The 'Name' exceeds the maximum length of [200] characters`); } - if (entity.Value?.length > 2000) { - throw new ValidationError(`The 'Value' exceeds the maximum length of [2000] characters`); + if (entity.Value?.length > 3000) { + throw new ValidationError(`The 'Value' exceeds the maximum length of [3000] characters`); } for (const next of validationModules) { next.validate(entity); diff --git a/codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts b/codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts new file mode 100644 index 0000000..a46fe82 --- /dev/null +++ b/codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts @@ -0,0 +1,145 @@ +import { Controller, Get, Post, Put, Delete, request, response } from "sdk/http" +import { Extensions } from "sdk/extensions" +import { ProductLeafletRepository, ProductLeafletEntityOptions } from "../../dao/Products/ProductLeafletRepository"; +import { ValidationError } from "../utils/ValidationError"; +import { HttpUtils } from "../utils/HttpUtils"; + +const validationModules = await Extensions.loadExtensionModules("codbex-products-Products-ProductLeaflet", ["validate"]); + +@Controller +class ProductLeafletService { + + private readonly repository = new ProductLeafletRepository(); + + @Get("/") + public getAll(_: any, ctx: any) { + try { + const options: ProductLeafletEntityOptions = { + $limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined, + $offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined, + $language: request.getLocale().slice(0, 2) + }; + + let Title = parseInt(ctx.queryParameters.Title); + Title = isNaN(Title) ? ctx.queryParameters.Title : Title; + + if (Title !== undefined) { + options.$filter = { + equals: { + Title: Title + } + }; + } + + return this.repository.findAll(options); + } catch (error: any) { + this.handleError(error); + } + } + + @Post("/") + public create(entity: any) { + try { + this.validateEntity(entity); + entity.Id = this.repository.create(entity); + response.setHeader("Content-Location", "/services/ts/codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts/" + entity.Id); + response.setStatus(response.CREATED); + return entity; + } catch (error: any) { + this.handleError(error); + } + } + + @Get("/count") + public count() { + try { + return { count: this.repository.count() }; + } catch (error: any) { + this.handleError(error); + } + } + + @Post("/count") + public countWithFilter(filter: any) { + try { + return { count: this.repository.count(filter) }; + } catch (error: any) { + this.handleError(error); + } + } + + @Post("/search") + public search(filter: any) { + try { + return this.repository.findAll(filter); + } catch (error: any) { + this.handleError(error); + } + } + + @Get("/:id") + public getById(_: any, ctx: any) { + try { + const id = parseInt(ctx.pathParameters.id); + const options: ProductLeafletEntityOptions = { + $language: request.getLocale().slice(0, 2) + }; + const entity = this.repository.findById(id, options); + if (entity) { + return entity; + } else { + HttpUtils.sendResponseNotFound("ProductLeaflet not found"); + } + } catch (error: any) { + this.handleError(error); + } + } + + @Put("/:id") + public update(entity: any, ctx: any) { + try { + entity.Id = ctx.pathParameters.id; + this.validateEntity(entity); + this.repository.update(entity); + return entity; + } catch (error: any) { + this.handleError(error); + } + } + + @Delete("/:id") + public deleteById(_: any, ctx: any) { + try { + const id = ctx.pathParameters.id; + const entity = this.repository.findById(id); + if (entity) { + this.repository.deleteById(id); + HttpUtils.sendResponseNoContent(); + } else { + HttpUtils.sendResponseNotFound("ProductLeaflet not found"); + } + } catch (error: any) { + this.handleError(error); + } + } + + private handleError(error: any) { + if (error.name === "ForbiddenError") { + HttpUtils.sendForbiddenRequest(error.message); + } else if (error.name === "ValidationError") { + HttpUtils.sendResponseBadRequest(error.message); + } else { + HttpUtils.sendInternalServerError(error.message); + } + } + + private validateEntity(entity: any): void { + if (entity.LeafletLink?.length > 500) { + throw new ValidationError(`The 'LeafletLink' exceeds the maximum length of [500] characters`); + } + for (const next of validationModules) { + next.validate(entity); + } + } + +} diff --git a/codbex-products/gen/codbex-products/codbex-products.openapi b/codbex-products/gen/codbex-products/codbex-products.openapi index 81b363f..cf7db64 100644 --- a/codbex-products/gen/codbex-products/codbex-products.openapi +++ b/codbex-products/gen/codbex-products/codbex-products.openapi @@ -18,6 +18,7 @@ tags: - name: Settings - name: Campaigns - name: Products + - name: Products paths: /codbex-products/gen/codbex-products/api/Settings/ProductTypeService.ts: get: @@ -3675,177 +3676,577 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' -components: - schemas: - ProductType: - type: object - required: - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 200 - ProductTypeFilterOptions: - type: object - properties: - $filter: - type: object - properties: - equals: - type: object - properties: - Id: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - Name: - oneOf: - - type: string - minLength: 0 - maxLength: 200 - - type: array - items: - type: string - format: double - minLength: 0 - maxLength: 200 - notEquals: - type: object - properties: - Id: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - Name: - oneOf: - - type: string - minLength: 0 - maxLength: 200 - - type: array - items: - type: string - format: double - minLength: 0 - maxLength: 200 - contains: - type: object - properties: - Id: - Name: - type: string - minLength: 0 - maxLength: 200 - greaterThan: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 200 - greaterThanOrEqual: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 200 - lessThan: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 200 - lessThanOrEqual: - type: object - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 200 - $select: - type: array - example: ["Id", "Name"] - items: + /codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts: + get: + summary: List ProductLeaflet + parameters: + - in: query + name: $limit + description: The number of records to be returned _(both `$limit` and `$offset` should be provided)_. + required: false + allowReserved: true + schema: + type: integer + allowEmptyValue: true + - in: query + name: $offset + description: The number of records to skip _(both `$limit` and `$offset` should be provided)_. + required: false + allowReserved: true + schema: + type: integer + allowEmptyValue: true + tags: + - Products + responses: + 200: + description: Successful Request + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ProductLeaflet' + 400: + description: Bad Request Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + summary: Create ProductLeaflet + tags: + - Products + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProductLeaflet' + required: true + responses: + 201: + description: Successful Request + content: + application/json: + schema: + $ref: '#/components/schemas/ProductLeaflet' + 400: + description: Bad Request Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts/{id}: + get: + summary: Get ProductLeaflet by Id + parameters: + - in: path + name: id + description: The Id of the entity. + required: true + schema: type: string - $sort: - - type: string - example: "Id,Name" - $order: - type: string - enum: ["asc", "desc"] - example: "asc" - $offset: - type: integer - example: 0 - $limit: - type: integer - example: 10 - ProductCategory: - type: object - required: - properties: - Id: - type: integer - format: int32 - Name: - type: string - minLength: 0 - maxLength: 200 - Path: - type: string - minLength: 0 - maxLength: 2000 - ProductCategoryFilterOptions: - type: object - properties: - $filter: - type: object - properties: - equals: - type: object - properties: - Id: - oneOf: - - type: integer - format: int32 - - type: array - items: - type: integer - format: int32 - Name: - oneOf: - - type: string - minLength: 0 - maxLength: 200 - - type: array - items: - type: string - format: double - minLength: 0 + tags: + - Products + responses: + 200: + description: Successful Request + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ProductLeaflet' + 404: + description: Entity Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + summary: Update ProductLeaflet by Id + parameters: + - in: path + name: id + description: The Id of the entity. + required: true + schema: + type: string + tags: + - Products + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProductLeaflet' + required: true + responses: + 200: + description: Successful Request + content: + application/json: + schema: + $ref: '#/components/schemas/ProductLeaflet' + 400: + description: Bad Request Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 404: + description: Entity Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + summary: Delete ProductLeaflet by Id + parameters: + - in: path + name: id + description: The Id of the entity. + required: true + schema: + type: string + tags: + - Products + responses: + 204: + description: Successful Request + 404: + description: Entity Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts/count: + get: + summary: Count the number of ProductLeaflet + tags: + - Products + responses: + 200: + description: Successful Request + content: + application/json: + schema: + type: integer + example: 100 + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + summary: Count the number of ProductLeaflet by ProductLeafletFilterOptions + tags: + - Products + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProductLeafletFilterOptions' + examples: + countWithMultipleCriteria: + summary: Count with multiple criteria + value: + $filter: + notEquals: + Id: 33 + contains: + LeafletLink: "abcd" + greaterThan: + Id: 0 + lessThanOrEqual: + Id: 100 + countWithEquals: + summary: Count with Equals + value: + $filter: + equals: + Id: 0 + countWithNotEquals: + summary: Count with Not Equals + value: + $filter: + notEquals: + Id: 0 + countWithContains: + summary: Count with Contains + value: + $filter: + contains: + LeafletLink: "abcd" + countWithGreaterThan: + summary: Count with Greater Than + value: + $filter: + greaterThan: + Id: 0 + countWithGreaterThanOrEqual: + summary: Count with Greater Than Or Equal + value: + $filter: + greaterThanOrEqual: + Id: 0 + countWithLessThan: + summary: Count with Less Than + value: + $filter: + lessThan: + Id: 0 + countWithLessThanOrEqual: + summary: Count with Less Than Or Equal + value: + $filter: + lessThanOrEqual: + Id: 0 + required: true + responses: + 200: + description: Successful Request + content: + application/json: + schema: + type: integer + example: 100 + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts/search: + post: + summary: Search ProductLeaflet by ProductLeafletFilterOptions + tags: + - Products + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProductLeafletFilterOptions' + examples: + searchWithMultipleCriteria: + summary: Search with multiple criteria + value: + $filter: + notEquals: + Id: 33 + contains: + LeafletLink: "abcd" + greaterThan: + Id: 0 + lessThanOrEqual: + Id: 100 + searchWithEquals: + summary: Search with Equals + value: + $filter: + equals: + Id: 0 + searchWithNotEquals: + summary: Search with Not Equals + value: + $filter: + notEquals: + Id: 0 + searchWithContains: + summary: Search with Contains + value: + $filter: + contains: + LeafletLink: "abcd" + searchWithGreaterThan: + summary: Search with Greater Than + value: + $filter: + greaterThan: + Id: 0 + searchWithGreaterThanOrEqual: + summary: Search with Greater Than Or Equal + value: + $filter: + greaterThanOrEqual: + Id: 0 + searchWithLessThan: + summary: Search with Less Than + value: + $filter: + lessThan: + Id: 0 + searchWithLessThanOrEqual: + summary: Search with Less Than Or Equal + value: + $filter: + lessThanOrEqual: + Id: 0 + required: true + responses: + 200: + description: Successful Request + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ProductLeaflet' + 403: + description: Forbidden Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' +components: + schemas: + ProductType: + type: object + required: + properties: + Id: + type: integer + format: int32 + Name: + type: string + minLength: 0 + maxLength: 200 + ProductTypeFilterOptions: + type: object + properties: + $filter: + type: object + properties: + equals: + type: object + properties: + Id: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + Name: + oneOf: + - type: string + minLength: 0 + maxLength: 200 + - type: array + items: + type: string + format: double + minLength: 0 + maxLength: 200 + notEquals: + type: object + properties: + Id: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + Name: + oneOf: + - type: string + minLength: 0 + maxLength: 200 + - type: array + items: + type: string + format: double + minLength: 0 + maxLength: 200 + contains: + type: object + properties: + Id: + Name: + type: string + minLength: 0 + maxLength: 200 + greaterThan: + type: object + properties: + Id: + type: integer + format: int32 + Name: + type: string + minLength: 0 + maxLength: 200 + greaterThanOrEqual: + type: object + properties: + Id: + type: integer + format: int32 + Name: + type: string + minLength: 0 + maxLength: 200 + lessThan: + type: object + properties: + Id: + type: integer + format: int32 + Name: + type: string + minLength: 0 + maxLength: 200 + lessThanOrEqual: + type: object + properties: + Id: + type: integer + format: int32 + Name: + type: string + minLength: 0 + maxLength: 200 + $select: + type: array + example: ["Id", "Name"] + items: + type: string + $sort: + - type: string + example: "Id,Name" + $order: + type: string + enum: ["asc", "desc"] + example: "asc" + $offset: + type: integer + example: 0 + $limit: + type: integer + example: 10 + ProductCategory: + type: object + required: + properties: + Id: + type: integer + format: int32 + Name: + type: string + minLength: 0 + maxLength: 200 + Path: + type: string + minLength: 0 + maxLength: 2000 + ProductCategoryFilterOptions: + type: object + properties: + $filter: + type: object + properties: + equals: + type: object + properties: + Id: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + Name: + oneOf: + - type: string + minLength: 0 + maxLength: 200 + - type: array + items: + type: string + format: double + minLength: 0 maxLength: 200 Path: oneOf: @@ -5050,7 +5451,7 @@ components: Value: type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: type: integer format: int32 @@ -5094,13 +5495,13 @@ components: oneOf: - type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 - type: array items: type: string format: double minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: oneOf: - type: integer @@ -5143,13 +5544,13 @@ components: oneOf: - type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 - type: array items: type: string format: double minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: oneOf: - type: integer @@ -5170,7 +5571,7 @@ components: Value: type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: greaterThan: type: object @@ -5188,7 +5589,7 @@ components: Value: type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: type: integer format: int32 @@ -5208,7 +5609,7 @@ components: Value: type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: type: integer format: int32 @@ -5228,7 +5629,7 @@ components: Value: type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: type: integer format: int32 @@ -5248,7 +5649,7 @@ components: Value: type: string minLength: 0 - maxLength: 2000 + maxLength: 3000 Group: type: integer format: int32 @@ -6341,6 +6742,165 @@ components: $limit: type: integer example: 10 + ProductLeaflet: + type: object + required: + properties: + Id: + type: integer + format: int32 + Title: + type: integer + format: int32 + LeafletLink: + type: string + minLength: 0 + maxLength: 500 + ProductLeafletFilterOptions: + type: object + properties: + $filter: + type: object + properties: + equals: + type: object + properties: + Id: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + Title: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + LeafletLink: + oneOf: + - type: string + minLength: 0 + maxLength: 500 + - type: array + items: + type: string + format: double + minLength: 0 + maxLength: 500 + notEquals: + type: object + properties: + Id: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + Title: + oneOf: + - type: integer + format: int32 + - type: array + items: + type: integer + format: int32 + LeafletLink: + oneOf: + - type: string + minLength: 0 + maxLength: 500 + - type: array + items: + type: string + format: double + minLength: 0 + maxLength: 500 + contains: + type: object + properties: + Id: + Title: + LeafletLink: + type: string + minLength: 0 + maxLength: 500 + greaterThan: + type: object + properties: + Id: + type: integer + format: int32 + Title: + type: integer + format: int32 + LeafletLink: + type: string + minLength: 0 + maxLength: 500 + greaterThanOrEqual: + type: object + properties: + Id: + type: integer + format: int32 + Title: + type: integer + format: int32 + LeafletLink: + type: string + minLength: 0 + maxLength: 500 + lessThan: + type: object + properties: + Id: + type: integer + format: int32 + Title: + type: integer + format: int32 + LeafletLink: + type: string + minLength: 0 + maxLength: 500 + lessThanOrEqual: + type: object + properties: + Id: + type: integer + format: int32 + Title: + type: integer + format: int32 + LeafletLink: + type: string + minLength: 0 + maxLength: 500 + $select: + type: array + example: ["Id", "Title", "LeafletLink"] + items: + type: string + $sort: + - type: string + example: "Id,Title,LeafletLink" + $order: + type: string + enum: ["asc", "desc"] + example: "asc" + $offset: + type: integer + example: 0 + $limit: + type: integer + example: 10 Error: type: object properties: diff --git a/codbex-products/gen/codbex-products/dao/Products/ProductLeaflet.extensionpoint b/codbex-products/gen/codbex-products/dao/Products/ProductLeaflet.extensionpoint new file mode 100644 index 0000000..08a6caa --- /dev/null +++ b/codbex-products/gen/codbex-products/dao/Products/ProductLeaflet.extensionpoint @@ -0,0 +1,4 @@ +{ + "name": "codbex-products-Products-ProductLeaflet", + "description": "Extension Point for the codbex-products-Products-ProductLeaflet entity" +} \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/dao/Products/ProductLeafletRepository.ts b/codbex-products/gen/codbex-products/dao/Products/ProductLeafletRepository.ts new file mode 100644 index 0000000..154c938 --- /dev/null +++ b/codbex-products/gen/codbex-products/dao/Products/ProductLeafletRepository.ts @@ -0,0 +1,211 @@ +import { sql, query } from "sdk/db"; +import { producer } from "sdk/messaging"; +import { extensions } from "sdk/extensions"; +import { dao as daoApi } from "sdk/db"; + +export interface ProductLeafletEntity { + readonly Id: number; + Title?: number; + LeafletLink?: string; +} + +export interface ProductLeafletCreateEntity { + readonly Title?: number; + readonly LeafletLink?: string; +} + +export interface ProductLeafletUpdateEntity extends ProductLeafletCreateEntity { + readonly Id: number; +} + +export interface ProductLeafletEntityOptions { + $filter?: { + equals?: { + Id?: number | number[]; + Title?: number | number[]; + LeafletLink?: string | string[]; + }; + notEquals?: { + Id?: number | number[]; + Title?: number | number[]; + LeafletLink?: string | string[]; + }; + contains?: { + Id?: number; + Title?: number; + LeafletLink?: string; + }; + greaterThan?: { + Id?: number; + Title?: number; + LeafletLink?: string; + }; + greaterThanOrEqual?: { + Id?: number; + Title?: number; + LeafletLink?: string; + }; + lessThan?: { + Id?: number; + Title?: number; + LeafletLink?: string; + }; + lessThanOrEqual?: { + Id?: number; + Title?: number; + LeafletLink?: string; + }; + }, + $select?: (keyof ProductLeafletEntity)[], + $sort?: string | (keyof ProductLeafletEntity)[], + $order?: 'ASC' | 'DESC', + $offset?: number, + $limit?: number, + $language?: string +} + +export interface ProductLeafletEntityEvent { + readonly operation: 'create' | 'update' | 'delete'; + readonly table: string; + readonly entity: Partial; + readonly key: { + name: string; + column: string; + value: number; + } +} + +export interface ProductLeafletUpdateEntityEvent extends ProductLeafletEntityEvent { + readonly previousEntity: ProductLeafletEntity; +} + +export class ProductLeafletRepository { + + private static readonly DEFINITION = { + table: "CODBEX_PRODUCTLEAFLET", + properties: [ + { + name: "Id", + column: "PRODUCTLEAFLET_ID", + type: "INTEGER", + id: true, + autoIncrement: true, + }, + { + name: "Title", + column: "PRODUCTLEAFLET_TITLE", + type: "INTEGER", + }, + { + name: "LeafletLink", + column: "PRODUCTLEAFLET_LEAFLETLINK", + type: "VARCHAR", + } + ] + }; + + private readonly dao; + + constructor(dataSource = "DefaultDB") { + this.dao = daoApi.create(ProductLeafletRepository.DEFINITION, undefined, dataSource); + } + + public findAll(options: ProductLeafletEntityOptions = {}): ProductLeafletEntity[] { + let list = this.dao.list(options); + return list; + } + + public findById(id: number, options: ProductLeafletEntityOptions = {}): ProductLeafletEntity | undefined { + const entity = this.dao.find(id); + return entity ?? undefined; + } + + public create(entity: ProductLeafletCreateEntity): number { + const id = this.dao.insert(entity); + this.triggerEvent({ + operation: "create", + table: "CODBEX_PRODUCTLEAFLET", + entity: entity, + key: { + name: "Id", + column: "PRODUCTLEAFLET_ID", + value: id + } + }); + return id; + } + + public update(entity: ProductLeafletUpdateEntity): void { + const previousEntity = this.findById(entity.Id); + this.dao.update(entity); + this.triggerEvent({ + operation: "update", + table: "CODBEX_PRODUCTLEAFLET", + entity: entity, + previousEntity: previousEntity, + key: { + name: "Id", + column: "PRODUCTLEAFLET_ID", + value: entity.Id + } + }); + } + + public upsert(entity: ProductLeafletCreateEntity | ProductLeafletUpdateEntity): number { + const id = (entity as ProductLeafletUpdateEntity).Id; + if (!id) { + return this.create(entity); + } + + const existingEntity = this.findById(id); + if (existingEntity) { + this.update(entity as ProductLeafletUpdateEntity); + return id; + } else { + return this.create(entity); + } + } + + public deleteById(id: number): void { + const entity = this.dao.find(id); + this.dao.remove(id); + this.triggerEvent({ + operation: "delete", + table: "CODBEX_PRODUCTLEAFLET", + entity: entity, + key: { + name: "Id", + column: "PRODUCTLEAFLET_ID", + value: id + } + }); + } + + public count(options?: ProductLeafletEntityOptions): number { + return this.dao.count(options); + } + + public customDataCount(): number { + const resultSet = query.execute('SELECT COUNT(*) AS COUNT FROM "CODBEX_PRODUCTLEAFLET"'); + if (resultSet !== null && resultSet[0] !== null) { + if (resultSet[0].COUNT !== undefined && resultSet[0].COUNT !== null) { + return resultSet[0].COUNT; + } else if (resultSet[0].count !== undefined && resultSet[0].count !== null) { + return resultSet[0].count; + } + } + return 0; + } + + private async triggerEvent(data: ProductLeafletEntityEvent | ProductLeafletUpdateEntityEvent) { + const triggerExtensions = await extensions.loadExtensionModules("codbex-products-Products-ProductLeaflet", ["trigger"]); + triggerExtensions.forEach(triggerExtension => { + try { + triggerExtension.trigger(data); + } catch (error) { + console.error(error); + } + }); + producer.topic("codbex-products-Products-ProductLeaflet").send(JSON.stringify(data)); + } +} diff --git a/codbex-products/gen/codbex-products/schema/codbex-products.schema b/codbex-products/gen/codbex-products/schema/codbex-products.schema index 85cdda4..49193d3 100644 --- a/codbex-products/gen/codbex-products/schema/codbex-products.schema +++ b/codbex-products/gen/codbex-products/schema/codbex-products.schema @@ -221,7 +221,7 @@ }, { "type": "VARCHAR", - "length": 2000, + "length": 3000, "nullable": true, "name": "PRODUCTATTRIBUTE_VALUE" }, @@ -402,6 +402,30 @@ } ] }, + { + "name": "CODBEX_PRODUCTLEAFLET", + "type": "TABLE", + "columns": [ + { + "type": "INTEGER", + "primaryKey": true, + "identity": true, + "nullable": true, + "name": "PRODUCTLEAFLET_ID" + }, + { + "type": "INTEGER", + "nullable": true, + "name": "PRODUCTLEAFLET_TITLE" + }, + { + "type": "VARCHAR", + "length": 500, + "nullable": true, + "name": "PRODUCTLEAFLET_LEAFLETLINK" + } + ] + }, { "name": "Product_Currency", "type": "foreignKey", @@ -500,6 +524,15 @@ "columns": "CAMPAIGNENTRY_CAMPAIGN", "referencedTable": "CODBEX_CAMPAIGN", "referencedColumns": "CAMPAIGN_ID" + }, + { + "name": "ProductLeaflet_Product", + "type": "foreignKey", + "table": "CODBEX_PRODUCTLEAFLET", + "constraintName": "ProductLeaflet_Product", + "columns": "PRODUCTLEAFLET_TITLE", + "referencedTable": "CODBEX_PRODUCT", + "referencedColumns": "PRODUCT_ID" } ] }, diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/controller.js b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/controller.js new file mode 100644 index 0000000..3b4196c --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/controller.js @@ -0,0 +1,257 @@ +angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) + .config(['EntityServiceProvider', (EntityServiceProvider) => { + EntityServiceProvider.baseUrl = '/services/ts/codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts'; + }]) + .controller('PageController', ($scope, $http, EntityService, Extensions, LocaleService, ButtonStates) => { + const Dialogs = new DialogHub(); + let translated = { + yes: 'Yes', + no: 'No', + deleteConfirm: 'Are you sure you want to delete ProductLeaflet? This action cannot be undone.', + deleteTitle: 'Delete ProductLeaflet?' + }; + + LocaleService.onInit(() => { + translated.yes = LocaleService.t('codbex-products:codbex-products-model.defaults.yes'); + translated.no = LocaleService.t('codbex-products:codbex-products-model.defaults.no'); + translated.deleteTitle = LocaleService.t('codbex-products:codbex-products-model.defaults.deleteTitle', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + translated.deleteConfirm = LocaleService.t('codbex-products:codbex-products-model.messages.deleteConfirm', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + }); + //-----------------Custom Actions-------------------// + Extensions.getWindows(['codbex-products-custom-action']).then((response) => { + $scope.pageActions = response.data.filter(e => e.perspective === 'Products' && e.view === 'ProductLeaflet' && (e.type === 'page' || e.type === undefined)); + $scope.entityActions = response.data.filter(e => e.perspective === 'Products' && e.view === 'ProductLeaflet' && e.type === 'entity'); + }); + + $scope.triggerPageAction = (action) => { + Dialogs.showWindow({ + hasHeader: true, + title: LocaleService.t(action.translation.key, action.translation.options, action.label), + path: action.path, + params: { + selectedMainEntityKey: 'Title', + selectedMainEntityId: $scope.selectedMainEntityId, + }, + maxWidth: action.maxWidth, + maxHeight: action.maxHeight, + closeButton: true + }); + }; + + $scope.triggerEntityAction = (action) => { + Dialogs.showWindow({ + hasHeader: true, + title: LocaleService.t(action.translation.key, action.translation.options, action.label), + path: action.path, + params: { + id: $scope.entity.Id, + selectedMainEntityKey: 'Title', + selectedMainEntityId: $scope.selectedMainEntityId, + }, + closeButton: true + }); + }; + //-----------------Custom Actions-------------------// + + function resetPagination() { + $scope.dataPage = 1; + $scope.dataCount = 0; + $scope.dataLimit = 10; + } + resetPagination(); + + //-----------------Events-------------------// + Dialogs.addMessageListener({ topic: 'codbex-products.Products.Product.entitySelected', handler: (data) => { + resetPagination(); + $scope.selectedMainEntityId = data.selectedMainEntityId; + $scope.loadPage($scope.dataPage); + }}); + Dialogs.addMessageListener({ topic: 'codbex-products.Products.Product.clearDetails', handler: () => { + $scope.$evalAsync(() => { + resetPagination(); + $scope.selectedMainEntityId = null; + $scope.data = null; + }); + }}); + Dialogs.addMessageListener({ topic: 'codbex-products.Products.ProductLeaflet.clearDetails', handler: () => { + $scope.$evalAsync(() => { + $scope.entity = {}; + $scope.action = 'select'; + }); + }}); + Dialogs.addMessageListener({ topic: 'codbex-products.Products.ProductLeaflet.entityCreated', handler: () => { + $scope.loadPage($scope.dataPage, $scope.filter); + }}); + Dialogs.addMessageListener({ topic: 'codbex-products.Products.ProductLeaflet.entityUpdated', handler: () => { + $scope.loadPage($scope.dataPage, $scope.filter); + }}); + Dialogs.addMessageListener({ topic: 'codbex-products.Products.ProductLeaflet.entitySearch', handler: (data) => { + resetPagination(); + $scope.filter = data.filter; + $scope.filterEntity = data.entity; + $scope.loadPage($scope.dataPage, $scope.filter); + }}); + //-----------------Events-------------------// + + $scope.loadPage = (pageNumber, filter) => { + let Title = $scope.selectedMainEntityId; + $scope.dataPage = pageNumber; + if (!filter && $scope.filter) { + filter = $scope.filter; + } + if (!filter) { + filter = {}; + } + if (!filter.$filter) { + filter.$filter = {}; + } + if (!filter.$filter.equals) { + filter.$filter.equals = {}; + } + filter.$filter.equals.Title = Title; + EntityService.count(filter).then((resp) => { + if (resp.data) { + $scope.dataCount = resp.data.count; + } + filter.$offset = (pageNumber - 1) * $scope.dataLimit; + filter.$limit = $scope.dataLimit; + EntityService.search(filter).then((response) => { + $scope.data = response.data; + }, (error) => { + const message = error.data ? error.data.message : ''; + Dialogs.showAlert({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + message: LocaleService.t('codbex-products:codbex-products-model.messages.error.unableToLF', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)', message: message }), + type: AlertTypes.Error + }); + console.error('EntityService:', error); + }); + }, (error) => { + const message = error.data ? error.data.message : ''; + Dialogs.showAlert({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + message: LocaleService.t('codbex-products:codbex-products-model.messages.error.unableToCount', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)', message: message }), + type: AlertTypes.Error + }); + console.error('EntityService:', error); + }); + }; + + $scope.selectEntity = (entity) => { + $scope.selectedEntity = entity; + }; + + $scope.openDetails = (entity) => { + $scope.selectedEntity = entity; + Dialogs.showWindow({ + id: 'ProductLeaflet-details', + params: { + action: 'select', + entity: entity, + optionsTitle: $scope.optionsTitle, + }, + }); + }; + + $scope.openFilter = () => { + Dialogs.showWindow({ + id: 'ProductLeaflet-filter', + params: { + entity: $scope.filterEntity, + optionsTitle: $scope.optionsTitle, + }, + }); + }; + + $scope.createEntity = () => { + $scope.selectedEntity = null; + Dialogs.showWindow({ + id: 'ProductLeaflet-details', + params: { + action: 'create', + entity: { + 'Title': $scope.selectedMainEntityId + }, + selectedMainEntityKey: 'Title', + selectedMainEntityId: $scope.selectedMainEntityId, + optionsTitle: $scope.optionsTitle, + }, + closeButton: false + }); + }; + + $scope.updateEntity = (entity) => { + Dialogs.showWindow({ + id: 'ProductLeaflet-details', + params: { + action: 'update', + entity: entity, + selectedMainEntityKey: 'Title', + selectedMainEntityId: $scope.selectedMainEntityId, + optionsTitle: $scope.optionsTitle, + }, + closeButton: false + }); + }; + + $scope.deleteEntity = (entity) => { + let id = entity.Id; + Dialogs.showDialog({ + title: translated.deleteTitle, + message: translated.deleteConfirm, + buttons: [{ + id: 'delete-btn-yes', + state: ButtonStates.Emphasized, + label: translated.yes, + }, { + id: 'delete-btn-no', + label: translated.no, + }], + closeButton: false + }).then((buttonId) => { + if (buttonId === 'delete-btn-yes') { + EntityService.delete(id).then(() => { + $scope.loadPage($scope.dataPage, $scope.filter); + Dialogs.triggerEvent('codbex-products.Products.ProductLeaflet.clearDetails'); + }, (error) => { + const message = error.data ? error.data.message : ''; + Dialogs.showAlert({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + message: LocaleService.t('codbex-products:codbex-products-model.messages.error.unableToDelete', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)', message: message }), + type: AlertTypes.Error, + }); + console.error('EntityService:', error); + }); + } + }); + }; + + //----------------Dropdowns-----------------// + $scope.optionsTitle = []; + + + $http.get('/services/ts/codbex-products/gen/codbex-products/api/Products/ProductService.ts').then((response) => { + $scope.optionsTitle = response.data.map(e => ({ + value: e.Id, + text: e.Name + })); + }, (error) => { + console.error(error); + const message = error.data ? error.data.message : ''; + Dialogs.showAlert({ + title: 'Title', + message: LocaleService.t('codbex-products:codbex-products-model.messages.error.unableToLoad', { message: message }), + type: AlertTypes.Error + }); + }); + + $scope.optionsTitleValue = function (optionKey) { + for (let i = 0; i < $scope.optionsTitle.length; i++) { + if ($scope.optionsTitle[i].value === optionKey) { + return $scope.optionsTitle[i].text; + } + } + return null; + }; + //----------------Dropdowns-----------------// + }); diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/controller.js b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/controller.js new file mode 100644 index 0000000..377ae7b --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/controller.js @@ -0,0 +1,64 @@ +angular.module('page', ['blimpKit', 'platformView', 'platformLocale']).controller('PageController', ($scope, ViewParameters) => { + const Dialogs = new DialogHub(); + $scope.entity = {}; + $scope.forms = { + details: {}, + }; + + let params = ViewParameters.get(); + if (Object.keys(params).length) { + $scope.entity = params.entity ?? {}; + $scope.selectedMainEntityKey = params.selectedMainEntityKey; + $scope.selectedMainEntityId = params.selectedMainEntityId; + $scope.optionsTitle = params.optionsTitle; + } + + $scope.filter = () => { + let entity = $scope.entity; + const filter = { + $filter: { + equals: { + }, + notEquals: { + }, + contains: { + }, + greaterThan: { + }, + greaterThanOrEqual: { + }, + lessThan: { + }, + lessThanOrEqual: { + } + }, + }; + if (entity.Id !== undefined) { + filter.$filter.equals.Id = entity.Id; + } + if (entity.Title !== undefined) { + filter.$filter.equals.Title = entity.Title; + } + if (entity.LeafletLink) { + filter.$filter.contains.LeafletLink = entity.LeafletLink; + } + Dialogs.postMessage({ topic: 'codbex-products.Products.ProductLeaflet.entitySearch', data: { + entity: entity, + filter: filter + }}); + $scope.cancel(); + }; + + $scope.resetFilter = () => { + $scope.entity = {}; + $scope.filter(); + }; + + $scope.cancel = () => { + Dialogs.closeWindow({ id: 'ProductLeaflet-filter' }); + }; + + $scope.clearErrorMessage = () => { + $scope.errorMessage = null; + }; +}); \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/index.html b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/index.html new file mode 100644 index 0000000..df62e47 --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/index.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + {{ errorMessage }} + + + + +
+ {{ 'codbex-products:codbex-products-model.t.PRODUCTLEAFLET_LEAFLETLINK' | t }} +
+
+ + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.extension b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.extension new file mode 100644 index 0000000..812486e --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.extension @@ -0,0 +1,5 @@ +{ + "module": "codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.js", + "extensionPoint": "application-windows", + "description": "codbex-products - Application Dialog Window" +} \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.js b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.js new file mode 100644 index 0000000..e49c60c --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/view.js @@ -0,0 +1,20 @@ +/* + * Generated by Eclipse Dirigible based on model and template. + * + * Do not modify the content as it may be re-generated again. + */ +const viewData = { + id: 'ProductLeaflet-filter', + label: 'ProductLeaflet Filter', + translation: { + key: 'codbex-products:codbex-products-model.extName', + options: { + content: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET) $t(codbex-products:codbex-products-model.defaults.filter)', + } + }, + path: '/services/web/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-filter/index.html', + perspectiveName: 'Products' +}; +if (typeof exports !== 'undefined') { + exports.getView = () => viewData; +} \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/controller.js b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/controller.js new file mode 100644 index 0000000..6731c4f --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/controller.js @@ -0,0 +1,101 @@ +angular.module('page', ['blimpKit', 'platformView', 'platformLocale', 'EntityService']) + .config(['EntityServiceProvider', (EntityServiceProvider) => { + EntityServiceProvider.baseUrl = '/services/ts/codbex-products/gen/codbex-products/api/Products/ProductLeafletService.ts'; + }]) + .controller('PageController', ($scope, $http, ViewParameters, LocaleService, EntityService) => { + const Dialogs = new DialogHub(); + const Notifications = new NotificationHub(); + let description = 'Description'; + let propertySuccessfullyCreated = 'ProductLeaflet successfully created'; + let propertySuccessfullyUpdated = 'ProductLeaflet successfully updated'; + $scope.entity = {}; + $scope.forms = { + details: {}, + }; + $scope.formHeaders = { + select: 'ProductLeaflet Details', + create: 'Create ProductLeaflet', + update: 'Update ProductLeaflet' + }; + $scope.action = 'select'; + + LocaleService.onInit(() => { + description = LocaleService.t('codbex-products:codbex-products-model.defaults.description'); + $scope.formHeaders.select = LocaleService.t('codbex-products:codbex-products-model.defaults.formHeadSelect', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + $scope.formHeaders.create = LocaleService.t('codbex-products:codbex-products-model.defaults.formHeadCreate', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + $scope.formHeaders.update = LocaleService.t('codbex-products:codbex-products-model.defaults.formHeadUpdate', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + propertySuccessfullyCreated = LocaleService.t('codbex-products:codbex-products-model.messages.propertySuccessfullyCreated', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + propertySuccessfullyUpdated = LocaleService.t('codbex-products:codbex-products-model.messages.propertySuccessfullyUpdated', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)' }); + }); + + let params = ViewParameters.get(); + if (Object.keys(params).length) { + $scope.action = params.action; + $scope.entity = params.entity; + $scope.selectedMainEntityKey = params.selectedMainEntityKey; + $scope.selectedMainEntityId = params.selectedMainEntityId; + $scope.optionsTitle = params.optionsTitle; + } + + $scope.create = () => { + let entity = $scope.entity; + entity[$scope.selectedMainEntityKey] = $scope.selectedMainEntityId; + EntityService.create(entity).then((response) => { + Dialogs.postMessage({ topic: 'codbex-products.Products.ProductLeaflet.entityCreated', data: response.data }); + Notifications.show({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + description: propertySuccessfullyCreated, + type: 'positive' + }); + $scope.cancel(); + }, (error) => { + const message = error.data ? error.data.message : ''; + Dialogs.showAlert({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + message: LocaleService.t('codbex-products:codbex-products-model.messages.error.unableToCreate', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)', message: message }), + type: AlertTypes.Error + }); + console.error('EntityService:', error); + }); + }; + + $scope.update = () => { + let id = $scope.entity.Id; + let entity = $scope.entity; + entity[$scope.selectedMainEntityKey] = $scope.selectedMainEntityId; + EntityService.update(id, entity).then((response) => { + Dialogs.postMessage({ topic: 'codbex-products.Products.ProductLeaflet.entityUpdated', data: response.data }); + Notifications.show({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + description: propertySuccessfullyUpdated, + type: 'positive' + }); + $scope.cancel(); + }, (error) => { + const message = error.data ? error.data.message : ''; + Dialogs.showAlert({ + title: LocaleService.t('codbex-products:codbex-products-model.t.PRODUCTLEAFLET'), + message: LocaleService.t('codbex-products:codbex-products-model.messages.error.unableToUpdate', { name: '$t(codbex-products:codbex-products-model.t.PRODUCTLEAFLET)', message: message }), + type: AlertTypes.Error + }); + console.error('EntityService:', error); + }); + }; + + $scope.serviceTitle = '/services/ts/codbex-products/gen/codbex-products/api/Products/ProductService.ts'; + + $scope.alert = (message) => { + if (message) Dialogs.showAlert({ + title: description, + message: message, + type: AlertTypes.Information, + preformatted: true, + }); + }; + + $scope.cancel = () => { + $scope.entity = {}; + $scope.action = 'select'; + Dialogs.closeWindow({ id: 'ProductLeaflet-details' }); + }; + }); \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/index.html b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/index.html new file mode 100644 index 0000000..b916492 --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/index.html @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + +
+ {{ 'codbex-products:codbex-products-model.t.PRODUCTLEAFLET_LEAFLETLINK' | t }} +
+
+ {{entity.LeafletLink}} +
+
+ + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.extension b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.extension new file mode 100644 index 0000000..cca8322 --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.extension @@ -0,0 +1,5 @@ +{ + "module": "codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.js", + "extensionPoint": "application-windows", + "description": "codbex-products - Application Dialog Window" +} \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.js b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.js new file mode 100644 index 0000000..10d9a4e --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/view.js @@ -0,0 +1,17 @@ +/* + * Generated by Eclipse Dirigible based on model and template. + * + * Do not modify the content as it may be re-generated again. + */ +const viewData = { + id: 'ProductLeaflet-details', + label: 'ProductLeaflet', + translation: { + key: 'codbex-products:codbex-products-model.t.PRODUCTLEAFLET', + }, + path: '/services/web/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/dialog-window/index.html', + perspectiveName: 'Products' +}; +if (typeof exports !== 'undefined') { + exports.getView = () => viewData; +} \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/index.html b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/index.html new file mode 100644 index 0000000..c2d171b --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/index.html @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + {{'codbex-products:codbex-products-model.messages.detailSelectRecord' | t}} + + + + {{'codbex-products:codbex-products-model.defaults.items' | t}} + + + + + + + + + + + + + + + + + + + + + + +
{{ 'codbex-products:codbex-products-model.t.PRODUCTLEAFLET_LEAFLETLINK' | t:'LeafletLink' }}
{{'codbex-products:codbex-products-model.messages.noData' | t}}
+ {{next.LeafletLink}} + + + + + + + + + + + + + + +
+
+ + + + + + + diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.extension b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.extension new file mode 100644 index 0000000..464f04b --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.extension @@ -0,0 +1,5 @@ +{ + "module": "codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.js", + "extensionPoint": "application-views", + "description": "codbex-products - Application View - Details" +} \ No newline at end of file diff --git a/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.js b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.js new file mode 100644 index 0000000..326a3c2 --- /dev/null +++ b/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/view.js @@ -0,0 +1,20 @@ +/* + * Generated by Eclipse Dirigible based on model and template. + * + * Do not modify the content as it may be re-generated again. + */ +const viewData = { + id: 'ProductLeaflet', + label: 'ProductLeaflet', + translation: { + key: 'codbex-products:codbex-products-model.t.PRODUCTLEAFLET', + }, + region: 'bottom', + lazyLoad: false, + autoFocusTab: true, + path: '/services/web/codbex-products/gen/codbex-products/ui/Products/Product/ProductLeaflet/index.html', + perspectiveName: 'Products' +}; +if (typeof exports !== 'undefined') { + exports.getView = () => viewData; +} \ No newline at end of file diff --git a/codbex-products/translations/en-US/codbex-products.model.json b/codbex-products/translations/en-US/codbex-products.model.json index 9d795e3..82b8bdc 100644 --- a/codbex-products/translations/en-US/codbex-products.model.json +++ b/codbex-products/translations/en-US/codbex-products.model.json @@ -156,6 +156,10 @@ "CAMPAIGNENTRY_OLDPRICE": "OldPrice", "CAMPAIGNENTRY_NEWPRICE": "NewPrice", "CAMPAIGNENTRY_GIFT": "Gift", + "PRODUCTLEAFLET": "ProductLeaflet", + "PRODUCTLEAFLET_ID": "Id", + "PRODUCTLEAFLET_TITLE": "Title", + "PRODUCTLEAFLET_LEAFLETLINK": "LeafletLink", "Products": "Products", "Categories": "Categories", "Campaigns": "Campaings"