Skip to content

Commit

Permalink
#149_adding_temporal_filter_Kundenportal finished
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmpp committed Jan 16, 2024
1 parent c66ad56 commit f083a7b
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 15 deletions.
41 changes: 41 additions & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ angular
LITER: addExtendedEnumValue('Liter', gettext('Liter'), gettext('l')),
PORTION: addExtendedEnumValue('Portion', gettext('Portion'), gettext('Por.'))
})
.constant('ZEITRAUM', {
AB_HEUTE: addExtendedEnumValue('D', gettext('Ab Heute'), gettext('Ab Heute')),
NUR_HEUTE: addExtendedEnumValue('d',gettext('Nur Heute'),gettext('Nur Heute')),
DIESE_WOCHE: addExtendedEnumValue('w',gettext('Diese Woche'),gettext('Diese Woche')),
DIESEN_MONAT: addExtendedEnumValue('M',gettext('Diesen Monat'),gettext('Diesen Monat')),
VERGANGENE: addExtendedEnumValue('V',gettext('Vergangene'),gettext('Vergangene'))
})
.constant('USER_ROLES', {
Guest: 'Guest',
Administrator: 'Administrator',
Expand Down Expand Up @@ -138,6 +145,40 @@ angular
}
};
}])
.factory('localeSensitiveComparator', function() {
var isString = function(value) {
return typeof value.value === 'string';
};

var isNumber = function(value) {
return typeof value.value === 'number';
};

var isBoolean = function(value) {
return typeof value.value === 'boolean';
};

return function(v1, v2) {
if (isString(v1) && isString(v2)) {
return v1.value.localeCompare(v2.value);
}

if ((isNumber(v1) && isNumber(v2)) || (isBoolean(v1) && isBoolean(v2))) {
return v1.value - v2.value;
}

if (angular.isUndefined(v1.value) && !angular.isUndefined(v2.value)) {
return -1;
}

if (angular.isUndefined(v2.value) && !angular.isUndefined(v1.value)) {
return 1;
}

// If we don't get strings, numbers or booleans, just compare by index
return v1.index < v2.index ? -1 : 1;
};
})
.factory('convertDateStringsToDatesFct', function() {
return function(input) {
return convertDateStringsToDates(input);
Expand Down
104 changes: 94 additions & 10 deletions app/scripts/arbeitsangebote/list/arbeitsangebotelist.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ angular
'appConfig',
'ooAuthService',
'$location',
'EnumUtil',
'ZEITRAUM',
'msgBus',
'gettextCatalog',
'localeSensitiveComparator',
'lodash',
function(
$scope,
NgTableParams,
Expand All @@ -33,7 +38,12 @@ angular
appConfig,
ooAuthService,
$location,
msgBus
EnumUtil,
ZEITRAUM,
msgBus,
gettextCatalog,
localeSensitiveComparator,
lodash
) {
$scope.arbeitsangebotTableParams = undefined;

Expand All @@ -49,7 +59,8 @@ angular
counts: [],
sorting: {
zeitVon: 'asc'
}
},
filter:{zeitVonF:'D'}
},
{
filterDelay: 0,
Expand All @@ -66,20 +77,67 @@ angular
if (!$scope.entries) {
return;
}
var orderedData = params.sorting ? $filter('orderBy')(
$scope.entries,
params.orderBy(),
false
)
: $scope.entries;
var f = params.filter();
var data = $scope.entries;
if(f.zeitVonF && f.zeitVonF !== null) {
var from, to;
if(f.zeitVonF === 'D') {
from = moment().startOf('day').toDate();
to = new Date(8640000000000000);
} else if(f.zeitVonF === 'd') {
from = moment().startOf('day').toDate();
to = moment().endOf('day').toDate();
} else if(f.zeitVonF === 'w') {
from = moment().startOf('week').toDate();
to = moment().endOf('week').toDate();
} else if(f.zeitVonF === 'M') {
from = moment().startOf('month').toDate();
to = moment().endOf('month').toDate();
} else if(f.zeitVonF === 'V') {
from =new Date(-8640000000000000);
to = moment().startOf('day').toDate();
} else {
from =new Date(-8640000000000000);
to = new Date(8640000000000000);
}
data = $filter('dateRange') (
data,
from,
to,
'zeitVon'
);
}
// use build-in angular filter
var filteredData = $filter('filter')(
data,
$scope.search.query
);
f = params.filter(true);
delete f.zeitVonF;
var orderedData = $filter('filter')(
filteredData,
f
);
orderedData = params.sorting ? $filter('orderBy')(
orderedData,
params.orderBy(),
false,
localeSensitiveComparator
)
: orderedData;

params.total(orderedData.length);
return orderedData;
return orderedData.slice(0,$scope.maxEntries);
}
}
);
}

$scope.search = {
query: '',
filterQuery: ''
};

$scope.loadArbeitsangebotTableParams= function(){
$scope.entries = ArbeitsangeboteModel.query({
g: /^\d+$/.test($scope.geschaeftsjahr)?$scope.geschaeftsjahr:''
Expand All @@ -91,19 +149,45 @@ angular

$scope.loadArbeitsangebotTableParams();

$scope.$watch(
'search.query',
function() {
$scope.search.filterQuery = FilterQueryUtil.transform(
$scope.search.query
);
$scope.loadArbeitsangebotTableParams();
},
true
);

$scope.zeitraumLAsArray = EnumUtil.asArray(ZEITRAUM);
$scope.zeitraumL = [];
angular.forEach(lodash.sortBy($scope.zeitraumLAsArray, function(zr){
return gettextCatalog.getString(zr.label).toLowerCase();
}), function(value, key) {
$scope.zeitraumL.push({
'id': value.id,
'title': gettextCatalog.getString(value.label)
});
});

var existingGJ = $location.search().g;
if (existingGJ) {
$scope.geschaeftsjahr = existingGJ;
}

$scope.hasData = function() {
return $scope.entries !== undefined;
};

$scope.selectGeschaeftsjahr = function(gj) {
if(angular.isDefined(gj)) {
$scope.geschaeftsjahr = gj;
} else {
$scope.geschaeftsjahr = undefined;
}
$scope.initGJ = true;
$scope.maxEntries = 10;
$scope.loadArbeitsangebotTableParams();
return false;
}
Expand Down Expand Up @@ -276,7 +360,7 @@ angular
});

$scope.showMore = function() {
$scope.maxEntries = Number.MAX_SAFE_INTEGER;
$scope.maxEntries = $scope.maxEntries + 10;
if($scope.arbeitsangebotTableParams) {
$scope.arbeitsangebotTableParams.reload();
}
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/arbeitsangebote/list/arbeitsangebotelist.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
</oo-overviewfilter-geschaeftsjahre>
</div>
<div class="col-md-12">
<table ng-show="entries" ng-table="arbeitsangebotTableParams" class="table table-striped" show-filter="false" template-pagination="scripts/ngtable/oo-ngtable-noPaginationTemplate.html">
<table ng-show="entries" ng-table="arbeitsangebotTableParams" class="table table-striped" show-filter="{{showFilter && hasData()}}" template-pagination="scripts/ngtable/oo-ngtable-noPaginationTemplate.html">
<tr ng-repeat="arbeitsangebot in $data">
<td data-title="'Titel'|translate" sortable="'titel'">
<a id="arbeitsangebot{{arbeitsangebot.id}}">{{arbeitsangebot.titel}}</a>
<span ng-if="arbeitsangebot.bezeichnung">&nbsp;<i class="fa fa-info-circle ng-scope" uib-tooltip-html="arbeitsangebot.bezeichnung"></i></span>
</td>
<td data-title="'Zeitpunkt'|translate" sortable="'zeitVon'">
<td data-title="'Zeitpunkt'|translate" sortable="'zeitVon'" filter="{zeitVonF: 'select'}" filter-data="zeitraumL">
<span ng-if="sameDay(arbeitsangebot.zeitBis, arbeitsangebot.zeitVon)">
{{arbeitsangebot.zeitVon | date:'dd.MM.yyyy'}}
{{arbeitsangebot.zeitVon | date:'@ HH:mm'}} - {{arbeitsangebot.zeitBis | date:'HH:mm'}}
Expand All @@ -34,7 +34,7 @@
<td data-title="'Ort'|translate">
{{arbeitsangebot.ort}}
</td>
<td data-title="'#Pers.'|translate" sortable="'anzahlPersonen'">
<td data-title="'#Pers.'|translate">
{{arbeitsangebot.anzahlEingeschriebene}} / <span ng-if="!arbeitsangebot.mehrPersonenOk" translate>max.</span> {{arbeitsangebot.anzahlPersonen}}<span ng-if="arbeitsangebot.mehrPersonenOk" translate>+</span>
</td>
<td data-title="'Kategorien'|translate">
Expand Down
19 changes: 17 additions & 2 deletions app/scripts/filters/oo-currency.filter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
'use strict';

angular.module('openolitor-kundenportal').filter('ooCurrency', ['$rootScope','$filter', 'gettextCatalog','WAEHRUNG','EnumUtil','lodash',
function($rootScope, $filter, gettextCatalog, WAEHRUNG, EnumUtil, lodash) {
angular
.module('openolitor-kundenportal')
.filter('ooCurrency', [
'$rootScope',
'$filter',
'gettextCatalog',
'WAEHRUNG',
'EnumUtil',
'lodash',
function(
$rootScope,
$filter,
gettextCatalog,
WAEHRUNG,
EnumUtil,
lodash
) {
return function(value, showTag, currency) {
var waehrungen = EnumUtil.asArray(WAEHRUNG);
var projektCurrency = $rootScope.projekt.waehrung;
Expand Down
33 changes: 33 additions & 0 deletions app/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,36 @@ tr.error {
background-color:#fff;
border-color:#ccc;
}
.btn-default:hover {
color:#333;
background-color:#fff;
border-color:#ccc;
}
.btn-default:focus {
color:#333;
background-color:#fff;
border-color:#ccc;
}
.btn-default:active{
color:#333;
background-color:#fff;
border-color:#ccc;
}
.btn-default:active:hover{
color:#333;
background-color:#fff;
border-color:#ccc;
}
.open > .dropdown-toggle.btn-default {
color:#333;
background-color:#fff;
border-color:#ccc;
}
.open > .dropdown-toggle.btn-default:hover {
color:#333;
background-color:#fff;
border-color:#ccc;
}
.dropdown-menu > li > a {
color:#333;
}

0 comments on commit f083a7b

Please sign in to comment.