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

View File

@ -76,7 +76,7 @@ class AdminPanelMenu extends React.Component {
getGroupItemIndex() {
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});
}
@ -90,7 +90,23 @@ class AdminPanelMenu extends React.Component {
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() {
const customLists = this.getCustomlists();
return this.getItemsByFilteredByLevel([
{
groupName: i18n('DASHBOARD'),
@ -135,7 +151,8 @@ class AdminPanelMenu extends React.Component {
name: i18n('CUSTOM_RESPONSES'),
path: '/admin/panel/tickets/custom-responses',
level: 2
}
},
...customLists
])
},
{

View File

@ -14,13 +14,15 @@ class AdminPanelSearchTickets extends React.Component {
return (
<div className="admin-panel-all-tickets">
<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>
);
}
getFilters() {
let customList = window.customTicketList[this.props.location.query.custom*1] ? window.customTicketList[this.props.location.query.custom*1] : null
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">
<body>
<div id="app"></div>
<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>
</body>

View File

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