Adds 'include closed' checkbox to all-tickets view with no integration with the search bar

This commit is contained in:
Maxi Redigonda 2018-10-18 12:02:39 -03:00
parent 73b92bba86
commit c9ef8f1766
3 changed files with 31 additions and 5 deletions

View File

@ -32,12 +32,14 @@ export default {
};
},
retrieveAllTickets(page = 1) {
retrieveAllTickets(page = 1, closed = 0) {
console.log('Closed is:');
console.log(closed);
return {
type: 'ALL_TICKETS',
payload: API.call({
path: '/staff/get-all-tickets',
data: {page}
data: {page, closed}
})
};
},

View File

@ -20,7 +20,8 @@ class AdminPanelAllTickets extends React.Component {
state = {
page: 1,
query: ''
query: '',
closedTicketsShown: false
};
componentDidMount() {
@ -52,10 +53,22 @@ class AdminPanelAllTickets extends React.Component {
ticketPath: '/admin/panel/tickets/view-ticket/',
onPageChange: this.onPageChange.bind(this),
page: this.state.page,
pages: this.props.pages
pages: this.props.pages,
closedTicketsShown: this.state.closedTicketsShown,
onClosedTicketsShownChange: this.onClosedTicketsShownChange.bind(this)
};
}
onClosedTicketsShownChange() {
this.setState(function(state) {
return {
closedTicketsShown: !state.closedTicketsShown
};
}, () => {
this.props.dispatch(AdminDataAction.retrieveAllTickets(this.state.page, this.state.closedTicketsShown * 1));
});
}
onSearch(query) {
this.setState({query, page: 1});

View File

@ -14,6 +14,7 @@ use Respect\Validation\Validator as DataValidator;
* @apiPermission staff1
*
* @apiParam {Number} page The page number.
* @apiParam {Boolean} closed Include closed tickets.
*
* @apiUse NO_PERMISSION
* @apiUse INVALID_PAGE
@ -59,7 +60,8 @@ class GetAllTicketsStaffController extends Controller {
$page = Controller::request('page');
$query = $this->getStaffDepartmentsQueryFilter();
$query .= 'ORDER BY id DESC LIMIT 10 OFFSET ' . (($page-1)*10);
$query .= $this->getClosedFilter();
$query .= ' ORDER BY id DESC LIMIT 10 OFFSET ' . (($page-1)*10);
return Ticket::find($query);
}
@ -81,4 +83,13 @@ class GetAllTicketsStaffController extends Controller {
return $query;
}
private function getClosedFilter() {
$closed = Controller::request('closed')*1;
if ($closed) {
return '';
} else {
return " AND (closed = '0')";
}
}
}