-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#149_adding_temporal_filter_Kundenportal Adding overview filter gesch…
…aeftsjahre
- Loading branch information
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
app/scripts/util/overviewfiltergeschaeftsjahre/overviewfiltergeschaeftsjahre.controller.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="geschaeftsjahre-dropdown" ng-show="showFilter"> | ||
<span ng-if="selectedGJ != 'Alle' && selectedGJ.jahr != 'Alle'" translate>Geschäftsjahr</span> | ||
<span ng-if="selectedGJ === 'Alle' || selectedGJ.jahr === 'Alle'" translate>Geschäftsjahre</span> | ||
<oo-dropdown | ||
dropdown-id="geschaeftsjahre" | ||
display-style="uib-dropdown" | ||
values="geschaeftsjahre" | ||
display-function="displayGeschaeftsjahre" | ||
selected-function="selectGJ" | ||
selected-prop="jahr" | ||
selected-value="selectedGJ" | ||
disabled="disabled"> | ||
</oo-dropdown> | ||
</div> |
95 changes: 95 additions & 0 deletions
95
app/scripts/util/overviewfiltergeschaeftsjahre/overviewfiltergeschaeftsjahre.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
'use strict'; | ||
|
||
/** | ||
*/ | ||
angular.module('openolitor-kundenportal') | ||
.controller('OverviewfilterGeschaeftsjahreController', ['$scope', '$rootScope', | ||
'ProjektModel', 'moment', '$cookies', '$location', | ||
function($scope, $rootScope, ProjektModel, moment, $cookies, $location) { | ||
|
||
const ALLE = {jahr:'Alle'}; | ||
|
||
$scope.showFilter = true; | ||
|
||
var gjDisabled = $location.search().gjDisabled; | ||
if (gjDisabled) { | ||
$scope.showFilter = false; | ||
} | ||
|
||
var storeSelected = function(selected) { | ||
var expireDate = new Date(); | ||
expireDate.setDate(expireDate.getDate() + 3650); | ||
$cookies.put('gjFilterSelected', selected, {'expires' : expireDate}); | ||
}; | ||
|
||
var fetchSelected = function() { | ||
return $cookies.get('gjFilterSelected'); | ||
}; | ||
|
||
ProjektModel.query({}, function(result) { | ||
$scope.projekt = result; | ||
ProjektModel.geschaeftsjahre({id: result.id}, function(gjL) { | ||
$scope.geschaeftsjahre = gjL.reverse(); | ||
$scope.geschaeftsjahre.unshift(ALLE); | ||
if(angular.isUndefined($scope.select)) { | ||
//if no preselected value, check if | ||
if(angular.isDefined($scope.selectCurrent) && false && !angular.isDefined(fetchSelected())) { | ||
var thisYearsGJstart = moment().date($scope.projekt.geschaeftsjahrTag).month($scope.projekt.geschaeftsjahrMonat - 1); | ||
if(moment().isBefore(thisYearsGJstart)) { | ||
$scope.select = moment().year() - 1; | ||
} else { | ||
$scope.select = moment().year(); | ||
} | ||
} else if(angular.isDefined($scope.selectCurrent)) { | ||
var stored = fetchSelected(); | ||
if(angular.isDefined(stored)) { | ||
$scope.select = stored; | ||
} | ||
} | ||
} | ||
|
||
if(angular.isDefined($scope.select)) { | ||
$scope.geschaeftsjahre.forEach((item) => { | ||
if($scope.select == item.jahr) { | ||
$scope.selectGJ($scope.select, true); | ||
} | ||
}); | ||
} else { | ||
//by default 'ALLE' is selected | ||
$scope.selectGJ(ALLE.jahr, true); | ||
} | ||
}); | ||
}); | ||
|
||
$scope.displayGeschaeftsjahre = function(gj) { | ||
var von = moment(gj.jahr + '-' + gj.monat + '-' + gj.tag); | ||
var bis = moment(von); | ||
bis.add(1, 'year'); | ||
bis.add(-1, 'day'); | ||
if(angular.isUndefined(gj.tag)) { | ||
return gj.jahr; | ||
} else { | ||
return von.format('L') + ' - ' + bis.format('L'); | ||
} | ||
}; | ||
|
||
$scope.selectGJ = function(gj, init) { | ||
if(!$scope.showFilter) { | ||
$scope.selectedFunct()(); | ||
return; | ||
} | ||
if(angular.isUndefined(init)) { | ||
init = false; | ||
} | ||
$scope.selectedGJ = gj; | ||
if(gj && gj != ALLE.jahr && (angular.isUndefined(gj.jahr) || gj.jahr != ALLE.jahr)) { | ||
$scope.selectedFunct()((gj.jahr) ? gj.jahr : gj); | ||
} else { | ||
$scope.selectedFunct()(); | ||
} | ||
if(angular.isDefined($scope.selectCurrent) || !init) { | ||
storeSelected(angular.isDefined($scope.selectedGJ.jahr) ? $scope.selectedGJ.jahr : $scope.selectedGJ); | ||
} | ||
}; | ||
} | ||
]); |
19 changes: 19 additions & 0 deletions
19
app/scripts/util/overviewfiltergeschaeftsjahre/overviewfiltergeschaeftsjahre.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
angular.module('openolitor-kundenportal').directive('ooOverviewfilterGeschaeftsjahre', [ | ||
function() { | ||
return { | ||
restrict: 'E', | ||
replace: true, | ||
scope: { | ||
selectedFunct: '&', | ||
select: '=?', | ||
disabled: '=', | ||
selectCurrent: '=?' | ||
}, | ||
transclude: true, | ||
templateUrl: 'scripts/util/overviewfiltergeschaeftsjahre/overviewfiltergeschaeftsjahre.controller.html', | ||
controller: 'OverviewfilterGeschaeftsjahreController' | ||
}; | ||
} | ||
]); |