{"version":3,"sources":["webpack:///../WCC.UI/App/components/topic/contentImage/contentImage.html?e5fb","webpack:///../WCC.UI/App/components/topic/contentImage/contentImage.scss?1906","webpack:///../WCC.UI/App/components/topic/contentImage/contentImage.ts","webpack:///../WCC.UI/App/managers/ideation.ts","webpack:///../WCC.UI/App/managers/topic/votes.ts","webpack:///../WCC.UI/App/models/threadVote.ts","webpack:///../WCC.UI/App/webpack/runtime/htmlExposer.js","webpack:///../WCC.UI/App/components/topic/contentImage/contentImage.scss","webpack:///../WCC.UI/App/components/topic/contentImage/contentImage.html"],"names":["content","expose","__esModule","default","api","module","i","options","exports","locals","TopicContentImageVM","constructor","config","info","storage","topicId","ko","flattenComputed","this","ideationManager","get","IdeationManager","attachments","TopicAttachmentsManager","pluck","m","topicContentImage","pureComputed","getImage","imageURL","img","hqUrl","isReady","undefined","applyBindingsToNode","element","isIdeation","isRatingStage","find","attachment","fileType","enums","AttachmentTypes","IdeaRatingImage","value","ActivityInstructionsImage","__decorate","injectable","__param","inject","wccModules","componentConfig","componentInfo","_ref","user","CurrentUserManager","discussionId","settings","person","isRegularUser","u","isRegular","topic","TopicManager","t","stage","ideationStage","upvotesCount","ideationUpvotes","downvotesCount","ideationDownvotes","votesManager","TopicVotesManager","loadingVotes","loading","votes","personUpvotes","filter","v","personDownvotes","usedUpvotes","reduce","r","availableUpvotes","usedDownvotes","availableDownvotes","hasUpvotes","is","count","hasDownvotes","IdeationStages","IdeaRating","isDoneVoting","isVotingStage","managerConfig","topicsService","effects","source","register","CollectionDataSource","load","bind","mapper","jsonVote","ThreadVote","list","busy","requestsProcessed","updating","withEffect","events","replyAdded","on","onLocalReplyAdded","replyUpdated","onLocalReplyUpdated","replyDeleted","onLocalReplyDeleted","update","queries","toArray","WCCEntity","json","super","personId","createField","threadId","linkedThreadId","system","SystemHelpers","html","getTemplatesAndResources","forEach","node","document","head","appendChild","___CSS_LOADER_API_IMPORT___","push"],"mappings":"mJAAA,UAAO,CACC,mHACA,wDAIC,KAJ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oBd,KAAKnF,OACrD4F,UAAOM,aAAaJ,GAAG9F,KAAKmG,oBAAoBhB,KAAKnF,UAG9D,CAAC2E,IAGRyB,SACIpG,KAAK+E,OAAOG,OAGRA,OACJ,OAAOlF,KAAK6E,cAAcwB,QAAQ5C,MAAMzD,KAAKH,SAASyG,UAGlDP,kBAAkBlG,GAClBG,KAAKH,SAAWA,GAChBG,KAAKoG,SAGLH,oBAAoBpG,GACpBG,KAAKH,SAAWA,GAChBG,KAAKoG,SAGLD,oBAAoBtG,GACpBG,KAAKH,SAAWA,GAChBG,KAAKoG,WA9DI9C,EAAiB1B,EAAA,CADrCC,cAWQC,EAAA,EAAAC,YAAOC,IAAW4C,gBAClB9C,EAAA,EAAAC,YAAOC,IAAWpC,UAClBkC,EAAA,EAAAC,YAAOC,IAAW6C,gBAClB/C,EAAA,EAAAC,YAAOC,IAAW8C,WAbNxB,W,yIChBrB,4EASc,MAAOgC,UAAmBiB,IAMpC9G,YAAY+G,GACRC,QAEAzG,KAAK0G,SAAW1G,KAAK2G,YAAYH,EAAM,YACvCxG,KAAK4G,SAAW5G,KAAK2G,YAAYH,EAAM,YACvCxG,KAAK0B,MAAQ1B,KAAK2G,YAAYH,EAAM,YAAa,GACjDxG,KAAK6G,eAAiB7G,KAAK2G,YAAYH,EAAM,qB,+DCtBrD,WAOC,KAPD,aACI,MAAMM,EAAS,EAAQ,mCAAkBC,cAEzC,OAAO,SAAUC,GACbF,EAAOG,yBAAyBD,GAC3BE,SAAQ,SAAUC,GAAQC,SAASC,KAAKC,YAAYH,QAEhE,+B,8KCLD7H,EADkC,EAAQ,wDAChCiI,EAA4B,IAE9BC,KAAK,CAACrI,EAAOC,EAAI,+GAAgH,KAEzID,EAAOG,QAAUA,G,8HCHjBH,EAAOG,QAFI","file":"201.000edc79a73e76531f27.js","sourcesContent":["define([\n \"!!../../../../node_modules/html-loader/dist/cjs.js??ref--26-1!./contentImage.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!./contentImage.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, SubscribableOrValue } from 'knockout';\r\nimport IdeationManager from 'managers/ideation';\r\nimport { IWCCStorageManager } from 'managers/iStorage';\r\nimport TopicAttachmentsManager from 'managers/topic/attachments';\r\nimport WCCAttachment from 'models/attachments/attachment';\r\nimport WCCImage from 'models/attachments/image';\r\nimport './contentImage.html';\r\nimport './contentImage.scss';\r\n\r\ninterface TopicContentImageConfig {\r\n topicId?: SubscribableOrValue\r\n}\r\n\r\n@injectable()\r\nexport default class TopicContentImageVM {\r\n private ideationManager: Subscribable\r\n\r\n imageURL: Subscribable\r\n\r\n constructor(\r\n @inject(wccModules.componentConfig) config: TopicContentImageConfig,\r\n @inject(wccModules.componentInfo) info: ko.components.ComponentInfo,\r\n @inject(wccModules.storage) storage: IWCCStorageManager\r\n ) {\r\n const topicId = ko.flattenComputed(config.topicId);\r\n\r\n this.ideationManager = storage.get(IdeationManager, { topicId });\r\n\r\n const attachmentsManager = storage.get(TopicAttachmentsManager, { topicId });\r\n const attachments = attachmentsManager.pluck(m => m.attachments, []);\r\n const topicContentImage = ko.pureComputed(() => this.getImage(attachments()));\r\n this.imageURL = topicContentImage.pluck(img => img.hqUrl);\r\n\r\n var isReady = ko.pureComputed(() => this.imageURL() != undefined);\r\n\r\n ko.applyBindingsToNode(info.element, {\r\n 'visible': isReady,\r\n\r\n 'css': {\r\n 'topic-content-image': true\r\n }\r\n }, this);\r\n }\r\n\r\n getImage(attachments: Array) {\r\n const ideationManager = this.ideationManager();\r\n\r\n if (ideationManager != undefined) {\r\n if (ideationManager.isIdeation() && ideationManager.isRatingStage())\r\n return attachments.find(attachment => attachment.fileType() === enums.AttachmentTypes.IdeaRatingImage.value);\r\n else\r\n return attachments.find(attachment => attachment.fileType() === enums.AttachmentTypes.ActivityInstructionsImage.value);\r\n }\r\n }\r\n}","import { wccModules } from 'enums/wccModules';\r\nimport { inject, injectable } from 'inversify';\r\nimport { PureComputed, Subscribable } from 'knockout';\r\nimport { CurrentUserManager } from 'managers/currentUser';\r\nimport { IWCCStorageManager } from 'managers/iStorage';\r\nimport { TopicManager } from 'managers/topic';\r\nimport TopicVotesManager from './topic/votes';\r\n\r\nexport interface TopicVotesManagerConfig {\r\n topicId: string\r\n}\r\n\r\n@injectable()\r\nexport default class IdeationManager {\r\n stage: Subscribable\r\n\r\n availableUpvotes: Subscribable\r\n availableDownvotes: Subscribable\r\n\r\n hasUpvotes: Subscribable\r\n hasDownvotes: Subscribable\r\n\r\n isIdeation: Subscribable\r\n isRatingStage: Subscribable\r\n isVotingStage: Subscribable\r\n isDoneVoting: Subscribable\r\n\r\n isReady: Subscribable\r\n\r\n constructor(\r\n @inject(wccModules.managerConfig) { topicId }: TopicVotesManagerConfig,\r\n @inject(wccModules.storage) storage: IWCCStorageManager\r\n ) {\r\n const userManager = storage.get(CurrentUserManager, { discussionId: settings.discussionId });\r\n const user = userManager.pluck(m => m.person);\r\n const isRegularUser = user.pluck(u => u.isRegular, false);\r\n\r\n const topicManager = storage.get(TopicManager, { topicId });\r\n const topic = topicManager.pluck(m => m.topic);\r\n this.isIdeation = topic.pluck(t => t.isIdeation, false);\r\n this.stage = topic.pluck(t => t.ideationStage, 0);\r\n const upvotesCount = topic.pluck(t => t.ideationUpvotes, 0);\r\n const downvotesCount = topic.pluck(t => t.ideationDownvotes, 0);\r\n\r\n const votesManager = storage.get(TopicVotesManager, { topicId: topicId });\r\n const loadingVotes = votesManager.pluck(m => m.loading, true);\r\n const votes = votesManager.pluck(m => m.votes, []);\r\n\r\n const personUpvotes = votes.filter(v => v.value() > 0);\r\n const personDownvotes = votes.filter(v => v.value() < 0);\r\n\r\n const usedUpvotes = personUpvotes.reduce((r, v) => r + v.value(), () => 0);\r\n this.availableUpvotes = ko.pureComputed(() => isRegularUser() ? upvotesCount() - usedUpvotes() : 0);\r\n\r\n const usedDownvotes = personDownvotes.reduce((r, v) => r - v.value(), () => 0);\r\n this.availableDownvotes = ko.pureComputed(() => isRegularUser() ? downvotesCount() - usedDownvotes() : 0);\r\n\r\n this.hasUpvotes = this.availableUpvotes.is(count => count > 0);\r\n this.hasDownvotes = this.availableDownvotes.is(count => count > 0);\r\n\r\n this.isRatingStage = ko.pureComputed(() => this.stage() === enums.IdeationStages.IdeaRating.value);\r\n this.isDoneVoting = this.availableUpvotes.is(0);\r\n\r\n this.isVotingStage = ko.pureComputed(() => this.isIdeation() && isRegularUser() && this.isRatingStage() && !this.isDoneVoting());\r\n\r\n this.isReady = ko.pureComputed(() => !this.isIdeation() || user() != undefined && topic() != undefined && !loadingVotes());\r\n } \r\n}","import { wccModules } from 'enums/wccModules';\r\nimport { inject, injectable } from 'inversify';\r\nimport { PureComputed, Subscribable } from 'knockout';\r\nimport { CollectionDataSource } from 'managers/datasources/collection';\r\nimport events from 'managers/events';\r\nimport IdeationManager from 'managers/ideation';\r\nimport { IWCCStorageManager } from 'managers/iStorage';\r\nimport { withEffect } from 'mixins/withEffect';\r\nimport { EffectsContainer } from 'mixins/withEffects';\r\nimport ThreadVote, { JSONThreadVote } from 'models/threadVote';\r\nimport { TopicsService } from 'services/topics';\r\n\r\nexport interface TopicVotesManagerConfig {\r\n topicId: string\r\n}\r\n\r\n@injectable()\r\nexport default class TopicVotesManager {\r\n private topicId: string\r\n private source: CollectionDataSource\r\n\r\n votes: Subscribable>\r\n\r\n loading: PureComputed\r\n updating: PureComputed\r\n\r\n constructor(\r\n @inject(wccModules.managerConfig) { topicId }: TopicVotesManagerConfig,\r\n @inject(wccModules.storage) storage: IWCCStorageManager,\r\n @inject(wccModules.topicsService) private topicsService: TopicsService,\r\n @inject(wccModules.effects) effects: EffectsContainer,\r\n ) {\r\n this.topicId = topicId;\r\n\r\n this.source = effects.register(new CollectionDataSource({\r\n load: this.load.bind(this),\r\n mapper: jsonVote => new ThreadVote(jsonVote)\r\n }));\r\n\r\n this.votes = this.source.list; \r\n\r\n this.loading = ko.pureComputed(() => this.source.busy() && this.source.requestsProcessed() === 0);\r\n this.updating = ko.pureComputed(() => this.source.busy() && this.source.requestsProcessed() > 0);\r\n\r\n const ideationManager = storage.get(IdeationManager, { topicId: topicId });\r\n const isVotingStage = ideationManager.pluck(m => m.isVotingStage, false);\r\n\r\n //we're inside voting stage so any replies changes require votes update\r\n effects.register(isVotingStage => {\r\n if (isVotingStage) {\r\n return withEffect([\r\n events.replyAdded.on(this.onLocalReplyAdded.bind(this)),\r\n events.replyUpdated.on(this.onLocalReplyUpdated.bind(this)),\r\n events.replyDeleted.on(this.onLocalReplyDeleted.bind(this))\r\n ]);\r\n }\r\n }, [isVotingStage]);\r\n }\r\n\r\n update() {\r\n this.source.load();\r\n }\r\n\r\n private load() {\r\n return this.topicsService.queries.votes(this.topicId).toArray();\r\n }\r\n\r\n private onLocalReplyAdded(topicId: string) {\r\n if (this.topicId == topicId)\r\n this.update();\r\n }\r\n\r\n private onLocalReplyUpdated(topicId: string) {\r\n if (this.topicId == topicId)\r\n this.update();\r\n }\r\n\r\n private onLocalReplyDeleted(topicId: string) {\r\n if (this.topicId == topicId)\r\n this.update();\r\n }\r\n}","import { Observable } from 'knockout';\r\nimport WCCEntity from './entity';\r\n\r\nexport interface JSONThreadVote {\r\n PersonId: string,\r\n ThreadId: string,\r\n VoteValue: number,\r\n LinkedThreadId: string\r\n}\r\n\r\nexport default class ThreadVote extends WCCEntity {\r\n personId: Observable\r\n threadId: Observable\r\n value: Observable\r\n linkedThreadId: Observable\r\n\r\n constructor(json: JSONThreadVote) {\r\n super();\r\n\r\n this.personId = this.createField(json, 'PersonId');\r\n this.threadId = this.createField(json, 'ThreadId');\r\n this.value = this.createField(json, 'VoteValue', 0);\r\n this.linkedThreadId = this.createField(json, 'LinkedThreadId');\r\n }\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, \".topic-content-image{display:block}.topic-content-image__content{display:block;width:100%;border-radius:4px}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","// Module\nvar code = \"\";\n// Exports\nmodule.exports = code;"],"sourceRoot":""}