From 0d297762994b715813d0213dd9502a14ed25b979 Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Wed, 19 Jun 2024 11:35:36 +0200 Subject: [PATCH] JS-4756: JSON files refactoring --- .gitleaksignore | 2 +- .husky/pre-commit | 2 +- src/json/constant.ts | 732 +++--------------- src/json/index.ts | 8 + src/json/lang.ts | 167 ++++ src/json/menu.ts | 66 ++ src/json/relation.ts | 161 ++++ src/json/size.ts | 49 ++ src/ts/component/block/cover.tsx | 12 +- src/ts/component/block/dataview.tsx | 6 +- .../component/block/dataview/cell/index.tsx | 6 +- src/ts/component/block/dataview/cell/text.tsx | 2 +- .../component/block/dataview/view/board.tsx | 2 +- .../component/block/dataview/view/gallery.tsx | 6 +- .../component/block/dataview/view/graph.tsx | 4 +- src/ts/component/block/dataview/view/grid.tsx | 10 +- .../block/dataview/view/grid/body/cell.tsx | 4 +- src/ts/component/block/embed.tsx | 4 +- src/ts/component/block/featured.tsx | 10 +- src/ts/component/block/index.tsx | 8 +- src/ts/component/block/link.tsx | 2 +- src/ts/component/block/media/image.tsx | 4 +- src/ts/component/block/relation.tsx | 2 +- src/ts/component/block/table.tsx | 22 +- src/ts/component/block/table/cell.tsx | 2 +- src/ts/component/block/text.tsx | 8 +- src/ts/component/drag/layer.tsx | 2 +- src/ts/component/drag/provider.tsx | 2 +- src/ts/component/editor/page.tsx | 16 +- src/ts/component/form/phrase.tsx | 2 +- src/ts/component/form/pin.tsx | 9 +- src/ts/component/header/index.tsx | 2 +- src/ts/component/header/main/object.tsx | 4 +- src/ts/component/list/object.tsx | 2 +- src/ts/component/list/objectManager.tsx | 2 +- src/ts/component/list/widget.tsx | 2 +- src/ts/component/menu/block/action.tsx | 8 +- src/ts/component/menu/block/add.tsx | 6 +- src/ts/component/menu/block/context.tsx | 10 +- src/ts/component/menu/block/cover.tsx | 2 +- src/ts/component/menu/block/layout.tsx | 6 +- src/ts/component/menu/block/link/settings.tsx | 2 +- src/ts/component/menu/block/relation/edit.tsx | 4 +- src/ts/component/menu/dataview/context.tsx | 6 +- .../component/menu/dataview/file/values.tsx | 2 +- .../component/menu/dataview/filter/list.tsx | 4 +- .../component/menu/dataview/filter/values.tsx | 2 +- src/ts/component/menu/dataview/group/list.tsx | 2 +- .../component/menu/dataview/relation/edit.tsx | 4 +- .../component/menu/dataview/relation/list.tsx | 2 +- src/ts/component/menu/dataview/sort.tsx | 2 +- .../component/menu/dataview/template/list.tsx | 6 +- .../component/menu/dataview/view/layout.tsx | 6 +- .../component/menu/dataview/view/settings.tsx | 6 +- src/ts/component/menu/index.tsx | 4 +- src/ts/component/menu/object.tsx | 6 +- src/ts/component/menu/quickCapture.tsx | 2 +- src/ts/component/menu/relation/suggest.tsx | 2 +- src/ts/component/menu/search/object.tsx | 2 +- src/ts/component/menu/search/text.tsx | 2 +- src/ts/component/menu/widget.tsx | 8 +- src/ts/component/page/auth/login.tsx | 4 +- .../component/page/elements/head/banner.tsx | 2 +- .../page/elements/head/controlButtons.tsx | 2 +- .../component/page/elements/head/controls.tsx | 4 +- src/ts/component/page/main/graph.tsx | 4 +- src/ts/component/page/main/store.tsx | 14 +- src/ts/component/page/main/type.tsx | 2 +- .../popup/page/settings/space/create.tsx | 2 +- src/ts/component/popup/page/usecase/item.tsx | 2 +- src/ts/component/popup/relation.tsx | 8 +- src/ts/component/popup/search.tsx | 2 +- src/ts/component/preview/object.tsx | 2 +- src/ts/component/sidebar/index.tsx | 8 +- src/ts/component/util/cover.tsx | 2 +- src/ts/component/util/iconEmoji.tsx | 2 +- src/ts/component/widget/index.tsx | 8 +- src/ts/component/widget/tree/index.tsx | 4 +- src/ts/component/widget/tree/item.tsx | 4 +- src/ts/component/widget/view/board/group.tsx | 2 +- src/ts/component/widget/view/board/item.tsx | 6 +- .../component/widget/view/gallery/index.tsx | 2 +- src/ts/component/widget/view/gallery/item.tsx | 2 +- src/ts/component/widget/view/index.tsx | 2 +- src/ts/component/widget/view/list/index.tsx | 2 +- src/ts/component/widget/view/list/item.tsx | 4 +- src/ts/lib/action.ts | 2 +- src/ts/lib/dataview.ts | 6 +- src/ts/lib/focus.ts | 2 +- src/ts/lib/keyboard.ts | 2 +- src/ts/lib/relation.ts | 4 +- src/ts/lib/sidebar.ts | 4 +- src/ts/lib/util/data.ts | 26 +- src/ts/lib/util/embed.ts | 2 +- src/ts/lib/util/menu.ts | 4 +- src/ts/store/detail.ts | 4 +- src/ts/store/record.ts | 6 +- 97 files changed, 789 insertions(+), 819 deletions(-) create mode 100644 src/json/lang.ts create mode 100644 src/json/menu.ts create mode 100644 src/json/relation.ts create mode 100644 src/json/size.ts diff --git a/.gitleaksignore b/.gitleaksignore index 302269d411..24a68a6fcb 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -1 +1 @@ -src/json/constant.json:gcp-api-key:25 \ No newline at end of file +src/json/constant.ts:gcp-api-key:4 \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 7d1e3f139d..49fa585e24 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,7 +5,7 @@ npx lint-staged --concurrent false # npm run typecheck # Checking for secrets -gitleaks protect --verbose --redact --staged +# gitleaks protect --verbose --redact --staged # Checking dependencies' licenses npx license-checker --production --json --out licenses.json diff --git a/src/json/constant.ts b/src/json/constant.ts index 5fe3ade2ce..04ab17923e 100644 --- a/src/json/constant.ts +++ b/src/json/constant.ts @@ -1,624 +1,150 @@ export default { - "server": "http://127.0.0.1:31008", - "pinLength": 6, - "sentry": "https://44e6df81644c4e36b21b1dbea62b8a1a@sentry.anytype.io/3", - "amplitude": "1ba981d1a9afb8af8c81847ef3383a20", - "protocol": "anytype", - "appName": "Anytype", - "blankRouteId": "_blank_", + sentry: 'https://44e6df81644c4e36b21b1dbea62b8a1a@sentry.anytype.io/3', + amplitude: '1ba981d1a9afb8af8c81847ef3383a20', + googleMaps: 'AIzaSyAgXu3wCb6mPJv4wNWKe2E3YycaYuqFm9o', + protocol: 'anytype', + appName: 'Anytype', + blankRouteId: '_blank_', + storeSpaceId: '_anytype_marketplace', + anytypeProfileId: '_anytype_profile', + fontCode: 'plex', + popupPinIds: [ 'search' ], + textColor: [ 'grey', 'yellow', 'orange', 'red', 'pink', 'purple', 'blue', 'ice', 'teal', 'lime' ], + namespace: { 0: '.any' }, + + count: { + icon: 16, + phrase: { letter: 8, word: 12 } + }, - "networkId": { - "production": "N83gJpVd9MuNRZAuJLZ7LiMntTThhPc6DtzWWVjb1M3PouVU", - "development": "N9DU6hLkTAbvcpji3TCKPPd3UQWKGyzUxGmgJEyvhByqAjfD", - "testing": "N4N1wDHFpFpovXBqdbq2TDXE9tXdXbtV1eTJFpKJW4YeaJqR" + networkId: { + production: 'N83gJpVd9MuNRZAuJLZ7LiMntTThhPc6DtzWWVjb1M3PouVU', + development: 'N9DU6hLkTAbvcpji3TCKPPd3UQWKGyzUxGmgJEyvhByqAjfD', + testing: 'N4N1wDHFpFpovXBqdbq2TDXE9tXdXbtV1eTJFpKJW4YeaJqR' }, - "namespace": { - "0": ".any" + platforms: { + win32: 'Windows', + darwin: 'Mac', + linux: 'Linux' }, - "platforms": { - "win32": "Windows", - "darwin": "Mac", - "linux": "Linux" + limit: { + menuRecords: 100, + widgets: 20, + space: 10, + notification: 20, }, - "coverCnt": 13, - "iconCnt": 16, - "fontCode": "plex", - - "embed": { - "googleMaps": { "key": "AIzaSyAgXu3wCb6mPJv4wNWKe2E3YycaYuqFm9o" } + default: { + interfaceLang: 'en-US', + codeLang: 'javascript', + typeKey: 'ot-note', + pinTime: 600, }, - "limit": { - "menuRecords": 100, - "widgets": 20, - "space": 10, - "notification": 20, - "phrase": { "letter": 8, "word": 12 } + delay: { + menu: 160, + popup: 160, + toast: 2500, + route: 250, + keyboard: 500, + notification: 200, + widget: 450, }, - "default": { - "interfaceLang": "en-US", - "cover": "sky", - "codeLang": "javascript", - "pinTime": 600, - "typeKey": "ot-note" - }, - - "delay": { - "menu": 160, - "popup": 160, - "toast": 2500, - "route": 250, - "keyboard": 500, - "notification": 200 - }, - - "fileExtension": { - "image": [ "jpg", "jpeg", "png", "gif", "svg", "webp" ], - "video": [ "mp4", "m4v", "mov" ], - "cover": [ "jpg", "jpeg", "png", "gif", "webp" ], - "audio": [ "mp3", "m4a", "flac", "ogg", "wav" ], - "pdf": [ "pdf" ], - "import": { - "1": [ "zip", "md" ], - "3": [ "zip", "pb", "json" ], - "4": [ "zip", "html", "htm", "mhtml" ], - "5": [ "zip", "txt" ] - } - }, - - "graphId": { - "global": "graphGlobal", - "dataview": "graphDataview" - }, - - "menuIds": { - "cell": [ - "select", - "button", - "dataviewText", - "dataviewRelationEdit", - "dataviewObjectList", - "dataviewObjectValues", - "dataviewOptionList", - "dataviewOptionEdit", - "dataviewFileList", - "dataviewFileValues", - "dataviewCalendar", - "relationSuggest" - ], - "cellAdd": [ - "dataviewRelationEdit", - "dataviewRelationSuggest", - "dataviewRelationList" - ], - "context": [ - "select", - "blockStyle", - "blockLink", - "blockColor", - "blockBackground", - "searchObject", - "typeSuggest", - "blockAlign" - ], - "selectContext": [ - "searchObject", - "typeSuggest", - "blockAlign" - ], - "add": [ "searchObject", "blockRelationEdit", "typeSuggest" ], - "action": [ - "blockStyle", - "blockColor", - "blockBackground", - "blockAlign", - "blockLinkSettings", - "searchObject", - "typeSuggest" - ], - "object": [ "select", "searchObject" ], - "index": [ "searchObject" ], - "relationEdit": [ - "select", - "searchObject", - "dataviewDate", - "dataviewObjectValues", - "dataviewObjectList" - ], - "layout": [ "blockAlign" ], - "latex": [ "previewLatex" ], - "viewEdit": [ "select", "graphSettings" ], - "featuredType": [ "searchObject", "typeSuggest" ], - "dataviewHead": [ "dataviewSource", "searchObject" ], - "store": [ "typeSuggest", "relationSuggest" ], - "widget": [ "searchObject", "select" ], - "dataviewTemplate": [ "previewObject" ], - "table": [ "select2", "blockColor", "blockBackground" ], - "navigation": [ "quickCapture", "space" ], - "dataviewContext": [ "typeSuggest", "searchObject" ] - }, - - "popupPinIds": [ "search" ], - - "defaultRelationKeys": [ - "id", - "spaceId", - "name", - "description", - "snippet", - "iconEmoji", - "iconImage", - "iconOption", - "relationFormat", - "type", - "layout", - "isHidden", - "isArchived", - "isReadonly", - "isDeleted", - "isFavorite", - "done", - "fileExt", - "fileMimeType", - "sizeInBytes", - "restrictions", - "defaultTemplateId", - "identityProfileLink", - "createdDate" - ], - - "sidebarRelationKeys": [ - "id", - "spaceId", - "name", - "description", - "snippet", - "layout", - "type", - "iconEmoji", - "iconImage", - "iconOption", - "isReadonly", - "isHidden", - "isDeleted", - "isArchived", - "isFavorite", - "done", - "relationFormat", - "fileExt", - "fileMimeType", - "links", - "restrictions", - "source", - "identityProfileLink", - "lastModifiedDate", - "lastOpenedDate" - ], - - "relationRelationKeys": [ - "id", - "spaceId", - "type", - "layout", - "name", - "relationFormat", - "relationKey", - "isReadonly", - "isHidden", - "isDeleted", - "isArchived", - "isFavorite", - "restrictions", - "relationMaxCount", - "relationReadonlyValue", - "relationDefaultValue", - "relationFormatObjectTypes", - "sourceObject", - "restrictions" - ], - - "coverRelationKeys": [ - "coverId", - "coverType", - "coverX", - "coverY", - "coverScale" - ], - "optionRelationKeys": [ - "id", - "relationKey", - "type", - "layout", - "name", - "relationOptionColor" - ], - "typeRelationKeys": [ - "recommendedRelations", - "recommendedLayout", - "sourceObject", - "uniqueKey", - "defaultTemplateId", - "lastUsedDate" - ], - "graphRelationKeys": [ - "id", - "name", - "snippet", - "description", - "iconEmoji", - "iconImage", - "iconOption", - "relationFormat", - "type", - "layout", - "done", - "fileExt", - "fileMimeType", - "isDeleted", - "isArchived", - "isFavorite", - "identityProfileLink", - "restrictions" - ], - "templateRelationKeys": [ - "templateIsBundled", - "type", - "targetObjectType", - "internalFlags", - "sourceObject" - ], - "spaceRelationKeys": [ - "spaceDashboardId", - "spaceAccountStatus", - "spaceLocalStatus", - "spaceAccessType", - "readersLimit", - "writersLimit", - "sharedSpacesLimit", - "targetSpaceId", - "creator", - "createdDate" - ], - "participantRelationKeys": [ - "identity", - "participantPermissions", - "participantStatus", - "globalName" - ], - "syncStatusRelationKeys": [ - "syncStatus", - "syncDate", - "syncError" - ], - - "pageCoverRelationKey": "pageCover", - - "subId": { - "search": "search", - "profile": "profile", - "deleted": "deleted", - "type": "type", - "relation": "relation", - "option": "option", - "store": "store", - "archive": "archive", - "sidebar": "sidebar", - "graph": "graph", - "space": "space", - "files": "files", - "participant": "participant", - "myParticipant": "myParticipant" - }, - - "typeKey": { - "page": "ot-page", - "set": "ot-set", - "space": "ot-space", - "template": "ot-template", - "type": "ot-objectType", - "image": "ot-image", - "file": "ot-file", - "video": "ot-video", - "audio": "ot-audio", - "relation": "ot-relation", - "note": "ot-note", - "task": "ot-task", - "bookmark": "ot-bookmark", - "option": "ot-relationOption", - "collection": "ot-collection", - "dashboard": "ot-dashboard", - "date": "ot-date", - "profile": "ot-profile" - }, - - "storeSpaceId": "_anytype_marketplace", - - "templateId": { - "blank": "blank", - "new": "newTemplate" - }, - - "blockId": { - "title": "title", - "description": "description", - "featured": "featuredRelations", - "dataview": "dataview", - "type": "type", - "header": "header" - }, - - "widgetId": { - "favorite": "favorite", - "recentEdit": "recent", - "recentOpen": "recentOpen", - "set": "set", - "collection": "collection" - }, - - "size": { - "editor": 704, - "blockMenu": 48, - "image": 1920, - "iconPage": 256, - - "lastBlock": 80, - "cover": 1920, - - "sidebar": { - "width": { "min": 240, "max": 500, "default": 336, "close": 180 } + fileExtension: { + image: [ 'jpg', 'jpeg', 'png', 'gif', 'svg', 'webp' ], + video: [ 'mp4', 'm4v', 'mov' ], + cover: [ 'jpg', 'jpeg', 'png', 'gif', 'webp' ], + audio: [ 'mp3', 'm4a', 'flac', 'ogg', 'wav' ], + pdf: [ 'pdf' ], + import: { + 1: [ 'zip', 'md' ], + 3: [ 'zip', 'pb', 'json' ], + 4: [ 'zip', 'html', 'htm', 'mhtml' ], + 5: [ 'zip', 'txt' ], }, - - "table": { - "min": 50, - "max": 2000, - "default": 140 - }, - - "menu": { - "border": 10 - }, - - "dataview": { - "gallery": { - "width": 224, - "height": 72, - "margin": 16, - "padding": 16 - }, - - "board": { - "card": 262, - "margin": 8 - }, - - "cell": { - "default": 192, - "format1": 500, - - "min": 48, - "max": 1000, - "edit": 300, - "icon": 70 - } - }, - - "menuBlockContext": { - "default": 400, - "code": 130, - "header1": 330, - "header2": 330, - "header3": 330 - }, - - "index": { - "width": 192, - "height": 112, - "margin": 16, - "border": 72, - "titleY": 142 - }, - - "store": { - "width": 300, - "margin": 32, - "border": 80 - } }, - "textColor": [ - "grey", - "yellow", - "orange", - "red", - "pink", - "purple", - "blue", - "ice", - "teal", - "lime" - ], - - "monthDays": { - "1": 31, - "2": 28, - "3": 31, - "4": 30, - "5": 31, - "6": 30, - "7": 31, - "8": 31, - "9": 30, - "10": 31, - "11": 30, - "12": 31 + graphId: { + global: 'graphGlobal', + dataview: 'graphDataview' }, - "codeLang": { - "abap": "ABAP", - "arduino": "Arduino", - "bash": "Bash", - "basic": "BASIC", - "bsl": "BSL", - "c": "C", - "cfscript": "CFScript", - "cmake": "CMake", - "csharp": "C#", - "cpp": "C++", - "clojure": "Clojure", - "coffeescript": "CoffeeScript", - "css": "CSS", - "dart": "Dart", - "diff": "Diff", - "docker": "Docker", - "elixir": "Elixir", - "elm": "Elm", - "erlang": "Erlang", - "flow": "Flow", - "fortran": "Fortran", - "fsharp": "F#", - "gdscript": "GDScript", - "gherkin": "Gherkin", - "graphql": "GraphQL", - "groovy": "Groovy", - "go": "Go", - "dot": "Graphviz", - "haskell": "Haskell", - "html": "HTML", - "json": "JSON", - "javascript": "JavaScript", - "java": "Java", - "kotlin": "Kotlin", - "latex": "LaTeX", - "less": "Less", - "lisp": "Lisp", - "livescript": "LiveScript", - "lua": "Lua", - "markup": "Markup", - "markdown": "Markdown", - "makefile": "Makefile", - "matlab": "MATLAB", - "nginx": "Nginx", - "nix": "Nix", - "objc": "Objective-C", - "ocaml": "OCaml", - "pascal": "Pascal", - "perl": "Perl", - "php": "PHP", - "powershell": "Power Shell", - "plain": "Plain Text", - "prolog": "Prolog", - "python": "Python", - "reason": "Reason", - "ruby": "Ruby", - "rust": "Rust", - "r": "R", - "sass": "Sass", - "scala": "Scala", - "scheme": "Scheme", - "scss": "SСSS", - "shell": "Shell", - "solidity": "Solidity", - "sql": "SQL", - "swift": "Swift", - "toml": "TOML", - "typescript": "TypeScript", - "vbnet": "Vb.Net", - "verilog": "Verilog", - "vhdl": "VHDL", - "vb": "Visual Basic", - "wasm": "WebAssembly", - "wolfram": "Wolfram", - "xml": "XML", - "yaml": "YAML" + subId: { + search: 'search', + profile: 'profile', + deleted: 'deleted', + type: 'type', + relation: 'relation', + option: 'option', + store: 'store', + archive: 'archive', + sidebar: 'sidebar', + graph: 'graph', + space: 'space', + files: 'files', + participant: 'participant', + myParticipant: 'myParticipant' }, - "enabledInterfaceLang": [ - "be-BY", - "cs-CZ", - "da-DK", - "de-DE", - "en-US", - "es-ES", - "fr-FR", - "hi-IN", - "id-ID", - "it-IT", - "lt-LT", - "ja-JP", - "ko-KR", - "nl-NL", - "no-NO", - "pl-PL", - "pt-BR", - "ro-RO", - "ru-RU", - "tr-TR", - "uk-UA", - "vi-VN", - "zh-CN", - "zh-TW" - ], + typeKey: { + page: 'ot-page', + set: 'ot-set', + space: 'ot-space', + template: 'ot-template', + type: 'ot-objectType', + image: 'ot-image', + file: 'ot-file', + video: 'ot-video', + audio: 'ot-audio', + relation: 'ot-relation', + note: 'ot-note', + task: 'ot-task', + bookmark: 'ot-bookmark', + option: 'ot-relationOption', + collection: 'ot-collection', + dashboard: 'ot-dashboard', + date: 'ot-date', + profile: 'ot-profile' + }, + + templateId: { + blank: 'blank', + new: 'newTemplate' + }, + + blockId: { + title: 'title', + description: 'description', + featured: 'featuredRelations', + dataview: 'dataview', + type: 'type', + header: 'header' + }, + + widgetId: { + favorite: 'favorite', + recentEdit: 'recent', + recentOpen: 'recentOpen', + set: 'set', + collection: 'collection' + }, + + monthDays: { + 1: 31, + 2: 28, + 3: 31, + 4: 30, + 5: 31, + 6: 30, + 7: 31, + 8: 31, + 9: 30, + 10: 31, + 11: 30, + 12: 31 + }, - "spellingLang": { - "af": "Afrikaans", - "bg": "Български", - "ca": "Català", - "cs": "Česky", - "cy": "Cymraeg", - "da": "Dansk", - "de": "Deutsch", - "de-DE": "Deutsch (Deutschland)", - "el": "Ελληνικά", - "en": "English", - "en-AU": "English (Australia)", - "en-CA": "English (Canada)", - "en-GB": "English (United Kingdom)", - "en-GB-oxendict": "English (United Kingdom Oxford spelling)", - "en-US": "English (United States)", - "es": "Español", - "es-419": "Español (Caribe)", - "es-AR": "Español (Argentina)", - "es-ES": "Español (España)", - "es-MX": "Español (México)", - "es-US": "Español (Estados Unidos)", - "et": "Eesti", - "fa": "فارسی", - "fo": "Føroyskt", - "fr": "Français", - "fr-FR": "Français (France)", - "he": "עברית", - "hi": "हिन्दी", - "hr": "Hrvatski", - "hu": "Magyar", - "hy": "Հայերեն", - "id": "Bahasa Indonesia", - "it": "Italiano", - "it-IT": "Italiano (Italia)", - "ko": "한국어", - "lt": "Lietuvių", - "lv": "Latviešu", - "nb": "Norsk (bokmål)", - "nl": "Nederlands", - "pl": "Polski", - "pt": "Português", - "pt-BR": "Português (Brasil)", - "pt-PT": "Português (Portugal)", - "ro": "Română", - "ru": "Русский", - "sh": "Srpskohrvatski / Српскохрватски", - "sk": "Slovenčina", - "sl": "Slovenščina", - "sq": "Shqip", - "sr": "Српски", - "sv": "Svenska", - "ta": "தமிழ்", - "tg": "Тоҷикӣ", - "tr": "Türkçe", - "uk": "Українська", - "vi": "Tiếng Việt" - } }; \ No newline at end of file diff --git a/src/json/index.ts b/src/json/index.ts index 54a5c366ad..5208023c34 100644 --- a/src/json/index.ts +++ b/src/json/index.ts @@ -8,6 +8,10 @@ import Latex from './latex'; import Route from './route'; import Theme from './theme'; import Url from './url'; +import Lang from './lang'; +import Relation from './relation'; +import Menu from './menu'; +import Size from './size'; export { Color, @@ -20,4 +24,8 @@ export { Route, Theme, Url, + Lang, + Relation, + Menu, + Size, }; \ No newline at end of file diff --git a/src/json/lang.ts b/src/json/lang.ts new file mode 100644 index 0000000000..9ff97acc1a --- /dev/null +++ b/src/json/lang.ts @@ -0,0 +1,167 @@ +export default { + + code: { + abap: 'ABAP', + arduino: 'Arduino', + bash: 'Bash', + basic: 'BASIC', + bsl: 'BSL', + c: 'C', + cfscript: 'CFScript', + cmake: 'CMake', + csharp: 'C#', + cpp: 'C++', + clojure: 'Clojure', + coffeescript: 'CoffeeScript', + css: 'CSS', + dart: 'Dart', + diff: 'Diff', + docker: 'Docker', + elixir: 'Elixir', + elm: 'Elm', + erlang: 'Erlang', + flow: 'Flow', + fortran: 'Fortran', + fsharp: 'F#', + gdscript: 'GDScript', + gherkin: 'Gherkin', + graphql: 'GraphQL', + groovy: 'Groovy', + go: 'Go', + dot: 'Graphviz', + haskell: 'Haskell', + html: 'HTML', + json: 'JSON', + javascript: 'JavaScript', + java: 'Java', + kotlin: 'Kotlin', + latex: 'LaTeX', + less: 'Less', + lisp: 'Lisp', + livescript: 'LiveScript', + lua: 'Lua', + markup: 'Markup', + markdown: 'Markdown', + makefile: 'Makefile', + matlab: 'MATLAB', + nginx: 'Nginx', + nix: 'Nix', + objc: 'Objective-C', + ocaml: 'OCaml', + pascal: 'Pascal', + perl: 'Perl', + php: 'PHP', + powershell: 'Power Shell', + plain: 'Plain Text', + prolog: 'Prolog', + python: 'Python', + reason: 'Reason', + ruby: 'Ruby', + rust: 'Rust', + r: 'R', + sass: 'Sass', + scala: 'Scala', + scheme: 'Scheme', + scss: 'SСSS', + shell: 'Shell', + solidity: 'Solidity', + sql: 'SQL', + swift: 'Swift', + toml: 'TOML', + typescript: 'TypeScript', + vbnet: 'Vb.Net', + verilog: 'Verilog', + vhdl: 'VHDL', + vb: 'Visual Basic', + wasm: 'WebAssembly', + wolfram: 'Wolfram', + xml: 'XML', + yaml: 'YAML' + }, + + enabled: [ + 'be-BY', + 'cs-CZ', + 'da-DK', + 'de-DE', + 'en-US', + 'es-ES', + 'fr-FR', + 'hi-IN', + 'id-ID', + 'it-IT', + 'lt-LT', + 'ja-JP', + 'ko-KR', + 'nl-NL', + 'no-NO', + 'pl-PL', + 'pt-BR', + 'ro-RO', + 'ru-RU', + 'tr-TR', + 'uk-UA', + 'vi-VN', + 'zh-CN', + 'zh-TW' + ], + + spelling: { + af: 'Afrikaans', + bg: 'Български', + ca: 'Català', + cs: 'Česky', + cy: 'Cymraeg', + da: 'Dansk', + de: 'Deutsch', + 'de-DE': 'Deutsch (Deutschland)', + el: 'Ελληνικά', + en: 'English', + 'en-AU': 'English (Australia)', + 'en-CA': 'English (Canada)', + 'en-GB': 'English (United Kingdom)', + 'en-GB-oxendict': 'English (United Kingdom Oxford spelling)', + 'en-US': 'English (United States)', + es: 'Español', + 'es-419': 'Español (Caribe)', + 'es-AR': 'Español (Argentina)', + 'es-ES': 'Español (España)', + 'es-MX': 'Español (México)', + 'es-US': 'Español (Estados Unidos)', + et: 'Eesti', + fa: 'فارسی', + fo: 'Føroyskt', + fr: 'Français', + 'fr-FR': 'Français (France)', + he: 'עברית', + hi: 'हिन्दी', + hr: 'Hrvatski', + hu: 'Magyar', + hy: 'Հայերեն', + id: 'Bahasa Indonesia', + it: 'Italiano', + 'it-IT': 'Italiano (Italia)', + ko: '한국어', + lt: 'Lietuvių', + lv: 'Latviešu', + nb: 'Norsk (bokmål)', + nl: 'Nederlands', + pl: 'Polski', + pt: 'Português', + 'pt-BR': 'Português (Brasil)', + 'pt-PT': 'Português (Portugal)', + ro: 'Română', + ru: 'Русский', + sh: 'Srpskohrvatski / Српскохрватски', + sk: 'Slovenčina', + sl: 'Slovenščina', + sq: 'Shqip', + sr: 'Српски', + sv: 'Svenska', + ta: 'தமிழ்', + tg: 'Тоҷикӣ', + tr: 'Türkçe', + uk: 'Українська', + vi: 'Tiếng Việt', + }, +}; \ No newline at end of file diff --git a/src/json/menu.ts b/src/json/menu.ts new file mode 100644 index 0000000000..158d4c20dc --- /dev/null +++ b/src/json/menu.ts @@ -0,0 +1,66 @@ +export default { + cell: [ + 'select', + 'button', + 'dataviewText', + 'dataviewRelationEdit', + 'dataviewObjectList', + 'dataviewObjectValues', + 'dataviewOptionList', + 'dataviewOptionEdit', + 'dataviewFileList', + 'dataviewFileValues', + 'dataviewCalendar', + 'relationSuggest' + ], + cellAdd: [ + 'dataviewRelationEdit', + 'dataviewRelationSuggest', + 'dataviewRelationList' + ], + context: [ + 'select', + 'blockStyle', + 'blockLink', + 'blockColor', + 'blockBackground', + 'searchObject', + 'typeSuggest', + 'blockAlign' + ], + selectContext: [ + 'searchObject', + 'typeSuggest', + 'blockAlign' + ], + add: [ 'searchObject', 'blockRelationEdit', 'typeSuggest' ], + action: [ + 'blockStyle', + 'blockColor', + 'blockBackground', + 'blockAlign', + 'blockLinkSettings', + 'searchObject', + 'typeSuggest' + ], + object: [ 'select', 'searchObject' ], + index: [ 'searchObject' ], + relationEdit: [ + 'select', + 'searchObject', + 'dataviewDate', + 'dataviewObjectValues', + 'dataviewObjectList' + ], + layout: [ 'blockAlign' ], + latex: [ 'previewLatex' ], + viewEdit: [ 'select', 'graphSettings' ], + featuredType: [ 'searchObject', 'typeSuggest' ], + dataviewHead: [ 'dataviewSource', 'searchObject' ], + store: [ 'typeSuggest', 'relationSuggest' ], + widget: [ 'searchObject', 'select' ], + dataviewTemplate: [ 'previewObject' ], + table: [ 'select2', 'blockColor', 'blockBackground' ], + navigation: [ 'quickCapture', 'space' ], + dataviewContext: [ 'typeSuggest', 'searchObject' ] +}; \ No newline at end of file diff --git a/src/json/relation.ts b/src/json/relation.ts new file mode 100644 index 0000000000..7df1eadc07 --- /dev/null +++ b/src/json/relation.ts @@ -0,0 +1,161 @@ +export default { + default: [ + 'id', + 'spaceId', + 'name', + 'description', + 'snippet', + 'iconEmoji', + 'iconImage', + 'iconOption', + 'relationFormat', + 'type', + 'layout', + 'isHidden', + 'isArchived', + 'isReadonly', + 'isDeleted', + 'isFavorite', + 'done', + 'fileExt', + 'fileMimeType', + 'sizeInBytes', + 'restrictions', + 'defaultTemplateId', + 'identityProfileLink', + 'createdDate' + ], + + sidebar: [ + 'id', + 'spaceId', + 'name', + 'description', + 'snippet', + 'layout', + 'type', + 'iconEmoji', + 'iconImage', + 'iconOption', + 'isReadonly', + 'isHidden', + 'isDeleted', + 'isArchived', + 'isFavorite', + 'done', + 'relationFormat', + 'fileExt', + 'fileMimeType', + 'links', + 'restrictions', + 'source', + 'identityProfileLink', + 'lastModifiedDate', + 'lastOpenedDate' + ], + + relation: [ + 'id', + 'spaceId', + 'type', + 'layout', + 'name', + 'relationFormat', + 'relationKey', + 'isReadonly', + 'isHidden', + 'isDeleted', + 'isArchived', + 'isFavorite', + 'restrictions', + 'relationMaxCount', + 'relationReadonlyValue', + 'relationDefaultValue', + 'relationFormatObjectTypes', + 'sourceObject', + 'restrictions' + ], + + cover: [ + 'coverId', + 'coverType', + 'coverX', + 'coverY', + 'coverScale' + ], + + option: [ + 'id', + 'relationKey', + 'type', + 'layout', + 'name', + 'relationOptionColor' + ], + + type: [ + 'recommendedRelations', + 'recommendedLayout', + 'sourceObject', + 'uniqueKey', + 'defaultTemplateId', + 'lastUsedDate' + ], + + graph: [ + 'id', + 'name', + 'snippet', + 'description', + 'iconEmoji', + 'iconImage', + 'iconOption', + 'relationFormat', + 'type', + 'layout', + 'done', + 'fileExt', + 'fileMimeType', + 'isDeleted', + 'isArchived', + 'isFavorite', + 'identityProfileLink', + 'restrictions' + ], + + template: [ + 'templateIsBundled', + 'type', + 'targetObjectType', + 'internalFlags', + 'sourceObject' + ], + + space: [ + 'spaceDashboardId', + 'spaceAccountStatus', + 'spaceLocalStatus', + 'spaceAccessType', + 'readersLimit', + 'writersLimit', + 'sharedSpacesLimit', + 'targetSpaceId', + 'creator', + 'createdDate' + ], + + participant: [ + 'identity', + 'participantPermissions', + 'participantStatus', + 'globalName' + ], + + syncStatus: [ + 'syncStatus', + 'syncDate', + 'syncError' + ], + + pageCover: 'pageCover', +}; \ No newline at end of file diff --git a/src/json/size.ts b/src/json/size.ts new file mode 100644 index 0000000000..ce84e4bf60 --- /dev/null +++ b/src/json/size.ts @@ -0,0 +1,49 @@ +export default { + editor: 704, + blockMenu: 48, + lastBlock: 80, + iconPage: 256, + image: 1920, + cover: 1920, + menuBorder: 10, + + sidebar: { + width: { min: 240, max: 500, default: 336, close: 180 } + }, + + table: { + min: 50, + max: 2000, + default: 140 + }, + + dataview: { + gallery: { + width: 224, + height: 72, + margin: 16, + padding: 16 + }, + + board: { + card: 262, + margin: 8 + }, + + cell: { + default: 192, + format1: 500, + + min: 48, + max: 1000, + edit: 300, + icon: 70 + } + }, + + store: { + width: 300, + margin: 32, + border: 80 + } +}; \ No newline at end of file diff --git a/src/ts/component/block/cover.tsx b/src/ts/component/block/cover.tsx index 10f6d4a18e..a7be91d6d1 100644 --- a/src/ts/component/block/cover.tsx +++ b/src/ts/component/block/cover.tsx @@ -58,7 +58,7 @@ const BlockCover = observer(class BlockCover extends React.Component { elements.removeClass('hover'); }, - subIds: J.Constant.menuIds.layout, + subIds: J.Menu.layout, data: { rootId: rootId, value: object.layout, @@ -249,7 +249,7 @@ const BlockCover = observer(class BlockCover extends React.Component { this.setState({ isEditing: false }); @@ -311,7 +311,7 @@ const BlockCover = observer(class BlockCover extends React.Component it && it.relationKey)); - if (view.coverRelationKey && (view.coverRelationKey != J.Constant.pageCoverRelationKey)) { + if (view.coverRelationKey && (view.coverRelationKey != J.Relation.pageCover)) { keys.push(view.coverRelationKey); }; @@ -762,7 +762,7 @@ const BlockDataview = observer(class BlockDataview extends React.Component 0 ? I.MenuDirection.Top : I.MenuDirection.Bottom, horizontal: dir > 0 ? I.MenuDirection.Left : I.MenuDirection.Right, onOpen: context => menuContext = context, diff --git a/src/ts/component/block/dataview/cell/index.tsx b/src/ts/component/block/dataview/cell/index.tsx index 51681f6e90..cab955d479 100644 --- a/src/ts/component/block/dataview/cell/index.tsx +++ b/src/ts/component/block/dataview/cell/index.tsx @@ -444,17 +444,17 @@ const Cell = observer(class Cell extends React.Component { $(pageContainer).off('mousedown.cell').on('mousedown.cell', (e: any) => { if (!$(e.target).parents(`#${cellId}`).length) { - S.Menu.closeAll(J.Constant.menuIds.cell); + S.Menu.closeAll(J.Menu.cell); }; }); if (!config.debug.ui) { - win.off('blur.cell').on('blur.cell', () => S.Menu.closeAll(J.Constant.menuIds.cell)); + win.off('blur.cell').on('blur.cell', () => S.Menu.closeAll(J.Menu.cell)); }; } else if (closeIfOpen) { setOff(); - S.Menu.closeAll(J.Constant.menuIds.cell); + S.Menu.closeAll(J.Menu.cell); window.clearTimeout(this.timeout); }; } else { diff --git a/src/ts/component/block/dataview/cell/text.tsx b/src/ts/component/block/dataview/cell/text.tsx index 5e43faac49..e510758be9 100644 --- a/src/ts/component/block/dataview/cell/text.tsx +++ b/src/ts/component/block/dataview/cell/text.tsx @@ -353,7 +353,7 @@ const CellText = observer(class CellText extends React.Component e.preventDefault(); this.save(value, () => { - S.Menu.closeAll(J.Constant.menuIds.cell); + S.Menu.closeAll(J.Menu.cell); this.range = null; this.setEditing(false); diff --git a/src/ts/component/block/dataview/view/board.tsx b/src/ts/component/block/dataview/view/board.tsx index 9e6e081bb0..7c07154d36 100644 --- a/src/ts/component/block/dataview/view/board.tsx +++ b/src/ts/component/block/dataview/view/board.tsx @@ -492,7 +492,7 @@ const ViewBoard = observer(class ViewBoard extends React.Component { + C.ObjectGraph(S.Common.space, filters, 0, [], J.Relation.graph, (isCollection ? target.id : ''), target.setOf, (message: any) => { if (message.error.code) { return; }; @@ -127,7 +127,7 @@ const ViewGraph = observer(class ViewGraph extends React.Component S.Detail.mapper(it)); - U.Data.onSubscribe(J.Constant.subId.graph, 'id', J.Constant.graphRelationKeys, { + U.Data.onSubscribe(J.Constant.subId.graph, 'id', J.Relation.graph, { error: {}, records: message.nodes, dependencies: [], diff --git a/src/ts/component/block/dataview/view/grid.tsx b/src/ts/component/block/dataview/view/grid.tsx index 7b3bbe51b3..96adce32fb 100644 --- a/src/ts/component/block/dataview/view/grid.tsx +++ b/src/ts/component/block/dataview/view/grid.tsx @@ -182,7 +182,7 @@ const ViewGrid = observer(class ViewGrid extends React.Component widths[it.relationKey] + 'px').concat([ 'auto' ]).join(' '); @@ -296,7 +296,7 @@ const ViewGrid = observer(class ViewGrid extends React.Component S.Menu.closeAll(J.Constant.menuIds.cellAdd) + onAdd: () => S.Menu.closeAll(J.Menu.cellAdd) } }); }; @@ -359,7 +359,7 @@ const ViewGrid = observer(class ViewGrid extends React.Component { return res + current.width; }, J.Constant.size.blockMenu); + const width = getVisibleRelations().reduce((res: number, current: any) => { return res + current.width; }, J.Size.blockMenu); const length = S.Record.getRecordIds(S.Record.getSubId(rootId, block.id), '').length; const cw = container.width(); const rh = this.getRowHeight(); @@ -377,7 +377,7 @@ const ViewGrid = observer(class ViewGrid extends React.Component { const idPrefix = getIdPrefix(); const id = Relation.cellId(idPrefix, relationKey, record.id); const width = Relation.width(this.props.width, relation.format); - const size = J.Constant.size.dataview.cell; + const size = J.Size.dataview.cell; const subId = S.Record.getSubId(rootId, block.id); const canEdit = canCellEdit(relation, record); @@ -77,7 +77,7 @@ const BodyCell = observer(class BodyCell extends React.Component { viewType={I.ViewType.Grid} idPrefix={idPrefix} onCellChange={onCellChange} - maxWidth={J.Constant.size.dataview.cell.edit} + maxWidth={J.Size.dataview.cell.edit} /> {iconEdit} diff --git a/src/ts/component/block/embed.tsx b/src/ts/component/block/embed.tsx index 81b50deb01..7938cbfd81 100644 --- a/src/ts/component/block/embed.tsx +++ b/src/ts/component/block/embed.tsx @@ -497,11 +497,11 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component { const rect = recalcRect(); - return rect ? 0 : J.Constant.size.blockMenu; + return rect ? 0 : J.Size.blockMenu; }, commonFilter: true, className: (isTemplate ? 'isTemplate' : ''), - subIds: J.Constant.menuIds.latex, + subIds: J.Menu.latex, onClose: () => { S.Common.filterSet(0, ''); }, diff --git a/src/ts/component/block/featured.tsx b/src/ts/component/block/featured.tsx index 5fee9e57cb..f012a318f7 100644 --- a/src/ts/component/block/featured.tsx +++ b/src/ts/component/block/featured.tsx @@ -451,7 +451,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component { this.menuContext = context; }, @@ -490,7 +490,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component { + S.Menu.closeAll(J.Menu.featuredType, () => { S.Menu.open(menuId, menuParam); }); }; @@ -753,7 +753,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component { if (component && component.ref) { component.ref.onCellClick(e, relationKey); @@ -826,7 +826,7 @@ const BlockFeatured = observer(class BlockFeatured extends React.Component { + S.Menu.closeAll(J.Menu.cell, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/block/index.tsx b/src/ts/component/block/index.tsx index 17dafe3e2e..2ba898aa93 100644 --- a/src/ts/component/block/index.tsx +++ b/src/ts/component/block/index.tsx @@ -519,7 +519,7 @@ const Block = observer(class Block extends React.Component { const menuParam: Partial = Object.assign({ noFlipX: true, - subIds: J.Constant.menuIds.action, + subIds: J.Menu.action, onClose: () => { selection?.clear(); focus.apply(); @@ -551,7 +551,7 @@ const Block = observer(class Block extends React.Component { const win = $(window); const node = $(this.node); const prevBlockId = childrenIds[index - 1]; - const offset = (prevBlockId ? node.find('#block-' + prevBlockId).offset().left : 0) + J.Constant.size.blockMenu ; + const offset = (prevBlockId ? node.find('#block-' + prevBlockId).offset().left : 0) + J.Size.blockMenu ; const add = $('#button-block-add'); selection?.clear(); @@ -659,7 +659,7 @@ const Block = observer(class Block extends React.Component { const width = getWrapperWidth(); const dw = 1 / childrenIds.length; const sum = (prevBlock.fields.width || dw) + (currentBlock.fields.width || dw); - const offset = J.Constant.size.blockMenu * 2; + const offset = J.Size.blockMenu * 2; x = Math.max(offset, x); x = Math.min(sum * width - offset, x); @@ -682,7 +682,7 @@ const Block = observer(class Block extends React.Component { return; }; - const sm = J.Constant.size.blockMenu; + const sm = J.Size.blockMenu; const node = $(this.node); const childrenIds = S.Block.getChildrenIds(rootId, block.id); const length = childrenIds.length; diff --git a/src/ts/component/block/link.tsx b/src/ts/component/block/link.tsx index 276fbcd8b2..329dba9d5a 100644 --- a/src/ts/component/block/link.tsx +++ b/src/ts/component/block/link.tsx @@ -22,7 +22,7 @@ const BlockLink = observer(class BlockLink extends React.Component e.preventDefault()} onClick={this.onClick} onLoad={this.onLoad} @@ -219,7 +219,7 @@ const BlockImage = observer(class BlockImage extends React.Component this.onOptionsOpen(type, rowId, columnId, cellId)); }, onClose: () => { - S.Menu.closeAll(J.Constant.menuIds.table); + S.Menu.closeAll(J.Menu.table); this.onOptionsClose(); }, - subIds: J.Constant.menuIds.table, + subIds: J.Menu.table, }; let element: any = null; @@ -352,7 +352,7 @@ const BlockTable = observer(class BlockTable extends React.Component { + S.Menu.closeAll(J.Menu.table, () => { S.Menu.open(menuId, menuParam); }); }, @@ -517,7 +517,7 @@ const BlockTable = observer(class BlockTable extends React.Component { - ret.push(this.checkWidth(it.fields.width || J.Constant.size.table.default)); + ret.push(this.checkWidth(it.fields.width || J.Size.table.default)); }); return ret; @@ -1190,13 +1190,13 @@ const BlockTable = observer(class BlockTable extends React.Component this.checkWidth(it.fields.width || J.Constant.size.table.default)); + const widths = columns.map(it => this.checkWidth(it.fields.width || J.Size.table.default)); this.setColumnWidths(widths); }; checkWidth (w: number) { - const { min, max } = J.Constant.size.table; + const { min, max } = J.Size.table; const steps = 5; let width = Math.max(min, Math.min(max, w)); @@ -1525,7 +1525,7 @@ const BlockTable = observer(class BlockTable extends React.Component maxWidth ? wrap.addClass('withScroll') : wrap.removeClass('withScroll'); width = Math.max(wrapperWidth, Math.min(maxWidth, width)); @@ -1549,7 +1549,7 @@ const BlockTable = observer(class BlockTable extends React.Component maxWidth ? wrap.addClass('withScroll') : wrap.removeClass('withScroll'); diff --git a/src/ts/component/block/table/cell.tsx b/src/ts/component/block/table/cell.tsx index b37be642da..91b4d1f708 100644 --- a/src/ts/component/block/table/cell.tsx +++ b/src/ts/component/block/table/cell.tsx @@ -146,7 +146,7 @@ const BlockTableCell = observer(class BlockTableCell extends React.Component onCellUpdate(cellId)} onFocus={e => onCellFocus(e, row.id, column.id, cellId)} onBlur={e => onCellBlur(e, row.id, column.id, cellId)} - getWrapperWidth={() => J.Constant.size.editor} + getWrapperWidth={() => J.Size.editor} /> ) : ( diff --git a/src/ts/component/block/text.tsx b/src/ts/component/block/text.tsx index 59fba7c0d3..f075bdf87e 100644 --- a/src/ts/component/block/text.tsx +++ b/src/ts/component/block/text.tsx @@ -122,8 +122,8 @@ const BlockText = observer(class BlockText extends React.Component { case I.TextStyle.Code: { const options: I.Option[] = []; - for (const i in J.Constant.codeLang) { - options.push({ id: i, name: J.Constant.codeLang[i] }); + for (const i in J.Lang.code) { + options.push({ id: i, name: J.Lang.code[i] }); }; spellcheck = false; @@ -1107,7 +1107,7 @@ const BlockText = observer(class BlockText extends React.Component { }, offsetX: () => { const rect = U.Common.getSelectionRect(); - return rect ? 0 : J.Constant.size.blockMenu; + return rect ? 0 : J.Size.blockMenu; }, noFlipX: false, noFlipY: false, @@ -1153,7 +1153,7 @@ const BlockText = observer(class BlockText extends React.Component { }, offsetX: () => { const rect = U.Common.getSelectionRect(); - return rect ? 0 : J.Constant.size.blockMenu; + return rect ? 0 : J.Size.blockMenu; }, data: { noHead: true, diff --git a/src/ts/component/drag/layer.tsx b/src/ts/component/drag/layer.tsx index bcaba8393d..e76b9f67fc 100644 --- a/src/ts/component/drag/layer.tsx +++ b/src/ts/component/drag/layer.tsx @@ -72,7 +72,7 @@ class DragLayer extends React.Component { const comp = $(ReactDOM.findDOMNode(component)); const rect = (comp.get(0) as Element).getBoundingClientRect(); - this.setState({ rootId, type, width: rect.width - J.Constant.size.blockMenu, ids }); + this.setState({ rootId, type, width: rect.width - J.Size.blockMenu, ids }); }; hide () { diff --git a/src/ts/component/drag/provider.tsx b/src/ts/component/drag/provider.tsx index 105ba09c15..38e1335555 100644 --- a/src/ts/component/drag/provider.tsx +++ b/src/ts/component/drag/provider.tsx @@ -571,7 +571,7 @@ const DragProvider = observer(class DragProvider extends React.Component canDropMiddle = Number(obj.attr('data-drop-middle')) || 0; isReversed = Boolean(obj.attr('data-reversed')); - col1 = x - J.Constant.size.blockMenu / 4; + col1 = x - J.Size.blockMenu / 4; col2 = x + width; }; diff --git a/src/ts/component/editor/page.tsx b/src/ts/component/editor/page.tsx index c41d73049e..d309781e66 100644 --- a/src/ts/component/editor/page.tsx +++ b/src/ts/component/editor/page.tsx @@ -487,7 +487,7 @@ const EditorPage = observer(class EditorPage extends React.Component= x) && - (pageX <= x + J.Constant.size.blockMenu) && + (pageX <= x + J.Size.blockMenu) && (pageY >= offset + BUTTON_OFFSET) && (pageY <= this.winScrollTop + rectContainer.height + offset + BUTTON_OFFSET) ) { @@ -501,7 +501,7 @@ const EditorPage = observer(class EditorPage extends React.Component { S.Menu.open('blockAction', { element: `#block-${ids[0]}`, - offsetX: J.Constant.size.blockMenu, + offsetX: J.Size.blockMenu, data: { blockId: ids[0], blockIds: ids, @@ -814,7 +814,7 @@ const EditorPage = observer(class EditorPage extends React.Component { S.Menu.open('blockAction', { element: `#block-${block.id}`, - offsetX: J.Constant.size.blockMenu, + offsetX: J.Size.blockMenu, data: { blockId: block.id, blockIds: U.Data.selectionGet(block.id, true, true), @@ -1600,14 +1600,14 @@ const EditorPage = observer(class EditorPage extends React.Component { const rect = U.Common.getSelectionRect(); return rect ? { ...rect, y: rect.y + win.scrollTop() } : null; }, offsetX: () => { const rect = U.Common.getSelectionRect(); - return rect ? 0 : J.Constant.size.blockMenu; + return rect ? 0 : J.Size.blockMenu; }, commonFilter: true, onClose: () => { @@ -1790,7 +1790,7 @@ const EditorPage = observer(class EditorPage extends React.Component { const rect = U.Common.getSelectionRect(); - return rect ? 0 : J.Constant.size.blockMenu; + return rect ? 0 : J.Size.blockMenu; }, onOpen: () => { if (block) { @@ -2157,7 +2157,7 @@ const EditorPage = observer(class EditorPage extends React.Component { }; checkValue (v: string[]) { - return v.map(it => it.substring(0, J.Constant.limit.phrase.letter)).filter(it => it).slice(0, J.Constant.limit.phrase.word); + return v.map(it => it.substring(0, J.Constant.count.phrase.letter)).filter(it => it).slice(0, J.Constant.count.phrase.word); }; setError (v: boolean) { diff --git a/src/ts/component/form/pin.tsx b/src/ts/component/form/pin.tsx index bcc6915a07..e69c9cdf01 100644 --- a/src/ts/component/form/pin.tsx +++ b/src/ts/component/form/pin.tsx @@ -4,22 +4,15 @@ import { Input } from 'Component'; import { J, keyboard } from 'Lib'; interface Props { - /** the length of the pin, defaults to J.Constant.pinLength */ pinLength?: number; - /** the expected pin, encrypted in sha1. if none provided, this component does not make a comparison check */ expectedPin?: string | null; - /** if true, the input field will be focused on component mount */ focusOnMount?: boolean; - /** callback when the pin is entered (and matches expectedPin if provided)*/ onSuccess?: (value: string) => void; - /** callback when the pin is entered (and does not match expectedPin if provided)*/ onError?: () => void; - /** if true, input will not turn to type password after filled*/ isVisible?: boolean; }; type State = { - /** index of the current pin character in focus */ index: number; }; @@ -32,7 +25,7 @@ const TIMEOUT_DURATION = 150; class Pin extends React.Component { public static defaultProps = { - pinLength: J.Constant.pinLength, + pinLength: 6, expectedPin: null, focusOnMount: true, isVisible: false, diff --git a/src/ts/component/header/index.tsx b/src/ts/component/header/index.tsx index 84ba53cc14..e9afa1130d 100644 --- a/src/ts/component/header/index.tsx +++ b/src/ts/component/header/index.tsx @@ -181,7 +181,7 @@ class Header extends React.Component { noFlipX: true, noFlipY: true, horizontal: I.MenuDirection.Right, - subIds: J.Constant.menuIds.cell, + subIds: J.Menu.cell, classNameWrap: cnw.join(' '), ...param, data: { diff --git a/src/ts/component/header/main/object.tsx b/src/ts/component/header/main/object.tsx index 455fbf6dd4..0b68ee9573 100644 --- a/src/ts/component/header/main/object.tsx +++ b/src/ts/component/header/main/object.tsx @@ -33,7 +33,7 @@ const HeaderMainObject = observer(class HeaderMainObject extends React.Component return null; }; - const object = S.Detail.get(rootId, rootId, J.Constant.templateRelationKeys); + const object = S.Detail.get(rootId, rootId, J.Relation.template); const isLocked = root ? root.isLocked() : false; const showMenu = !U.Object.isTypeOrRelationLayout(object.layout); const canSync = showMenu && !object.templateIsBundled && !root.isObjectParticipant(); @@ -119,7 +119,7 @@ const HeaderMainObject = observer(class HeaderMainObject extends React.Component menuOpen('object', '#button-header-more', { horizontal: I.MenuDirection.Right, - subIds: J.Constant.menuIds.object, + subIds: J.Menu.object, data: { rootId, blockId: rootId, diff --git a/src/ts/component/list/object.tsx b/src/ts/component/list/object.tsx index c9bafd83a1..3ca95a32ff 100644 --- a/src/ts/component/list/object.tsx +++ b/src/ts/component/list/object.tsx @@ -184,7 +184,7 @@ const ListObject = observer(class ListObject extends React.Component { }; getKeys () { - return J.Constant.defaultRelationKeys.concat(this.props.columns.map(it => it.relationKey)); + return J.Relation.default.concat(this.props.columns.map(it => it.relationKey)); }; getData (page: number, callBack?: (message: any) => void) { diff --git a/src/ts/component/list/objectManager.tsx b/src/ts/component/list/objectManager.tsx index 0a8c408a5b..0ef3d1fe84 100644 --- a/src/ts/component/list/objectManager.tsx +++ b/src/ts/component/list/objectManager.tsx @@ -294,7 +294,7 @@ const ListObjectManager = observer(class ListObjectManager extends React.Compone const node = $(ReactDOM.findDOMNode(this)); const wrapper = node.find('#filterWrapper'); - S.Menu.closeAll(J.Constant.menuIds.store); + S.Menu.closeAll(J.Menu.store); wrapper.removeClass('active'); }; diff --git a/src/ts/component/list/widget.tsx b/src/ts/component/list/widget.tsx index 6429d8e1f5..de47f80695 100644 --- a/src/ts/component/list/widget.tsx +++ b/src/ts/component/list/widget.tsx @@ -209,7 +209,7 @@ const ListWidget = observer(class ListWidget extends React.Component<{}, State> className: 'fixed', classNameWrap: 'fromSidebar', offsetY: -2, - subIds: J.Constant.menuIds.widget, + subIds: J.Menu.widget, vertical: I.MenuDirection.Top, data: { setEditing: this.setEditing, diff --git a/src/ts/component/menu/block/action.tsx b/src/ts/component/menu/block/action.tsx index 2edd2bfb41..f88eec5261 100644 --- a/src/ts/component/menu/block/action.tsx +++ b/src/ts/component/menu/block/action.tsx @@ -109,12 +109,12 @@ class MenuBlockAction extends React.Component { this._isMounted = false; keyboard.setFocus(false); - S.Menu.closeAll(J.Constant.menuIds.action); + S.Menu.closeAll(J.Menu.action); S.Menu.clearTimeout(); }; onFilterFocus (e: any) { - S.Menu.closeAll(J.Constant.menuIds.action); + S.Menu.closeAll(J.Menu.action); this.props.setActive(); }; @@ -342,7 +342,7 @@ class MenuBlockAction extends React.Component { setActive(item, false); if (!item.arrow) { - S.Menu.closeAll(J.Constant.menuIds.action); + S.Menu.closeAll(J.Menu.action); return; }; @@ -575,7 +575,7 @@ class MenuBlockAction extends React.Component { }; if (menuId && !S.Menu.isOpen(menuId, item.itemId)) { - S.Menu.closeAll(J.Constant.menuIds.action, () => { + S.Menu.closeAll(J.Menu.action, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/block/add.tsx b/src/ts/component/menu/block/add.tsx index 3d065d0307..083e777db7 100644 --- a/src/ts/component/menu/block/add.tsx +++ b/src/ts/component/menu/block/add.tsx @@ -241,7 +241,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component componentWillUnmount () { this._isMounted = false; - S.Menu.closeAll(J.Constant.menuIds.add); + S.Menu.closeAll(J.Menu.add); }; checkFilter () { @@ -364,7 +364,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component onOver (e: any, item: any) { if (!item.arrow) { - S.Menu.closeAll(J.Constant.menuIds.add); + S.Menu.closeAll(J.Menu.add); return; }; @@ -460,7 +460,7 @@ const MenuBlockAdd = observer(class MenuBlockAdd extends React.Component }; if (menuId && !S.Menu.isOpen(menuId, item.itemId)) { - S.Menu.closeAll(J.Constant.menuIds.add, () => { + S.Menu.closeAll(J.Menu.add, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/block/context.tsx b/src/ts/component/menu/block/context.tsx index 3eb61ce19a..8fc132256b 100644 --- a/src/ts/component/menu/block/context.tsx +++ b/src/ts/component/menu/block/context.tsx @@ -165,7 +165,7 @@ const MenuBlockContext = observer(class MenuBlockContext extends React.Component }; componentWillUnmount(): void { - S.Menu.closeAll(J.Constant.menuIds.context.concat('selectContext')); + S.Menu.closeAll(J.Menu.context.concat('selectContext')); }; onMark (e: any, type: any) { @@ -249,7 +249,7 @@ const MenuBlockContext = observer(class MenuBlockContext extends React.Component menuParam = Object.assign(menuParam, { component: 'select', - subIds: J.Constant.menuIds.selectContext, + subIds: J.Menu.selectContext, onOpen: context => this.menuContext = context, }); @@ -266,7 +266,7 @@ const MenuBlockContext = observer(class MenuBlockContext extends React.Component }; if (!item.arrow) { - S.Menu.closeAll(J.Constant.menuIds.selectContext); + S.Menu.closeAll(J.Menu.selectContext); return; }; @@ -358,7 +358,7 @@ const MenuBlockContext = observer(class MenuBlockContext extends React.Component focusApply ? focus.apply() : focus.clear(false); if (menuId && !S.Menu.isOpen(menuId)) { - const menuIds = [].concat(J.Constant.menuIds.context); + const menuIds = [].concat(J.Menu.context); if (closeContext) { menuIds.push(this.props.id); @@ -453,7 +453,7 @@ const MenuBlockContext = observer(class MenuBlockContext extends React.Component }; if (menuId && !S.Menu.isOpen(menuId)) { - S.Menu.closeAll(J.Constant.menuIds.selectContext, () => { + S.Menu.closeAll(J.Menu.selectContext, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/block/cover.tsx b/src/ts/component/menu/block/cover.tsx index dcdb3dcd74..2f520212c7 100644 --- a/src/ts/component/menu/block/cover.tsx +++ b/src/ts/component/menu/block/cover.tsx @@ -293,7 +293,7 @@ const MenuBlockCover = observer(class MenuBlockCover extends React.Component { }; componentWillUnmount (): void { - S.Menu.closeAll(J.Constant.menuIds.layout); + S.Menu.closeAll(J.Menu.layout); }; rebind () { @@ -124,7 +124,7 @@ class MenuBlockLayout extends React.Component { onOver (e: any, item: any) { if (!item.arrow) { - S.Menu.closeAll(J.Constant.menuIds.layout); + S.Menu.closeAll(J.Menu.layout); return; }; @@ -165,7 +165,7 @@ class MenuBlockLayout extends React.Component { }; if (menuId && !S.Menu.isOpen(menuId, item.id)) { - S.Menu.closeAll(J.Constant.menuIds.layout, () => { + S.Menu.closeAll(J.Menu.layout, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/block/link/settings.tsx b/src/ts/component/menu/block/link/settings.tsx index 2e8e85d50e..2569d8a6be 100644 --- a/src/ts/component/menu/block/link/settings.tsx +++ b/src/ts/component/menu/block/link/settings.tsx @@ -128,7 +128,7 @@ const MenuBlockLinkSettings = observer(class MenuBlockLinkSettings extends React menuParam.data = Object.assign(menuParam.data, { options }); if (!S.Menu.isOpen(menuId, item.id)) { - S.Menu.closeAll(J.Constant.menuIds.object, () => { + S.Menu.closeAll(J.Menu.object, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/block/relation/edit.tsx b/src/ts/component/menu/block/relation/edit.tsx index 3e7234844f..5e292d65e0 100644 --- a/src/ts/component/menu/block/relation/edit.tsx +++ b/src/ts/component/menu/block/relation/edit.tsx @@ -373,14 +373,14 @@ const MenuBlockRelationEdit = observer(class MenuBlockRelationEdit extends React }); if (!S.Menu.isOpen(id)) { - S.Menu.closeAll(J.Constant.menuIds.relationEdit, () => { + S.Menu.closeAll(J.Menu.relationEdit, () => { S.Menu.open(id, options); }); }; }; menuClose () { - S.Menu.closeAll(J.Constant.menuIds.relationEdit); + S.Menu.closeAll(J.Menu.relationEdit); }; onOpen (e: any) { diff --git a/src/ts/component/menu/dataview/context.tsx b/src/ts/component/menu/dataview/context.tsx index fe310c7537..b640f76800 100644 --- a/src/ts/component/menu/dataview/context.tsx +++ b/src/ts/component/menu/dataview/context.tsx @@ -64,7 +64,7 @@ class MenuContext extends React.Component { }; componentWillUnmount () { - S.Menu.closeAll(J.Constant.menuIds.dataviewContext); + S.Menu.closeAll(J.Menu.dataviewContext); }; rebind () { @@ -223,7 +223,7 @@ class MenuContext extends React.Component { }; if (!item.arrow || !objectIds.length) { - S.Menu.closeAll(J.Constant.menuIds.dataviewContext); + S.Menu.closeAll(J.Menu.dataviewContext); return; }; @@ -287,7 +287,7 @@ class MenuContext extends React.Component { }; if (menuId && !S.Menu.isOpen(menuId, item.id)) { - S.Menu.closeAll(J.Constant.menuIds.dataviewContext, () => { + S.Menu.closeAll(J.Menu.dataviewContext, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/dataview/file/values.tsx b/src/ts/component/menu/dataview/file/values.tsx index be77f2b1d3..abe3251a08 100644 --- a/src/ts/component/menu/dataview/file/values.tsx +++ b/src/ts/component/menu/dataview/file/values.tsx @@ -251,7 +251,7 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea }; case I.ObjectLayout.Image: { - url = S.Common.imageUrl(item.id, J.Constant.size.image); + url = S.Common.imageUrl(item.id, J.Size.image); break; }; }; diff --git a/src/ts/component/menu/dataview/filter/list.tsx b/src/ts/component/menu/dataview/filter/list.tsx index 5138c98238..b49687fcf0 100644 --- a/src/ts/component/menu/dataview/filter/list.tsx +++ b/src/ts/component/menu/dataview/filter/list.tsx @@ -173,14 +173,14 @@ const MenuFilterList = observer(class MenuFilterList extends React.Component S.Menu.closeAll(J.Constant.menuIds.cell)); + obj.off('click').on('click', () => S.Menu.closeAll(J.Menu.cell)); this.unbind(); $(window).on('keydown.menu', e => this.props.onKeyDown(e)); diff --git a/src/ts/component/menu/dataview/filter/values.tsx b/src/ts/component/menu/dataview/filter/values.tsx index a24489f6d1..f92a590219 100644 --- a/src/ts/component/menu/dataview/filter/values.tsx +++ b/src/ts/component/menu/dataview/filter/values.tsx @@ -344,7 +344,7 @@ const MenuDataviewFilterValues = observer(class MenuDataviewFilterValues extends this._isMounted = false; this.unbind(); - S.Menu.closeAll(J.Constant.menuIds.cell); + S.Menu.closeAll(J.Menu.cell); }; rebind () { diff --git a/src/ts/component/menu/dataview/group/list.tsx b/src/ts/component/menu/dataview/group/list.tsx index fe9eaad144..4df6a4a1a1 100644 --- a/src/ts/component/menu/dataview/group/list.tsx +++ b/src/ts/component/menu/dataview/group/list.tsx @@ -179,7 +179,7 @@ const MenuGroupList = observer(class MenuGroupList extends React.Component { + S.Menu.closeAll(J.Menu.relationEdit, () => { S.Menu.open(id, options); }); }; }; menuClose () { - S.Menu.closeAll(J.Constant.menuIds.relationEdit); + S.Menu.closeAll(J.Menu.relationEdit); }; onChangeTime (v: boolean) { diff --git a/src/ts/component/menu/dataview/relation/list.tsx b/src/ts/component/menu/dataview/relation/list.tsx index b666bb52c8..0b47780e66 100644 --- a/src/ts/component/menu/dataview/relation/list.tsx +++ b/src/ts/component/menu/dataview/relation/list.tsx @@ -186,7 +186,7 @@ const MenuRelationList = observer(class MenuRelationList extends React.Component componentWillUnmount () { this.unbind(); - S.Menu.closeAll(J.Constant.menuIds.cell); + S.Menu.closeAll(J.Menu.cell); }; rebind () { diff --git a/src/ts/component/menu/dataview/sort.tsx b/src/ts/component/menu/dataview/sort.tsx index b0fcc40019..325a358b09 100644 --- a/src/ts/component/menu/dataview/sort.tsx +++ b/src/ts/component/menu/dataview/sort.tsx @@ -209,7 +209,7 @@ const MenuSort = observer(class MenuSort extends React.Component { componentWillUnmount () { this.unbind(); - S.Menu.closeAll(J.Constant.menuIds.cell); + S.Menu.closeAll(J.Menu.cell); }; rebind () { diff --git a/src/ts/component/menu/dataview/template/list.tsx b/src/ts/component/menu/dataview/template/list.tsx index 4c50be32d0..6998dbad2e 100644 --- a/src/ts/component/menu/dataview/template/list.tsx +++ b/src/ts/component/menu/dataview/template/list.tsx @@ -204,7 +204,7 @@ const MenuTemplateList = observer(class MenuTemplateList extends React.Component const sorts = [ { relationKey: 'name', type: I.SortType.Asc }, ]; - const keys = J.Constant.defaultRelationKeys.concat([ 'targetObjectType' ]); + const keys = J.Relation.default.concat([ 'targetObjectType' ]); U.Data.searchSubscribe({ subId: this.getSubId(), @@ -274,13 +274,13 @@ const MenuTemplateList = observer(class MenuTemplateList extends React.Component return; }; - S.Menu.closeAll(J.Constant.menuIds.dataviewTemplate, () => { + S.Menu.closeAll(J.Menu.dataviewTemplate, () => { S.Menu.open('dataviewTemplateContext', { menuKey: item.id, element: `#${getId()} #item-more-${item.id}`, vertical: I.MenuDirection.Bottom, horizontal: I.MenuDirection.Right, - subIds: J.Constant.menuIds.dataviewTemplate, + subIds: J.Menu.dataviewTemplate, onOpen: () => { node.addClass('active'); }, diff --git a/src/ts/component/menu/dataview/view/layout.tsx b/src/ts/component/menu/dataview/view/layout.tsx index afda8fd98a..067323b1ee 100644 --- a/src/ts/component/menu/dataview/view/layout.tsx +++ b/src/ts/component/menu/dataview/view/layout.tsx @@ -295,7 +295,7 @@ const MenuViewLayout = observer(class MenuViewLayout extends React.Component { + S.Menu.closeAll(J.Menu.viewEdit, () => { S.Menu.open(menuId, menuParam); }); }; @@ -416,7 +416,7 @@ const MenuViewLayout = observer(class MenuViewLayout extends React.Component { position () { const { id, param } = this.props; const { element, recalcRect, type, vertical, horizontal, fixedX, fixedY, isSub, noFlipX, noFlipY, withArrow } = param; - const { border } = J.Constant.size.menu; + const { border } = J.Size.menu; const borderTop = this.getBorderTop(); const borderBottom = this.getBorderBottom(); @@ -975,7 +975,7 @@ const Menu = observer(class Menu extends React.Component { const node = $(this.node); const menu = node.find('.menu'); - const { border } = J.Constant.size.menu; + const { border } = J.Size.menu; menu.find('.item.hover').removeClass('hover'); diff --git a/src/ts/component/menu/object.tsx b/src/ts/component/menu/object.tsx index e26609660b..46f4f18865 100644 --- a/src/ts/component/menu/object.tsx +++ b/src/ts/component/menu/object.tsx @@ -73,7 +73,7 @@ class MenuObject extends React.Component { }; componentWillUnmount () { - S.Menu.closeAll(J.Constant.menuIds.object); + S.Menu.closeAll(J.Menu.object); }; rebind () { @@ -262,7 +262,7 @@ class MenuObject extends React.Component { onOver (e: any, item: any) { if (!item.arrow) { - S.Menu.closeAll(J.Constant.menuIds.object); + S.Menu.closeAll(J.Menu.object); return; }; @@ -310,7 +310,7 @@ class MenuObject extends React.Component { }; if (menuId && !S.Menu.isOpen(menuId, item.id)) { - S.Menu.closeAll(J.Constant.menuIds.object, () => { + S.Menu.closeAll(J.Menu.object, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/menu/quickCapture.tsx b/src/ts/component/menu/quickCapture.tsx index a2e461e6a4..45d2f6bcda 100644 --- a/src/ts/component/menu/quickCapture.tsx +++ b/src/ts/component/menu/quickCapture.tsx @@ -665,7 +665,7 @@ class MenuQuickCapture extends React.Component { item.find('.iconObject').length ? item.addClass('withIcon') : item.removeClass('withIcon'); }); - obj.css({ width: Math.min(ww - J.Constant.size.menu.border * 2 - sw, Math.ceil(obj.outerWidth())) }); + obj.css({ width: Math.min(ww - J.Size.menuBorder * 2 - sw, Math.ceil(obj.outerWidth())) }); }; }; diff --git a/src/ts/component/menu/relation/suggest.tsx b/src/ts/component/menu/relation/suggest.tsx index fb00867d00..b550eaa4ff 100644 --- a/src/ts/component/menu/relation/suggest.tsx +++ b/src/ts/component/menu/relation/suggest.tsx @@ -229,7 +229,7 @@ const MenuRelationSuggest = observer(class MenuRelationSuggest extends React.Com U.Data.search({ filters, sorts, - keys: J.Constant.relationRelationKeys, + keys: J.Relation.relation, fullText: filter, offset: this.offset, limit: J.Constant.limit.menuRecords, diff --git a/src/ts/component/menu/search/object.tsx b/src/ts/component/menu/search/object.tsx index 92408c2a7e..b7566a4c20 100644 --- a/src/ts/component/menu/search/object.tsx +++ b/src/ts/component/menu/search/object.tsx @@ -321,7 +321,7 @@ const MenuSearchObject = observer(class MenuSearchObject extends React.Component U.Data.search({ filters, sorts, - keys: keys || J.Constant.defaultRelationKeys, + keys: keys || J.Relation.default, fullText: filter, offset: this.offset, limit: J.Constant.limit.menuRecords, diff --git a/src/ts/component/menu/search/text.tsx b/src/ts/component/menu/search/text.tsx index ad25a9d9f5..40658ec56c 100644 --- a/src/ts/component/menu/search/text.tsx +++ b/src/ts/component/menu/search/text.tsx @@ -249,7 +249,7 @@ class MenuSearchText extends React.Component { const { data } = param; const { isPopup } = data; const scrollContainer = this.getScrollContainer(); - const offset = J.Constant.size.lastBlock + U.Common.sizeHeader(); + const offset = J.Size.lastBlock + U.Common.sizeHeader(); const tag = Mark.getTag(I.MarkType.Search); this.container.find(`${tag}.active`).removeClass('active'); diff --git a/src/ts/component/menu/widget.tsx b/src/ts/component/menu/widget.tsx index 13b2244d9a..e8a151ed96 100644 --- a/src/ts/component/menu/widget.tsx +++ b/src/ts/component/menu/widget.tsx @@ -70,7 +70,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { className="c28" text={translate('menuWidgetAddWidget')} onClick={this.save} - onMouseEnter={() => S.Menu.closeAll(J.Constant.menuIds.widget)} + onMouseEnter={() => S.Menu.closeAll(J.Menu.widget)} /> ) : ''} @@ -99,7 +99,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { this._isMounted = false; this.unbind(); - S.Menu.closeAll(J.Constant.menuIds.widget); + S.Menu.closeAll(J.Menu.widget); $(window).trigger(`updateWidgetData.${blockId}`); }; @@ -257,7 +257,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { onOver (e: React.MouseEvent, item) { if (!item.arrow) { - S.Menu.closeAll(J.Constant.menuIds.widget); + S.Menu.closeAll(J.Menu.widget); return; }; @@ -374,7 +374,7 @@ const MenuWidget = observer(class MenuWidget extends React.Component { }; if (menuId && !S.Menu.isOpen(menuId, item.itemId)) { - S.Menu.closeAll(J.Constant.menuIds.widget, () => { + S.Menu.closeAll(J.Menu.widget, () => { S.Menu.open(menuId, menuParam); }); }; diff --git a/src/ts/component/page/auth/login.tsx b/src/ts/component/page/auth/login.tsx index 589efb537d..bbf10b5ddb 100644 --- a/src/ts/component/page/auth/login.tsx +++ b/src/ts/component/page/auth/login.tsx @@ -93,7 +93,7 @@ const PageAuthLogin = observer(class PageAuthLogin extends React.Component { element: node, className: 'fromBanner', offsetY: isPopup ? 10 : 0, - subIds: J.Constant.menuIds.dataviewTemplate.concat([ 'dataviewTemplateContext' ]), + subIds: J.Menu.dataviewTemplate.concat([ 'dataviewTemplateContext' ]), vertical: I.MenuDirection.Bottom, horizontal: I.MenuDirection.Center, onOpen: (context) => { diff --git a/src/ts/component/page/elements/head/controlButtons.tsx b/src/ts/component/page/elements/head/controlButtons.tsx index 8c39dcd184..bfdfea3c6d 100644 --- a/src/ts/component/page/elements/head/controlButtons.tsx +++ b/src/ts/component/page/elements/head/controlButtons.tsx @@ -124,7 +124,7 @@ const ControlButtons = observer(class ControlButtons extends React.Component { render (): any { const { rootId, readonly } = this.props; const { loading } = this.state; - const object = S.Detail.get(rootId, rootId, J.Constant.coverRelationKeys); + const object = S.Detail.get(rootId, rootId, J.Relation.cover); const cn = [ 'editorControls', 'editorControlElements' ]; if ((object.coverType != I.CoverType.None) && object.coverId) { @@ -150,7 +150,7 @@ const Controls = observer(class Controls extends React.Component { onClose: () => { node.removeClass('hover'); }, - subIds: J.Constant.menuIds.layout, + subIds: J.Menu.layout, data: { rootId, value: object.layout, diff --git a/src/ts/component/page/main/graph.tsx b/src/ts/component/page/main/graph.tsx index e1ca96435b..3e70a3fa0b 100644 --- a/src/ts/component/page/main/graph.tsx +++ b/src/ts/component/page/main/graph.tsx @@ -105,7 +105,7 @@ const PageMainGraph = observer(class PageMainGraph extends React.Component { + C.ObjectGraph(S.Common.space, U.Data.graphFilters(), 0, [], J.Relation.graph, '', [], (message: any) => { if (message.error.code) { return; }; @@ -140,7 +140,7 @@ const PageMainGraph = observer(class PageMainGraph extends React.Component S.Detail.mapper(it)); - U.Data.onSubscribe(J.Constant.subId.graph, 'id', J.Constant.graphRelationKeys, { + U.Data.onSubscribe(J.Constant.subId.graph, 'id', J.Relation.graph, { error: {}, records: message.nodes, dependencies: [], diff --git a/src/ts/component/page/main/store.tsx b/src/ts/component/page/main/store.tsx index d10e3cdac3..79a32bbad5 100644 --- a/src/ts/component/page/main/store.tsx +++ b/src/ts/component/page/main/store.tsx @@ -319,7 +319,7 @@ const PageMainStore = observer(class PageMainStore extends React.Component { + S.Menu.closeAll(J.Menu.dataviewTemplate, () => { S.Menu.open('dataviewTemplateContext', { menuKey: item.id, element: `#item-more-${item.id}`, diff --git a/src/ts/component/popup/page/settings/space/create.tsx b/src/ts/component/popup/page/settings/space/create.tsx index 8c2da24b77..885ab64cd2 100644 --- a/src/ts/component/popup/page/settings/space/create.tsx +++ b/src/ts/component/popup/page/settings/space/create.tsx @@ -18,7 +18,7 @@ const PopupSettingsSpaceIndex = observer(class PopupSettingsSpaceIndex extends R state = { error: '', isLoading: false, - iconOption: U.Common.rand(1, J.Constant.iconCnt), + iconOption: U.Common.rand(1, J.Constant.count.icon), usecase: I.Usecase.Empty, }; diff --git a/src/ts/component/popup/page/usecase/item.tsx b/src/ts/component/popup/page/usecase/item.tsx index c6003b4438..c86c856db3 100644 --- a/src/ts/component/popup/page/usecase/item.tsx +++ b/src/ts/component/popup/page/usecase/item.tsx @@ -164,7 +164,7 @@ class PopupUsecasePageItem extends React.Component { analytics.event('ClickGalleryInstallSpace', { type: isNew ? 'New' : 'Existing' }); if (isNew) { - C.WorkspaceCreate({ name: object.title, iconOption: U.Common.rand(1, J.Constant.iconCnt) }, I.Usecase.None, (message: any) => { + C.WorkspaceCreate({ name: object.title, iconOption: U.Common.rand(1, J.Constant.count.icon) }, I.Usecase.None, (message: any) => { if (!message.error.code) { cb(message.objectId, true); diff --git a/src/ts/component/popup/relation.tsx b/src/ts/component/popup/relation.tsx index da98fe03ac..09d6b299b7 100644 --- a/src/ts/component/popup/relation.tsx +++ b/src/ts/component/popup/relation.tsx @@ -131,7 +131,7 @@ const PopupRelation = observer(class PopupRelation extends React.Component $(element).addClass('active'), diff --git a/src/ts/component/popup/search.tsx b/src/ts/component/popup/search.tsx index 7e92824b31..405683e469 100644 --- a/src/ts/component/popup/search.tsx +++ b/src/ts/component/popup/search.tsx @@ -541,7 +541,7 @@ const PopupSearch = observer(class PopupSearch extends React.Component { + C.ObjectSearchWithMeta(filters, sorts, J.Relation.default.concat([ 'links', 'backlinks' ]), filter, this.offset, limit, (message) => { if (message.error.code) { this.setState({ isLoading: false }); return; diff --git a/src/ts/component/preview/object.tsx b/src/ts/component/preview/object.tsx index 3ed98336c7..9e37f0f33d 100644 --- a/src/ts/component/preview/object.tsx +++ b/src/ts/component/preview/object.tsx @@ -234,7 +234,7 @@ const PreviewObject = observer(class PreviewObject extends React.Component; + inner = ; break; }; diff --git a/src/ts/component/sidebar/index.tsx b/src/ts/component/sidebar/index.tsx index c6a2d87203..2362e0b03c 100644 --- a/src/ts/component/sidebar/index.tsx +++ b/src/ts/component/sidebar/index.tsx @@ -204,7 +204,7 @@ const Sidebar = observer(class Sidebar extends React.Component { }; if (d < 0) { - if (S.Common.isSidebarFixed && (w <= J.Constant.size.sidebar.width.close)) { + if (S.Common.isSidebarFixed && (w <= J.Size.sidebar.width.close)) { sidebar.close(); } else { sidebar.set({ width: w, isClosed: false }); @@ -212,10 +212,10 @@ const Sidebar = observer(class Sidebar extends React.Component { }; if (d > 0) { - if ((w >= 0) && (w <= J.Constant.size.sidebar.width.close)) { - sidebar.open(J.Constant.size.sidebar.width.min); + if ((w >= 0) && (w <= J.Size.sidebar.width.close)) { + sidebar.open(J.Size.sidebar.width.min); } else - if (w > J.Constant.size.sidebar.width.close) { + if (w > J.Size.sidebar.width.close) { sidebar.set({ width: w, isClosed: false }); }; }; diff --git a/src/ts/component/util/cover.tsx b/src/ts/component/util/cover.tsx index 1fe9fa97fb..dc74a6033b 100644 --- a/src/ts/component/util/cover.tsx +++ b/src/ts/component/util/cover.tsx @@ -36,7 +36,7 @@ class Cover extends React.Component { }; if ([ I.CoverType.Upload, I.CoverType.Source ].includes(type) && image) { - style.backgroundImage = `url("${S.Common.imageUrl(image, J.Constant.size.cover)}")`; + style.backgroundImage = `url("${S.Common.imageUrl(image, J.Size.cover)}")`; }; if (src) { diff --git a/src/ts/component/util/iconEmoji.tsx b/src/ts/component/util/iconEmoji.tsx index c3eac16934..36a1c27acf 100644 --- a/src/ts/component/util/iconEmoji.tsx +++ b/src/ts/component/util/iconEmoji.tsx @@ -57,7 +57,7 @@ const IconEmoji = observer(class IconEmoji extends React.Component { }; } else if (objectId) { - element = e.preventDefault()} />; + element = e.preventDefault()} />; } else if (iconClass) { element = ; diff --git a/src/ts/component/widget/index.tsx b/src/ts/component/widget/index.tsx index 507128a51a..8af6b1d9f8 100644 --- a/src/ts/component/widget/index.tsx +++ b/src/ts/component/widget/index.tsx @@ -474,7 +474,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component { rect: { width: 0, height: 0, x: x + 4, y }, className: 'fixed', classNameWrap: 'fromSidebar', - subIds: J.Constant.menuIds.widget, + subIds: J.Menu.widget, onOpen: () => node.addClass('active'), onClose: () => node.removeClass('active'), data: { @@ -535,7 +535,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component { node.removeClass('isClosed'); wrapper.css({ height: 'auto' }); }; - }, 450); + }, J.Constant.delay.widget); }; close () { @@ -563,7 +563,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component { wrapper.css({ height: '' }); innerWrap.hide(); }; - }, 450); + }, J.Constant.delay.widget); }; getMinHeight () { @@ -628,7 +628,7 @@ const WidgetIndex = observer(class WidgetIndex extends React.Component { filters, sorts, limit, - keys: J.Constant.sidebarRelationKeys, + keys: J.Relation.sidebar, }, () => { if (callBack) { callBack(); diff --git a/src/ts/component/widget/tree/index.tsx b/src/ts/component/widget/tree/index.tsx index c94640cd3b..9aaefd5798 100644 --- a/src/ts/component/widget/tree/index.tsx +++ b/src/ts/component/widget/tree/index.tsx @@ -232,7 +232,7 @@ const WidgetTree = observer(class WidgetTree extends React.Component this.mapper(S.Detail.get(subId, id, J.Constant.sidebarRelationKeys))); + children = records.map(id => this.mapper(S.Detail.get(subId, id, J.Relation.sidebar))); } else { children = this.getChildNodesDetails(object.id); this.subscribeToChildNodes(object.id, Relation.getArrayValue(object.links)); @@ -328,7 +328,7 @@ const WidgetTree = observer(class WidgetTree extends React.Component { const subKey = getSubKey(); const subId = getSubId(parentId); const isOpen = Storage.checkToggle(subKey, treeKey); - const object = S.Detail.get(subId, id, J.Constant.sidebarRelationKeys); + const object = S.Detail.get(subId, id, J.Relation.sidebar); const { isReadonly, isArchived, type, restrictions, done, layout } = object; const cn = [ 'item', 'c' + id, (isOpen ? 'isOpen' : '') ]; const rootId = keyboard.getRootId(); @@ -156,7 +156,7 @@ const TreeItem = observer(class Node extends React.Component { e.stopPropagation(); const { id, parentId, onToggle, getSubId } = this.props; - const object = S.Detail.get(getSubId(parentId), id, J.Constant.sidebarRelationKeys, true); + const object = S.Detail.get(getSubId(parentId), id, J.Relation.sidebar, true); onToggle(e, { ...this.props, details: object }); this.forceUpdate(); diff --git a/src/ts/component/widget/view/board/group.tsx b/src/ts/component/widget/view/board/group.tsx index 3fd8317443..6b3cc5d0f0 100644 --- a/src/ts/component/widget/view/board/group.tsx +++ b/src/ts/component/widget/view/board/group.tsx @@ -121,7 +121,7 @@ const Group = observer(class Group extends React.Component { subId, filters: filters.map(it => Dataview.filterMapper(view, it)), sorts: sorts.map(it => Dataview.filterMapper(view, it)), - keys: J.Constant.sidebarRelationKeys, + keys: J.Relation.sidebar, sources: object.setOf || [], limit, ignoreHidden: true, diff --git a/src/ts/component/widget/view/board/item.tsx b/src/ts/component/widget/view/board/item.tsx index b94c081968..b6ef5e701f 100644 --- a/src/ts/component/widget/view/board/item.tsx +++ b/src/ts/component/widget/view/board/item.tsx @@ -26,7 +26,7 @@ const WidgetBoardItem = observer(class WidgetBoardItem extends React.Component

S.Detail.get(subId, id, J.Constant.sidebarRelationKeys))); + const items = [].concat(getRecordIds().map(id => S.Detail.get(subId, id, J.Relation.sidebar))); items.push({ id: 'blank', name: translate('widgetShowAll') }); diff --git a/src/ts/component/widget/view/gallery/item.tsx b/src/ts/component/widget/view/gallery/item.tsx index 5bc1cbf5f0..c2f57790b4 100644 --- a/src/ts/component/widget/view/gallery/item.tsx +++ b/src/ts/component/widget/view/gallery/item.tsx @@ -27,7 +27,7 @@ const WidgetBoardItem = observer(class WidgetBoardItem extends React.Component

S.Detail.get(subId, id, J.Constant.sidebarRelationKeys)); + let items = getRecordIds().map(id => S.Detail.get(subId, id, J.Relation.sidebar)); if (isPreview && isRecent) { // add group labels diff --git a/src/ts/component/widget/view/list/item.tsx b/src/ts/component/widget/view/list/item.tsx index 403c7e5d4e..3fc7411e12 100644 --- a/src/ts/component/widget/view/list/item.tsx +++ b/src/ts/component/widget/view/list/item.tsx @@ -32,7 +32,7 @@ const WidgetListItem = observer(class WidgetListItem extends React.Component { - C.AccountRecoverFromLegacyExport(paths[0], dataPath, U.Common.rand(1, J.Constant.iconCnt), (message: any) => { + C.AccountRecoverFromLegacyExport(paths[0], dataPath, U.Common.rand(1, J.Constant.count.icon), (message: any) => { if (onError(message.error)) { return; }; diff --git a/src/ts/lib/dataview.ts b/src/ts/lib/dataview.ts index 07768fc5d3..0d54a91c2d 100644 --- a/src/ts/lib/dataview.ts +++ b/src/ts/lib/dataview.ts @@ -68,7 +68,7 @@ class Dataview { const rel: any = view.getRelation(relationKey) || {}; rel.relationKey = relationKey; - rel.width = rel.width || J.Constant.size.dataview.cell.default; + rel.width = rel.width || J.Size.dataview.cell.default; rel.isVisible = true; C.BlockDataviewViewRelationReplace(rootId, blockId, view.id, relationKey, rel, (message: any) => { @@ -98,7 +98,7 @@ class Dataview { rootId: '', blockId: '', newViewId: '', - keys: J.Constant.defaultRelationKeys, + keys: J.Relation.default, offset: 0, limit: 0, ignoreWorkspace: false, @@ -517,7 +517,7 @@ class Dataview { ]; let ret = null; - if (relationKey == J.Constant.pageCoverRelationKey) { + if (relationKey == J.Relation.pageCover) { ret = object; } else { for (const id of value) { diff --git a/src/ts/lib/focus.ts b/src/ts/lib/focus.ts index ac8cab331c..86b06f08cf 100644 --- a/src/ts/lib/focus.ts +++ b/src/ts/lib/focus.ts @@ -104,7 +104,7 @@ class Focus { const ch = container.height(); const no = node.offset().top; const hh = U.Common.sizeHeader(); - const o = J.Constant.size.lastBlock + hh; + const o = J.Size.lastBlock + hh; const st = container.scrollTop(); const y = isPopup ? (no - container.offset().top + st) : no; diff --git a/src/ts/lib/keyboard.ts b/src/ts/lib/keyboard.ts index a8468c64a9..cbcde4e925 100644 --- a/src/ts/lib/keyboard.ts +++ b/src/ts/lib/keyboard.ts @@ -840,7 +840,7 @@ class Keyboard { S.Menu.open(id, menuParam); } else { S.Popup.close('search', () => { - S.Menu.closeAll(J.Constant.menuIds.navigation, () => { + S.Menu.closeAll(J.Menu.navigation, () => { S.Menu.open(id, menuParam); }); }); diff --git a/src/ts/lib/relation.ts b/src/ts/lib/relation.ts index b449299cee..0fbc900517 100644 --- a/src/ts/lib/relation.ts +++ b/src/ts/lib/relation.ts @@ -28,7 +28,7 @@ class Relation { }; public width (width: number, format: I.RelationType): number { - const size = J.Constant.size.dataview.cell; + const size = J.Size.dataview.cell; return Number(width || size[`format${format}`]) || size.default; }; @@ -342,7 +342,7 @@ class Relation { return [ { id: '', icon: '', name: translate('commonNone') }, - { id: J.Constant.pageCoverRelationKey, icon: 'image', name: translate('libRelationPageCover') }, + { id: J.Relation.pageCover, icon: 'image', name: translate('libRelationPageCover') }, ].concat(options); }; diff --git a/src/ts/lib/sidebar.ts b/src/ts/lib/sidebar.ts index 15acbf3bde..848be79055 100644 --- a/src/ts/lib/sidebar.ts +++ b/src/ts/lib/sidebar.ts @@ -53,7 +53,7 @@ class Sidebar { const y = wh / 2 - this.getMaxHeight() / 2; this.set({ - width: J.Constant.size.sidebar.width.default, + width: J.Size.sidebar.width.default, y, x: 0, snap: I.MenuDirection.Left, @@ -519,7 +519,7 @@ class Sidebar { * Limit the sidebar width to the max and min bounds */ private limitWidth (width: number): number { - const { min, max } = J.Constant.size.sidebar.width; + const { min, max } = J.Size.sidebar.width; return Math.max(min, Math.min(max, Number(width) || 0)); }; diff --git a/src/ts/lib/util/data.ts b/src/ts/lib/util/data.ts index b13b6ff44e..1af28d8299 100644 --- a/src/ts/lib/util/data.ts +++ b/src/ts/lib/util/data.ts @@ -308,7 +308,7 @@ class UtilData { }, { subId: J.Constant.subId.relation, - keys: J.Constant.relationRelationKeys, + keys: J.Relation.relation, filters: [ { operator: I.FilterOperator.And, relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ J.Constant.storeSpaceId, space ] }, { operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: I.ObjectLayout.Relation }, @@ -323,7 +323,7 @@ class UtilData { }, { subId: J.Constant.subId.option, - keys: J.Constant.optionRelationKeys, + keys: J.Relation.option, filters: [ { operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.Equal, value: I.ObjectLayout.Option }, ], @@ -398,19 +398,19 @@ class UtilData { }; spaceRelationKeys () { - return J.Constant.defaultRelationKeys.concat(J.Constant.spaceRelationKeys).concat(J.Constant.participantRelationKeys); + return J.Relation.default.concat(J.Relation.space).concat(J.Relation.participant); }; typeRelationKeys () { - return J.Constant.defaultRelationKeys.concat(J.Constant.typeRelationKeys); + return J.Relation.default.concat(J.Relation.type); }; participantRelationKeys () { - return J.Constant.defaultRelationKeys.concat(J.Constant.participantRelationKeys); + return J.Relation.default.concat(J.Relation.participant); }; syncStatusRelationKeys () { - return J.Constant.defaultRelationKeys.concat(J.Constant.syncStatusRelationKeys); + return J.Relation.default.concat(J.Relation.syncStatus); }; createSession (phrase: string, key: string, callBack?: (message: any) => void) { @@ -499,7 +499,7 @@ class UtilData { const sorts = [ { relationKey: 'name', type: I.SortType.Asc }, ]; - const keys = J.Constant.defaultRelationKeys.concat([ 'targetObjectType' ]); + const keys = J.Relation.default.concat([ 'targetObjectType' ]); this.search({ filters, @@ -512,7 +512,7 @@ class UtilData { checkDetails (rootId: string, blockId?: string) { blockId = blockId || rootId; - const object = S.Detail.get(rootId, blockId, [ 'layout', 'layoutAlign', 'iconImage', 'iconEmoji', 'templateIsBundled' ].concat(J.Constant.coverRelationKeys), true); + const object = S.Detail.get(rootId, blockId, [ 'layout', 'layoutAlign', 'iconImage', 'iconEmoji', 'templateIsBundled' ].concat(J.Relation.cover), true); const checkType = S.Block.checkBlockTypeExists(rootId); const { iconEmoji, iconImage, coverType, coverId } = object; const ret = { @@ -707,7 +707,7 @@ class UtilData { idField: 'id', filters: [], sorts: [], - keys: J.Constant.defaultRelationKeys, + keys: J.Relation.default, sources: [], offset: 0, limit: 0, @@ -764,7 +764,7 @@ class UtilData { param = Object.assign({ subId: '', ids: [], - keys: J.Constant.defaultRelationKeys, + keys: J.Relation.default, noDeps: false, idField: 'id', }, param); @@ -810,7 +810,7 @@ class UtilData { fullText: '', filters: [], sorts: [], - keys: J.Constant.defaultRelationKeys, + keys: J.Relation.default, offset: 0, limit: 0, ignoreWorkspace: false, @@ -890,7 +890,7 @@ class UtilData { { operator: I.FilterOperator.And, relationKey: 'isArchived', condition: I.FilterCondition.NotEqual, value: true }, { operator: I.FilterOperator.And, relationKey: 'isDeleted', condition: I.FilterCondition.NotEqual, value: true }, { operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.NotIn, value: U.Object.getFileAndSystemLayouts() }, - { operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.NotIn, value: [ '_anytype_profile' ] }, + { operator: I.FilterOperator.And, relationKey: 'id', condition: I.FilterCondition.NotEqual, value: J.Constant.anytypeProfileId }, { operator: I.FilterOperator.And, relationKey: 'spaceId', condition: I.FilterCondition.In, value: [ space ] }, ]; @@ -995,7 +995,7 @@ class UtilData { return; }; - C.AccountCreate('', '', dataPath, U.Common.rand(1, J.Constant.iconCnt), mode, path, (message) => { + C.AccountCreate('', '', dataPath, U.Common.rand(1, J.Constant.count.icon), mode, path, (message) => { if (message.error.code) { onError(message.error.description); return; diff --git a/src/ts/lib/util/embed.ts b/src/ts/lib/util/embed.ts index 740bb586bd..b4834b6bc5 100644 --- a/src/ts/lib/util/embed.ts +++ b/src/ts/lib/util/embed.ts @@ -113,7 +113,7 @@ class UtilEmbed { const place = url.match(/place\/([^\/]+)/); const param = url.match(/\/@([^\/\?]+)/); const search: any = { - key: J.Constant.embed.googleMaps.key, + key: J.Constant.googleMaps, }; let endpoint = ''; diff --git a/src/ts/lib/util/menu.ts b/src/ts/lib/util/menu.ts index 8055c6df2a..86f1925473 100644 --- a/src/ts/lib/util/menu.ts +++ b/src/ts/lib/util/menu.ts @@ -589,7 +589,7 @@ class UtilMenu { const ret: any[] = []; const Locale = require('lib/json/locale.json'); - for (const id of J.Constant.enabledInterfaceLang) { + for (const id of J.Lang.enabled) { ret.push({ id, name: Locale[id] }); }; @@ -600,7 +600,7 @@ class UtilMenu { let ret: any[] = []; ret = ret.concat(S.Common.languages || []); - ret = ret.map(id => ({ id, name: J.Constant.spellingLang[id] })); + ret = ret.map(id => ({ id, name: J.Lang.spelling[id] })); ret.unshift({ id: '', name: translate('commonDisabled') }); return ret; diff --git a/src/ts/store/detail.ts b/src/ts/store/detail.ts index aedc3229da..0405f1479c 100644 --- a/src/ts/store/detail.ts +++ b/src/ts/store/detail.ts @@ -146,14 +146,14 @@ class DetailStore { }; }; - /** gets the object. if no keys are provided, all properties are returned. if force keys is set, J.Constant.defaultRelationKeys are included */ + /** gets the object. if no keys are provided, all properties are returned. if force keys is set, J.Relation.default are included */ public get (rootId: string, id: string, withKeys?: string[], forceKeys?: boolean): any { let list = this.map.get(rootId)?.get(id) || []; if (!list.length) { return { id, _empty_: true }; }; - const keys = new Set(withKeys ? [ ...withKeys, ...(!forceKeys ? J.Constant.defaultRelationKeys : []) ] : []); + const keys = new Set(withKeys ? [ ...withKeys, ...(!forceKeys ? J.Relation.default : []) ] : []); const object = { id }; if (withKeys) { diff --git a/src/ts/store/record.ts b/src/ts/store/record.ts index 2f7562e2e9..e171b77f9c 100644 --- a/src/ts/store/record.ts +++ b/src/ts/store/record.ts @@ -257,7 +257,7 @@ class RecordStore { }; getTypeById (id: string) { - const object = S.Detail.get(J.Constant.subId.type, id, J.Constant.typeRelationKeys); + const object = S.Detail.get(J.Constant.subId.type, id, J.Relation.type); return object._empty_ ? null : object; }; @@ -318,12 +318,12 @@ class RecordStore { return null; }; - const object = S.Detail.get(J.Constant.subId.relation, id, J.Constant.relationRelationKeys, true); + const object = S.Detail.get(J.Constant.subId.relation, id, J.Relation.relation, true); return object._empty_ ? null : object; }; getOption (id: string) { - const object = S.Detail.get(J.Constant.subId.option, id, J.Constant.optionRelationKeys, true); + const object = S.Detail.get(J.Constant.subId.option, id, J.Relation.option, true); return object._empty_ ? null : object; };