-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] [ENTERPRISE] Allows to set a group of departments accepted for forwarding chats #17335
Changes from 2 commits
d9b5109
c6cfce4
00ba0bf
c237cf0
e728456
31dc229
437f61b
416f5ef
912a49e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,7 +8,6 @@ import { ChatRoom } from '../../../../../models'; | |||||
import { t } from '../../../../../utils'; | ||||||
import './visitorForward.html'; | ||||||
import { APIClient } from '../../../../../utils/client'; | ||||||
import { getCustomFormTemplate } from '../customTemplates/register'; | ||||||
|
||||||
Template.visitorForward.helpers({ | ||||||
visitor() { | ||||||
|
@@ -54,16 +53,9 @@ Template.visitorForward.helpers({ | |||||
return Template.instance().onSelectDepartments; | ||||||
}, | ||||||
departmentConditions() { | ||||||
return { enabled: true, numAgents: { $gt: 0 } }; | ||||||
}, | ||||||
customFieldsTemplate() { | ||||||
return getCustomFormTemplate('visitorForward'); | ||||||
}, | ||||||
showDefaultDepartmentForm() { | ||||||
return !getCustomFormTemplate('visitorForward') && Template.instance().departments.get().filter((department) => department.enabled === true).length > 0; | ||||||
}, | ||||||
data() { | ||||||
return Template.instance().room; | ||||||
const departmentForwardRestrictions = Template.instance().departmentForwardRestrictions.get(); | ||||||
console.log(departmentForwardRestrictions); | ||||||
return { enabled: true, numAgents: { $gt: 0 }, ...departmentForwardRestrictions }; | ||||||
}, | ||||||
}); | ||||||
|
||||||
|
@@ -73,6 +65,7 @@ Template.visitorForward.onCreated(async function() { | |||||
this.departments = new ReactiveVar([]); | ||||||
this.selectedAgents = new ReactiveVar([]); | ||||||
this.selectedDepartments = new ReactiveVar([]); | ||||||
this.departmentForwardRestrictions = new ReactiveVar(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
this.onSelectDepartments = ({ item: department }) => { | ||||||
department.text = department.name; | ||||||
|
@@ -99,6 +92,12 @@ Template.visitorForward.onCreated(async function() { | |||||
|
||||||
this.autorun(() => { | ||||||
this.room.set(ChatRoom.findOne({ _id: Template.currentData().roomId })); | ||||||
const { departmentId } = this.room.get(); | ||||||
if (departmentId) { | ||||||
Meteor.call('livechat:getDepartmentForwardRestrictions', departmentId, (err, result) => { | ||||||
this.departmentForwardRestrictions.set(result); | ||||||
}); | ||||||
} | ||||||
}); | ||||||
|
||||||
const { departments } = await APIClient.v1.get('livechat/department'); | ||||||
|
@@ -123,12 +122,6 @@ Template.visitorForward.events({ | |||||
transferData.departmentId = department && department._id; | ||||||
} | ||||||
|
||||||
instance.$('.customFormField').each((i, el) => { | ||||||
const elField = instance.$(el); | ||||||
const name = elField.attr('name'); | ||||||
transferData[name] = elField.val(); | ||||||
}); | ||||||
|
||||||
if (!transferData.userId && !transferData.departmentId) { | ||||||
return; | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||
import { Meteor } from 'meteor/meteor'; | ||||||
|
||||||
import { callbacks } from '../../../callbacks'; | ||||||
|
||||||
Meteor.methods({ | ||||||
'livechat:getDepartmentForwardRestrictions'(departmentId) { | ||||||
if (!Meteor.userId()) { | ||||||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'livechat:getTagsList' }); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
return callbacks.run('livechat.onLoadForwardDepartmentRestrictions', departmentId); | ||||||
}, | ||||||
}); |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,17 @@ | ||||||
import { callbacks } from '../../../../../app/callbacks'; | ||||||
import { LivechatDepartment } from '../../../../../app/models/server'; | ||||||
|
||||||
callbacks.add('livechat.onLoadForwardDepartmentRestrictions', (departmentId) => { | ||||||
if (!departmentId) { | ||||||
return {}; | ||||||
} | ||||||
const department = LivechatDepartment.findOneById(departmentId); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (!department) { | ||||||
return {}; | ||||||
} | ||||||
const { departmentsAllowedToForward } = department; | ||||||
if (!departmentsAllowedToForward) { | ||||||
return {}; | ||||||
} | ||||||
return { _id: { $in: departmentsAllowedToForward } }; | ||||||
}, callbacks.priority.MEDIUM, 'livechat-on-load-forward-department-restrictions'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this console here =D