Merge pull request #704 from guillegiu/master

Update Lodash and fix minor bugs
This commit is contained in:
Guillermo Giuliana 2020-01-23 20:37:45 -03:00 committed by GitHub
commit 7ccadadb81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 13 deletions

View File

@ -73,7 +73,7 @@
"html-to-text": "^4.0.0",
"keycode": "^2.1.4",
"localStorage": "^1.0.3",
"lodash": "^3.10.0",
"lodash": "^4.17.15",
"messageformat": "^0.2.2",
"qs": "^6.5.2",
"quill-image-resize-module-react": "^3.0.0",

View File

@ -671,14 +671,14 @@ class TicketViewer extends React.Component {
{content: 'None', id: 0}
];
if(_.any(userDepartments, {id: ticketDepartmentId})) {
if(_.some(userDepartments, {id: ticketDepartmentId})) {
staffAssignmentItems.push({content: i18n('ASSIGN_TO_ME'), id: userId});
}
staffAssignmentItems = staffAssignmentItems.concat(
_.map(
_.filter(staffMembers, ({id, departments}) => {
return (id != userId) && _.any(departments, {id: ticketDepartmentId});
return (id != userId) && _.some(departments, {id: ticketDepartmentId});
}),
({id, name}) => ({content: name, id})
)

View File

@ -35,7 +35,7 @@ class EditTitleController extends Controller {
'permission' => 'user',
'requestData' => [
'title' => [
'validation' => DataValidator::length(1, 200),
'validation' => DataValidator::notBlank()->length(1, 200),
'error' => ERRORS::INVALID_TITLE
],
'ticketNumber' => [
@ -49,7 +49,7 @@ class EditTitleController extends Controller {
'permission' => 'any',
'requestData' => [
'title' => [
'validation' => DataValidator::length(1, 200),
'validation' => DataValidator::notBlank()->length(1, 200),
'error' => ERRORS::INVALID_TITLE
],
'ticketNumber' => [

View File

@ -112,6 +112,7 @@ class SearchController extends Controller {
'orderBy' => json_decode(Controller::request('orderBy'),true),
'page' => Controller::request('page'),
'allowedDepartments' => Controller::getLoggedUser()->sharedDepartmentList->toArray(),
'staffId' => Controller::getLoggedUser()->id
];
@ -172,7 +173,9 @@ class SearchController extends Controller {
if(array_key_exists('unreadStaff',$inputs)) $this->setSeenFilter($inputs['unreadStaff'], $filters);
if(array_key_exists('priority',$inputs)) $this->setPriorityFilter($inputs['priority'], $filters);
if(array_key_exists('dateRange',$inputs)) $this->setDateFilter($inputs['dateRange'], $filters);
if(array_key_exists('departments',$inputs)) $this->setDepartmentFilter($inputs['departments'],$inputs['allowedDepartments'], $filters);
if(array_key_exists('departments',$inputs) && array_key_exists('allowedDepartments',$inputs) && array_key_exists('staffId',$inputs)){
$this->setDepartmentFilter($inputs['departments'],$inputs['allowedDepartments'], $inputs['staffId'], $filters);
}
if(array_key_exists('authors',$inputs)) $this->setAuthorFilter($inputs['authors'], $filters);
if(array_key_exists('query',$inputs)) $this->setStringFilter($inputs['query'], $filters);
if($filters != "") $filters = " WHERE " . $filters;
@ -207,7 +210,7 @@ class SearchController extends Controller {
}
}
private function setPriorityFilter($priorities, &$filters){
if($priorities !== null){
if($priorities){
$first = TRUE;
if ($filters != "") $filters .= " and ";
foreach(array_unique($priorities) as $priority) {
@ -244,8 +247,7 @@ class SearchController extends Controller {
}
}
private function setDepartmentFilter($departments,$allowedDepartments, &$filters){
$idStaff = Controller::getLoggedUser()->id ;
private function setDepartmentFilter($departments,$allowedDepartments, $idStaff, &$filters){
if ($filters != "") $filters .= " and ";
$validDepartments = $this->generateValidDepartmentList($departments, $allowedDepartments);
@ -265,7 +267,6 @@ class SearchController extends Controller {
$filters .= "(";
}
$filters .= "ticket.author_staff_id = " . $idStaff . ")";
}
private function setAuthorFilter($authors, &$filters){

View File

@ -173,6 +173,7 @@ class SearchControllerTest extends TestCase {
$this->assertEquals(
$this->searchController->getSQLQuery([
'departments' => null,
'staffId' => 1,
'allowedDepartments' => [
[
'id' => 2
@ -185,12 +186,13 @@ class SearchControllerTest extends TestCase {
]
]
]),
'FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE ( ticket.department_id = 2 or ticket.department_id = 1 or ticket.department_id = 3) GROUP BY ticket.id'
'FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE ( ticket.department_id = 2 or ticket.department_id = 1 or ticket.department_id = 3 or ticket.author_staff_id = 1) GROUP BY ticket.id'
);
$this->assertEquals(
$this->searchController->getSQLQuery([
'departments' => [1],
'staffId' => 1,
'allowedDepartments' => [
[
'id' => 2
@ -203,12 +205,13 @@ class SearchControllerTest extends TestCase {
]
]
]),
'FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE ( ticket.department_id = 1) GROUP BY ticket.id'
'FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE ( ticket.department_id = 1 or ticket.author_staff_id = 1) GROUP BY ticket.id'
);
$this->assertEquals(
$this->searchController->getSQLQuery([
'departments' => [1,2,3],
'staffId' => 1,
'allowedDepartments' => [
[
'id' => 2
@ -221,7 +224,7 @@ class SearchControllerTest extends TestCase {
]
]
]),
'FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE ( ticket.department_id = 1 or ticket.department_id = 2 or ticket.department_id = 3) GROUP BY ticket.id'
'FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE ( ticket.department_id = 1 or ticket.department_id = 2 or ticket.department_id = 3 or ticket.author_staff_id = 1) GROUP BY ticket.id'
);
}