feat(Carrier::Loads): Allow find list of private loads by default
This commit is contained in:
@@ -65,6 +65,7 @@ function getAndFilterList( query ){
|
|||||||
truck_type,
|
truck_type,
|
||||||
state,
|
state,
|
||||||
city,
|
city,
|
||||||
|
privacy,
|
||||||
} = query;
|
} = query;
|
||||||
|
|
||||||
if( company ){ filter_list.push( { company } ); }
|
if( company ){ filter_list.push( { company } ); }
|
||||||
@@ -85,6 +86,7 @@ function getAndFilterList( query ){
|
|||||||
if( destination_warehouse ) { filter_list.push({ destination_warehouse }); }
|
if( destination_warehouse ) { filter_list.push({ destination_warehouse }); }
|
||||||
if( alert_list ) { filter_list.push({ alert_list }); }
|
if( alert_list ) { filter_list.push({ alert_list }); }
|
||||||
if( truck_type ) { filter_list.push({ truck_type }); }
|
if( truck_type ) { filter_list.push({ truck_type }); }
|
||||||
|
if( privacy ) { filter_list.push({ privacy }); }
|
||||||
|
|
||||||
if( state ) {
|
if( state ) {
|
||||||
filter_list.push({
|
filter_list.push({
|
||||||
@@ -158,25 +160,19 @@ async function findLoads( companyId, query ){
|
|||||||
const { $sort, company_name } = query;
|
const { $sort, company_name } = query;
|
||||||
const { page, elements } = getPagination( query );
|
const { page, elements } = getPagination( query );
|
||||||
const andFilterList = getAndFilterList( query ) || [];
|
const andFilterList = getAndFilterList( query ) || [];
|
||||||
|
/// Get list of companyIds that gave authorization to see the loads
|
||||||
const { privacy } = query;
|
const companiesIds = await getCompanyIdListFromGroups( companyId ) || [];
|
||||||
const privacyVal = ( privacy && ( privacy >= 1 || privacy.toLowerCase() === 'true' ))? true: false;
|
|
||||||
|
|
||||||
let filter = {};
|
let filter = {};
|
||||||
|
filter = {
|
||||||
if( privacyVal ){
|
$or : [
|
||||||
const companiesIds = await getCompanyIdListFromGroups( companyId ) || [];
|
{ privacy : false },
|
||||||
filter = {
|
{ privacy : { $exists : false } },
|
||||||
company : { $in : companiesIds },
|
{
|
||||||
privacy: true,
|
company : { $in : companiesIds },
|
||||||
}
|
privacy: true
|
||||||
}else{
|
}
|
||||||
filter = {
|
]
|
||||||
$or : [
|
|
||||||
{ privacy : false },
|
|
||||||
{ privacy : { $exists : false } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( company_name ){
|
if( company_name ){
|
||||||
|
|||||||
Reference in New Issue
Block a user