403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/js/im/v2/component/message/support/vote/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/js/im/v2/component/message/support/vote/src/vote.js
import { Type } from 'main.core';

import { BaseMessage } from 'im.v2.component.message.base';
import { Notifier } from 'im.v2.lib.notifier';

import { VoteService } from './classes/vote-service';
import { VoteType } from './const/vote-type';
import { VoteParamKey as ParamKey } from './const/vote-params-keys';

import './css/vote.css';

import type { ImModelMessage } from 'im.v2.model';

// @vue/component
export const SupportVoteMessage = {
	name: 'SupportVote',
	components: { BaseMessage },
	props:
	{
		item: {
			type: Object,
			required: true,
		},
		dialogId: {
			type: String,
			required: true,
		},
		withTitle: {
			type: Boolean,
			default: true,
		},
	},
	computed:
	{
		message(): ImModelMessage
		{
			return this.item;
		},
		currentVote(): $Values<typeof VoteType>
		{
			return this.message.componentParams[ParamKey.currentVote] || VoteType.none;
		},
		voteText(): string
		{
			if (this.currentVote === VoteType.none)
			{
				return this.message.componentParams[ParamKey.voteText];
			}

			if (this.currentVote === VoteType.like)
			{
				return this.message.componentParams[ParamKey.likeText];
			}

			return this.message.componentParams[ParamKey.dislikeText];
		},
		voteClosed(): boolean
		{
			const closeDate = this.message.componentParams[ParamKey.voteCloseDate];
			if (!Type.isStringFilled(closeDate))
			{
				return false;
			}

			return new Date(closeDate).getTime() < Date.now();
		},
		likeClasses(): { [className: string]: boolean }
		{
			return {
				'--active': this.currentVote === VoteType.like,
				'--disabled': this.currentVote === VoteType.dislike,
			};
		},
		dislikeClasses(): { [className: string]: boolean }
		{
			return {
				'--active': this.currentVote === VoteType.dislike,
				'--disabled': this.currentVote === VoteType.like,
			};
		},
	},
	methods:
	{
		onLike()
		{
			if (this.currentVote === VoteType.like)
			{
				return;
			}

			if (this.voteClosed)
			{
				this.showVoteClosedNotification();

				return;
			}
			this.getVoteService().like();
		},
		onDislike()
		{
			if (this.currentVote === VoteType.dislike)
			{
				return;
			}

			if (this.voteClosed)
			{
				this.showVoteClosedNotification();

				return;
			}
			this.getVoteService().dislike();
		},
		showVoteClosedNotification()
		{
			Notifier.support.onVoteClosedError();
		},
		getVoteService(): VoteService
		{
			if (!this.voteService)
			{
				this.voteService = new VoteService(this.message.id, this.dialogId);
			}

			return this.voteService;
		},
		loc(phraseCode: string, replacements: {[p: string]: string} = {}): string
		{
			return this.$Bitrix.Loc.getMessage(phraseCode, replacements);
		},
	},
	template: `
		<BaseMessage
			:item="item"
			:dialogId="dialogId"
			:withTitle="withTitle"
			:withContextMenu="false"
			:withReactions="false"
		>
			<div class="bx-im-message-support-vote__container">
				<div class="bx-im-message-support-vote__title">{{ loc('IM_MESSAGE_SUPPORT_VOTE_TITLE') }}</div>
				<div class="bx-im-message-support-vote__subtitle">{{ voteText }}</div>
				<div class="bx-im-message-support-vote__actions">
					<div class="bx-im-message-support-vote__action_item --like" :class="likeClasses" @click="onLike"></div>
					<div class="bx-im-message-support-vote__action_item --dislike" :class="dislikeClasses" @click="onDislike"></div>
				</div>
			</div>
		</BaseMessage>
	`,
};

Youez - 2016 - github.com/yon3zu
LinuXploit