|
|
|
|
@ -15,7 +15,6 @@ import { settings } from '../../../../../settings'; |
|
|
|
|
import { t, handleError, roomTypes } from '../../../../../utils'; |
|
|
|
|
import { hasRole, hasAllPermission, hasAtLeastOnePermission } from '../../../../../authorization'; |
|
|
|
|
import { LivechatVisitor } from '../../../collections/LivechatVisitor'; |
|
|
|
|
import { LivechatRoom } from '../../../collections/LivechatRoom'; |
|
|
|
|
import './visitorInfo.html'; |
|
|
|
|
import { APIClient } from '../../../../../utils/client'; |
|
|
|
|
|
|
|
|
|
@ -51,7 +50,7 @@ Template.visitorInfo.helpers({ |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
room() { |
|
|
|
|
return LivechatRoom.findOne({ _id: this.rid }); |
|
|
|
|
return Template.instance().room.get(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
department() { |
|
|
|
|
@ -73,7 +72,7 @@ Template.visitorInfo.helpers({ |
|
|
|
|
|
|
|
|
|
const data = Template.currentData(); |
|
|
|
|
if (data && data.rid) { |
|
|
|
|
const room = LivechatRoom.findOne(data.rid); |
|
|
|
|
const room = Template.instance().room.get(); |
|
|
|
|
if (room) { |
|
|
|
|
livechatData = _.extend(livechatData, room.livechatData); |
|
|
|
|
} |
|
|
|
|
@ -148,7 +147,7 @@ Template.visitorInfo.helpers({ |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
roomOpen() { |
|
|
|
|
const room = LivechatRoom.findOne({ _id: this.rid }); |
|
|
|
|
const room = Template.instance().room.get(); |
|
|
|
|
const uid = Meteor.userId(); |
|
|
|
|
return room && room.open && ((room.servedBy && room.servedBy._id === uid) || hasRole(uid, 'livechat-manager')); |
|
|
|
|
}, |
|
|
|
|
@ -259,7 +258,7 @@ Template.visitorInfo.events({ |
|
|
|
|
}, () => { |
|
|
|
|
Meteor.call('livechat:returnAsInquiry', this.rid, function(error/* , result*/) { |
|
|
|
|
if (error) { |
|
|
|
|
console.log(error); |
|
|
|
|
handleError(error); |
|
|
|
|
} else { |
|
|
|
|
Session.set('openedRoom'); |
|
|
|
|
FlowRouter.go('/home'); |
|
|
|
|
@ -284,6 +283,7 @@ Template.visitorInfo.onCreated(function() { |
|
|
|
|
this.tags = new ReactiveVar(null); |
|
|
|
|
this.routingConfig = new ReactiveVar({}); |
|
|
|
|
this.department = new ReactiveVar({}); |
|
|
|
|
this.room = new ReactiveVar({}); |
|
|
|
|
|
|
|
|
|
Meteor.call('livechat:getCustomFields', (err, customFields) => { |
|
|
|
|
if (customFields) { |
|
|
|
|
@ -298,13 +298,20 @@ Template.visitorInfo.onCreated(function() { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const loadRoomData = async (rid) => { |
|
|
|
|
const { room } = await APIClient.v1.get(`rooms.info?roomId=${ rid }`); |
|
|
|
|
this.visitorId.set(room && room.v && room.v._id); |
|
|
|
|
this.departmentId.set(room && room.departmentId); |
|
|
|
|
this.tags.set(room && room.tags); |
|
|
|
|
this.room.set(room); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (rid) { |
|
|
|
|
this.subscribe('livechat:rooms', { _id: rid }); |
|
|
|
|
this.autorun(() => { |
|
|
|
|
const room = LivechatRoom.findOne({ _id: rid }); |
|
|
|
|
this.visitorId.set(room && room.v && room.v._id); |
|
|
|
|
this.departmentId.set(room && room.departmentId); |
|
|
|
|
this.tags.set(room && room.tags); |
|
|
|
|
const action = this.action.get(); |
|
|
|
|
if (action === undefined) { |
|
|
|
|
loadRoomData(rid); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.subscribe('livechat:visitorInfo', { rid }); |
|
|
|
|
|