<select class="form-control" id="appointment-time" ng-model="appt.slot_time"
name="slot_time" style="display: block;"
required ng-focus="refreshAvailableTimes(appt)">
- <option ng-repeat="t in appt.available_times track by t.time" value="{{t.time}}">[% l('[_1] (Available: [_2])', '{{t.time_fmt}}', '{{t.available}}') %]</option>
+ <option value=""></option>
+ <option ng-repeat="t in appt.available_times track by t.time" value="{{t.time}}"
+ ng-disabled="t.available === 0 && appt.original_slot_time !== t.time">
+ [% l('[_1] (Available: [_2])', '{{t.time_fmt}}', '{{t.available}}') %]
+ </option>
</select>
</div>
<div class="col-md-2">
function mungeAvailableTimes(hash, times) {
var existing_present = false;
+ if (angular.isDefined(hash.slot_time) && hash.slot_time !== null) {
+ hash.original_slot_time = hash.slot_time;
+ }
hash.available_times = times.map(function(t) {
- if (hash.slot_time !== null && hash.slot_time === t[0]) existing_present = true;
+ if (angular.isDefined(hash.slot_time) && hash.slot_time !== null && hash.slot_time === t[0]) {
+ existing_present = true;
+ }
return {
time: t[0],
available: t[1],
time_fmt: moment(t[0], [moment.ISO_8601, 'HH:mm:ss']).format('LT')
};
});
- if (hash.slot_time !== null && !existing_present) {
+ if (angular.isDefined(hash.slot_time) && hash.slot_time !== null && !existing_present) {
hash.available_times.unshift({
time: hash.slot_time,
available: 0,