From 09d3cd42386158799086302cb1f0873358dd6f1f Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Fri, 14 Jan 2022 15:20:31 +0600 Subject: [PATCH] Inventory (#823) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- common/config/rush/pnpm-lock.yaml | 109 +++++++++- dev/prod/package.json | 5 +- dev/prod/src/platform.ts | 3 + models/all/package.json | 1 + models/all/src/index.ts | 2 + models/attachment/src/index.ts | 12 +- models/inventory/.eslintrc.js | 7 + models/inventory/.npmignore | 4 + models/inventory/config/rig.json | 18 ++ models/inventory/package.json | 40 ++++ models/inventory/src/index.ts | 148 +++++++++++++ models/inventory/src/plugin.ts | 45 ++++ models/inventory/tsconfig.json | 8 + packages/panel/src/components/Panel.svelte | 115 +++++++---- plugins/attachment-assets/lang/en.json | 3 +- .../src/components/Photos.svelte | 195 ++++++++++++++++++ plugins/attachment-resources/src/index.ts | 13 +- plugins/attachment-resources/src/plugin.ts | 12 +- plugins/attachment/src/index.ts | 11 +- plugins/inventory-assets/assets/icons.svg | 21 ++ plugins/inventory-assets/lang/en.json | 23 +++ plugins/inventory-assets/package.json | 33 +++ plugins/inventory-assets/src/index.ts | 27 +++ plugins/inventory-assets/tsconfig.json | 15 ++ plugins/inventory-resources/.eslintrc.js | 7 + plugins/inventory-resources/package.json | 43 ++++ plugins/inventory-resources/postcss.config.js | 5 + .../src/components/Categories.svelte | 114 ++++++++++ .../src/components/CategoryPresenter.svelte | 26 +++ .../src/components/CreateCategory.svelte | 71 +++++++ .../src/components/CreateProduct.svelte | 90 ++++++++ .../src/components/CreateVariant.svelte | 72 +++++++ .../src/components/EditProduct.svelte | 152 ++++++++++++++ .../src/components/HierarchyElement.svelte | 139 +++++++++++++ .../src/components/HierarchyView.svelte | 109 ++++++++++ .../src/components/ProductPresenter.svelte | 50 +++++ .../src/components/Products.svelte | 132 ++++++++++++ .../src/components/VariantPresenter.svelte | 26 +++ .../src/components/Variants.svelte | 75 +++++++ .../src/components/icons/Collapse.svelte | 8 + .../src/components/icons/Expand.svelte | 8 + plugins/inventory-resources/src/index.ts | 46 +++++ plugins/inventory-resources/src/plugin.ts | 43 ++++ plugins/inventory-resources/svelte.config.js | 5 + plugins/inventory-resources/tsconfig.json | 15 ++ plugins/inventory/.eslintrc.js | 7 + plugins/inventory/.npmignore | 4 + plugins/inventory/package.json | 32 +++ plugins/inventory/src/index.ts | 76 +++++++ plugins/inventory/tsconfig.json | 9 + rush.json | 20 ++ 51 files changed, 2191 insertions(+), 63 deletions(-) create mode 100644 models/inventory/.eslintrc.js create mode 100644 models/inventory/.npmignore create mode 100644 models/inventory/config/rig.json create mode 100644 models/inventory/package.json create mode 100644 models/inventory/src/index.ts create mode 100644 models/inventory/src/plugin.ts create mode 100644 models/inventory/tsconfig.json create mode 100644 plugins/attachment-resources/src/components/Photos.svelte create mode 100644 plugins/inventory-assets/assets/icons.svg create mode 100644 plugins/inventory-assets/lang/en.json create mode 100644 plugins/inventory-assets/package.json create mode 100644 plugins/inventory-assets/src/index.ts create mode 100644 plugins/inventory-assets/tsconfig.json create mode 100644 plugins/inventory-resources/.eslintrc.js create mode 100644 plugins/inventory-resources/package.json create mode 100644 plugins/inventory-resources/postcss.config.js create mode 100644 plugins/inventory-resources/src/components/Categories.svelte create mode 100644 plugins/inventory-resources/src/components/CategoryPresenter.svelte create mode 100644 plugins/inventory-resources/src/components/CreateCategory.svelte create mode 100644 plugins/inventory-resources/src/components/CreateProduct.svelte create mode 100644 plugins/inventory-resources/src/components/CreateVariant.svelte create mode 100644 plugins/inventory-resources/src/components/EditProduct.svelte create mode 100644 plugins/inventory-resources/src/components/HierarchyElement.svelte create mode 100644 plugins/inventory-resources/src/components/HierarchyView.svelte create mode 100644 plugins/inventory-resources/src/components/ProductPresenter.svelte create mode 100644 plugins/inventory-resources/src/components/Products.svelte create mode 100644 plugins/inventory-resources/src/components/VariantPresenter.svelte create mode 100644 plugins/inventory-resources/src/components/Variants.svelte create mode 100644 plugins/inventory-resources/src/components/icons/Collapse.svelte create mode 100644 plugins/inventory-resources/src/components/icons/Expand.svelte create mode 100644 plugins/inventory-resources/src/index.ts create mode 100644 plugins/inventory-resources/src/plugin.ts create mode 100644 plugins/inventory-resources/svelte.config.js create mode 100644 plugins/inventory-resources/tsconfig.json create mode 100644 plugins/inventory/.eslintrc.js create mode 100644 plugins/inventory/.npmignore create mode 100644 plugins/inventory/package.json create mode 100644 plugins/inventory/src/index.ts create mode 100644 plugins/inventory/tsconfig.json diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 63d60d1f90..6a7c37180e 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -36,6 +36,9 @@ specifiers: '@rush-temp/gmail-resources': file:./projects/gmail-resources.tgz '@rush-temp/image-cropper': file:./projects/image-cropper.tgz '@rush-temp/image-cropper-resources': file:./projects/image-cropper-resources.tgz + '@rush-temp/inventory': file:./projects/inventory.tgz + '@rush-temp/inventory-assets': file:./projects/inventory-assets.tgz + '@rush-temp/inventory-resources': file:./projects/inventory-resources.tgz '@rush-temp/lead': file:./projects/lead.tgz '@rush-temp/lead-assets': file:./projects/lead-assets.tgz '@rush-temp/lead-resources': file:./projects/lead-resources.tgz @@ -51,6 +54,7 @@ specifiers: '@rush-temp/model-core': file:./projects/model-core.tgz '@rush-temp/model-demo': file:./projects/model-demo.tgz '@rush-temp/model-gmail': file:./projects/model-gmail.tgz + '@rush-temp/model-inventory': file:./projects/model-inventory.tgz '@rush-temp/model-lead': file:./projects/model-lead.tgz '@rush-temp/model-recruit': file:./projects/model-recruit.tgz '@rush-temp/model-rig': file:./projects/model-rig.tgz @@ -217,6 +221,9 @@ dependencies: '@rush-temp/gmail-resources': file:projects/gmail-resources.tgz_096c09b0b673a57c275d9767a12070b1 '@rush-temp/image-cropper': file:projects/image-cropper.tgz '@rush-temp/image-cropper-resources': file:projects/image-cropper-resources.tgz_096c09b0b673a57c275d9767a12070b1 + '@rush-temp/inventory': file:projects/inventory.tgz + '@rush-temp/inventory-assets': file:projects/inventory-assets.tgz + '@rush-temp/inventory-resources': file:projects/inventory-resources.tgz_096c09b0b673a57c275d9767a12070b1 '@rush-temp/lead': file:projects/lead.tgz '@rush-temp/lead-assets': file:projects/lead-assets.tgz '@rush-temp/lead-resources': file:projects/lead-resources.tgz_096c09b0b673a57c275d9767a12070b1 @@ -232,6 +239,7 @@ dependencies: '@rush-temp/model-core': file:projects/model-core.tgz_typescript@4.5.4 '@rush-temp/model-demo': file:projects/model-demo.tgz_typescript@4.5.4 '@rush-temp/model-gmail': file:projects/model-gmail.tgz_typescript@4.5.4 + '@rush-temp/model-inventory': file:projects/model-inventory.tgz_typescript@4.5.4 '@rush-temp/model-lead': file:projects/model-lead.tgz_typescript@4.5.4 '@rush-temp/model-recruit': file:projects/model-recruit.tgz_typescript@4.5.4 '@rush-temp/model-rig': file:projects/model-rig.tgz_37f79b97d0d86442e45d380c86f520c5 @@ -11436,6 +11444,82 @@ packages: - supports-color dev: false + file:projects/inventory-assets.tgz: + resolution: {integrity: sha512-z58zb5383o9j4S1y3tBAYdcGXdI9IORHbh5w+z/lI2PnS41B+HK1JsIrlrep+XG/w+xyAWn3OHlw77VJMQEDNw==, tarball: file:projects/inventory-assets.tgz} + name: '@rush-temp/inventory-assets' + version: 0.0.0 + dependencies: + '@rushstack/heft': 0.41.8 + '@types/heft-jest': 1.0.2 + '@types/node': 16.11.14 + '@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237 + '@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4 + eslint: 7.32.0 + eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a + eslint-plugin-import: 2.25.3_eslint@7.32.0 + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 + prettier: 2.5.1 + typescript: 4.5.4 + transitivePeerDependencies: + - supports-color + dev: false + + file:projects/inventory-resources.tgz_096c09b0b673a57c275d9767a12070b1: + resolution: {integrity: sha512-PiKSp7YMOeYnOnyDukPG1Qno6QmImWvc3qBJUY5ZKXiQyZWA9JpWqJm3WfoaprfoLVKCiSvqkA2r2XrqfIjJcQ==, tarball: file:projects/inventory-resources.tgz} + id: file:projects/inventory-resources.tgz + name: '@rush-temp/inventory-resources' + version: 0.0.0 + dependencies: + '@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237 + '@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4 + eslint: 7.32.0 + eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a + eslint-plugin-import: 2.25.3_eslint@7.32.0 + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 + eslint-plugin-svelte3: 3.2.1_eslint@7.32.0+svelte@3.44.3 + prettier: 2.5.1 + prettier-plugin-svelte: 2.5.1_prettier@2.5.1+svelte@3.44.3 + sass: 1.45.0 + svelte: 3.44.3 + svelte-check: 2.2.11_4374c622c67ed7479ff0e44c29d09bce + svelte-loader: 3.1.2_svelte@3.44.3 + svelte-preprocess: 4.10.1_14d64cad431e31f100de7363af24a44f + typescript: 4.5.4 + transitivePeerDependencies: + - '@babel/core' + - coffeescript + - less + - node-sass + - postcss + - postcss-load-config + - pug + - stylus + - sugarss + - supports-color + dev: false + + file:projects/inventory.tgz: + resolution: {integrity: sha512-gd3ZCKg7WVdifG6BWuXJhwBNgjdyaFyTaWdlH9e+gFI2a9M9HYeIVmYBWDC2X6QP6//G2yv6sykXytwVaMgqKw==, tarball: file:projects/inventory.tgz} + name: '@rush-temp/inventory' + version: 0.0.0 + dependencies: + '@rushstack/heft': 0.41.8 + '@types/heft-jest': 1.0.2 + '@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237 + '@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4 + eslint: 7.32.0 + eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a + eslint-plugin-import: 2.25.3_eslint@7.32.0 + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 + prettier: 2.5.1 + typescript: 4.5.4 + transitivePeerDependencies: + - supports-color + dev: false + file:projects/lead-assets.tgz: resolution: {integrity: sha512-cRYB8PutP6HmaJjoEMLIEyMQEhKAQaCu0w2NJMF5TUW9vokia/22TXsHo1+xEGI1rx2epywbGXet/fL40tdbDw==, tarball: file:projects/lead-assets.tgz} name: '@rush-temp/lead-assets' @@ -11580,7 +11664,7 @@ packages: dev: false file:projects/model-all.tgz_typescript@4.5.4: - resolution: {integrity: sha512-oKPQz2zoE53ROTtb76Vp43+PatfI+CKrdq0sUleUVaKPfWw74BKTXmqSAkZU1PVnr/DaKY/Gnl9Eo9JrXOUiig==, tarball: file:projects/model-all.tgz} + resolution: {integrity: sha512-QqT4D4AgEQSvRi5epmizX6ipSCnOlaklFy5ne2rUIVJ1MU0cLgOfIXdCjkl47VTsT98JLOWSjv7y5X82bRGnHw==, tarball: file:projects/model-all.tgz} id: file:projects/model-all.tgz name: '@rush-temp/model-all' version: 0.0.0 @@ -11730,6 +11814,27 @@ packages: - typescript dev: false + file:projects/model-inventory.tgz_typescript@4.5.4: + resolution: {integrity: sha512-P+V2OydmT65gpPhJm85tPkIn5uLRKQmu2sMHg/1oRJLXKCeQz1wAgb5ZzlzmgbilrrfchcwYtJHyPANNcnBrdg==, tarball: file:projects/model-inventory.tgz} + id: file:projects/model-inventory.tgz + name: '@rush-temp/model-inventory' + version: 0.0.0 + dependencies: + '@rushstack/heft': 0.41.8 + '@types/heft-jest': 1.0.2 + '@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237 + '@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4 + eslint: 7.32.0 + eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a + eslint-plugin-import: 2.25.3_eslint@7.32.0 + eslint-plugin-node: 11.1.0_eslint@7.32.0 + eslint-plugin-promise: 5.2.0_eslint@7.32.0 + prettier: 2.5.1 + transitivePeerDependencies: + - supports-color + - typescript + dev: false + file:projects/model-lead.tgz_typescript@4.5.4: resolution: {integrity: sha512-3+Wf+/TdMpbuSoiTaI/ga+1KHSsPd1q9MDtpG6i4oAhxt/48aTZnfOV4nt9hrpWy2MmQWVhK9YJFTaKGIgKwOA==, tarball: file:projects/model-lead.tgz} id: file:projects/model-lead.tgz @@ -12154,7 +12259,7 @@ packages: dev: false file:projects/prod.tgz_sass@1.45.0+typescript@4.5.4: - resolution: {integrity: sha512-7OeW4OKQlYw/FrF1rSmbwacpTXSVzNnIPCb/mIP/Q4Kc+uxroItvCRRYUqVH/V9u8W7nyTE7CjDM+KrADL/BAg==, tarball: file:projects/prod.tgz} + resolution: {integrity: sha512-aYcYW/uvTMNxOOsjG9io+pTV+pyk0a2CIsoJsF8tFnywgIBJb2X39Yj33nmjRvPpYdsaF4ujn0IdbK4IfM0kZw==, tarball: file:projects/prod.tgz} id: file:projects/prod.tgz name: '@rush-temp/prod' version: 0.0.0 diff --git a/dev/prod/package.json b/dev/prod/package.json index 4d2068e871..19fc17cc26 100644 --- a/dev/prod/package.json +++ b/dev/prod/package.json @@ -90,6 +90,9 @@ "@anticrm/gmail-assets": "~0.6.0", "@anticrm/gmail-resources": "~0.6.0", "@anticrm/image-cropper": "~0.6.0", - "@anticrm/image-cropper-resources": "~0.6.0" + "@anticrm/image-cropper-resources": "~0.6.0", + "@anticrm/inventory": "~0.6.0", + "@anticrm/inventory-assets": "~0.6.0", + "@anticrm/inventory-resources": "~0.6.0" } } diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 4fd7bba820..8a0b7bfdef 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -30,6 +30,7 @@ import { leadId } from '@anticrm/lead' import { clientId } from '@anticrm/client' import { gmailId } from '@anticrm/gmail' import { imageCropperId } from '@anticrm/image-cropper' +import { inventoryId } from '@anticrm/inventory' import '@anticrm/login-assets' import '@anticrm/task-assets' @@ -44,6 +45,7 @@ import '@anticrm/telegram-assets' import '@anticrm/lead-assets' import '@anticrm/gmail-assets' import '@anticrm/workbench-assets' +import '@anticrm/inventory-assets' import { setMetadata } from '@anticrm/platform' export async function configurePlatform() { @@ -73,4 +75,5 @@ export async function configurePlatform() { addLocation(attachmentId, () => import(/* webpackChunkName: "attachment" */ '@anticrm/attachment-resources')) addLocation(gmailId, () => import(/* webpackChunkName: "gmail" */ '@anticrm/gmail-resources')) addLocation(imageCropperId, () => import(/* webpackChunkName: "image-cropper" */ '@anticrm/image-cropper-resources')) + addLocation(inventoryId, () => import(/* webpackChunkName: "inventory" */ '@anticrm/inventory-resources')) } diff --git a/models/all/package.json b/models/all/package.json index 51ec13ceb6..e0ff9b7e05 100644 --- a/models/all/package.json +++ b/models/all/package.json @@ -46,6 +46,7 @@ "@anticrm/model-activity": "~0.6.0", "@anticrm/model-attachment": "~0.6.0", "@anticrm/model-gmail": "~0.6.0", + "@anticrm/model-inventory": "~0.6.0", "@anticrm/core": "~0.6.13" } } diff --git a/models/all/src/index.ts b/models/all/src/index.ts index 0d3b0929fe..43714c3c3d 100644 --- a/models/all/src/index.ts +++ b/models/all/src/index.ts @@ -27,6 +27,7 @@ import { createModel as telegramModel } from '@anticrm/model-telegram' import { createModel as attachmentModel } from '@anticrm/model-attachment' import { createModel as leadModel } from '@anticrm/model-lead' import { createModel as gmailModel } from '@anticrm/model-gmail' +import { createModel as inventoryModel } from '@anticrm/model-inventory' import { createModel as serverCoreModel } from '@anticrm/model-server-core' import { createModel as serverChunterModel } from '@anticrm/model-server-chunter' @@ -50,6 +51,7 @@ settingModel(builder) telegramModel(builder) leadModel(builder) gmailModel(builder) +inventoryModel(builder) serverCoreModel(builder) serverChunterModel(builder) diff --git a/models/attachment/src/index.ts b/models/attachment/src/index.ts index 1ce7be05d6..986c6bb733 100644 --- a/models/attachment/src/index.ts +++ b/models/attachment/src/index.ts @@ -17,7 +17,7 @@ import type { IntlString } from '@anticrm/platform' import { Builder, Model, Prop, UX, TypeString, TypeTimestamp } from '@anticrm/model' import type { Domain } from '@anticrm/core' import core, { TAttachedDoc } from '@anticrm/model-core' -import type { Attachment } from '@anticrm/attachment' +import type { Attachment, Photo } from '@anticrm/attachment' import activity from '@anticrm/activity' import view from '@anticrm/model-view' @@ -46,8 +46,12 @@ export class TAttachment extends TAttachedDoc implements Attachment { lastModified!: number } +@Model(attachment.class.Photo, attachment.class.Attachment) +@UX('Photo' as IntlString) +export class TPhoto extends TAttachment implements Photo {} + export function createModel (builder: Builder): void { - builder.createModel(TAttachment) + builder.createModel(TAttachment, TPhoto) builder.mixin(attachment.class.Attachment, core.class.Class, view.mixin.AttributePresenter, { presenter: attachment.component.AttachmentPresenter @@ -57,6 +61,10 @@ export function createModel (builder: Builder): void { editor: attachment.component.Attachments }) + builder.mixin(attachment.class.Photo, core.class.Class, view.mixin.AttributeEditor, { + editor: attachment.component.Photos + }) + builder.createDoc( activity.class.TxViewlet, core.space.Model, diff --git a/models/inventory/.eslintrc.js b/models/inventory/.eslintrc.js new file mode 100644 index 0000000000..c3c2c49417 --- /dev/null +++ b/models/inventory/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + extends: ['./node_modules/@anticrm/model-rig/profiles/default/config/eslint.config.json'], + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.json' + } +} diff --git a/models/inventory/.npmignore b/models/inventory/.npmignore new file mode 100644 index 0000000000..e3ec093c38 --- /dev/null +++ b/models/inventory/.npmignore @@ -0,0 +1,4 @@ +* +!/lib/** +!CHANGELOG.md +/lib/**/__tests__/ diff --git a/models/inventory/config/rig.json b/models/inventory/config/rig.json new file mode 100644 index 0000000000..e9a9ee9add --- /dev/null +++ b/models/inventory/config/rig.json @@ -0,0 +1,18 @@ +// The "rig.json" file directs tools to look for their config files in an external package. +// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package +{ + "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", + + /** + * (Required) The name of the rig package to inherit from. + * It should be an NPM package name with the "-rig" suffix. + */ + "rigPackageName": "@anticrm/model-rig" + + /** + * (Optional) Selects a config profile from the rig package. The name must consist of + * lowercase alphanumeric words separated by hyphens, for example "sample-profile". + * If omitted, then the "default" profile will be used." + */ + // "rigProfile": "your-profile-name" +} diff --git a/models/inventory/package.json b/models/inventory/package.json new file mode 100644 index 0000000000..cb817ccf57 --- /dev/null +++ b/models/inventory/package.json @@ -0,0 +1,40 @@ +{ + "name": "@anticrm/model-inventory", + "version": "0.6.0", + "main": "lib/index.js", + "author": "Anticrm Platform Contributors", + "license": "EPL-2.0", + "scripts": { + "build": "heft build", + "build:watch": "tsc", + "lint:fix": "eslint --fix src", + "lint": "eslint src", + "format": "prettier --write src && eslint --fix src" + }, + "devDependencies": { + "@anticrm/model-rig": "~0.6.0", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-promise": "^5.1.1", + "eslint-plugin-node": "^11.1.0", + "eslint": "^7.32.0", + "@types/heft-jest": "^1.0.2", + "@typescript-eslint/parser": "^5.4.0", + "eslint-config-standard-with-typescript": "^21.0.1", + "prettier": "^2.4.1", + "@rushstack/heft": "^0.41.1" + }, + "dependencies": { + "@anticrm/core": "~0.6.11", + "@anticrm/model": "~0.6.0", + "@anticrm/model-workbench": "~0.6.0", + "@anticrm/model-attachment": "~0.6.0", + "@anticrm/model-core": "~0.6.0", + "@anticrm/ui": "~0.6.0", + "@anticrm/platform": "~0.6.5", + "@anticrm/inventory": "~0.6.0", + "@anticrm/inventory-resources": "~0.6.0", + "@anticrm/view": "~0.6.0", + "@anticrm/workbench": "~0.6.1" + } +} diff --git a/models/inventory/src/index.ts b/models/inventory/src/index.ts new file mode 100644 index 0000000000..d0d0175e96 --- /dev/null +++ b/models/inventory/src/index.ts @@ -0,0 +1,148 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021, 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// To help typescript locate view plugin properly +import type { Category, Product, Variant } from '@anticrm/inventory' +import { Doc, Domain, FindOptions, Ref } from '@anticrm/core' +import { Builder, Collection, Model, Prop, TypeRef, TypeString, UX } from '@anticrm/model' +import core, { TAttachedDoc } from '@anticrm/model-core' +import type { IntlString } from '@anticrm/platform' +import type {} from '@anticrm/view' +import inventory from './plugin' +import workbench from '@anticrm/model-workbench' +import view from '@anticrm/view' +import attachment from '@anticrm/model-attachment' + +export const DOMAIN_INVENTORY = 'inventory' as Domain +@Model(inventory.class.Category, core.class.AttachedDoc, DOMAIN_INVENTORY) +@UX(inventory.string.Category, inventory.icon.Categories, undefined, 'name') +export class TCategory extends TAttachedDoc implements Category { + @Prop(TypeString(), 'Name' as IntlString) + name!: string +} + +@Model(inventory.class.Product, core.class.AttachedDoc, DOMAIN_INVENTORY) +@UX(inventory.string.Product, inventory.icon.Products, undefined, 'name') +export class TProduct extends TAttachedDoc implements Product { + // We need to declare, to provide property with label + @Prop(TypeRef(inventory.class.Category), inventory.string.Category) + declare attachedTo: Ref + + @Prop(TypeString(), 'Name' as IntlString) + name!: string + + @Prop(Collection(attachment.class.Photo), attachment.string.Photos) + photos?: number + + @Prop(Collection(inventory.class.Variant), inventory.string.Variants) + variants?: number + + @Prop(Collection(attachment.class.Attachment), 'Attachments' as IntlString) + attachments?: number +} + +@Model(inventory.class.Variant, core.class.AttachedDoc, DOMAIN_INVENTORY) +@UX(inventory.string.Variant, inventory.icon.Variant, undefined, 'name') +export class TVariant extends TAttachedDoc implements Variant { + // We need to declare, to provide property with label + @Prop(TypeRef(inventory.class.Product), inventory.string.Product) + declare attachedTo: Ref + + @Prop(TypeString(), 'Name' as IntlString) + name!: string + + @Prop(TypeString(), inventory.string.SKU) + sku!: string +} + +export function createModel (builder: Builder): void { + builder.createModel(TCategory, TProduct, TVariant) + + builder.mixin(inventory.class.Category, core.class.Class, view.mixin.AttributePresenter, { + presenter: inventory.component.CategoryPresenter + }) + + builder.mixin(inventory.class.Product, core.class.Class, view.mixin.AttributePresenter, { + presenter: inventory.component.ProductPresenter + }) + + builder.mixin(inventory.class.Variant, core.class.Class, view.mixin.AttributePresenter, { + presenter: inventory.component.VariantPresenter + }) + + builder.mixin(inventory.class.Variant, core.class.Class, view.mixin.AttributeEditor, { + editor: inventory.component.Variants + }) + + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: inventory.class.Product, + descriptor: view.viewlet.Table, + open: inventory.component.EditProduct, + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + options: { + lookup: { + attachedTo: inventory.class.Category + } + } as FindOptions, + config: ['', '$lookup.attachedTo', 'modifiedOn'] + }) + + builder.createDoc( + workbench.class.Application, + core.space.Model, + { + label: inventory.string.Inventory, + icon: inventory.icon.InventoryApplication, + hidden: false, + navigatorModel: { + specials: [ + { + id: 'Categories', + label: inventory.string.Categories, + icon: inventory.icon.Categories, + component: inventory.component.Categories + }, + { + id: 'Products', + label: inventory.string.Products, + icon: inventory.icon.Products, + component: inventory.component.Products + } + ], + spaces: [] + } + }, + inventory.app.Inventory + ) + + builder.createDoc(view.class.ActionTarget, core.space.Model, { + target: inventory.class.Category, + action: inventory.action.CreateSubcategory + }) + + builder.createDoc( + view.class.Action, + core.space.Model, + { + label: inventory.string.CreateSubcategory, + icon: inventory.icon.Categories, + action: inventory.actionImpl.CreateSubcategory + }, + inventory.action.CreateSubcategory + ) +} + +export { default } from './plugin' diff --git a/models/inventory/src/plugin.ts b/models/inventory/src/plugin.ts new file mode 100644 index 0000000000..68f1670120 --- /dev/null +++ b/models/inventory/src/plugin.ts @@ -0,0 +1,45 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021, 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import type { Doc, Ref } from '@anticrm/core' +import { inventoryId } from '@anticrm/inventory' +import inventory from '@anticrm/inventory-resources/src/plugin' +import { mergeIds, Resource } from '@anticrm/platform' +import type { AnyComponent } from '@anticrm/ui' +import { Action } from '@anticrm/view' +import { Application } from '@anticrm/workbench' + +export default mergeIds(inventoryId, inventory, { + app: { + Inventory: '' as Ref + }, + action: { + CreateSubcategory: '' as Ref + }, + actionImpl: { + CreateSubcategory: '' as Resource<(object: Doc) => Promise> + }, + component: { + Categories: '' as AnyComponent, + Products: '' as AnyComponent, + CreateProduct: '' as AnyComponent, + EditProduct: '' as AnyComponent, + CategoryPresenter: '' as AnyComponent, + Variants: '' as AnyComponent, + ProductPresenter: '' as AnyComponent, + VariantPresenter: '' as AnyComponent + } +}) diff --git a/models/inventory/tsconfig.json b/models/inventory/tsconfig.json new file mode 100644 index 0000000000..1d60db76b4 --- /dev/null +++ b/models/inventory/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "./node_modules/@anticrm/model-rig/profiles/default/tsconfig.json", + + "compilerOptions": { + "rootDir": "./src", + "outDir": "./lib", + } +} \ No newline at end of file diff --git a/packages/panel/src/components/Panel.svelte b/packages/panel/src/components/Panel.svelte index bc3279ebfd..0b5d2ac6e8 100644 --- a/packages/panel/src/components/Panel.svelte +++ b/packages/panel/src/components/Panel.svelte @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. --> - -
{ dispatch('close') }}/> +
{ + dispatch('close') + }} +/>
- -{#if fullSize} -
-
- -
-
{title}
-
Candidate pool name
+ {#if fullSize} +
+
+ +
+
{title}
+ {#if subtitle} +
{subtitle}
+ {/if} +
+ +
+ {#if $$slots.subtitle}
{/if} +
+
+ +
-
- {#if $$slots.subtitle}
{/if} -
-
+
+ +
+ {:else} +
+
+ +
+
{title}
+
Candidate pool name
+
+ +
+ {#if $$slots.subtitle}
{/if} + + -
+
-
-
- -
-{:else} -
-
- -
-
{title}
-
Candidate pool name
-
- -
- {#if $$slots.subtitle}
{/if} - - - - -
-{/if} + {/if}
-
{ fullSize = !fullSize }}>
-
{ dispatch('close') }}>
+
{ + fullSize = !fullSize + }} + > +
+
+
{ + dispatch('close') + }} + > +
+
@@ -116,9 +136,11 @@ display: flex; flex-direction: column; - height: max-content; - - .header { padding: 0 6rem 0 2.5rem; } + height: max-content; + + .header { + padding: 0 6rem 0 2.5rem; + } } .fullSize { @@ -126,7 +148,8 @@ left: 1rem; } - .leftSection, .rightSection { + .leftSection, + .rightSection { flex-basis: 50%; width: 50%; min-height: 0; @@ -140,7 +163,7 @@ margin: 2.5rem 2rem 1.5rem; .content { flex-shrink: 0; - margin: .5rem .5rem 0; + margin: 0.5rem 0.5rem 0; } } } @@ -158,7 +181,9 @@ margin-left: 1rem; color: var(--theme-content-accent-color); cursor: pointer; - &:hover { color: var(--theme-caption-color); } + &:hover { + color: var(--theme-caption-color); + } } } @@ -171,4 +196,4 @@ background: #000; opacity: .5; } - \ No newline at end of file + diff --git a/plugins/attachment-assets/lang/en.json b/plugins/attachment-assets/lang/en.json index 1005646234..aabe40158b 100644 --- a/plugins/attachment-assets/lang/en.json +++ b/plugins/attachment-assets/lang/en.json @@ -3,6 +3,7 @@ "UploadDropFilesHere": "Upload or drop files here", "NoAttachments": "There are no attachments for this", "AddAttachment": "uploaded an attachment", - "Attachments": "Attachments" + "Attachments": "Attachments", + "Photos": "Photos" } } \ No newline at end of file diff --git a/plugins/attachment-resources/src/components/Photos.svelte b/plugins/attachment-resources/src/components/Photos.svelte new file mode 100644 index 0000000000..fc6b4e9834 --- /dev/null +++ b/plugins/attachment-resources/src/components/Photos.svelte @@ -0,0 +1,195 @@ + + + +
+
+ + {#if loading} + + {:else} + { + inputFile.click() + }} + /> + {/if} + +
+ +
{ + dragover = true + }} + on:dragleave={() => { + dragover = false + }} + on:drop|preventDefault|stopPropagation={fileDrop} + > + {#each images as image (image._id)} +
{ + click(ev, image) + }} + > + {image.name} +
+ {/each} +
+ +
+
+
+ + diff --git a/plugins/attachment-resources/src/index.ts b/plugins/attachment-resources/src/index.ts index 51b17a7f1f..588b925e84 100644 --- a/plugins/attachment-resources/src/index.ts +++ b/plugins/attachment-resources/src/index.ts @@ -1,14 +1,14 @@ // // Copyright © 2020 Anticrm Platform Contributors. -// +// // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// +// // See the License for the specific language governing permissions and // limitations under the License. // @@ -17,15 +17,18 @@ import AttachmentsPresenter from './components/AttachmentsPresenter.svelte' import AttachmentPresenter from './components/AttachmentPresenter.svelte' import TxAttachmentCreate from './components/activity/TxAttachmentCreate.svelte' import Attachments from './components/Attachments.svelte' +import Photos from './components/Photos.svelte' +import { Resources } from '@anticrm/platform' import { uploadFile, deleteFile } from './utils' export { Attachments, AttachmentsPresenter } -export default async () => ({ +export default async (): Promise => ({ component: { AttachmentsPresenter, AttachmentPresenter, - Attachments + Attachments, + Photos }, activity: { TxAttachmentCreate diff --git a/plugins/attachment-resources/src/plugin.ts b/plugins/attachment-resources/src/plugin.ts index 98708e60b8..c295596fa5 100644 --- a/plugins/attachment-resources/src/plugin.ts +++ b/plugins/attachment-resources/src/plugin.ts @@ -1,14 +1,15 @@ // -// Copyright © 2020 Anticrm Platform Contributors. -// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021, 2022 Hardcore Engineering Inc. +// // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// +// // See the License for the specific language governing permissions and // limitations under the License. // @@ -22,6 +23,7 @@ export default mergeIds(attachmentId, attachment, { string: { NoAttachments: '' as IntlString, UploadDropFilesHere: '' as IntlString, - Attachments: '' as IntlString + Attachments: '' as IntlString, + Photos: '' as IntlString } }) diff --git a/plugins/attachment/src/index.ts b/plugins/attachment/src/index.ts index 40345eaf56..a550e6c56a 100644 --- a/plugins/attachment/src/index.ts +++ b/plugins/attachment/src/index.ts @@ -30,6 +30,11 @@ export interface Attachment extends AttachedDoc { lastModified: number } +/** + * @public + */ +export interface Photo extends Attachment {} + /** * @public */ @@ -37,13 +42,15 @@ export const attachmentId = 'attachment' as Plugin export default plugin(attachmentId, { component: { - Attachments: '' as AnyComponent + Attachments: '' as AnyComponent, + Photos: '' as AnyComponent }, icon: { Attachment: '' as Asset }, class: { - Attachment: '' as Ref> + Attachment: '' as Ref>, + Photo: '' as Ref> }, helper: { UploadFile: '' as Resource<(file: File, space?: Ref, attachedTo?: Ref) => Promise>, diff --git a/plugins/inventory-assets/assets/icons.svg b/plugins/inventory-assets/assets/icons.svg new file mode 100644 index 0000000000..79c76c5aaa --- /dev/null +++ b/plugins/inventory-assets/assets/icons.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/inventory-assets/lang/en.json b/plugins/inventory-assets/lang/en.json new file mode 100644 index 0000000000..06c7261e8a --- /dev/null +++ b/plugins/inventory-assets/lang/en.json @@ -0,0 +1,23 @@ +{ + "status": { + "CategoryRequired": "Category required", + "NameRequired": "Name required" + }, + "string": { + "Categories": "Categories", + "Category": "Category", + "CreateCategoryShort": "+ Category", + "CreateCategory": "Create category", + "CreateSubcategory": "Create subcategory", + "Inventory": "Inventory", + "CreateProductShort": "+ Product", + "CreateProduct": "Create product", + "Products": "Products", + "Product": "Product", + "Variant": "Variant", + "SKU": "SKU", + "Variants": "Variants", + "NoVariantsForProduct": "There are no variants for this product.", + "CreateVariant": "Create variant" + } +} \ No newline at end of file diff --git a/plugins/inventory-assets/package.json b/plugins/inventory-assets/package.json new file mode 100644 index 0000000000..a1fa61dbd8 --- /dev/null +++ b/plugins/inventory-assets/package.json @@ -0,0 +1,33 @@ +{ + "name": "@anticrm/inventory-assets", + "version": "0.6.0", + "main": "src/index.ts", + "author": "Anticrm Platform Contributors", + "license": "EPL-2.0", + "scripts": { + "build": "heft build", + "lint": "eslint src", + "lint:fix": "eslint --fix src", + "format": "prettier --write src && eslint --fix src", + "build:watch": "tsc" + }, + "devDependencies": { + "@anticrm/platform-rig": "~0.6.0", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "@typescript-eslint/parser": "^5.4.0", + "eslint-config-standard-with-typescript": "^21.0.1", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.1", + "eslint": "^7.32.0", + "prettier": "^2.4.1", + "@types/heft-jest": "^1.0.2", + "@rushstack/heft": "^0.41.1", + "typescript": "^4.3.5", + "@types/node": "^16.4.10" + }, + "dependencies": { + "@anticrm/platform": "~0.6.5", + "@anticrm/inventory": "~0.6.0" + } +} diff --git a/plugins/inventory-assets/src/index.ts b/plugins/inventory-assets/src/index.ts new file mode 100644 index 0000000000..84d180e237 --- /dev/null +++ b/plugins/inventory-assets/src/index.ts @@ -0,0 +1,27 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { addStringsLoader, loadMetadata } from '@anticrm/platform' +import inventory, { inventoryId } from '@anticrm/inventory' + +const icons = require('../assets/icons.svg') +loadMetadata(inventory.icon, { + InventoryApplication: `${icons}#inventory`, + Categories: `${icons}#categories`, + Variant: `${icons}#variant`, + Products: `${icons}#products` +}) +addStringsLoader(inventoryId, async (lang: string) => await import(`../lang/${lang}.json`)) diff --git a/plugins/inventory-assets/tsconfig.json b/plugins/inventory-assets/tsconfig.json new file mode 100644 index 0000000000..cabe5aefad --- /dev/null +++ b/plugins/inventory-assets/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "target": "esnext", + "module": "esnext", + "declaration": true, + "outDir": "./lib", + "strict": true, + "esModuleInterop": true, + "lib": [ + "esnext", + "dom" + ] + } +} \ No newline at end of file diff --git a/plugins/inventory-resources/.eslintrc.js b/plugins/inventory-resources/.eslintrc.js new file mode 100644 index 0000000000..a327214967 --- /dev/null +++ b/plugins/inventory-resources/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + extends: ['./node_modules/@anticrm/platform-rig/profiles/ui/config/eslint.config.json'], + parserOptions: { tsconfigRootDir: __dirname }, + settings: { + 'svelte3/ignore-styles': () => true + } +} diff --git a/plugins/inventory-resources/package.json b/plugins/inventory-resources/package.json new file mode 100644 index 0000000000..63d47c4020 --- /dev/null +++ b/plugins/inventory-resources/package.json @@ -0,0 +1,43 @@ +{ + "name": "@anticrm/inventory-resources", + "version": "0.6.0", + "main": "src/index.ts", + "author": "Anticrm Platform Contributors", + "license": "EPL-2.0", + "scripts": { + "build": "echo 'no build for ui'", + "build:docs": "api-extractor run --local", + "lint": "svelte-check && eslint", + "lint:fix": "eslint --fix src", + "format": "prettier --write --plugin-search-dir=. src && eslint --fix src" + }, + "devDependencies": { + "@anticrm/platform-rig": "~0.6.0", + "svelte-loader": "^3.1.2", + "sass": "^1.37.5", + "svelte-preprocess": "^4.7.4", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-promise": "^5.1.1", + "eslint-plugin-node": "^11.1.0", + "eslint": "^7.32.0", + "@typescript-eslint/parser": "^5.4.0", + "eslint-config-standard-with-typescript": "^21.0.1", + "eslint-plugin-svelte3": "~3.2.1", + "prettier-plugin-svelte": "^2.2.0", + "prettier": "^2.4.1", + "svelte-check": "^2.2.10", + "typescript": "^4.3.5" + }, + "dependencies": { + "@anticrm/platform": "~0.6.5", + "svelte": "^3.37.0", + "@anticrm/inventory": "~0.6.0", + "@anticrm/ui": "~0.6.0", + "@anticrm/panel": "~0.6.0", + "@anticrm/presentation": "~0.6.2", + "@anticrm/view": "~0.6.0", + "@anticrm/view-resources": "~0.6.0", + "@anticrm/core": "~0.6.11" + } +} diff --git a/plugins/inventory-resources/postcss.config.js b/plugins/inventory-resources/postcss.config.js new file mode 100644 index 0000000000..88752c6cb0 --- /dev/null +++ b/plugins/inventory-resources/postcss.config.js @@ -0,0 +1,5 @@ +module.exports = { + plugins: [ + require('autoprefixer') + ] +} diff --git a/plugins/inventory-resources/src/components/Categories.svelte b/plugins/inventory-resources/src/components/Categories.svelte new file mode 100644 index 0000000000..d62a675364 --- /dev/null +++ b/plugins/inventory-resources/src/components/Categories.svelte @@ -0,0 +1,114 @@ + + + +
+
+
+ + +
+
+ + { + resultQuery = {} + }} + /> +
+ +
+
+ + + +
+
+ + diff --git a/plugins/inventory-resources/src/components/CategoryPresenter.svelte b/plugins/inventory-resources/src/components/CategoryPresenter.svelte new file mode 100644 index 0000000000..5d5b811982 --- /dev/null +++ b/plugins/inventory-resources/src/components/CategoryPresenter.svelte @@ -0,0 +1,26 @@ + + + +{#if value} +
+ {value.name} +
+{/if} diff --git a/plugins/inventory-resources/src/components/CreateCategory.svelte b/plugins/inventory-resources/src/components/CreateCategory.svelte new file mode 100644 index 0000000000..3552560eae --- /dev/null +++ b/plugins/inventory-resources/src/components/CreateCategory.svelte @@ -0,0 +1,71 @@ + + + + 0} + on:close={() => { + dispatch('close') + }} +> + + + + + diff --git a/plugins/inventory-resources/src/components/CreateProduct.svelte b/plugins/inventory-resources/src/components/CreateProduct.svelte new file mode 100644 index 0000000000..183a640410 --- /dev/null +++ b/plugins/inventory-resources/src/components/CreateProduct.svelte @@ -0,0 +1,90 @@ + + + + 0 && doc.attachedTo !== undefined} + bind:space={doc.space} + on:close={() => { + dispatch('close') + }} +> + + + + + diff --git a/plugins/inventory-resources/src/components/CreateVariant.svelte b/plugins/inventory-resources/src/components/CreateVariant.svelte new file mode 100644 index 0000000000..2f3a229d10 --- /dev/null +++ b/plugins/inventory-resources/src/components/CreateVariant.svelte @@ -0,0 +1,72 @@ + + + + 0 && doc.sku.trim().length > 0} + bind:space={doc.space} + on:close={() => { + dispatch('close') + }} +> + + + + + diff --git a/plugins/inventory-resources/src/components/EditProduct.svelte b/plugins/inventory-resources/src/components/EditProduct.svelte new file mode 100644 index 0000000000..125f5879df --- /dev/null +++ b/plugins/inventory-resources/src/components/EditProduct.svelte @@ -0,0 +1,152 @@ + + + +{#if object !== undefined} + { + dispatch('close') + }} + > +
+ {#if keys} + + {/if} +
+ {#each collectionKeys as collection} +
+ {#await getCollectionEditor(collection) then is} + + {/await} +
+ {/each} +
+{/if} + + diff --git a/plugins/inventory-resources/src/components/HierarchyElement.svelte b/plugins/inventory-resources/src/components/HierarchyElement.svelte new file mode 100644 index 0000000000..b107a8812a --- /dev/null +++ b/plugins/inventory-resources/src/components/HierarchyElement.svelte @@ -0,0 +1,139 @@ + + + +{#each descendants.get(parent) ?? [] as object, row (object._id)} + + {#each model as attribute, cell} + {#if !cell} + +
+ {#if descendants.has(object._id)} +
click(object._id)}> + {#if expanded.has(object._id)} + + {:else} + + {/if} +
+ {/if} + + +
+ + {:else} + + + + {/if} + {/each} + + {#if expanded.has(object._id)} + + {/if} +{/each} + + diff --git a/plugins/inventory-resources/src/components/HierarchyView.svelte b/plugins/inventory-resources/src/components/HierarchyView.svelte new file mode 100644 index 0000000000..21e3f93e24 --- /dev/null +++ b/plugins/inventory-resources/src/components/HierarchyView.svelte @@ -0,0 +1,109 @@ + + + +{#await buildModel({ client, _class, keys: config, options })} + +{:then model} + + + + {#each model as attribute} + + {/each} + + + {#if objects} + + + + {/if} +
+
+
+
+{/await} + + diff --git a/plugins/inventory-resources/src/components/ProductPresenter.svelte b/plugins/inventory-resources/src/components/ProductPresenter.svelte new file mode 100644 index 0000000000..e1fcead631 --- /dev/null +++ b/plugins/inventory-resources/src/components/ProductPresenter.svelte @@ -0,0 +1,50 @@ + + + +{#if value} +
+ +
{value.name}
+
+{/if} + + diff --git a/plugins/inventory-resources/src/components/Products.svelte b/plugins/inventory-resources/src/components/Products.svelte new file mode 100644 index 0000000000..830670c69e --- /dev/null +++ b/plugins/inventory-resources/src/components/Products.svelte @@ -0,0 +1,132 @@ + + + +
+
+
+ + +
+
+ + { + resultQuery = {} + }} + /> +
+ +
+
+ + {#await tableDescriptor then descr} + {#if descr} + + {/if} + {/await} + + + + + diff --git a/plugins/inventory-resources/src/components/VariantPresenter.svelte b/plugins/inventory-resources/src/components/VariantPresenter.svelte new file mode 100644 index 0000000000..f10a1ae8c7 --- /dev/null +++ b/plugins/inventory-resources/src/components/VariantPresenter.svelte @@ -0,0 +1,26 @@ + + + +{#if value} +
+ {value.name} +
+{/if} diff --git a/plugins/inventory-resources/src/components/Variants.svelte b/plugins/inventory-resources/src/components/Variants.svelte new file mode 100644 index 0000000000..956fa69568 --- /dev/null +++ b/plugins/inventory-resources/src/components/Variants.svelte @@ -0,0 +1,75 @@ + + + +
+
+
+ +
+ {#if variants > 0} +
+ {:else} +
+ +
+
+
+ +
+
+ {/if} + + + diff --git a/plugins/inventory-resources/src/components/icons/Collapse.svelte b/plugins/inventory-resources/src/components/icons/Collapse.svelte new file mode 100644 index 0000000000..c0f1bda900 --- /dev/null +++ b/plugins/inventory-resources/src/components/icons/Collapse.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/plugins/inventory-resources/src/components/icons/Expand.svelte b/plugins/inventory-resources/src/components/icons/Expand.svelte new file mode 100644 index 0000000000..ca1b5023ab --- /dev/null +++ b/plugins/inventory-resources/src/components/icons/Expand.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/plugins/inventory-resources/src/index.ts b/plugins/inventory-resources/src/index.ts new file mode 100644 index 0000000000..282c591b49 --- /dev/null +++ b/plugins/inventory-resources/src/index.ts @@ -0,0 +1,46 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021, 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { Resources } from '@anticrm/platform' +import Categories from './components/Categories.svelte' +import CreateCategory from './components/CreateCategory.svelte' +import CategoryPresenter from './components/CategoryPresenter.svelte' +import Products from './components/Products.svelte' +import ProductPresenter from './components/ProductPresenter.svelte' +import EditProduct from './components/EditProduct.svelte' +import Variants from './components/Variants.svelte' +import VariantPresenter from './components/VariantPresenter.svelte' +import { Doc } from '@anticrm/core' +import { showPopup } from '@anticrm/ui' + +async function createSubcategory (object: Doc): Promise { + showPopup(CreateCategory, { attachedTo: object._id }) +} + +export default async (): Promise => ({ + actionImpl: { + CreateSubcategory: createSubcategory + }, + component: { + Categories, + CategoryPresenter, + Products, + ProductPresenter, + EditProduct, + Variants, + VariantPresenter + } +}) diff --git a/plugins/inventory-resources/src/plugin.ts b/plugins/inventory-resources/src/plugin.ts new file mode 100644 index 0000000000..35e2719d52 --- /dev/null +++ b/plugins/inventory-resources/src/plugin.ts @@ -0,0 +1,43 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { IntlString, mergeIds, StatusCode } from '@anticrm/platform' + +import inventory, { inventoryId } from '@anticrm/inventory' + +export default mergeIds(inventoryId, inventory, { + status: { + CategoryRequired: '' as StatusCode, + NameRequired: '' as StatusCode + }, + string: { + Categories: '' as IntlString, + Category: '' as IntlString, + CreateCategoryShort: '' as IntlString, + CreateCategory: '' as IntlString, + CreateSubcategory: '' as IntlString, + Inventory: '' as IntlString, + CreateProductShort: '' as IntlString, + CreateProduct: '' as IntlString, + Products: '' as IntlString, + Product: '' as IntlString, + SKU: '' as IntlString, + Variant: '' as IntlString, + Variants: '' as IntlString, + NoVariantsForProduct: '' as IntlString, + CreateVariant: '' as IntlString + } +}) diff --git a/plugins/inventory-resources/svelte.config.js b/plugins/inventory-resources/svelte.config.js new file mode 100644 index 0000000000..944a06f73e --- /dev/null +++ b/plugins/inventory-resources/svelte.config.js @@ -0,0 +1,5 @@ +const sveltePreprocess = require('svelte-preprocess') + +module.exports = { + preprocess: sveltePreprocess() +}; \ No newline at end of file diff --git a/plugins/inventory-resources/tsconfig.json b/plugins/inventory-resources/tsconfig.json new file mode 100644 index 0000000000..cabe5aefad --- /dev/null +++ b/plugins/inventory-resources/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "target": "esnext", + "module": "esnext", + "declaration": true, + "outDir": "./lib", + "strict": true, + "esModuleInterop": true, + "lib": [ + "esnext", + "dom" + ] + } +} \ No newline at end of file diff --git a/plugins/inventory/.eslintrc.js b/plugins/inventory/.eslintrc.js new file mode 100644 index 0000000000..5da5872d4a --- /dev/null +++ b/plugins/inventory/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + extends: ['./node_modules/@anticrm/platform-rig/profiles/default/config/eslint.config.json'], + parserOptions: { + tsconfigRootDir: __dirname, + project: './tsconfig.json' + } +} diff --git a/plugins/inventory/.npmignore b/plugins/inventory/.npmignore new file mode 100644 index 0000000000..e3ec093c38 --- /dev/null +++ b/plugins/inventory/.npmignore @@ -0,0 +1,4 @@ +* +!/lib/** +!CHANGELOG.md +/lib/**/__tests__/ diff --git a/plugins/inventory/package.json b/plugins/inventory/package.json new file mode 100644 index 0000000000..adf8848162 --- /dev/null +++ b/plugins/inventory/package.json @@ -0,0 +1,32 @@ +{ + "name": "@anticrm/inventory", + "version": "0.6.0", + "main": "lib/index.js", + "author": "Anticrm Platform Contributors", + "license": "EPL-2.0", + "scripts": { + "build": "heft build", + "build:watch": "tsc", + "lint:fix": "eslint --fix src", + "lint": "eslint src", + "format": "prettier --write src && eslint --fix src" + }, + "devDependencies": { + "@anticrm/platform-rig": "~0.6.0", + "@types/heft-jest": "^1.0.2", + "@typescript-eslint/eslint-plugin": "^5.4.0", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-promise": "^5.1.1", + "eslint-plugin-node": "^11.1.0", + "eslint": "^7.32.0", + "@typescript-eslint/parser": "^5.4.0", + "eslint-config-standard-with-typescript": "^21.0.1", + "prettier": "^2.4.1", + "@rushstack/heft": "^0.41.1", + "typescript": "^4.3.5" + }, + "dependencies": { + "@anticrm/core": "~0.6.11", + "@anticrm/platform": "~0.6.5" + } +} diff --git a/plugins/inventory/src/index.ts b/plugins/inventory/src/index.ts new file mode 100644 index 0000000000..cc358bd764 --- /dev/null +++ b/plugins/inventory/src/index.ts @@ -0,0 +1,76 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021, 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { AttachedDoc, Class, Ref, Space } from '@anticrm/core' +import type { Asset, Plugin } from '@anticrm/platform' +import { plugin } from '@anticrm/platform' + +/** + * @public + */ +export interface Category extends AttachedDoc { + name: string +} + +/** + * @public + */ +export interface Product extends AttachedDoc { + attachments?: number + photos?: number + variants?: number + name: string +} + +/** + * @public + */ +export interface Variant extends AttachedDoc { + name: string + sku: string +} + +/** + * @public + */ +export const inventoryId = 'inventory' as Plugin + +/** + * @public + */ +const inventory = plugin(inventoryId, { + class: { + Product: '' as Ref>, + Category: '' as Ref>, + Variant: '' as Ref> + }, + icon: { + InventoryApplication: '' as Asset, + Products: '' as Asset, + Categories: '' as Asset, + Variant: '' as Asset + }, + global: { + // Global category root, if not attached to some other object. + Category: '' as Ref + }, + space: { + Category: '' as Ref, + Products: '' as Ref + } +}) + +export default inventory diff --git a/plugins/inventory/tsconfig.json b/plugins/inventory/tsconfig.json new file mode 100644 index 0000000000..32045300ce --- /dev/null +++ b/plugins/inventory/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json", + + "compilerOptions": { + "rootDir": "./src", + "outDir": "./lib", + "lib": ["esnext", "dom"] + } +} \ No newline at end of file diff --git a/rush.json b/rush.json index 4857fdb943..e02ae80b64 100644 --- a/rush.json +++ b/rush.json @@ -921,5 +921,25 @@ "projectFolder": "plugins/gmail-resources", "shouldPublish": true }, + { + "packageName": "@anticrm/model-inventory", + "projectFolder": "models/inventory", + "shouldPublish": true + }, + { + "packageName": "@anticrm/inventory", + "projectFolder": "plugins/inventory", + "shouldPublish": true + }, + { + "packageName": "@anticrm/inventory-assets", + "projectFolder": "plugins/inventory-assets", + "shouldPublish": true + }, + { + "packageName": "@anticrm/inventory-resources", + "projectFolder": "plugins/inventory-resources", + "shouldPublish": true + } ] }