Moved placeholder into separate template file.
This commit is contained in:
parent
d996c1cadf
commit
8719c4350e
3 changed files with 67 additions and 68 deletions
|
@ -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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<table class="settings-list">
|
<table class="settings-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%- @T('Active') %>
|
<th><%- @T('Active') %>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<%- @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: %>
|
||||||
|
@ -27,22 +27,6 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% 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">
|
<tr class="settings-list-controlRow">
|
||||||
<td>
|
<td>
|
||||||
<td class="js-datePicker">
|
<td class="js-datePicker">
|
||||||
|
@ -56,4 +40,4 @@
|
||||||
<%- @Icon('plus-small') %> <%- @T('Add') %>
|
<%- @Icon('plus-small') %> <%- @T('Add') %>
|
||||||
</div>
|
</div>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
|
@ -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>
|
Loading…
Reference in a new issue