Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Add postcode and distance to webshop providers page in filter #2072

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ const ProvidersComponent = function(
) {
const $ctrl = this;

$ctrl.showmap = false;
$ctrl.showMap = false;
$ctrl.officesShown = [];
$ctrl.countFiltersApplied = 0;

$ctrl.distances = [
{ id: null, name: 'Overal' },
{ id: 3, name: '< 3 km' },
{ id: 5, name: '< 5 km' },
{ id: 10, name: '< 10 km' },
{ id: 15, name: '< 15 km' },
{ id: 25, name: '< 25 km' },
{ id: 50, name: '< 50 km' },
{ id: 75, name: '< 75 km' }
];

$ctrl.filtersList = [
'q', 'fund', 'businessType',
];
Expand Down Expand Up @@ -37,8 +48,10 @@ const ProvidersComponent = function(
$ctrl.buildQuery = (values) => ({
q: values.q,
page: values.page,
fund_id: values.fund ? values.fund.id : null,
business_type_id: values.businessType ? values.businessType.id : null,
fund_id: values.fund_id || null,
business_type_id: values.business_type_id || null,
postcode: values.postcode || '',
distance: values.distance || null,
});

$ctrl.onPageChange = (values) => {
Expand Down Expand Up @@ -83,6 +96,8 @@ const ProvidersComponent = function(
q: query.q || '',
page: query.page,
fund_id: query.fund_id,
postcode: query.postcode,
distance: query.distance,
business_type_id: query.business_type_id,
show_map: $ctrl.showMap,
show_menu: $ctrl.showModalFilters,
Expand All @@ -93,36 +108,31 @@ const ProvidersComponent = function(
let count = 0;

$ctrl.form.values.q && count++;
$ctrl.form.values.fund && $ctrl.form.values.fund.id && count++;
$ctrl.form.values.businessType && $ctrl.form.values.businessType.id && count++;
$ctrl.form.values.fund_id && count++;
$ctrl.form.values.business_type_id && count++;
$ctrl.countFiltersApplied = count;
};

$ctrl.$onInit = () => {
$ctrl.showMap = $stateParams.show_map;
$ctrl.businessTypes.unshift({
id: null,
name: 'Alle typen',
});

$ctrl.funds.unshift({
id: null,
name: 'Alle tegoeden',
});

const fund = $ctrl.funds.filter(fund => {
return fund.id == $stateParams.fund_id;
})[0] || $ctrl.funds[0];

const businessType = $ctrl.businessTypes.filter(businessType => {
return businessType.id == $stateParams.business_type_id;
})[0] || $ctrl.businessTypes[0];
$ctrl.businessTypes.unshift({
id: null,
name: 'Alle typen',
});

$ctrl.showModalFilters = $stateParams.show_menu;
$ctrl.form = FormBuilderService.build({
q: $stateParams.q || '',
fund: fund,
businessType: businessType,
q: $stateParams.q,
fund_id: $stateParams.fund_id || $ctrl.funds[0].id,
business_type_id: $stateParams.business_type_id || $ctrl.businessTypes[0].id,
postcode: $stateParams.postcode,
distance: $stateParams.distance,
});

if ($ctrl.showMap) {
Expand Down
43 changes: 12 additions & 31 deletions src/sources/forus-webshop/js/angular-1/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,41 +336,20 @@ module.exports = ['$stateProvider', '$locationProvider', 'appConfigs', function(

$stateProvider.state({
name: "providers",
url: "/providers?{page:int}&{q:string}&{fund_id:int}&{business_type_id:int}&{show_map:bool}&{show_menu:bool}",
url: "/providers?{page:int}&{q:string}&{fund_id:int}&{business_type_id:int}&{show_map:bool}&{show_menu:bool}&{distance:int}&{postcode:string}",
component: "providersComponent",
params: {
q: {
dynamic: true,
value: "",
squash: true,
},
page: {
dynamic: true,
value: 1,
squash: true,
},
fund_id: {
value: null,
squash: true
},
business_type_id: {
value: null,
squash: true
},
show_map: {
value: false,
squash: true
},
show_menu: {
dynamic: true,
value: false,
squash: true
},
q: { dynamic: true, value: "", squash: true },
page: { dynamic: true, value: 1, squash: true },
fund_id: { value: null, squash: true },
show_map: { value: false, squash: true },
distance: { dynamic: true, value: null, squash: true },
postcode: { dynamic: true, value: '', squash: true },
show_menu: { dynamic: true, value: false, squash: true },
business_type_id: { value: null, squash: true },
},
resolve: {
funds: ['FundService', (
FundService
) => repackResponse(FundService.list())],
funds: ['FundService', (FundService) => repackResponse(FundService.list())],
businessTypes: ['BusinessTypeService', (
BusinessTypeService
) => repackResponse(BusinessTypeService.list({
Expand All @@ -383,6 +362,8 @@ module.exports = ['$stateProvider', '$locationProvider', 'appConfigs', function(
q: $transition$.params().q,
page: $transition$.params().page,
fund_id: $transition$.params().fund_id,
distance: $transition$.params().distance,
postcode: $transition$.params().postcode,
business_type_id: $transition$.params().business_type_id,
}))]
}
Expand Down
38 changes: 32 additions & 6 deletions src/sources/forus-webshop/pug/tpl/pages/providers.pug
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,50 @@ block content
placeholder="Zoek aanbieder"
type="search"
aria-label="Zoeken")
.form-error(ng-repeat="error in $ctrl.form.errors.q" ng-bind="error")

.form-group
label.form-label(for="select_provider_type") Type aanbieder
label.form-label(for="business_type_id") Type aanbieder
select-control(
prop="id"
autoclear="true"
ng-model="$ctrl.form.values.businessType"
ng-model="$ctrl.form.values.business_type_id"
options="$ctrl.businessTypes"
placeholder="Selecteer type..."
id="select_provider_type")
id="business_type_id")
.form-error(ng-repeat="error in $ctrl.form.errors.business_type_id" ng-bind="error")

.form-group
label.form-label(for="select_fund") Tegoeden
label.form-label(for="fund_id") Tegoeden
select-control(
prop="id"
autoclear="true"
ng-model="$ctrl.form.values.fund"
options="$ctrl.funds"
placeholder="Selecteer tegoed..."
id="select_fund")
id="fund_id")
.form-error(ng-repeat="error in $ctrl.form.errors.fund_id" ng-bind="error")

.row
.col.col-md-6: .form-group
label.form-label(for="postcode") Postcode
input.form-control(
ng-model="$ctrl.form.values.postcode"
placeholder="Postcode"
type="text"
aria-label="Postcode...")
.form-error(ng-repeat="error in $ctrl.form.errors.postcode" ng-bind="error")

.col.col-md-6: .form-group
label.form-label(for="distance") Afstand
select-control(
prop="id"
autoclear="true"
ng-model="$ctrl.form.values.distance"
options="$ctrl.distances"
placeholder="Afstand..."
id="distance")
.form-error(ng-repeat="error in $ctrl.form.errors.distance" ng-bind="error")

+search_results('$ctrl.providers.meta.total', '$ctrl.showMap')

Expand All @@ -72,7 +98,7 @@ block content
em.mdi.mdi-map-marker-radius.icon-start
| Kaart

.block.block-organizations(ng-if="!$ctrl.showMap" id="providers_list")
.block.block-organizations(ng-if="!$ctrl.showMap" ng-show="$ctrl.providers.data.length > 0" id="providers_list")
provider-list-item(
ng-repeat="provider in $ctrl.providers.data"
provider="provider")
Expand Down
Loading