Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
915fa99e0b
6 changed files with 119 additions and 96 deletions
|
@ -1,36 +1,42 @@
|
||||||
class App.UiElement.business_hours
|
class App.UiElement.business_hours
|
||||||
@render: (attribute, params) ->
|
@render: (attribute, params) ->
|
||||||
|
|
||||||
hours = {
|
hours =
|
||||||
mon: {
|
mon:
|
||||||
active: true
|
active: true
|
||||||
timeframes: ['09:00-17:00']
|
timeframes: [
|
||||||
}
|
['09:00','17:00']
|
||||||
tue: {
|
]
|
||||||
|
tue:
|
||||||
active: true
|
active: true
|
||||||
timeframes: ['00:00-24:00']
|
timeframes: [
|
||||||
}
|
['00:00','24:00']
|
||||||
wed: {
|
]
|
||||||
|
wed:
|
||||||
active: true
|
active: true
|
||||||
timeframes: ['09:00-17:00']
|
timeframes: [
|
||||||
}
|
['09:00','17:00']
|
||||||
thu: {
|
]
|
||||||
|
thu:
|
||||||
active: true
|
active: true
|
||||||
timeframes: ['09:00-12:00', '13:00-17:00']
|
timeframes: [
|
||||||
}
|
['09:00','12:00']
|
||||||
fri: {
|
['13:00','17:00']
|
||||||
|
]
|
||||||
|
fri:
|
||||||
active: true
|
active: true
|
||||||
timeframes: ['09:00-17:00']
|
timeframes:
|
||||||
}
|
['09:00','17:00']
|
||||||
sat: {
|
sat:
|
||||||
active: false
|
active: false
|
||||||
timeframes: ['10:00-14:00']
|
timeframes: [
|
||||||
}
|
['10:00','14:00']
|
||||||
sun: {
|
]
|
||||||
|
sun:
|
||||||
active: false
|
active: false
|
||||||
timeframes: ['10:00-14:00']
|
timeframes: [
|
||||||
}
|
['10:00','14:00']
|
||||||
}
|
]
|
||||||
|
|
||||||
businessHours = new App.BusinessHours
|
businessHours = new App.BusinessHours
|
||||||
hours: hours
|
hours: hours
|
||||||
|
|
|
@ -4,13 +4,14 @@ class App.BusinessHours extends Spine.Controller
|
||||||
tag: 'table'
|
tag: 'table'
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click .js-activateColumn': 'activateColumn'
|
'click .js-toggle-day': 'toggleDay'
|
||||||
|
'click .js-add-time': 'addTime'
|
||||||
|
'click .js-remove-time': 'removeTime'
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
render: =>
|
@days =
|
||||||
days =
|
|
||||||
mon: App.i18n.translateInline('Monday')
|
mon: App.i18n.translateInline('Monday')
|
||||||
tue: App.i18n.translateInline('Tuesday')
|
tue: App.i18n.translateInline('Tuesday')
|
||||||
wed: App.i18n.translateInline('Wednesday')
|
wed: App.i18n.translateInline('Wednesday')
|
||||||
|
@ -19,18 +20,32 @@ class App.BusinessHours extends Spine.Controller
|
||||||
sat: App.i18n.translateInline('Saturday')
|
sat: App.i18n.translateInline('Saturday')
|
||||||
sun: App.i18n.translateInline('Sunday')
|
sun: App.i18n.translateInline('Sunday')
|
||||||
|
|
||||||
html = App.view('generic/business_hours')
|
render: =>
|
||||||
days: days
|
maxTimeframeDay = _.max @hours, (day) -> day.timeframes.length
|
||||||
hours: @options.hours
|
|
||||||
|
|
||||||
console.log "BusinessHours:", "days", days, "hours", @options.hours, "html", html
|
html = App.view('generic/business_hours')
|
||||||
|
days: @days
|
||||||
|
hours: @options.hours
|
||||||
|
maxTimeframes: maxTimeframeDay.timeframes.length
|
||||||
|
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
@$('.js-time').timepicker
|
@$('.js-time').timepicker
|
||||||
showMeridian: false # meridian = am/pm
|
showMeridian: false # meridian = am/pm
|
||||||
|
tillMidnight: true
|
||||||
|
|
||||||
activateColumn: (event) =>
|
addTime: (event) =>
|
||||||
|
day = @$(event.currentTarget).attr('data-day')
|
||||||
|
@options.hours[day].timeframes.push(['13:00', '17:00'])
|
||||||
|
@render()
|
||||||
|
|
||||||
|
removeTime: (event) =>
|
||||||
|
day = @$(event.currentTarget).attr('data-day')
|
||||||
|
@options.hours[day].timeframes.pop()
|
||||||
|
@render()
|
||||||
|
|
||||||
|
toggleDay: (event) =>
|
||||||
checkbox = @$(event.currentTarget)
|
checkbox = @$(event.currentTarget)
|
||||||
columnName = checkbox.attr('data-target')
|
day = checkbox.attr('data-target')
|
||||||
@$("[data-column=#{columnName}]").toggleClass('is-active', checkbox.prop('checked'))
|
@options.hours[day].active = checkbox.prop('checked')
|
||||||
|
@$("[data-day=#{day}]").toggleClass('is-active', checkbox.prop('checked'))
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
* - automatically jump from hours to minutes when typing in a number
|
* - automatically jump from hours to minutes when typing in a number
|
||||||
* - continue stepping from manually input value
|
* - continue stepping from manually input value
|
||||||
* - activate meridian on class 'time--12'
|
* - activate meridian on class 'time--12'
|
||||||
|
* - tillMidnight (special mode to allow to display 24:00)
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
this.template = options.template;
|
this.template = options.template;
|
||||||
this.appendWidgetTo = options.appendWidgetTo;
|
this.appendWidgetTo = options.appendWidgetTo;
|
||||||
this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
|
this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
|
||||||
|
this.tillMidnight = options.tillMidnight;
|
||||||
|
|
||||||
this._init();
|
this._init();
|
||||||
};
|
};
|
||||||
|
@ -140,7 +142,11 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.hour <= 0) {
|
if (this.hour <= 0) {
|
||||||
this.hour = this.maxHours;
|
if(this.tillMidnight) {
|
||||||
|
this.hour = this.maxHours;
|
||||||
|
} else {
|
||||||
|
this.hour = this.maxHours - 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.hour--;
|
this.hour--;
|
||||||
}
|
}
|
||||||
|
@ -514,10 +520,16 @@
|
||||||
this.hour = 0;
|
this.hour = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.hour === this.maxHours) {
|
if (this.tillMidnight) {
|
||||||
this.hour = 0;
|
if (this.hour === 24) {
|
||||||
|
this.hour = 1;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.hour === 23) {
|
||||||
|
this.hour = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.hour++;
|
this.hour++;
|
||||||
},
|
},
|
||||||
|
@ -537,6 +549,12 @@
|
||||||
} else {
|
} else {
|
||||||
this.minute = newVal;
|
this.minute = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tillMidnight && this.hour === 24) {
|
||||||
|
if (this.minute !== 0) {
|
||||||
|
this.hour = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
incrementSecond: function() {
|
incrementSecond: function() {
|
||||||
|
@ -548,6 +566,12 @@
|
||||||
} else {
|
} else {
|
||||||
this.second = newVal;
|
this.second = newVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tillMidnight && this.hour === 24) {
|
||||||
|
if (this.second !== 0) {
|
||||||
|
this.hour = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mousewheel: function(e) {
|
mousewheel: function(e) {
|
||||||
|
@ -1093,7 +1117,8 @@
|
||||||
template: false,
|
template: false,
|
||||||
appendWidgetTo: 'body',
|
appendWidgetTo: 'body',
|
||||||
showWidgetOnAddonClick: true,
|
showWidgetOnAddonClick: true,
|
||||||
maxHours: 23
|
maxHours: 23,
|
||||||
|
tillMidnight: false
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.timepicker.Constructor = Timepicker;
|
$.fn.timepicker.Constructor = Timepicker;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<th style="text-align: center">
|
<th style="text-align: center">
|
||||||
<label class="day-name">
|
<label class="day-name">
|
||||||
<span class="checkbox-replacement checkbox-replacement--inline">
|
<span class="checkbox-replacement checkbox-replacement--inline">
|
||||||
<input class="js-activateColumn" data-target="<%- id %>" type="checkbox"<%- ' checked' if @hours[id].active %>>
|
<input class="js-toggle-day" data-target="<%- id %>" type="checkbox"<%- ' checked' if @hours[id].active %>>
|
||||||
<%- @Icon('checkbox', 'icon-unchecked') %>
|
<%- @Icon('checkbox', 'icon-unchecked') %>
|
||||||
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
<%- @Icon('checkbox-checked', 'icon-checked') %>
|
||||||
</span>
|
</span>
|
||||||
|
@ -13,63 +13,36 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% for i in [0..@maxTimeframes-1]: %>
|
||||||
<tr>
|
<tr>
|
||||||
<td data-column="monday" class="form-group day-time is-active">
|
<% for id, day of @days: %>
|
||||||
<label for="monday_start_time">from</label>
|
<% if @hours[id].timeframes[i]: %>
|
||||||
<input type="text" id="monday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
<td data-day="<%- id %>" class="form-group day-time<%- ' is-active' if @hours[id].active %>">
|
||||||
<label for="monday_end_time">till</label>
|
<label for="<%- id %>_start_time">from</label>
|
||||||
<input type="text" id="monday_end_time" value="18:00" class="form-control form-control--small time js-time">
|
<input type="text" id="<%- id %>_start_time" value="<%- @hours[id].timeframes[i][0] %>" class="form-control form-control--small time js-time">
|
||||||
|
<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">
|
||||||
|
<% else: %>
|
||||||
|
<td class="empty-cell">
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<td data-column="tuesday" class="form-group day-time is-active">
|
<% if @maxTimeframes > 1: %>
|
||||||
<label for="tuesday_start_time">from</label>
|
|
||||||
<input type="text" id="tuesday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
|
||||||
<label for="tuesday_end_time">till</label>
|
|
||||||
<input type="text" id="tuesday_end_time" value="18:00" class="form-control form-control--small time js-time">
|
|
||||||
|
|
||||||
<td data-column="wednesday" class="form-group day-time is-active">
|
|
||||||
<label for="wednesday_start_time">from</label>
|
|
||||||
<input type="text" id="wednesday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
|
||||||
<label for="wednesday_end_time">till</label>
|
|
||||||
<input type="text" id="wednesday_end_time" value="18:00" class="form-control form-control--small time js-time">
|
|
||||||
|
|
||||||
<td data-column="thursday" class="form-group day-time is-active">
|
|
||||||
<label for="thursday_start_time">from</label>
|
|
||||||
<input type="text" id="thursday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
|
||||||
<label for="thursday_end_time">till</label>
|
|
||||||
<input type="text" id="thursday_end_time" value="18:00" class="form-control form-control--small time js-time">
|
|
||||||
|
|
||||||
<td data-column="friday" class="form-group day-time is-active">
|
|
||||||
<label for="friday_start_time">from</label>
|
|
||||||
<input type="text" id="friday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
|
||||||
<label for="friday_end_time">till</label>
|
|
||||||
<input type="text" id="friday_end_time" value="13:00" class="form-control form-control--small time js-time">
|
|
||||||
|
|
||||||
<td data-column="saturday" class="form-group day-time">
|
|
||||||
<label for="saturday_start_time">from</label>
|
|
||||||
<input type="text" id="saturday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
|
||||||
<label for="saturday_end_time">till</label>
|
|
||||||
<input type="text" id="saturday_end_time" value="18:00" class="form-control form-control--small time js-time">
|
|
||||||
|
|
||||||
<td data-column="sunday" class="form-group day-time">
|
|
||||||
<label for="sunday_start_time">from</label>
|
|
||||||
<input type="text" id="sunday_start_time" value="07:00" class="form-control form-control--small time js-time">
|
|
||||||
<label for="sunday_end_time">till</label>
|
|
||||||
<input type="text" id="sunday_end_time" value="18:00" class="form-control form-control--small time js-time">
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td data-column="monday" class="settings-list-action-cell js-add-time is-active">
|
<% for id, day of @days: %>
|
||||||
|
<% if @hours[id].timeframes.length > 1: %>
|
||||||
|
<td data-day="<%- id %>" class="settings-list-action-cell js-remove-time<%- ' is-active' if @hours[id].active %>">
|
||||||
|
<%- @Icon('minus-small') %>
|
||||||
|
<% else: %>
|
||||||
|
<td class="empty-cell">
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<% for id, day of @days: %>
|
||||||
|
<td data-day="<%- id %>" class="settings-list-action-cell js-add-time<%- ' is-active' if @hours[id].active %>">
|
||||||
<%- @Icon('plus-small') %>
|
<%- @Icon('plus-small') %>
|
||||||
<td data-column="tuesday" class="settings-list-action-cell js-add-time is-active">
|
<% end %>
|
||||||
<%- @Icon('plus-small') %>
|
|
||||||
<td data-column="wednesday" class="settings-list-action-cell js-add-time is-active">
|
|
||||||
<%- @Icon('plus-small') %>
|
|
||||||
<td data-column="thursday" class="settings-list-action-cell js-add-time is-active">
|
|
||||||
<%- @Icon('plus-small') %>
|
|
||||||
<td data-column="friday" class="settings-list-action-cell js-add-time is-active">
|
|
||||||
<%- @Icon('plus-small') %>
|
|
||||||
<td data-column="saturday" class="settings-list-action-cell js-add-time">
|
|
||||||
<%- @Icon('plus-small') %>
|
|
||||||
<td data-column="sunday" class="settings-list-action-cell js-add-time">
|
|
||||||
<%- @Icon('plus-small') %>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
|
@ -5860,6 +5860,10 @@ output {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td.empty-cell {
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
.text-muted {
|
.text-muted {
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Loading…
Reference in a new issue