mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Refactored the bulk edit controller.
This commit is contained in:
16
public/v1/js/ff/common/autocomplete.js
vendored
16
public/v1/js/ff/common/autocomplete.js
vendored
@@ -29,8 +29,8 @@ function initTagsAC() {
|
||||
prefetch: {
|
||||
url: 'json/tags?uid=' + uid,
|
||||
filter: function (list) {
|
||||
return $.map(list, function (tagTag) {
|
||||
return {name: tagTag};
|
||||
return $.map(list, function (item) {
|
||||
return {name: item.name};
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -38,8 +38,8 @@ function initTagsAC() {
|
||||
url: 'json/tags?search=%QUERY&uid=' + uid,
|
||||
wildcard: '%QUERY',
|
||||
filter: function (list) {
|
||||
return $.map(list, function (name) {
|
||||
return {name: name};
|
||||
return $.map(list, function (item) {
|
||||
return {name: item.name};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -145,8 +145,8 @@ function initCategoryAC() {
|
||||
prefetch: {
|
||||
url: 'json/categories?uid=' + uid,
|
||||
filter: function (list) {
|
||||
return $.map(list, function (name) {
|
||||
return {name: name};
|
||||
return $.map(list, function (object) {
|
||||
return {name: object.name};
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -154,8 +154,8 @@ function initCategoryAC() {
|
||||
url: 'json/categories?search=%QUERY&uid=' + uid,
|
||||
wildcard: '%QUERY',
|
||||
filter: function (list) {
|
||||
return $.map(list, function (name) {
|
||||
return {name: name};
|
||||
return $.map(list, function (object) {
|
||||
return {name: object.name};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
120
public/v1/js/ff/list/groups.js
vendored
Normal file
120
public/v1/js/ff/list/groups.js
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* groups.js
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var count = 0;
|
||||
|
||||
$(document).ready(function () {
|
||||
// top button to select all / deselect all:
|
||||
$('input[name="select-all"]').change(function () {
|
||||
if (this.checked) {
|
||||
checkAll();
|
||||
countChecked();
|
||||
updateActionButtons();
|
||||
} else {
|
||||
uncheckAll();
|
||||
countChecked();
|
||||
updateActionButtons();
|
||||
}
|
||||
});
|
||||
|
||||
// click the mass edit button:
|
||||
$('.mass-edit').click(goToMassEdit);
|
||||
// click the bulk edit button:
|
||||
$('.bulk-edit').click(goToBulkEdit);
|
||||
// click the delete button:
|
||||
$('.mass-delete').click(goToMassDelete);
|
||||
|
||||
// click checkbox:
|
||||
$('.mass-select').unbind('change').change(function () {
|
||||
countChecked();
|
||||
updateActionButtons();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function goToMassEdit() {
|
||||
console.log(mass_edit_url + '/' + getCheckboxes());
|
||||
window.location.href = mass_edit_url + '/' + getCheckboxes();
|
||||
return false;
|
||||
}
|
||||
|
||||
function goToBulkEdit() {
|
||||
console.log(bulk_edit_url + '/' + getCheckboxes());
|
||||
window.location.href = bulk_edit_url + '/' + getCheckboxes();
|
||||
return false;
|
||||
}
|
||||
|
||||
function goToMassDelete() {
|
||||
console.log(mass_delete_url + '/' + getCheckboxes());
|
||||
window.location.href = mass_delete_url + '/' + getCheckboxes();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Array}
|
||||
*/
|
||||
function getCheckboxes() {
|
||||
"use strict";
|
||||
var list = [];
|
||||
$.each($('.mass-select'), function (i, v) {
|
||||
var checkbox = $(v);
|
||||
if (checkbox.prop('checked')) {
|
||||
// add to list.
|
||||
list.push(checkbox.val());
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function countChecked() {
|
||||
count = $('.mass-select:checked').length;
|
||||
}
|
||||
|
||||
function checkAll() {
|
||||
$('.mass-select').prop('checked', true);
|
||||
}
|
||||
|
||||
function uncheckAll() {
|
||||
$('.mass-select').prop('checked', false);
|
||||
}
|
||||
|
||||
function updateActionButtons() {
|
||||
if (0 !== count) {
|
||||
$('.action-menu').show();
|
||||
|
||||
// also update labels:
|
||||
$('.mass-edit span').text(edit_selected_txt + ' (' + count + ')');
|
||||
$('.bulk-edit span').text(edit_bulk_selected_txt + ' (' + count + ')');
|
||||
$('.mass-delete span').text(delete_selected_txt + ' (' + count + ')');
|
||||
|
||||
}
|
||||
if (0 === count) {
|
||||
$('.action-menu').hide();
|
||||
}
|
||||
}
|
18
public/v1/js/ff/transactions/mass/edit-bulk.js
vendored
18
public/v1/js/ff/transactions/mass/edit-bulk.js
vendored
@@ -24,4 +24,22 @@ $(document).ready(function () {
|
||||
"use strict";
|
||||
initTagsAC();
|
||||
initCategoryAC();
|
||||
|
||||
// on change, remove the checkbox.
|
||||
$('input[name="category"]').change(function () {
|
||||
$('input[name="ignore_category"]').attr('checked', false);
|
||||
});
|
||||
|
||||
$('select[name="budget_id"]').change(function () {
|
||||
|
||||
$('input[name="ignore_budget"]').attr('checked', false);
|
||||
});
|
||||
|
||||
$('input[name="tags"]').on('itemAdded', function(event) {
|
||||
$('input[name="ignore_tags"]').attr('checked', false);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
Reference in New Issue
Block a user