mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-27 15:54:23 +02:00
Ivan - Add my tickets department dropdown, fix loading, add filter, merge master[skip ci]
This commit is contained in:
parent
22cd244846
commit
3179b29158
@ -12,6 +12,7 @@ import DateTransformer from 'lib-core/date-transformer';
|
|||||||
class TicketList extends React.Component {
|
class TicketList extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
loading: React.PropTypes.bool,
|
loading: React.PropTypes.bool,
|
||||||
|
ticketPath: React.PropTypes.string,
|
||||||
tickets: React.PropTypes.arrayOf(React.PropTypes.object),
|
tickets: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||||
type: React.PropTypes.oneOf([
|
type: React.PropTypes.oneOf([
|
||||||
'primary',
|
'primary',
|
||||||
@ -21,6 +22,7 @@ class TicketList extends React.Component {
|
|||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
tickets: [],
|
tickets: [],
|
||||||
|
ticketPath: '/dashboard/ticket/',
|
||||||
type: 'primary'
|
type: 'primary'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ class TicketList extends React.Component {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
),
|
),
|
||||||
title: (
|
title: (
|
||||||
<Button className="ticket-list__title-link" type="clean" route={{to: '/dashboard/ticket/' + ticket.ticketNumber}}>
|
<Button className="ticket-list__title-link" type="clean" route={{to: this.props.ticketPath + ticket.ticketNumber}}>
|
||||||
{titleText}
|
{titleText}
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import _ from 'lodash';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
|
|
||||||
import i18n from 'lib-app/i18n';
|
import i18n from 'lib-app/i18n';
|
||||||
@ -9,6 +10,15 @@ import DropDown from 'core-components/drop-down';
|
|||||||
import TicketList from 'app-components/ticket-list';
|
import TicketList from 'app-components/ticket-list';
|
||||||
|
|
||||||
class AdminPanelMyTickets extends React.Component {
|
class AdminPanelMyTickets extends React.Component {
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
departments: [],
|
||||||
|
tickets: []
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
selectedDepartment: 0
|
||||||
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.dispatch(AdminDataAction.retrieveMyTickets());
|
this.props.dispatch(AdminDataAction.retrieveMyTickets());
|
||||||
@ -16,31 +26,68 @@ class AdminPanelMyTickets extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="admin-panel-my-tickets">
|
||||||
<Header title={i18n('MY_TICKETS')} description={i18n('MY_TICKETS_DESCRIPTION')} />
|
<Header title={i18n('MY_TICKETS')} description={i18n('MY_TICKETS_DESCRIPTION')} />
|
||||||
<DropDown {...this.getProps()} />
|
<div className="admin-panel-my-tickets__department-select">
|
||||||
<TicketList tickets={this.props.tickets} type="secondary" loading={true} />
|
<DropDown {...this.getDropdownProps()} />
|
||||||
|
</div>
|
||||||
|
<TicketList {...this.getProps()}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getProps() {
|
getProps() {
|
||||||
console.log(this.props.tickets);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: this.props.departments.map(function (obj) {
|
tickets: this.getTickets(),
|
||||||
return {
|
type: 'secondary',
|
||||||
content: obj.name
|
loading: this.props.loading,
|
||||||
};
|
ticketPath: '/admin/panel/tickets/view-ticket/'
|
||||||
}),
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getDropdownProps() {
|
||||||
|
return {
|
||||||
|
items: this.getDepartments(),
|
||||||
|
onChange: this.changeSelectedDepartment.bind(this),
|
||||||
size: 'medium'
|
size: 'medium'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTickets() {
|
||||||
|
return (this.state.selectedDepartment) ? _.filter(this.props.tickets, (ticket) => {
|
||||||
|
return ticket.department.id == this.state.selectedDepartment
|
||||||
|
}) : this.props.tickets;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDepartments() {
|
||||||
|
let departments = this.props.departments.map((department) => {
|
||||||
|
return {content: department.name};
|
||||||
|
});
|
||||||
|
|
||||||
|
departments.unshift({
|
||||||
|
content: i18n('ALL_DEPARTMENTS')
|
||||||
|
});
|
||||||
|
|
||||||
|
return departments;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeSelectedDepartment(event) {
|
||||||
|
if(event.index === 0) {
|
||||||
|
this.setState({
|
||||||
|
selectedDepartment: 0
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
selectedDepartment: this.props.departments[event.index - 1].id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect((store) => {
|
export default connect((store) => {
|
||||||
return {
|
return {
|
||||||
departments: store.session.userDepartments,
|
departments: store.session.userDepartments,
|
||||||
tickets: store.adminData.myTickets
|
tickets: store.adminData.myTickets,
|
||||||
|
loading: !store.adminData.myTicketsLoaded
|
||||||
};
|
};
|
||||||
})(AdminPanelMyTickets);
|
})(AdminPanelMyTickets);
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
.admin-panel-my-tickets {
|
||||||
|
|
||||||
|
&__department-select {
|
||||||
|
margin-bottom: 25px;
|
||||||
|
}
|
||||||
|
}
|
@ -166,7 +166,7 @@ let DemoPage = React.createClass({
|
|||||||
else if(a.title1 > b.title1)
|
else if(a.title1 > b.title1)
|
||||||
ans = 1;
|
ans = 1;
|
||||||
return ans;
|
return ans;
|
||||||
}}/>
|
}} loading/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
|
|
||||||
&__loading-wrapper {
|
&__loading-wrapper {
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
|
position: relative;
|
||||||
|
background-color: $grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__loading {
|
&__loading {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
background-color: #F7F7F7;
|
background-color: #F7F7F7;
|
||||||
color: black;
|
color: black;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__pointer {
|
&__pointer {
|
||||||
|
@ -13,9 +13,7 @@ module.exports = [
|
|||||||
staff: true,
|
staff: true,
|
||||||
departments: [
|
departments: [
|
||||||
{id: 1, name: 'Sales Support'},
|
{id: 1, name: 'Sales Support'},
|
||||||
{id: 2, name: 'Technical Issues'},
|
{id: 2, name: 'Technical Issues'}
|
||||||
{id: 3, name: 'System and Administration'},
|
|
||||||
{id: 4, name: 'Guillermo\'s department'}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -23,7 +21,7 @@ module.exports = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/staff/get-tickets',
|
path: '/staff/get-tickets',
|
||||||
time: 2000,
|
time: 300,
|
||||||
response: function () {
|
response: function () {
|
||||||
return {
|
return {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@ -34,7 +32,7 @@ module.exports = [
|
|||||||
content: 'I had a problem with the installation of the php server',
|
content: 'I had a problem with the installation of the php server',
|
||||||
department: {
|
department: {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Environment Setup'
|
name: 'Technical Issues'
|
||||||
},
|
},
|
||||||
date: '20160416',
|
date: '20160416',
|
||||||
file: 'http://www.opensupports.com/some_file.zip',
|
file: 'http://www.opensupports.com/some_file.zip',
|
||||||
@ -52,7 +50,7 @@ module.exports = [
|
|||||||
name: 'Steve Jobs',
|
name: 'Steve Jobs',
|
||||||
email: 'steve@jobs.com'
|
email: 'steve@jobs.com'
|
||||||
},
|
},
|
||||||
actions: [
|
events: [
|
||||||
{
|
{
|
||||||
type: 'ASSIGN',
|
type: 'ASSIGN',
|
||||||
date: '20150409',
|
date: '20150409',
|
||||||
@ -153,7 +151,7 @@ module.exports = [
|
|||||||
content: 'I had a problem with the installation of the php server',
|
content: 'I had a problem with the installation of the php server',
|
||||||
department: {
|
department: {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Environment Setup'
|
name: 'Technical Issues'
|
||||||
},
|
},
|
||||||
date: '20160415',
|
date: '20160415',
|
||||||
file: 'http://www.opensupports.com/some_file.zip',
|
file: 'http://www.opensupports.com/some_file.zip',
|
||||||
@ -168,7 +166,7 @@ module.exports = [
|
|||||||
owner: {
|
owner: {
|
||||||
name: 'Steve Jobs'
|
name: 'Steve Jobs'
|
||||||
},
|
},
|
||||||
actions: [
|
events: [
|
||||||
{
|
{
|
||||||
type: 'ASSIGN',
|
type: 'ASSIGN',
|
||||||
date: '20150409',
|
date: '20150409',
|
||||||
@ -269,7 +267,7 @@ module.exports = [
|
|||||||
content: 'I had a problem with the installation of the php server',
|
content: 'I had a problem with the installation of the php server',
|
||||||
department: {
|
department: {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Environment Setup'
|
name: 'Technical Issues'
|
||||||
},
|
},
|
||||||
date: '20150409',
|
date: '20150409',
|
||||||
file: 'http://www.opensupports.com/some_file.zip',
|
file: 'http://www.opensupports.com/some_file.zip',
|
||||||
@ -284,7 +282,7 @@ module.exports = [
|
|||||||
owner: {
|
owner: {
|
||||||
name: 'Steve Jobs'
|
name: 'Steve Jobs'
|
||||||
},
|
},
|
||||||
actions: [
|
events: [
|
||||||
{
|
{
|
||||||
type: 'ASSIGN',
|
type: 'ASSIGN',
|
||||||
date: '20150409',
|
date: '20150409',
|
||||||
@ -378,6 +376,32 @@ module.exports = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ticketNumber: '445441',
|
||||||
|
title: 'Inscription ACM ICPC',
|
||||||
|
content: 'I had a problem with the installation of the php server',
|
||||||
|
department: {
|
||||||
|
id: 1,
|
||||||
|
name: 'Sales Support'
|
||||||
|
},
|
||||||
|
date: '20160416',
|
||||||
|
file: 'http://www.opensupports.com/some_file.zip',
|
||||||
|
language: 'en',
|
||||||
|
unread: false,
|
||||||
|
closed: false,
|
||||||
|
priority: 'low',
|
||||||
|
author: {
|
||||||
|
id: 12,
|
||||||
|
name: 'Haskell Curry',
|
||||||
|
email: 'haskell@lambda.com'
|
||||||
|
},
|
||||||
|
owner: {
|
||||||
|
id: 15,
|
||||||
|
name: 'Steve Jobs',
|
||||||
|
email: 'steve@jobs.com'
|
||||||
|
},
|
||||||
|
events: []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@ export default {
|
|||||||
'UN_ASSIGN': 'Unassign',
|
'UN_ASSIGN': 'Unassign',
|
||||||
'VIEW_TICKET': 'View Ticket',
|
'VIEW_TICKET': 'View Ticket',
|
||||||
'SELECT_CUSTOM_RESPONSE': 'Select a custom response...',
|
'SELECT_CUSTOM_RESPONSE': 'Select a custom response...',
|
||||||
|
'ALL_DEPARTMENTS': 'All Departments',
|
||||||
|
|
||||||
//VIEW DESCRIPTIONS
|
//VIEW DESCRIPTIONS
|
||||||
'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.',
|
'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.',
|
||||||
|
@ -17,7 +17,7 @@ class AdminDataReducer extends Reducer {
|
|||||||
getTypeHandlers() {
|
getTypeHandlers() {
|
||||||
return {
|
return {
|
||||||
'CUSTOM_RESPONSES_FULFILLED': this.onCustomResponses,
|
'CUSTOM_RESPONSES_FULFILLED': this.onCustomResponses,
|
||||||
'SESSION_CHECKED': this.onSessionChecked
|
'SESSION_CHECKED': this.onSessionChecked,
|
||||||
'MY_TICKETS_FULFILLED': this.onMyTicketsRetrieved,
|
'MY_TICKETS_FULFILLED': this.onMyTicketsRetrieved,
|
||||||
'MY_TICKETS_PENDING': this.onMyTicketsPending
|
'MY_TICKETS_PENDING': this.onMyTicketsPending
|
||||||
};
|
};
|
||||||
@ -44,13 +44,13 @@ class AdminDataReducer extends Reducer {
|
|||||||
onMyTicketsRetrieved(state, payload) {
|
onMyTicketsRetrieved(state, payload) {
|
||||||
return _.extend({}, state, {
|
return _.extend({}, state, {
|
||||||
myTickets: payload.data,
|
myTickets: payload.data,
|
||||||
customResponsesLoaded: true
|
myTicketsLoaded: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMyTicketsPending(state) {
|
onMyTicketsPending(state) {
|
||||||
return _.extennd({}, state, {
|
return _.extend({}, state, {
|
||||||
myTicketsLoaded: true
|
myTicketsLoaded: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user