No need to define a custom helper for selectAllOrNone, have this directly in backup's controllers

This commit is contained in:
Alexandre Aubin 2019-10-29 21:26:12 +01:00
parent b49621f0ca
commit 44c27a5d38
2 changed files with 27 additions and 16 deletions

View file

@ -62,7 +62,21 @@
data['apps'] = {};
c.api('GET', '/apps?with_backup', {}, function(apps_list) {
data['apps'] = apps_list.apps;
c.view('backup/backup_create', data, c.selectAllOrNone);
c.view('backup/backup_create', data, function() {
// Configure buttons "select all" and "select none"
// Remove active style from buttons
$(".select_all-none input").click(function(){ $(this).toggleClass("active"); });
// Select all checkbox in this panel
$(".select_all").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", true);
});
// Deselect all checkbox in this panel
$(".select_none").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", false);
});
});
});
});
});
@ -88,7 +102,18 @@
data.locale = y18n.locale;
c.view('backup/backup_info', data, function() {
c.selectAllOrNone();
// Configure buttons "select all" and "select none"
// Remove active style from buttons
$(".select_all-none input").click(function(){ $(this).toggleClass("active"); });
// Select all checkbox in this panel
$(".select_all").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", true);
});
// Deselect all checkbox in this panel
$(".select_none").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", false);
});
// Delete button
$('button[data-action="delete"]').on('click', function() {

View file

@ -497,20 +497,6 @@
// Misc helpers used in views etc..
//
selectAllOrNone: function () {
// Remove active style from buttons
$(".select_all-none input").click(function(){ $(this).toggleClass("active"); });
// Select all checkbox in this panel
$(".select_all").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", true);
});
// Deselect all checkbox in this panel
$(".select_none").click(function(){
$(this).parents(".panel").children(".list-group").find("input").prop("checked", false);
});
},
// Paste <pre>
prePaste: function() {
var pasteButtons = $('button[data-paste-content],a[data-paste-content]');