Skip to content

Commit

Permalink
Isuue #179: fix new category end date
Browse files Browse the repository at this point in the history
  • Loading branch information
yankedev committed Sep 1, 2016
1 parent c18dea1 commit 60fb485
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/webapp/resources/js/admin/ng-app/admin-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,23 @@
};
}]);

var createCategory = function(sticky, $scope) {

var createCategoryValidUntil = function(sticky, categoryEndTime) {
var now = moment().startOf('hour');
var inceptionDateTime = {
date: now.format('YYYY-MM-DD'),
time: now.format('HH:mm')
};
var expirationDateTime = {
date: now.format('YYYY-MM-DD'),
time: now.format('HH:mm')
};

if (!categoryEndTime.date){
categoryEndTime = {
date: now.format('YYYY-MM-DD'),
time: now.format('HH:mm')
};
}

var expirationDateTime = _.clone(categoryEndTime);

return {
inception: inceptionDateTime,
expiration: expirationDateTime,
Expand All @@ -185,7 +192,7 @@
};

var createAndPushCategory = function(sticky, $scope) {
$scope.event.ticketCategories.push(createCategory(sticky, $scope));
$scope.event.ticketCategories.push(createCategoryValidUntil(sticky, $scope.event.begin));
};

var initScopeForEventEditing = function ($scope, OrganizationService, PaymentProxyService, LocationService, EventService, $state, PAYMENT_PROXY_DESCRIPTIONS) {
Expand Down Expand Up @@ -634,7 +641,7 @@
};

$scope.addCategory = function(event) {
openCategoryDialog(createCategory(true, $scope), event).then(function() {
openCategoryDialog(createCategoryValidUntil(true, event.begin), event).then(function() {
loadData();
});
};
Expand Down

0 comments on commit 60fb485

Please sign in to comment.