Skip to content

Commit

Permalink
#110 - set default expiration to event start
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Jun 30, 2016
1 parent 94a3efe commit 63ba777
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ <h5 class="text-muted">Here are the additional fields defined</h5>
</div>

<div class="page-header">
<additional-services data-selected-languages="event.locales" data-available-languages="allLanguages" data-on-modification="setAdditionalServices(event, additionalServices)" data-event-id="event.id"></additional-services>
<additional-services data-selected-languages="event.locales" data-available-languages="allLanguages" data-on-modification="setAdditionalServices(event, additionalServices)" data-event-id="event.id" data-event-start-date="event.formattedBegin"></additional-services>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h4>Add from template <span data-ng-repeat="template in dynamicFieldTemplates" >
</div>

<div class="wMarginBottom">
<additional-services data-selected-languages="event.locales" data-available-languages="allLanguages" data-on-modification="setAdditionalServices(event, additionalServices)"></additional-services>
<additional-services data-selected-languages="event.locales" data-available-languages="allLanguages" data-on-modification="setAdditionalServices(event, additionalServices)" data-event-start-date="event.begin | formatDateTimeModification"></additional-services>
</div>

<control-buttons data-form-obj="editEvent"></control-buttons>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ <h3>Donation options</h3>
<div class="col-xs-12"><button type="button" class="btn btn-success pull-right" data-ng-click="asCtrl.edit()" data-ng-if="!asCtrl.editActive"><i class="fa fa-plus"></i> Add new</button></div>
</div>

<edit-additional-service data-ng-if="asCtrl.editActive" data-editing-item="asCtrl.editingItem" data-available-languages="asCtrl.availableLanguages" data-selected-languages="asCtrl.selectedLanguages" data-on-edit-complete="asCtrl.onEditComplete(item)" data-on-dismiss="asCtrl.onDismiss()"></edit-additional-service>
<edit-additional-service data-ng-if="asCtrl.editActive" data-editing-item="asCtrl.editingItem" data-available-languages="asCtrl.availableLanguages" data-selected-languages="asCtrl.selectedLanguages" data-on-edit-complete="asCtrl.onEditComplete(item)" data-on-dismiss="asCtrl.onDismiss()" data-event-start-date="asCtrl.eventStartDate"></edit-additional-service>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
selectedLanguages: '=',
availableLanguages: '=',
onModification: '&',
eventId: '='
eventId: '=',
eventStartDate: '='
},
bindToController: true,
templateUrl: '/resources/angular-templates/admin/partials/event/fragment/additional-services.html',
Expand All @@ -22,19 +23,28 @@
availableLanguages: '=',
selectedLanguages: '=',
onEditComplete: '&',
onDismiss: '&'
onDismiss: '&',
eventStartDate: '='
},
bindToController: true,
templateUrl: '/resources/angular-templates/admin/partials/event/fragment/edit-additional-service.html',
controller: 'EditAdditionalServiceController',
controllerAs: 'ctrl'
};
})
.filter('formatDateTimeModification', [function() {
return function(dateTimeModification) {
if(angular.isDefined(dateTimeModification)) {
return dateTimeModification.date + ' ' + dateTimeModification.time;
}
return moment().format('YYYY-MM-DD HH:mm');
};
}])
.controller('AdditionalServicesController', AdditionalServicesController)
.controller('EditAdditionalServiceController', EditAdditionalServiceController)
.service('AdditionalServiceManager', AdditionalServiceManager);

function AdditionalServicesController(AdditionalServiceManager, ValidationService) {
function AdditionalServicesController(AdditionalServiceManager) {
var self = this;

self.propagateChanges = angular.isDefined(self.eventId);
Expand Down Expand Up @@ -113,7 +123,7 @@
};
}

AdditionalServicesController.$inject = ['AdditionalServiceManager', 'ValidationService'];
AdditionalServicesController.$inject = ['AdditionalServiceManager'];

function EditAdditionalServiceController(ValidationService, AdditionalServiceManager, $q) {
var ctrl = this;
Expand All @@ -126,6 +136,15 @@
inception: {},
expiration: {}
};
if(angular.isDefined(ctrl.eventStartDate)) {
var d = moment.max(moment(ctrl.eventStartDate), moment().startOf('hour'));
ctrl.item = angular.extend(ctrl.item, {
expiration : {
date: d.format('YYYY-MM-DD'),
time: d.format('HH:mm')
}
});
}
}

if(!angular.isDefined(ctrl.item.title)) {
Expand Down

0 comments on commit 63ba777

Please sign in to comment.