Defect #17071 » patch_commit_6682c6d40dc8.patch
| app/views/watchers/_new.html.erb | ||
|---|---|---|
|
:project_id => @project) }')" %>
|
||
|
<div id="users_for_watcher">
|
||
|
<%= principals_check_box_tags('watcher[user_ids][]', users) %>
|
||
|
<%= principals_check_box_tags('watchers[]', users) %>
|
||
|
</div>
|
||
|
<div id="users_watching_issue" style="display: none;"></div>
|
||
|
<%= javascript_tag "var persistentWatcher = new persistWatchersList('watcher[user_ids][]', 'users_watching_issue', 'users_for_watcher');" %>
|
||
|
<%= javascript_tag do -%>
|
||
|
$(document).ajaxSuccess(function (evt, xhr, settings ) {
|
||
|
if (/^\/watchers\/autocomplete_for_user\?/.test(settings.url)) {
|
||
|
persistentWatcher.bindCheckboxes();
|
||
|
}
|
||
|
});
|
||
|
<% end -%>
|
||
|
<p class="buttons">
|
||
|
<%= submit_tag l(:button_add), :name => nil, :onclick => "hideModal(this);" %>
|
||
| app/views/watchers/autocomplete_for_user.html.erb | ||
|---|---|---|
|
<%= principals_check_box_tags 'watcher[user_ids][]', @users %>
|
||
|
<%= principals_check_box_tags 'watchers[]', @users %>
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
function toggleDisabledInit() {
|
||
|
$('input[data-disables], input[data-enables]').each(toggleDisabledOnChange);
|
||
|
}
|
||
|
function persistWatchersList(inputName, inputContainer, checkboxContainer) {
|
||
|
this.inputName = inputName;
|
||
|
this.inputContainer = $('#' + inputContainer);
|
||
|
this.checkboxContainer = $('#' + checkboxContainer);
|
||
|
|
||
|
this.bindCheckboxes();
|
||
|
}
|
||
|
persistWatchersList.prototype = {
|
||
|
bindCheckboxes: function () {
|
||
|
var oThis = this;
|
||
|
this.checkboxContainer.find("input[type='checkbox']").each(function(idx) {
|
||
|
var checkbox = $(this);
|
||
|
oThis.inputContainer.find("input[type='hidden']").each(function (index) {
|
||
|
if ($(this).val() == checkbox.val()) {
|
||
|
checkbox.prop('checked', true);
|
||
|
}
|
||
|
});
|
||
|
checkbox.change(function (evt) { oThis.watcherChange($(this)); });
|
||
|
});
|
||
|
},
|
||
|
|
||
|
watcherChange: function(input) {
|
||
|
if (input.is(':checked')) {
|
||
|
this.inputContainer.append(
|
||
|
'<input type="hidden" name="' + this.inputName + '" value="' + input.val() + '" />'
|
||
|
);
|
||
|
} else {
|
||
|
this.inputContainer.find('input[name="' + this.inputName + '"][value="' + input.val() + '"]').remove();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
$(document).ready(function(){
|
||
|
$('#content').on('change', 'input[data-disables], input[data-enables]', toggleDisabledOnChange);
|
||
|
toggleDisabledInit();
|
||