Moved placeholder into separate template file.

This commit is contained in:
Martin Edenhofer 2015-09-25 11:47:06 +02:00
parent d996c1cadf
commit 8719c4350e
3 changed files with 67 additions and 68 deletions

View file

@ -20,10 +20,10 @@ class App.UiElement.holiday_selector
item.find('.js-datePicker').html(datePicker) item.find('.js-datePicker').html(datePicker)
# set active/inactive of date # set active/inactive of date
item.find('.js-active').bind('click', (e) -> item.delegate('.js-active', 'click', (e) ->
active = $(e.target).prop('checked') active = $(e.target).prop('checked')
row = $(e.target).closest('tr') row = $(e.target).closest('tr')
input = $(e.target).closest('tr').find('.js-description') input = $(e.target).closest('tr').find('.js-summary')
if !active if !active
row.addClass('is-inactive') row.addClass('is-inactive')
input.prop('readonly', true) input.prop('readonly', true)
@ -35,7 +35,7 @@ class App.UiElement.holiday_selector
) )
# remove date # remove date
item.find('.js-remove').bind('click', (e) -> item.delegate('.js-remove', 'click', (e) ->
$(e.target).closest('tr').remove() $(e.target).closest('tr').remove()
) )
@ -61,14 +61,14 @@ class App.UiElement.holiday_selector
$(e.target).closest('tr').find('.js-summary').val('') $(e.target).closest('tr').find('.js-summary').val('')
# place new element # place new element
template = item.find('.js-placeholder').clone()
template.removeClass('hidden').removeClass('js-placeholder') template = App.view('calendar/holiday_selector_placeholder')(
template.attr('data-date', date) placeholderDate: date
template.find('.js-date').html(App.i18n.translateDate(date)) placeholderSummary: summary
template.find('.js-active').attr('name', "{boolean}public_holidays::#{date}::active") nameSummary: "public_holidays::#{date}::summary"
template.find('.js-summary').attr('name', "public_holidays::#{date}::summary") nameActive: "{boolean}public_holidays::#{date}::active"
template.find('.js-summary').val(summary) )
item.find('.js-placeholder').before(template) item.find('.settings-list-controlRow').before(template)
) )
item item

View file

@ -1,59 +1,43 @@
<table class="settings-list"> <table class="settings-list">
<thead> <thead>
<tr> <tr>
<th><%- @T('Active') %> <th><%- @T('Active') %>
<th><%- @T('Date') %> <th><%- @T('Date') %>
<th><%- @T('Description') %> <th><%- @T('Description') %>
<th><%- @T('Action') %> <th><%- @T('Action') %>
</thead> </thead>
<tbody> <tbody>
<% for day, meta of @days: %> <% for day, meta of @days: %>
<tr <% if !meta.active: %>class="is-inactive"<% end %> data-date="<%= day %>"> <tr <% if !meta.active: %>class="is-inactive"<% end %> data-date="<%= day %>">
<td> <td>
<label class="checkbox-replacement"> <label class="checkbox-replacement">
<input type="checkbox" <% if meta.active: %>checked<% end %> class="js-active" name="{boolean}public_holidays::<%= day %>::active" value="true"> <input type="checkbox" <% if meta.active: %>checked<% end %> class="js-active" name="{boolean}public_holidays::<%= day %>::active" value="true">
<%- @Icon('checkbox', 'icon-unchecked') %> <%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %> <%- @Icon('checkbox-checked', 'icon-checked') %>
</label> </label>
<td><%- @Tdate(day) %> <td><%- @Tdate(day) %>
<td><input class="form-control form-control--small js-description <% if !meta.active: %>is-disabled<% end %>" type="text" name="public_holidays::<%= day %>::summary" value="<%= meta.summary %>" required/> <td><input class="form-control form-control--small js-summary <% if !meta.active: %>is-disabled<% end %>" type="text" name="public_holidays::<%= day %>::summary" value="<%= meta.summary %>" required/>
<td> <td>
<div class="settings-list-rowControls"> <div class="settings-list-rowControls">
<% if !meta.feed: %> <% if !meta.feed: %>
<div class="btn btn--text js-remove"> <div class="btn btn--text js-remove">
<%- @Icon('trash') %> <%- @T('Remove') %> <%- @Icon('trash') %> <%- @T('Remove') %>
</div>
<% end %>
</div> </div>
<% end %> <% end %>
</div>
<% end %>
<tr class="hidden js-placeholder" data-date=""> <tr class="settings-list-controlRow">
<td> <td>
<label class="checkbox-replacement"> <td class="js-datePicker">
<input type="checkbox" checked class="js-active" name="" value="true"> <!-- not supported right now by ff
<%- @Icon('checkbox', 'icon-unchecked') %> <input class="form-control form-control--small" type="date" placeholder="<%- @T('Date') %>"/>
<%- @Icon('checkbox-checked', 'icon-checked') %> -->
</label> <td>
<td class="js-date"> <input class="form-control form-control--small js-summary" type="text" placeholder="<%- @T('Description') %>"/>
<td><input class="form-control form-control--small js-summary" type="text" name="" value="" required/> <td>
<td> <div class="btn btn--text js-add">
<div class="settings-list-rowControls"> <%- @Icon('plus-small') %> <%- @T('Add') %>
<div class="btn btn--text js-remove"> </div>
<%- @Icon('trash') %> <%- @T('Remove') %> </tbody>
</div> </table>
</div>
<tr class="settings-list-controlRow">
<td>
<td class="js-datePicker">
<!-- not supported right now by ff
<input class="form-control form-control--small" type="date" placeholder="<%- @T('Date') %>"/>
-->
<td>
<input class="form-control form-control--small js-summary" type="text" placeholder="<%- @T('Description') %>"/>
<td>
<div class="btn btn--text js-add">
<%- @Icon('plus-small') %> <%- @T('Add') %>
</div>
</tbody>
</table>

View file

@ -0,0 +1,15 @@
<tr class="" data-date="<%= @placeholderDate %>">
<td>
<label class="checkbox-replacement">
<input type="checkbox" checked class="js-active" name="<%= @nameActive %>" value="true">
<%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %>
</label>
<td><%- @Tdate(@placeholderDate) %>
<td><input class="form-control form-control--small js-summary" type="text" name="<%= @placeholderSummary %>" value="<%= @placeholderSummary %>" required/>
<td>
<div class="settings-list-rowControls">
<div class="btn btn--text js-remove">
<%- @Icon('trash') %> <%- @T('Remove') %>
</div>
</div>