Ivan - Add ticket view page for no user system[skip ci]
This commit is contained in:
parent
4e0669c4ae
commit
9db530f2dd
|
@ -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 MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-page';
|
||||||
import MainMaintenancePage from 'app/main/main-maintenance-page';
|
import MainMaintenancePage from 'app/main/main-maintenance-page';
|
||||||
import MainCheckTicketPage from 'app/main/main-check-ticket-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 DashboardLayout from 'app/main/dashboard/dashboard-layout';
|
||||||
import DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page';
|
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='create-ticket' component={DashboardCreateTicketPage}/>
|
||||||
<Route path='check-ticket(/:ticketNumber/:email)' component={MainCheckTicketPage}/>
|
<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='articles' component={DashboardListArticlesPage}/>
|
||||||
|
|
||||||
<Route path='dashboard' component={DashboardLayout}>
|
<Route path='dashboard' component={DashboardLayout}>
|
||||||
|
|
|
@ -12,6 +12,16 @@ import Header from 'core-components/header';
|
||||||
|
|
||||||
class AdminPanelViewTicket extends React.Component {
|
class AdminPanelViewTicket extends React.Component {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
avoidSeen: React.PropTypes.bool,
|
||||||
|
assignmentAllowed: React.PropTypes.bool
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
avoidSeen: false,
|
||||||
|
assignmentAllowed: true
|
||||||
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
ticket: {}
|
ticket: {}
|
||||||
|
@ -62,7 +72,7 @@ class AdminPanelViewTicket extends React.Component {
|
||||||
return {
|
return {
|
||||||
ticket: this.state.ticket,
|
ticket: this.state.ticket,
|
||||||
onChange: this.retrieveTicket.bind(this),
|
onChange: this.retrieveTicket.bind(this),
|
||||||
assignmentAllowed: true,
|
assignmentAllowed: this.props.assignmentAllowed,
|
||||||
customResponses: this.props.customResponses,
|
customResponses: this.props.customResponses,
|
||||||
editable: this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId
|
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
|
ticket: result.data
|
||||||
});
|
});
|
||||||
|
|
||||||
if(result.data.unreadStaff) {
|
if(!this.props.avoidSeen && result.data.unreadStaff) {
|
||||||
API.call({
|
API.call({
|
||||||
path: '/ticket/seen',
|
path: '/ticket/seen',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -88,7 +88,7 @@ class MainCheckTicketPage extends React.Component {
|
||||||
|
|
||||||
onTicketGetSuccess(result) {
|
onTicketGetSuccess(result) {
|
||||||
SessionStore.setItem('token', result.data.token);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
@ -0,0 +1,3 @@
|
||||||
|
.main-view-ticket-page {
|
||||||
|
padding: 0 15px;
|
||||||
|
}
|
|
@ -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;
|
|
|
@ -110,10 +110,12 @@ module.exports = [
|
||||||
closed: false,
|
closed: false,
|
||||||
priority: 'medium',
|
priority: 'medium',
|
||||||
author: {
|
author: {
|
||||||
|
id: 3,
|
||||||
name: 'Haskell Curry',
|
name: 'Haskell Curry',
|
||||||
email: 'haskell@lambda.com'
|
email: 'haskell@lambda.com'
|
||||||
},
|
},
|
||||||
owner: {
|
owner: {
|
||||||
|
id: 1,
|
||||||
name: 'Steve Jobs'
|
name: 'Steve Jobs'
|
||||||
},
|
},
|
||||||
events: [
|
events: [
|
||||||
|
|
Loading…
Reference in New Issue