Ivan - Add ticket view page for no user system[skip ci]

This commit is contained in:
ivan 2017-01-21 00:20:25 -03:00
parent 4e0669c4ae
commit 9db530f2dd
7 changed files with 40 additions and 108 deletions

View File

@ -14,6 +14,7 @@ import MainVerifyTokenPage from 'app/main/main-verify-token-page';
import MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-page';
import MainMaintenancePage from 'app/main/main-maintenance-page';
import MainCheckTicketPage from 'app/main/main-check-ticket-page';
import MainViewTicketPage from 'app/main/main-view-ticket-page';
import DashboardLayout from 'app/main/dashboard/dashboard-layout';
import DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page';
@ -67,7 +68,7 @@ export default (
<Route path='create-ticket' component={DashboardCreateTicketPage}/>
<Route path='check-ticket(/:ticketNumber/:email)' component={MainCheckTicketPage}/>
<Route path='view-ticket/:email/:ticketNumber' component={DashboardTicketPage}/>
<Route path='view-ticket/:ticketNumber' component={MainViewTicketPage}/>
<Route path='articles' component={DashboardListArticlesPage}/>
<Route path='dashboard' component={DashboardLayout}>

View File

@ -12,6 +12,16 @@ import Header from 'core-components/header';
class AdminPanelViewTicket extends React.Component {
static propTypes = {
avoidSeen: React.PropTypes.bool,
assignmentAllowed: React.PropTypes.bool
};
static defaultProps = {
avoidSeen: false,
assignmentAllowed: true
};
state = {
loading: true,
ticket: {}
@ -62,7 +72,7 @@ class AdminPanelViewTicket extends React.Component {
return {
ticket: this.state.ticket,
onChange: this.retrieveTicket.bind(this),
assignmentAllowed: true,
assignmentAllowed: this.props.assignmentAllowed,
customResponses: this.props.customResponses,
editable: this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId
};
@ -83,7 +93,7 @@ class AdminPanelViewTicket extends React.Component {
ticket: result.data
});
if(result.data.unreadStaff) {
if(!this.props.avoidSeen && result.data.unreadStaff) {
API.call({
path: '/ticket/seen',
data: {

View File

@ -88,7 +88,7 @@ class MainCheckTicketPage extends React.Component {
onTicketGetSuccess(result) {
SessionStore.setItem('token', result.data.token);
setTimeout(() => {browserHistory.push('/view-ticket/' + this.state.form.email + '/' + this.state.form.ticketNumber)}, 2000);
setTimeout(() => {browserHistory.push('/view-ticket/' + this.state.form.ticketNumber)}, 2000);
}
}

View File

@ -0,0 +1,20 @@
import React from 'react';
import AdminPanelViewTicket from 'app/admin/panel/tickets/admin-panel-view-ticket'
import Widget from 'core-components/widget';
class MainViewTicketPage extends React.Component {
render() {
return (
<div className="main-view-ticket-page">
<Widget>
<AdminPanelViewTicket {...this.props} avoidSeen assignmentAllowed={false} />
</Widget>
</div>
);
}
}
export default MainViewTicketPage;

View File

@ -0,0 +1,3 @@
.main-view-ticket-page {
padding: 0 15px;
}

View File

@ -1,104 +0,0 @@
import React from 'react';
import _ from 'lodash';
import {connect} from 'react-redux';
import API from 'lib-app/api-call';
import i18n from 'lib-app/i18n';
import SessionStore from 'lib-app/session-store';
import TicketViewer from 'app-components/ticket-viewer';
import Loading from 'core-components/loading';
import Header from 'core-components/header';
class MainViewTicket extends React.Component {
state = {
loading: true,
ticket: {}
};
componentDidMount() {
this.retrieveTicket();
}
render() {
return (
<div className="main-view-ticket">
<Header title={i18n('VIEW_TICKET')} description={i18n('TICKET_VIEW_DESCRIPTION')} />
{(this.state.loading) ? this.renderLoading() : this.renderView()}
</div>
);
}
renderLoading() {
return (
<div className="admin-panel-view-ticket__loading">
<Loading size="large" />
</div>
)
};
renderView() {
return (_.isEmpty(this.state.ticket)) ? this.renderNoPermissionError() : this.renderTicketView();
}
renderNoPermissionError() {
return (
<div className="admin-panel-view-ticket__error">
{i18n('NO_PERMISSION')}
</div>
);
}
renderTicketView() {
return (
<div className="admin-panel-view-ticket__ticket-view">
<TicketViewer {...this.getTicketViewProps()} />
</div>
);
}
getTicketViewProps() {
return {
ticket: this.state.ticket,
onChange: this.retrieveTicket.bind(this),
assignmentAllowed: true,
customResponses: this.props.customResponses,
editable: this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId
};
}
retrieveTicket() {
API.call({
path: '/ticket/get',
data: {
ticketNumber: this.props.params.ticketNumber
}
}).then(this.onRetrieveSuccess.bind(this)).catch(this.onRetrieveFail.bind(this))
}
onRetrieveSuccess(result) {
this.setState({
loading: false,
ticket: result.data
});
if(result.data.unreadStaff) {
API.call({
path: '/ticket/seen',
data: {
ticketNumber: this.props.params.ticketNumber
}
});
}
}
onRetrieveFail() {
this.setState({
loading: false,
ticket: {}
});
}
}
export default MainViewTicket;

View File

@ -110,10 +110,12 @@ module.exports = [
closed: false,
priority: 'medium',
author: {
id: 3,
name: 'Haskell Curry',
email: 'haskell@lambda.com'
},
owner: {
id: 1,
name: 'Steve Jobs'
},
events: [