Ivan - Fixes for Deploy
This commit is contained in:
parent
79dcbe030e
commit
9aceff4313
|
@ -32,7 +32,7 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
retrieveAllTickets(page) {
|
||||
retrieveAllTickets(page = 1) {
|
||||
return {
|
||||
type: 'ALL_TICKETS',
|
||||
payload: API.call({
|
||||
|
@ -42,7 +42,7 @@ export default {
|
|||
};
|
||||
},
|
||||
|
||||
searchTickets(query, page) {
|
||||
searchTickets(query, page = 1) {
|
||||
return {
|
||||
type: 'ALL_TICKETS',
|
||||
payload: API.call({
|
||||
|
|
|
@ -161,7 +161,7 @@ class TicketList extends React.Component {
|
|||
}
|
||||
|
||||
gerTicketTableObject(ticket) {
|
||||
let titleText = (ticket.unread) ? ticket.title + ' (1)' : ticket.title;
|
||||
let titleText = (this.isTicketUnread(ticket)) ? ticket.title + ' (1)' : ticket.title;
|
||||
|
||||
return {
|
||||
number: (
|
||||
|
@ -178,8 +178,8 @@ class TicketList extends React.Component {
|
|||
department: ticket.department.name,
|
||||
author: ticket.author.name,
|
||||
date: DateTransformer.transformToString(ticket.date),
|
||||
unread: ticket.unread,
|
||||
highlighted: ticket.unread
|
||||
unread: this.isTicketUnread(ticket),
|
||||
highlighted: this.isTicketUnread(ticket)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -231,6 +231,10 @@ class TicketList extends React.Component {
|
|||
}
|
||||
return row1.closed ? -1 : 1;
|
||||
}
|
||||
|
||||
isTicketUnread(ticket) {
|
||||
return (this.props.type === 'primary' && ticket.unread) || (this.props.type === 'secondary' && ticket.unreadStaff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
&__author {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__date {
|
||||
text-align: right;
|
||||
}
|
||||
|
|
|
@ -54,16 +54,7 @@ class TicketViewer extends React.Component {
|
|||
<div className="ticket-viewer__comments">
|
||||
{ticket.events && ticket.events.map(this.renderTicketEvent.bind(this))}
|
||||
</div>
|
||||
<div className="ticket-viewer__response">
|
||||
<div className="ticket-viewer__response-title row">{i18n('RESPOND')}</div>
|
||||
{this.renderCustomResponses()}
|
||||
<div className="ticket-viewer__response-field row">
|
||||
<Form {...this.getCommentFormProps()}>
|
||||
<FormField name="content" validation="TEXT_AREA" required field="textarea" />
|
||||
<SubmitButton>{i18n('RESPOND_TICKET')}</SubmitButton>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
{(!this.props.ticket.closed && (this.props.editable || !this.props.assignmentAllowed)) ? this.renderResponseField() : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -173,7 +164,7 @@ class TicketViewer extends React.Component {
|
|||
</Button>
|
||||
);
|
||||
} else {
|
||||
ownerNode = i18n((this.props.closed) ? 'CLOSED' : 'OPENED');
|
||||
ownerNode = i18n((this.props.ticket.closed) ? 'CLOSED' : 'OPENED');
|
||||
}
|
||||
|
||||
return ownerNode;
|
||||
|
@ -185,6 +176,21 @@ class TicketViewer extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
renderResponseField() {
|
||||
return (
|
||||
<div className="ticket-viewer__response">
|
||||
<div className="ticket-viewer__response-title row">{i18n('RESPOND')}</div>
|
||||
{this.renderCustomResponses()}
|
||||
<div className="ticket-viewer__response-field row">
|
||||
<Form {...this.getCommentFormProps()}>
|
||||
<FormField name="content" validation="TEXT_AREA" required field="textarea" />
|
||||
<SubmitButton>{i18n('RESPOND_TICKET')}</SubmitButton>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderCustomResponses() {
|
||||
let customResponsesNode = null;
|
||||
|
||||
|
|
|
@ -52,7 +52,11 @@ class AdminPanelAllTickets extends React.Component {
|
|||
|
||||
onSearch(query) {
|
||||
this.setState({query, page: 1});
|
||||
this.props.dispatch(AdminDataAction.searchTickets(query));
|
||||
if (query) {
|
||||
this.props.dispatch(AdminDataAction.searchTickets(query));
|
||||
} else {
|
||||
this.props.dispatch(AdminDataAction.retrieveAllTickets());
|
||||
}
|
||||
}
|
||||
|
||||
onPageChange(event) {
|
||||
|
|
|
@ -153,7 +153,7 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
API.call({
|
||||
path: '/ticket/edit-custom-response',
|
||||
data: {
|
||||
id: this.state.selectedIndex,
|
||||
id: this.props.items[this.state.selectedIndex].id,
|
||||
name: form.name,
|
||||
content: form.content,
|
||||
language: form.language
|
||||
|
@ -161,7 +161,7 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
}).then(() => {
|
||||
this.setState({formLoading: false});
|
||||
this.retrieveCustomResponses();
|
||||
});
|
||||
}).catch(this.onItemChange.bind(this, -1));
|
||||
} else {
|
||||
API.call({
|
||||
path: '/ticket/add-custom-response',
|
||||
|
@ -171,17 +171,19 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
language: form.language
|
||||
}
|
||||
}).then(() => {
|
||||
this.setState({formLoading: false});
|
||||
this.retrieveCustomResponses();
|
||||
});
|
||||
this.onItemChange(-1);
|
||||
}).catch(this.onItemChange.bind(this, -1));
|
||||
}
|
||||
}
|
||||
|
||||
onDiscardChangesClick() {
|
||||
onDiscardChangesClick(event) {
|
||||
event.preventDefault();
|
||||
this.onItemChange(this.state.selectedIndex);
|
||||
}
|
||||
|
||||
onDeleteClick() {
|
||||
onDeleteClick(event) {
|
||||
event.preventDefault();
|
||||
AreYouSure.openModal(i18n('WILL_DELETE_CUSTOM_RESPONSE'), this.deleteCustomResponse.bind(this));
|
||||
}
|
||||
|
||||
|
@ -189,9 +191,12 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
API.call({
|
||||
path: '/ticket/delete-custom-response',
|
||||
data: {
|
||||
id: this.state.selectedIndex
|
||||
id: this.props.items[this.state.selectedIndex].id
|
||||
}
|
||||
}).then(this.retrieveCustomResponses.bind(this));
|
||||
}).then(() => {
|
||||
this.retrieveCustomResponses();
|
||||
this.onItemChange(-1);
|
||||
});
|
||||
}
|
||||
|
||||
updateForm(index) {
|
||||
|
@ -204,6 +209,7 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
this.setState({
|
||||
selectedIndex: index,
|
||||
edited: false,
|
||||
formLoading: false,
|
||||
form: form,
|
||||
errors: {}
|
||||
});
|
||||
|
@ -211,6 +217,9 @@ class AdminPanelCustomResponses extends React.Component {
|
|||
|
||||
retrieveCustomResponses() {
|
||||
this.props.dispatch(AdminDataActions.retrieveCustomResponses());
|
||||
this.setState({
|
||||
edited: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class AdminPanelViewTicket extends React.Component {
|
|||
onChange: this.retrieveTicket.bind(this),
|
||||
assignmentAllowed: true,
|
||||
customResponses: this.props.customResponses,
|
||||
editable: _.get(this.state.ticket, 'owner.id') === SessionStore.getUserData().id
|
||||
editable: this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class AdminPanelViewTicket extends React.Component {
|
|||
data: {
|
||||
ticketNumber: this.props.params.ticketNumber
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ class DashboardTicketPage extends React.Component {
|
|||
data: {
|
||||
ticketNumber: ticket.ticketNumber
|
||||
}
|
||||
}).then(() => {
|
||||
this.retrieveUserData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ DataValidator::with('CustomValidations', true);
|
|||
class TicketGetController extends Controller {
|
||||
const PATH = '/get';
|
||||
|
||||
private $ticket;
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'user',
|
||||
|
@ -18,14 +20,19 @@ class TicketGetController extends Controller {
|
|||
}
|
||||
|
||||
public function handler() {
|
||||
$ticketNumber = Controller::request('ticketNumber');
|
||||
$this->ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
|
||||
|
||||
$ticket = Ticket::getByTicketNumber($ticketNumber);
|
||||
|
||||
if ($ticket->author->id != Controller::getLoggedUser()->id) {
|
||||
Response::respondError(ERRORS::INVALID_TICKET);
|
||||
if ($this->shouldDenyPermission()) {
|
||||
Response::respondError(ERRORS::NO_PERMISSION);
|
||||
} else {
|
||||
Response::respondSuccess($ticket->toArray());
|
||||
Response::respondSuccess($this->ticket->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
private function shouldDenyPermission() {
|
||||
$user = Controller::getLoggedUser();
|
||||
|
||||
return (!Controller::isStaffLogged() && $this->ticket->author->id !== $user->id) ||
|
||||
(Controller::isStaffLogged() && $this->ticket->owner && $this->ticket->owner->id !== $user->id);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ class CustomResponse extends DataStore {
|
|||
|
||||
public function toArray() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'language' => $this->language,
|
||||
'content' => $this->content,
|
||||
|
|
|
@ -16,7 +16,10 @@ class Department extends DataStore {
|
|||
$departmentsNameList = [];
|
||||
|
||||
foreach($departmentsList as $department) {
|
||||
$departmentsNameList[] = $department->name;
|
||||
$departmentsNameList[] = [
|
||||
'id' => $department->id,
|
||||
'name' => $department->name
|
||||
];
|
||||
}
|
||||
|
||||
return $departmentsNameList;
|
||||
|
|
|
@ -74,6 +74,7 @@ class Ticket extends DataStore {
|
|||
'file' => $this->file,
|
||||
'language' => $this->language,
|
||||
'unread' => !!$this->unread,
|
||||
'unreadStaff' => !!$this->unreadStaff,
|
||||
'closed' => !!$this->closed,
|
||||
'priority' => $this->priority,
|
||||
'author' => $this->authorToArray(),
|
||||
|
@ -106,7 +107,7 @@ class Ticket extends DataStore {
|
|||
'email' => $owner->email
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,6 +129,7 @@ class Ticket extends DataStore {
|
|||
'id'=> $author->id,
|
||||
'name' => $author->name,
|
||||
'email' =>$author->email,
|
||||
'profilePic' => ($author instanceof Staff) ? $author->profilePic : null,
|
||||
'staff' => $author instanceof Staff
|
||||
];
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ describe '/system/get-settings' do
|
|||
|
||||
(result['status']).should.equal('success')
|
||||
(result['data']['language']).should.equal('en')
|
||||
(result['data']['departments'][0]).should.equal('Tech Support')
|
||||
(result['data']['departments'][1]).should.equal('Suggestions')
|
||||
(result['data']['departments'][2]).should.equal('Sales and Subscriptions')
|
||||
(result['data']['departments'][0]['name']).should.equal('Tech Support')
|
||||
(result['data']['departments'][1]['name']).should.equal('Suggestions')
|
||||
(result['data']['departments'][2]['name']).should.equal('Sales and Subscriptions')
|
||||
end
|
||||
end
|
|
@ -75,7 +75,7 @@ describe '/ticket/get/' do
|
|||
(result['data']['unread']).should.equal(false)
|
||||
(result['data']['author']['name']).should.equal('Cersei Lannister')
|
||||
(result['data']['author']['email']).should.equal('cersei@os4.com')
|
||||
(result['data']['owner']).should.equal([])
|
||||
(result['data']['owner']).should.equal(nil)
|
||||
(result['data']['events'].size).should.equal(1)
|
||||
(result['data']['events'][0]['type']).should.equal('COMMENT')
|
||||
(result['data']['events'][0]['content']).should.equal('some valid comment made')
|
||||
|
|
|
@ -51,7 +51,7 @@ describe '/user/get' do
|
|||
(ticketFromUser['unread']).should.equal(false)
|
||||
(ticketFromUser['author']['name']).should.equal('User Get')
|
||||
(ticketFromUser['author']['email']).should.equal('user_get@os4.com')
|
||||
(ticketFromUser['owner']).should.equal([])
|
||||
(ticketFromUser['owner']).should.equal(nil)
|
||||
(ticketFromUser['events']).should.equal([])
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue