mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
Fix error in edit button for ticket owner. (#872)
* Retrieve staff members after edit staffs. * Delete retun after throw new RequestException in staff/edit.php * Resolve github Ivan comments. * wip
This commit is contained in:
parent
817240e0b4
commit
5184c31907
@ -814,23 +814,21 @@ class TicketViewer extends React.Component {
|
||||
userId,
|
||||
ticket
|
||||
} = this.props;
|
||||
const ticketDepartmentId = ticket.department.id;
|
||||
const FIRST_ITEM = 0;
|
||||
let staffAssignmentItems = [
|
||||
{content: i18n('NONE'), contentOnSelected: i18n('NONE'), id: 0}
|
||||
];
|
||||
|
||||
if(_.some(userDepartments, {id: ticketDepartmentId})) {
|
||||
if(_.some(userDepartments, {id: ticket.department.id})) {
|
||||
staffAssignmentItems.push({
|
||||
content: i18n('ASSIGN_TO_ME'),
|
||||
contentOnSelected: this.getStaffList({onlyMe: true})[FIRST_ITEM].name,
|
||||
contentOnSelected: this.getCurrentStaff().name,
|
||||
id: userId
|
||||
});
|
||||
}
|
||||
|
||||
staffAssignmentItems = staffAssignmentItems.concat(
|
||||
_.map(
|
||||
this.getStaffList({onlyMe: false}),
|
||||
this.getStaffList(),
|
||||
({id, name}) => ({content: name, contentOnSelected: name, id: id*1})
|
||||
)
|
||||
);
|
||||
@ -838,7 +836,7 @@ class TicketViewer extends React.Component {
|
||||
return staffAssignmentItems;
|
||||
}
|
||||
|
||||
getStaffList(onlyMeObject) {
|
||||
getStaffList() {
|
||||
const {
|
||||
userId,
|
||||
staffMembers,
|
||||
@ -846,12 +844,20 @@ class TicketViewer extends React.Component {
|
||||
} = this.props;
|
||||
|
||||
return _.filter(staffMembers, ({id, departments}) => {
|
||||
const idComparer = onlyMeObject.onlyMe ? (id == userId) : (id != userId);
|
||||
|
||||
return idComparer && _.some(departments, {id: ticket.department.id});
|
||||
return (id != userId) && _.some(departments, {id: ticket.department.id});
|
||||
})
|
||||
}
|
||||
|
||||
getCurrentStaff() {
|
||||
const {
|
||||
userId,
|
||||
staffMembers,
|
||||
ticket
|
||||
} = this.props;
|
||||
|
||||
return _.find(staffMembers, ({id}) => {return id == userId});
|
||||
}
|
||||
|
||||
getDepartmentsForTransfer() {
|
||||
return this.props.ticket.author.staff ? SessionStore.getDepartments() : this.getPublicDepartments();
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import classNames from 'classnames';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import AdminDataActions from 'actions/admin-data-actions';
|
||||
|
||||
import i18n from 'lib-app/i18n';
|
||||
import API from 'lib-app/api-call';
|
||||
@ -312,6 +315,7 @@ class StaffEditor extends React.Component {
|
||||
departments: (eventType === 'DEPARTMENTS') ? (departments && JSON.stringify(departments)) : null,
|
||||
}
|
||||
}).then(() => {
|
||||
this.retrieveStaffMembers();
|
||||
window.scrollTo(0,0);
|
||||
this.setState({message: eventType});
|
||||
|
||||
@ -361,6 +365,10 @@ class StaffEditor extends React.Component {
|
||||
this.setState({message: 'FAIL', loadingPicture: false});
|
||||
});
|
||||
}
|
||||
|
||||
retrieveStaffMembers() {
|
||||
this.props.dispatch(AdminDataActions.retrieveStaffMembers());
|
||||
}
|
||||
}
|
||||
|
||||
export default StaffEditor;
|
||||
export default connect()(StaffEditor);
|
||||
|
@ -64,11 +64,9 @@ class EditStaffController extends Controller {
|
||||
|
||||
if($this->staffInstance->isNull()) {
|
||||
throw new RequestException(ERRORS::INVALID_STAFF);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
throw new RequestException(ERRORS::NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Controller::request('departments')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user