business times: write changes to @options.hours
This commit is contained in:
parent
8c4bcf60e7
commit
f08e6341c6
3 changed files with 22 additions and 9 deletions
|
@ -1,6 +1,9 @@
|
||||||
class App.UiElement.business_hours
|
class App.UiElement.business_hours
|
||||||
@render: (attribute, params) ->
|
@render: (attribute, params) ->
|
||||||
|
|
||||||
|
# Martin: our frontend doesn't create 24:00.
|
||||||
|
# you have to check second values ('till') for 00:00
|
||||||
|
# and convert them to 24:00
|
||||||
hours =
|
hours =
|
||||||
mon:
|
mon:
|
||||||
active: true
|
active: true
|
||||||
|
@ -25,8 +28,9 @@ class App.UiElement.business_hours
|
||||||
]
|
]
|
||||||
fri:
|
fri:
|
||||||
active: true
|
active: true
|
||||||
timeframes:
|
timeframes: [
|
||||||
['09:00','17:00']
|
['09:00','17:00']
|
||||||
|
]
|
||||||
sat:
|
sat:
|
||||||
active: false
|
active: false
|
||||||
timeframes: [
|
timeframes: [
|
||||||
|
|
|
@ -30,9 +30,18 @@ class App.BusinessHours extends Spine.Controller
|
||||||
|
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
@$('.js-time').timepicker
|
@$('.js-time')
|
||||||
showMeridian: false # meridian = am/pm
|
.timepicker
|
||||||
tillMidnight: true
|
showMeridian: false # meridian = am/pm
|
||||||
|
.on 'changeTime.timepicker', @onTimeChange
|
||||||
|
|
||||||
|
onTimeChange: (event) =>
|
||||||
|
input = @$(event.currentTarget)
|
||||||
|
day = input.attr('data-day')
|
||||||
|
slot = input.attr('data-slot')
|
||||||
|
i = input.attr('data-i')
|
||||||
|
console.log "something changed", event.time
|
||||||
|
@options.hours[day].timeframes[slot][i] = "#{event.time.hours}:#{event.time.minutes}"
|
||||||
|
|
||||||
addTime: (event) =>
|
addTime: (event) =>
|
||||||
day = @$(event.currentTarget).attr('data-day')
|
day = @$(event.currentTarget).attr('data-day')
|
||||||
|
|
|
@ -13,15 +13,15 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% for i in [0..@maxTimeframes-1]: %>
|
<% for slot in [0..@maxTimeframes-1]: %>
|
||||||
<tr>
|
<tr>
|
||||||
<% for id, day of @days: %>
|
<% for id, day of @days: %>
|
||||||
<% if @hours[id].timeframes[i]: %>
|
<% if @hours[id].timeframes[slot]: %>
|
||||||
<td data-day="<%- id %>" class="form-group day-time<%- ' is-active' if @hours[id].active %>">
|
<td data-day="<%- id %>" data-slot="<%- slot %>" class="form-group day-time<%- ' is-active' if @hours[id].active %>">
|
||||||
<label for="<%- id %>_start_time">from</label>
|
<label for="<%- id %>_start_time">from</label>
|
||||||
<input type="text" id="<%- id %>_start_time" value="<%- @hours[id].timeframes[i][0] %>" class="form-control form-control--small time js-time">
|
<input type="text" id="<%- id %>_start_time" value="<%- @hours[id].timeframes[slot][0] %>" data-day="<%- id %>" data-slot="<%- slot %>" data-i="0" class="form-control form-control--small time js-time">
|
||||||
<label for="monday_end_time">till</label>
|
<label for="monday_end_time">till</label>
|
||||||
<input type="text" id="monday_end_time" value="<%- @hours[id].timeframes[i][1] %>" class="form-control form-control--small time js-time">
|
<input type="text" id="monday_end_time" value="<%- @hours[id].timeframes[slot][1] %>" data-day="<%- id %>" data-slot="<%- slot %>" data-i="1" class="form-control form-control--small time js-time">
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<td class="empty-cell">
|
<td class="empty-cell">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue