mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 00:04:31 +02:00
Moves filtering functionality to backend and adapts frontend
This commit is contained in:
parent
a2d3908c4d
commit
73b92bba86
BIN
client/src/actions/.admin-data-actions.js.swp
Normal file
BIN
client/src/actions/.admin-data-actions.js.swp
Normal file
Binary file not shown.
@ -12,12 +12,12 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
retrieveMyTickets() {
|
retrieveMyTickets(closed = 0) {
|
||||||
return {
|
return {
|
||||||
type: 'MY_TICKETS',
|
type: 'MY_TICKETS',
|
||||||
payload: API.call({
|
payload: API.call({
|
||||||
path: '/staff/get-tickets',
|
path: '/staff/get-tickets',
|
||||||
data: {}
|
data: {closed}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
Binary file not shown.
@ -44,17 +44,11 @@ class AdminPanelMyTickets extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterOpenedTickets(tickets){
|
|
||||||
return _.filter(tickets, (ticket) => {
|
|
||||||
return !ticket.closed
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getProps() {
|
getProps() {
|
||||||
return {
|
return {
|
||||||
userId: this.props.userId,
|
userId: this.props.userId,
|
||||||
departments: this.props.departments,
|
departments: this.props.departments,
|
||||||
tickets: this.state.closedTicketsShown ? this.props.tickets : this.filterOpenedTickets(this.props.tickets),
|
tickets: this.props.tickets,
|
||||||
type: 'secondary',
|
type: 'secondary',
|
||||||
loading: this.props.loading,
|
loading: this.props.loading,
|
||||||
ticketPath: '/admin/panel/tickets/view-ticket/',
|
ticketPath: '/admin/panel/tickets/view-ticket/',
|
||||||
@ -68,6 +62,8 @@ class AdminPanelMyTickets extends React.Component {
|
|||||||
return {
|
return {
|
||||||
closedTicketsShown: !state.closedTicketsShown
|
closedTicketsShown: !state.closedTicketsShown
|
||||||
};
|
};
|
||||||
|
}, () => {
|
||||||
|
this.props.dispatch(AdminDataAction.retrieveMyTickets(this.state.closedTicketsShown * 1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
server/controllers/staff/.get-all-tickets.php.swp
Normal file
BIN
server/controllers/staff/.get-all-tickets.php.swp
Normal file
Binary file not shown.
BIN
server/controllers/staff/.get-tickets.php.swp
Normal file
BIN
server/controllers/staff/.get-tickets.php.swp
Normal file
Binary file not shown.
@ -13,6 +13,8 @@ use Respect\Validation\Validator as DataValidator;
|
|||||||
*
|
*
|
||||||
* @apiPermission staff1
|
* @apiPermission staff1
|
||||||
*
|
*
|
||||||
|
* @apiParam {bool} closed Include closed tickets in the response.
|
||||||
|
*
|
||||||
* @apiUse NO_PERMISSION
|
* @apiUse NO_PERMISSION
|
||||||
*
|
*
|
||||||
* @apiSuccess {[Ticket](#api-Data_Structures-ObjectTicket)[]} data Array of tickets assigned to the staff
|
* @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() {
|
public function handler() {
|
||||||
$user = Controller::getLoggedUser();
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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) {
|
private function updateBeanProp($key, $value) {
|
||||||
if ($value instanceof DataStoreList) {
|
if ($value instanceof DataStoreList) {
|
||||||
$this->_bean[$key] = $value->toBeanList();
|
$this->_bean[$key] = $value->toBeanList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user