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

View file

@ -16,7 +16,7 @@
<%- @Icon('checkbox-checked', 'icon-checked') %>
</label>
<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>
<div class="settings-list-rowControls">
<% if !meta.feed: %>
@ -27,22 +27,6 @@
</div>
<% end %>
<tr class="hidden js-placeholder" data-date="">
<td>
<label class="checkbox-replacement">
<input type="checkbox" checked class="js-active" name="" value="true">
<%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %>
</label>
<td class="js-date">
<td><input class="form-control form-control--small js-summary" type="text" name="" value="" required/>
<td>
<div class="settings-list-rowControls">
<div class="btn btn--text js-remove">
<%- @Icon('trash') %> <%- @T('Remove') %>
</div>
</div>
<tr class="settings-list-controlRow">
<td>
<td class="js-datePicker">

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>