diff --git a/client/src/actions/.admin-data-actions.js.swp b/client/src/actions/.admin-data-actions.js.swp new file mode 100644 index 00000000..d8617a8d Binary files /dev/null and b/client/src/actions/.admin-data-actions.js.swp differ diff --git a/client/src/actions/admin-data-actions.js b/client/src/actions/admin-data-actions.js index 94c9cde5..24f2cbb6 100644 --- a/client/src/actions/admin-data-actions.js +++ b/client/src/actions/admin-data-actions.js @@ -12,12 +12,12 @@ export default { }; }, - retrieveMyTickets() { + retrieveMyTickets(closed = 0) { return { type: 'MY_TICKETS', payload: API.call({ path: '/staff/get-tickets', - data: {} + data: {closed} }) }; }, diff --git a/client/src/app/admin/panel/tickets/.admin-panel-my-tickets.js.swp b/client/src/app/admin/panel/tickets/.admin-panel-my-tickets.js.swp new file mode 100644 index 00000000..143fd996 Binary files /dev/null and b/client/src/app/admin/panel/tickets/.admin-panel-my-tickets.js.swp differ diff --git a/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js b/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js index 82d18344..80ec2d4d 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js +++ b/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js @@ -44,17 +44,11 @@ class AdminPanelMyTickets extends React.Component { ); } - filterOpenedTickets(tickets){ - return _.filter(tickets, (ticket) => { - return !ticket.closed - }); - } - getProps() { return { userId: this.props.userId, departments: this.props.departments, - tickets: this.state.closedTicketsShown ? this.props.tickets : this.filterOpenedTickets(this.props.tickets), + tickets: this.props.tickets, type: 'secondary', loading: this.props.loading, ticketPath: '/admin/panel/tickets/view-ticket/', @@ -68,6 +62,8 @@ class AdminPanelMyTickets extends React.Component { return { closedTicketsShown: !state.closedTicketsShown }; + }, () => { + this.props.dispatch(AdminDataAction.retrieveMyTickets(this.state.closedTicketsShown * 1)); }); } diff --git a/server/controllers/staff/.get-all-tickets.php.swp b/server/controllers/staff/.get-all-tickets.php.swp new file mode 100644 index 00000000..707340d3 Binary files /dev/null and b/server/controllers/staff/.get-all-tickets.php.swp differ diff --git a/server/controllers/staff/.get-tickets.php.swp b/server/controllers/staff/.get-tickets.php.swp new file mode 100644 index 00000000..c6af777c Binary files /dev/null and b/server/controllers/staff/.get-tickets.php.swp differ diff --git a/server/controllers/staff/get-tickets.php b/server/controllers/staff/get-tickets.php index 1f768042..137cb7eb 100755 --- a/server/controllers/staff/get-tickets.php +++ b/server/controllers/staff/get-tickets.php @@ -13,6 +13,8 @@ use Respect\Validation\Validator as DataValidator; * * @apiPermission staff1 * + * @apiParam {bool} closed Include closed tickets in the response. + * * @apiUse NO_PERMISSION * * @apiSuccess {[Ticket](#api-Data_Structures-ObjectTicket)[]} data Array of tickets assigned to the staff @@ -32,6 +34,11 @@ class GetTicketStaffController extends Controller { public function handler() { $user = Controller::getLoggedUser(); - Response::respondSuccess($user->sharedTicketList->toArray()); + $closed = Controller::request('closed'); + if ($closed) { + Response::respondSuccess($user->sharedTicketList->toArray()); + } else { + Response::respondSuccess($user->withCondition('closed = ?', ['0'])->sharedTicketList->toArray()); + } } -} \ No newline at end of file +} diff --git a/server/models/DataStore.php b/server/models/DataStore.php index 43ec9d22..d4310fdc 100755 --- a/server/models/DataStore.php +++ b/server/models/DataStore.php @@ -150,6 +150,10 @@ abstract class DataStore { } } + public function withCondition($condition, $values) { + return new static($this->_bean->withCondition($condition, $values)); + } + private function updateBeanProp($key, $value) { if ($value instanceof DataStoreList) { $this->_bean[$key] = $value->toBeanList();