{"version":3,"sources":["webpack:///../WCC.UI/App/components/editors/threadTranslation/threadTranslation.html?4811","webpack:///../WCC.UI/App/components/editors/threadTranslation/threadTranslation.scss?d8fc","webpack:///../WCC.UI/App/components/editors/threadTranslation/threadTranslation.ts","webpack:///../WCC.UI/App/components/editors/threadTranslation/validator.ts","webpack:///../WCC.UI/App/libraries/quill.js","webpack:///../WCC.UI/App/webpack/runtime/htmlExposer.js","webpack:///../WCC.UI/App/components/editors/threadTranslation/threadTranslation.scss","webpack:///../WCC.UI/App/components/editors/threadTranslation/threadTranslation.html"],"names":["content","expose","__esModule","default","api","module","i","options","exports","locals","Keyboard","Quill","import","components","preload","ThreadTranslationEditorVM","constructor","config","info","ctx","effects","_config$save","_config$cancel","validator","ThreadTranslationEditorVMValidator","this","labels","contentEditor","ko","observable","isSaving","areErrorsShown","save","async","validate","thread","undefined","Error","messages","InvalidRequest","jsonThread","toJson","TranslatedThreadContent","commentsService","saveTranslation","saveHandler","ex","system","handleError","cancel","_this$thread$translat","_this$thread","translatedContent","confirm","AreYouSureYouWantToCancelAllYourChanges","cancelHandler","flattenComputed","_","noop","contentEditorConfig","background","noBorder","formats","bindings","key","keys","TAB","handler","pluck","editor","extend","validateContent","isReady","pureComputed","register","withEffect","_thread$translatedCon","setContent","applyBindingsToNode","element","error","__decorate","injectable","__param","inject","wccModules","componentConfig","componentInfo","servicesContext","find","err","trim","length","MessageCantBeEmpty","SystemHelpers","html","getTemplatesAndResources","forEach","node","document","head","appendChild","___CSS_LOADER_API_IMPORT___","push"],"mappings":"+JAAA,UAAO,CACC,+HACA,wDAIC,KAJ4C,EAAF,SAAYA,EAASC,GAG5D,OADAA,EADAD,EAAUA,EAAQE,WAAaF,EAAQG,QAAUH,GAE1CA,GACV,4B,4FCNT,IAAII,EAAM,EAAQ,gFACFJ,EAAU,EAAQ,0KAIC,iBAFvBA,EAAUA,EAAQE,WAAaF,EAAQG,QAAUH,KAG/CA,EAAU,CAAC,CAACK,EAAOC,EAAIN,EAA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wQ,+DCAA,WAOC,KAPD,aACI,MAAM9C,EAAS,EAAQ,mCAAkB+C,cAEzC,OAAO,SAAUC,GACbhD,EAAOiD,yBAAyBD,GAC3BE,SAAQ,SAAUC,GAAQC,SAASC,KAAKC,YAAYH,QAEhE,+B,0LCLD1F,EADkC,EAAQ,wDAChC8F,EAA4B,IAE9BC,KAAK,CAAClG,EAAOC,EAAI,+dAAge,KAEzfD,EAAOG,QAAUA,G,0ICHjBH,EAAOG,QAFI","file":"216.fa2d7a6b2368163f7193.js","sourcesContent":["define([\n \"!!../../../../node_modules/html-loader/dist/cjs.js??ref--26-1!./threadTranslation.html\", \n \"!../../../webpack/runtime/htmlExposer.js\"], function (content, expose) {\n content = content.__esModule ? content.default : content;\n expose(content);\n return content;\n });","var api = require(\"!../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\");\n var content = require(\"!!../../../../node_modules/css-loader/dist/cjs.js!../../../../node_modules/sass-loader/dist/cjs.js!./threadTranslation.scss\");\n\n content = content.__esModule ? content.default : content;\n\n if (typeof content === 'string') {\n content = [[module.id, content, '']];\n }\n\nvar options = {};\n\noptions.insert = \"head\";\noptions.singleton = false;\n\nvar update = api(content, options);\n\n\n\nmodule.exports = content.locals || {};","import { wccModules } from 'enums/wccModules';\r\nimport { inject, injectable } from 'inversify';\r\nimport { Subscribable, SubscribableOrNullableValue } from 'knockout';\r\nimport { Quill } from 'libraries/quill';\r\nimport { withEffect } from 'mixins/withEffect';\r\nimport { EffectsContainer } from 'mixins/withEffects';\r\nimport { TopicThread } from 'models/topicThread';\r\nimport { ServicesContext } from 'services/context';\r\nimport { ChatEditorVMConfig, IChatEditorVM } from '../chat/chat.interfaces';\r\nimport './threadTranslation.html';\r\nimport './threadTranslation.scss';\r\nimport ThreadTranslationEditorVMValidator from './validator';\r\n\r\nconst Keyboard = Quill.import('modules/keyboard');\r\n\r\ncomponents.preload('chat-editor');\r\n\r\nexport interface ThreadTranslationEditorVMConfig {\r\n thread: SubscribableOrNullableValue\r\n\r\n save?: () => void\r\n cancel?: () => void\r\n}\r\n\r\n@injectable()\r\nexport default class ThreadTranslationEditorVM {\r\n private thread: Subscribable\r\n private validator = new ThreadTranslationEditorVMValidator(this)\r\n\r\n private saveHandler: () => void\r\n private cancelHandler: () => void\r\n\r\n labels = labels\r\n\r\n contentEditorConfig: ChatEditorVMConfig\r\n contentEditor = ko.observable();\r\n\r\n content: Subscribable\r\n\r\n isSaving = ko.observable(false)\r\n areErrorsShown = ko.observable(false)\r\n\r\n constructor(\r\n @inject(wccModules.componentConfig) config: ThreadTranslationEditorVMConfig,\r\n @inject(wccModules.componentInfo) info: ko.components.ComponentInfo,\r\n @inject(wccModules.servicesContext) private ctx: ServicesContext,\r\n @inject(wccModules.effects) effects: EffectsContainer\r\n ) {\r\n const thread = ko.flattenComputed(config.thread);\r\n\r\n this.thread = thread;\r\n\r\n this.saveHandler = config.save ?? _.noop;\r\n this.cancelHandler = config.cancel ?? _.noop;\r\n\r\n this.contentEditorConfig = {\r\n background: false,\r\n noBorder: true,\r\n\r\n formats: ['wcc-emoji'],\r\n\r\n bindings: {\r\n //'handleShiftEnter': { key: Keyboard.keys.ENTER, shiftKey: true, handler: () => this.save() },\r\n 'tab': { key: Keyboard.keys.TAB, handler: () => true }\r\n }\r\n }\r\n\r\n this.content = this.contentEditor.pluck(editor => editor.content, '').extend({ validate: () => this.validator.validateContent() });\r\n\r\n const isReady = ko.pureComputed(() => this.contentEditor() != undefined && thread() != undefined);\r\n\r\n effects.register(editor => {\r\n if (editor != undefined) {\r\n return withEffect(isReady => {\r\n if (isReady) {\r\n return withEffect(thread => {\r\n editor?.setContent(thread?.translatedContent() ?? '');\r\n }, [thread])\r\n }\r\n }, [editor.isReady]);\r\n }\r\n }, [this.contentEditor]);\r\n\r\n ko.applyBindingsToNode(info.element, {\r\n 'visible': isReady,\r\n\r\n 'css': {\r\n 'thread-translation-editor': true\r\n }\r\n });\r\n }\r\n\r\n save = async () => {\r\n this.areErrorsShown(false);\r\n this.areErrorsShown(true);\r\n\r\n if (!this.validate() || this.isSaving()) return;\r\n\r\n try {\r\n this.isSaving(true);\r\n\r\n const thread = this.thread();\r\n\r\n if (thread == undefined)\r\n throw new Error(messages.InvalidRequest);\r\n\r\n const jsonThread = thread.toJson();\r\n jsonThread.TranslatedThreadContent = this.content();\r\n\r\n await this.ctx.commentsService.saveTranslation(jsonThread);\r\n this.saveHandler();\r\n } catch (ex) {\r\n system.handleError(ex);\r\n } finally {\r\n this.isSaving(false);\r\n }\r\n }\r\n\r\n cancel = () => {\r\n const originalTranslation = this.thread()?.translatedContent() ?? '';\r\n\r\n if (originalTranslation !== this.content())\r\n system.confirm(messages.AreYouSureYouWantToCancelAllYourChanges, this.cancelHandler);\r\n else\r\n this.cancelHandler();\r\n }\r\n\r\n private validate() {\r\n const error = this.validator.validate();\r\n\r\n if (error != undefined)\r\n system.handleError(error);\r\n\r\n return error == undefined;\r\n }\r\n}","import ThreadTranslationEditorVM from './threadTranslation';\r\n\r\nexport default class ThreadTranslationEditorVMValidator {\r\n constructor(private editor: ThreadTranslationEditorVM) { }\r\n\r\n validate() {\r\n return [\r\n this.validateContent()\r\n ].find(err => err != undefined);\r\n }\r\n\r\n validateContent() {\r\n if (this.editor.content().trim().length === 0)\r\n return messages.MessageCantBeEmpty;\r\n }\r\n}","import Quill, { DeltaStatic, KeyboardStatic, RangeStatic, StringMap, SelectionChangeHandler, TextChangeHandler } from 'quill';\r\n\r\nimport 'quill/dist/quill.core.css';\r\nimport 'quill/dist/quill.snow.css';\r\nimport 'quill/dist/quill.bubble.css';\r\n\r\nexport {\r\n Quill,\r\n DeltaStatic,\r\n KeyboardStatic,\r\n RangeStatic,\r\n StringMap,\r\n SelectionChangeHandler,\r\n TextChangeHandler\r\n}","define(function () {\r\n const system = require('helpers/system').SystemHelpers;\r\n\r\n return function (html) {\r\n system.getTemplatesAndResources(html)\r\n .forEach(function (node) { document.head.appendChild(node) });\r\n }\r\n});","// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require(\"../../../../node_modules/css-loader/dist/runtime/api.js\");\nexports = ___CSS_LOADER_API_IMPORT___(false);\n// Module\nexports.push([module.id, \".thread-translation-editor{position:relative;display:block}.thread-translation-editor .nonEditableCover{border-radius:4px}.thread-translation-editor__body{background-color:#fff;border:1px solid #c6c6c6;border-top-left-radius:4px;border-top-right-radius:4px}.thread-translation-editor__footer{display:flex;justify-content:flex-end;align-items:center;background-color:#f8f8f7;border:1px solid #c6c6c6;border-top:none;border-bottom-left-radius:4px;border-bottom-right-radius:4px}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","// Module\nvar code = \"\";\n// Exports\nmodule.exports = code;"],"sourceRoot":""}