<commit_before>/**
 * FoodCoopShop - The open source software for your foodcoop
 *
 * Licensed under the GNU Affero General Public License version 3
 * For full copyright and license information, please see LICENSE
 * Redistributions of files must retain the above copyright notice.
 *
 * @since         FoodCoopShop 3.1.0
 * @license       https://opensource.org/licenses/AGPL-3.0
 * @author        <NAME> <<EMAIL>>
 * @copyright     Copyright (c) <NAME>, https://www.rothauer-it.com
 * @link          https://www.foodcoopshop.com
 */
foodcoopshop.ModalProductStatusEditBulk = {

    init : function() {

        var modalSelector = '#modal-product-status-edit-bulk';

        var button = $('#editStatusForSelectedProducts');
        foodcoopshop.Helper.disableButton(button);

        $('table.list').find('input.row-marker[type="checkbox"]').on('click', function () {
            foodcoopshop.Admin.updateObjectSelectionActionButton(button);
        });

        button.on('click', function () {

            var productIds = foodcoopshop.Admin.getSelectedProductIds();

            var html = '';
            var infoText = '';

            if (productIds.length == 1) {
                infoText = foodcoopshop.LocalizedJs.admin.YouSelectedOneProduct;
            } else {
                infoText = foodcoopshop.LocalizedJs.admin.YouSelected0Products.replace(/\{0\}/, '<b>' + productIds.length + '</b>');
            }
            infoText += '<br />';

            var products = [];
            for (var i in productIds) {
                products.push($('tr#product-' + productIds[i] + ' span.product-name').html());
            }
            html += '<ul><li>' + products.join('</li><li>') + '</li></ul>';

            var buttons = [
                foodcoopshop.Modal.createButton(['btn-success'], foodcoopshop.LocalizedJs.admin.Activate, 'fa-fw fas fa-check'),
                foodcoopshop.Modal.createButton(['btn-danger'], foodcoopshop.LocalizedJs.admin.Deactivate, 'fa-fw fas fa-minus-circle'),
                foodcoopshop.Modal.createButton(['btn-outline-light'], foodcoopshop.LocalizedJs.helper.cancel, null, true)
            ];

            foodcoopshop.Modal.appendModalToDom(
                modalSelector,
                foodcoopshop.LocalizedJs.admin.ChangeStatus,
                html,
                buttons
            );

            foodcoopshop.Modal.bindSuccessButton(modalSelector, function() {
                foodcoopshop.ModalProductStatusEditBulk.getSuccessHandler(modalSelector, 1);
            });

            $(modalSelector + ' .modal-footer .btn-danger').on('click', function() {
                foodcoopshop.Helper.addSpinnerToButton($(this), 'fa-minus-circle');
                foodcoopshop.Helper.disableButton($(this));
                foodcoopshop.ModalProductStatusEditBulk.getSuccessHandler(modalSelector, 0);
            });
    
            $(modalSelector).on('hidden.bs.modal', function (e) {
                foodcoopshop.ModalProductStatusEditBulk.getCloseHandler(modalSelector);
            });
            foodcoopshop.ModalProductStatusEditBulk.getOpenHandler(modalSelector);

        });

    },

    getCloseHandler : function(modalSelector) {
        $(modalSelector).remove();<commit_msg>version<commit_after>/**
 * FoodCoopShop - The open source software for your foodcoop
 *
 * Licensed under the GNU Affero General Public License version 3
 * For full copyright and license information, please see LICENSE
 * Redistributions of files must retain the above copyright notice.
 *
 * @since         FoodCoopShop 3.6.0
 * @license       https://opensource.org/licenses/AGPL-3.0
 * @author        <NAME> <<EMAIL>>
 * @copyright     Copyright (c) <NAME>, https://www.rothauer-it.com
 * @link          https://www.foodcoopshop.com
 */
foodcoopshop.ModalProductStatusEditBulk = {

    init : function() {

        var modalSelector = '#modal-product-status-edit-bulk';

        var button = $('#editStatusForSelectedProducts');
        foodcoopshop.Helper.disableButton(button);

        $('table.list').find('input.row-marker[type="checkbox"]').on('click', function () {
            foodcoopshop.Admin.updateObjectSelectionActionButton(button);
        });

        button.on('click', function () {

            var productIds = foodcoopshop.Admin.getSelectedProductIds();

            var html = '';
            var infoText = '';

            if (productIds.length == 1) {
                infoText = foodcoopshop.LocalizedJs.admin.YouSelectedOneProduct;
            } else {
                infoText = foodcoopshop.LocalizedJs.admin.YouSelected0Products.replace(/\{0\}/, '<b>' + productIds.length + '</b>');
            }
            infoText += '<br />';

            var products = [];
            for (var i in productIds) {
                products.push($('tr#product-' + productIds[i] + ' span.product-name').html());
            }
            html += '<ul><li>' + products.join('</li><li>') + '</li></ul>';

            var buttons = [
                foodcoopshop.Modal.createButton(['btn-success'], foodcoopshop.LocalizedJs.admin.Activate, 'fa-fw fas fa-check'),
                foodcoopshop.Modal.createButton(['btn-danger'], foodcoopshop.LocalizedJs.admin.Deactivate, 'fa-fw fas fa-minus-circle'),
                foodcoopshop.Modal.createButton(['btn-outline-light'], foodcoopshop.LocalizedJs.helper.cancel, null, true)
            ];

            foodcoopshop.Modal.appendModalToDom(
                modalSelector,
                foodcoopshop.LocalizedJs.admin.ChangeStatus,
                html,
                buttons
            );

            foodcoopshop.Modal.bindSuccessButton(modalSelector, function() {
                foodcoopshop.ModalProductStatusEditBulk.getSuccessHandler(modalSelector, 1);
            });

            $(modalSelector + ' .modal-footer .btn-danger').on('click', function() {
                foodcoopshop.Helper.addSpinnerToButton($(this), 'fa-minus-circle');
                foodcoopshop.Helper.disableButton($(this));
                foodcoopshop.ModalProductStatusEditBulk.getSuccessHandler(modalSelector, 0);
            });

            $(modalSelector).on('hidden.bs.modal', function (e) {
                foodcoopshop.ModalProductStatusEditBulk.getCloseHandler(modalSelector);
            });
            foodcoopshop.ModalProductStatusEditBulk.getOpenHandler(modalSelector);

        });

    },

    getCloseHandler : function(modalSelector) {
        $(modalSelector).remove();
{'fraction_non_alphanumeric': 0.13181398213735757, 'fraction_numerical': 0.0033877425315676007, 'mean_word_length': 2.3053435114503817, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6202085', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1738, 'n_words': 285}