<div class="col-md-6">
<div class="flex-row">
<div class="flex-cell"></div>
- <div class="checkbox pad-horiz">
+
+<div class="input-group">
+<div class="input-group-btn" uib-dropdown>
+ <button type="button" class="btn btn-default" uib-dropdown-toggle>
+ [% l('Date Options') %]
+ <span class="caret"></span>
+ </button>
+ <ul class="pull-right" uib-dropdown-menu>
+ <li>
+ <a href
+ ng-click="toggle_opt('sticky_date')">
+ <span ng-if="date_options.sticky_date"
+ class="label label-success">✓</span>
+ <span ng-if="!date_options.sticky_date"
+ class="label label-warning">✗</span>
+ <span>[% l('Specific Due Date') %]</span>
+ </a>
+ </li>
+ <li>
+ <a href
+ ng-click="toggle_opt('until_logout')">
+ <span ng-if="date_options.until_logout"
+ class="label label-success">✓</span>
+ <span ng-if="!date_options.until_logout"
+ class="label label-warning">✗</span>
+ <span>[% l('Use Specific Due Date Until Logout') %]</span>
+ </a>
+ </li>
+ </ul>
+</div>
+
+ <!-- <div class="checkbox pad-horiz">
<label>
<input type="checkbox" ng-model="checkoutArgs.sticky_date"/>
[% l('Specific Due Date') %]
</label>
- </div>
- <!--
- <div><input type="checkbox" class="checkbox" ng-model="checkoutArgs.sticky_date"/></div>
- <div class="pad-horiz">[% l('Specific Due Date') %]</div>
- -->
+ </div> -->
<!-- FIXME: This needs a time component as well, but type="datetime"
is not yet supported by any browsers -->
<div><eg-date-input ng-model="checkoutArgs.due_date"></eg-date-input>
</div>
+</div>
</div>
</div>
</div>
}
}
+ $scope.date_options = {
+ due_date : egCore.hatch.getSessionItem('eg.circ.checkout.due_date'),
+ sticky_date : egCore.hatch.getSessionItem('eg.circ.checkout.until_logout'),
+ until_logout : egCore.hatch.getSessionItem('eg.circ.checkout.until_logout')
+ }
+
+ if ($scope.date_options.until_logout) { // If until_logout is set there should also be a date set.
+ $scope.checkoutArgs.due_date = new Date($scope.date_options.due_date);
+ $scope.checkoutArgs.sticky_date = true;
+ }
+
+ $scope.toggle_opt = function(opt) {
+ if ($scope.date_options[opt]) {
+ $scope.date_options[opt] = false;
+ } else {
+ $scope.date_options[opt] = true;
+ }
+ }
+
+ // The interactions between these options are complicated enough that $watch'ing them all is the only safe way to keep things sane.
+ $scope.$watch('date_options.sticky_date', function(newval) {
+ if ( newval ) { // was false, is true
+ // $scope.date_options.due_date = checkoutArgs.due_date;
+ } else {
+ $scope.date_options.until_logout = false;
+ }
+ $scope.checkoutArgs.sticky_date = newval;
+ });
+
+ $scope.$watch('date_options.until_logout', function(newval) {
+ if ( newval ) { // was false, is true
+ $scope.date_options.sticky_date = true;
+ $scope.date_options.due_date = $scope.checkoutArgs.due_date;
+ egCore.hatch.setSessionItem('eg.circ.checkout.until_logout', true);
+ egCore.hatch.setSessionItem('eg.circ.checkout.due_date', $scope.checkoutArgs.due_date);
+ } else {
+ egCore.hatch.removeSessionItem('eg.circ.checkout.until_logout');
+ egCore.hatch.removeSessionItem('eg.circ.checkout.due_date');
+ }
+ });
+
+ $scope.$watch('checkoutArgs.due_date', function(newval) {
+ if ( $scope.date_options.until_logout ) {
+ egCore.hatch.setSessionItem('eg.circ.checkout.due_date', newval);
+ }
+ });
+
$scope.has_email_address = function() {
return (
patronSvc.current &&