All files / src/components gridAction.js

0% Statements 0/26
0% Branches 0/13
0% Functions 0/6
0% Lines 0/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47                                                                                             
const gridButton = {
    noGridAction : (event,that) => {
        event.preventDefault();
    },
    confirmGridAction : (event,that) => {
        event.preventDefault();
        var actionUrl = $(that).attr('href');
        if(!actionUrl) {
            LOG.error("confirmGridAction without valid element");
            return;
        }
        var text = $(that).data('confirm-text') || $(that).attr('title') || $(that).data('original-title');
        var utf8 = $(that).data('confirm-utf8') || LS.lang.confirm;
        var gridid = $(that).data('gridid') || $(that).closest(".grid-view").attr("id");
        $.bsconfirm(text,utf8,function onClickOK() {
            $('#'+gridid).yiiGridView('update', {
                type : 'POST',
                url : actionUrl,
                success: function(data) {
                    jQuery('#'+gridid).yiiGridView('update');
                    $('#identity__bsconfirmModal').modal('hide');
                    // todo : show an success alert box
                },
                error: function (request, status, error) {
                    $('#identity__bsconfirmModal').modal('hide');
                    alert(request.responseText);// Use a better alert box (see todo success)
                }
            });
        });
    },
    postGridAction : (event,that) => {
        event.preventDefault();
        var parts = $(that).attr('href').split("#");
        var actionUrl = parts[0];
        if(!actionUrl) {
            LOG.error("postGridAction without valid element");
            return;
        }
        var postAction = '';
        if(parts.length > 1) {
            postAction= parts[1];
        }
        window.LS.sendPost(actionUrl,postAction);
    }
}
export default {gridButton};