diff --git a/app/coffee/modules/common/components.coffee b/app/coffee/modules/common/components.coffee index 8972bfea..a376f75b 100644 --- a/app/coffee/modules/common/components.coffee +++ b/app/coffee/modules/common/components.coffee @@ -81,20 +81,30 @@ module.directive("tgSprintProgressbar", SprintProgressBarDirective) DateSelectorDirective =-> link = ($scope, $el, $attrs, $model) -> - $.selectedDate = null + selectedDate = null $el.picker = new Pikaday({ field: $el[0] format: "DD MMM YYYY" onSelect: (date) => - $.selectedDate = date + selectedDate = date onOpen: => - $el.picker.setDate($.selectedDate) if $.selectedDate? + $el.picker.setDate(selectedDate) if selectedDate? }) + if $attrs.greaterThan + $scope.$watch $attrs.greaterThan, (val) -> + console.log "HOLA" + console.log val + $el.picker.setMinDate(moment(val)) + + if $attrs.lessThan + $scope.$watch $attrs.lessThan, (val) -> + $el.picker.setMaxDate(moment(val)) + $scope.$on "sprints:loaded", (ctx, sprints) => if sprints.length > 0 estimatedStart = sprints[0].estimated_finish - $.selectedDate = estimatedStart + selectedDate = estimatedStart $el.val(moment(estimatedStart).format("DD MMM YYYY")) $el.picker.setDate(estimatedStart) diff --git a/app/partials/views/modules/lightbox-sprint-add-edit.jade b/app/partials/views/modules/lightbox-sprint-add-edit.jade index 46c10c92..bb017427 100644 --- a/app/partials/views/modules/lightbox-sprint-add-edit.jade +++ b/app/partials/views/modules/lightbox-sprint-add-edit.jade @@ -10,10 +10,12 @@ form fieldset.dates div input.date-start(type="text", name="estimated_start", placeholder="Estimated Start", - ng-model="sprint.estimated_start", data-required="true", tg-date-selector) + ng-model="sprint.estimated_start", data-required="true", tg-date-selector, + less-than="sprint.estimated_finish") div input.date-end(type="text", name="estimated_finish", placeholder="Estimated End", - ng-model="sprint.estimated_finish", data-required="true", tg-date-selector) + ng-model="sprint.estimated_finish", data-required="true", tg-date-selector + greater-than="sprint.estimated_start") a.button.button-green(href="", title="Save") span Create