add support for custom ticket lists

This commit is contained in:
Guillermo 2019-12-19 17:06:12 -03:00
parent c8634d457c
commit 0bd099d05a
5 changed files with 29 additions and 6 deletions

View File

@ -22,6 +22,12 @@ class TicketQueryList extends React.Component {
this.getTickets(); this.getTickets();
} }
componentDidUpdate(prevProps) {
if (this.props.customList.title !== prevProps.customList.title) {
this.getTickets();
}
}
render() { render() {
return ( return (
<div> <div>
@ -38,7 +44,7 @@ class TicketQueryList extends React.Component {
path: '/ticket/search', path: '/ticket/search',
data: { data: {
page : this.state.page, page : this.state.page,
...this.props.filters ...this.props.customList.filters
} }
}).then((result) => { }).then((result) => {
this.setState({ this.setState({

View File

@ -76,7 +76,7 @@ class AdminPanelMenu extends React.Component {
getGroupItemIndex() { getGroupItemIndex() {
const group = this.getRoutes()[this.getGroupIndex()]; const group = this.getRoutes()[this.getGroupIndex()];
const pathname = this.props.location.pathname; const pathname = this.props.location.pathname + this.props.location.search;
return _.findIndex(group.items, {path: pathname}); return _.findIndex(group.items, {path: pathname});
} }
@ -90,7 +90,23 @@ class AdminPanelMenu extends React.Component {
return (groupIndex === -1) ? 0 : groupIndex; return (groupIndex === -1) ? 0 : groupIndex;
} }
getCustomlists() {
if(window.customTicketList){
return window.customTicketList.map((item, index) => {
return {
name: item.title,
path: '/admin/panel/tickets/search-tickets?custom=' + index,
level: 1
}
})
} else {
return [];
}
}
getRoutes() { getRoutes() {
const customLists = this.getCustomlists();
return this.getItemsByFilteredByLevel([ return this.getItemsByFilteredByLevel([
{ {
groupName: i18n('DASHBOARD'), groupName: i18n('DASHBOARD'),
@ -135,7 +151,8 @@ class AdminPanelMenu extends React.Component {
name: i18n('CUSTOM_RESPONSES'), name: i18n('CUSTOM_RESPONSES'),
path: '/admin/panel/tickets/custom-responses', path: '/admin/panel/tickets/custom-responses',
level: 2 level: 2
} },
...customLists
]) ])
}, },
{ {

View File

@ -14,13 +14,15 @@ class AdminPanelSearchTickets extends React.Component {
return ( return (
<div className="admin-panel-all-tickets"> <div className="admin-panel-all-tickets">
<Header title={i18n('ALL_TICKETS')} description={i18n('SEARCH_TICKETS_DESCRIPTION')} /> <Header title={i18n('ALL_TICKETS')} description={i18n('SEARCH_TICKETS_DESCRIPTION')} />
{(this.props.error) ? <Message type="error">{i18n('ERROR_RETRIEVING_TICKETS')}</Message> : <TicketQueryList filters ={this.getFilters()}/>} {(this.props.error) ? <Message type="error">{i18n('ERROR_RETRIEVING_TICKETS')}</Message> : <TicketQueryList customList ={this.getFilters()}/>}
</div> </div>
); );
} }
getFilters() { getFilters() {
let customList = window.customTicketList[this.props.location.query.custom*1] ? window.customTicketList[this.props.location.query.custom*1] : null
return { return {
...customList
}; };
} }
} }

View File

@ -12,7 +12,6 @@
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<body> <body>
<div id="app"></div> <div id="app"></div>
<script src="/config.js"></script> <script src="/config.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=String.prototype.startsWith,Array.from,Array.prototype.fill,Array.prototype.keys,Array.prototype.find,Array.prototype.findIndex,Array.prototype.includes,String.prototype.repeat,Number.isInteger,Promise&flags=gated"></script> <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=String.prototype.startsWith,Array.from,Array.prototype.fill,Array.prototype.keys,Array.prototype.find,Array.prototype.findIndex,Array.prototype.includes,String.prototype.repeat,Number.isInteger,Promise&flags=gated"></script>
</body> </body>

View File

@ -13,7 +13,6 @@ describe'/staff/get-all' do
result['data'][0]['departments'] = result['data'][0]['departments'].sort_by do |department| result['data'][0]['departments'] = result['data'][0]['departments'].sort_by do |department|
department['id'].to_i department['id'].to_i
end end
puts result['data']
(result['data'][0]['name']).should.equal('Emilia Clarke') (result['data'][0]['name']).should.equal('Emilia Clarke')
(result['data'][0]['email']).should.equal('staff@opensupports.com') (result['data'][0]['email']).should.equal('staff@opensupports.com')