Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/oo#161 create delivery pickup date in screen #682

Merged
merged 2 commits into from
Jun 10, 2024
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
24 changes: 18 additions & 6 deletions app/scripts/abotypen/detail/lieferungen/lieferungen.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ angular.module('openolitor-admin')
return $scope.lieferungen !== undefined;
};


$scope.addLieferung = function() {
if ($scope.datumExistiert($scope.template.datum)) {
return;
Expand All @@ -38,7 +39,12 @@ angular.module('openolitor-admin')
vertriebId: $scope.selectedVertrieb.id
});
newModel.$save();
$scope.template.creating = $scope.template.creating + 1;
var newModel = {
daten: [$scope.template.datum],
abotypId: parseInt($routeParams.id),
vertriebId: $scope.selectedVertrieb.id
};
$scope.setupFlagToKnowIfCreating(newModel,[$scope.template.datum]);
$scope.template.datum = undefined;
$scope.status.open = false;
};
Expand Down Expand Up @@ -87,6 +93,14 @@ angular.module('openolitor-admin')
});
}

$scope.setupFlagToKnowIfCreating = function(lieferungenModel,uniqueLieferdaten){
$http.get(appConfig.get().API_URL +
'abotypen/' + lieferungenModel.abotypId + '/vertriebe/' + lieferungenModel.vertriebId + '/alleLieferungen', lieferungenModel).then(function(result) {
var allLieferungenDates = lodash.map(result.data, function(l){return l.datum.getFullYear() + '' + ("0" + (l.datum.getMonth() + 1 )).slice(-2) + '' + ("0" + l.datum.getDate()).slice(-2)});
var dateFormatUniqueLieferdaten = lodash.map(uniqueLieferdaten, function(d){return d.getFullYear() + '' + ("0" + (d.getMonth() + 1 )).slice(-2) + '' + ("0" + d.getDate()).slice(-2)})
$scope.template.creating = $scope.template.creating + dateFormatUniqueLieferdaten.length - lodash.intersectionWith(dateFormatUniqueLieferdaten, allLieferungenDates,lodash.isEqual).length;
});
};

$scope.generateLieferungen = function(lieferdaten) {
var uniqueLieferdaten = lodash.filter(lieferdaten, function(datum) {
Expand All @@ -100,11 +114,9 @@ angular.module('openolitor-admin')
$http.post(appConfig.get().API_URL +
'abotypen/' + newModel.abotypId + '/vertriebe/' + newModel.vertriebId +
'/lieferungen/aktionen/generieren',
newModel).then(function() {
$scope.template.creating = $scope.template.creating +
lieferdaten
.length;
});
newModel).then(function(){
$scope.setupFlagToKnowIfCreating(newModel,uniqueLieferdaten);
});
};

$scope.canGenerateLieferungen = function() {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/abotypen/detail/lieferungen/lieferungen.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h3 class="panel-title"><span translate>Lieferungen</span>
<span class="pull-right" ng-show="showLoading()"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i></span>
<span class="pull-right" ng-show="loading || template.creating > 0"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i></span>
</h3>
</div>
<div class="panel-body">
Expand All @@ -17,7 +17,7 @@ <h3 class="panel-title"><span translate>Lieferungen</span>
<div class="col-md-8">
<label for="lieferungen" translate>Geplante Lieferdaten</label>
</div>
<div class="col-md-4" ng-if="!showLoading()">
<div class="col-md-4" ng-if="!loading && !template.creating > 0">
<div class="pull-right">
<div uib-dropdown class="dropdown inline" is-open="status.open">
<a role="button" href="" class="btn btn-sm btn-default" uib-dropdown-toggle><span class="glyphicon glyphicon-plus"></span> </a>
Expand Down
Loading