View | Details | Raw Unified | Return to bug 36880
Collapse All | Expand All

(-)a/admin/marc-overlay-rules.pl (-15 / +4 lines)
Lines 66-88 my $get_rules = sub { Link Here
66
};
66
};
67
my $rules = $get_rules->();
67
my $rules = $get_rules->();
68
68
69
if ($op eq 'remove' || $op eq 'cud-remove') {
69
if ($op eq 'cud-remove') {
70
    my @remove_ids = $input->multi_param('batchremove');
70
    my @remove_ids = $input->multi_param('batchremove');
71
    push @remove_ids, scalar $input->param('id') if $input->param('id');
71
    push @remove_ids, scalar $input->param('id') if $input->param('id');
72
    if ($op eq 'remove') {
72
    Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete();
73
        $template->{VARS}->{removeConfirm} = 1;
73
    # Update $rules after deletion
74
        my %remove_ids = map { $_ => undef } @remove_ids;
74
    $rules = $get_rules->();
75
        for my $rule (@{$rules}) {
76
            $rule->{'removemarked'} = 1 if exists $remove_ids{$rule->{id}};
77
        }
78
    }
79
    elsif ($op eq 'cud-remove') {
80
        my @remove_ids = $input->multi_param('batchremove');
81
        push @remove_ids, scalar $input->param('id') if $input->param('id');
82
        Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete();
83
        # Update $rules after deletion
84
        $rules = $get_rules->();
85
    }
86
}
75
}
87
elsif ($op eq 'edit') {
76
elsif ($op eq 'edit') {
88
    $template->param( edit => 1 );
77
    $template->param( edit => 1 );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt (-33 / +23 lines)
Lines 66-86 Link Here
66
                    The [%  pref_MARCOverlayRules_link | $raw | $KohaSpan %] preference is not set, don't forget to enable it for rules to take effect.
66
                    The [%  pref_MARCOverlayRules_link | $raw | $KohaSpan %] preference is not set, don't forget to enable it for rules to take effect.
67
                </div>
67
                </div>
68
                [% END %]
68
                [% END %]
69
                [% IF removeConfirm %]
70
                <div class="dialog alert">
71
                    <h3>Remove rule?</h3>
72
                    <p>Are you sure you want to remove the selected rule(s)?</p>
73
74
                    <form action="/cgi-bin/koha/admin/marc-overlay-rules.pl" method="GET">
75
                        <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not remove</button>
76
                    </form>
77
                    <button type="button" class="approve" id="doremove"><i class="fa fa-fw fa-check"></i> Yes, remove</button>
78
                </div>
79
                [% END %]
80
69
81
                <div class="page-section">
70
                <div class="page-section">
82
                <form action="/cgi-bin/koha/admin/marc-overlay-rules.pl" method="POST" id="marc-overlay-rules-form">
71
                <form action="/cgi-bin/koha/admin/marc-overlay-rules.pl" method="POST" id="marc-overlay-rules-form">
83
                    [% INCLUDE 'csrf-token.inc' %]
72
                    [% INCLUDE 'csrf-token.inc' %]
73
                    <input type="hidden" name="op">
84
                    <table id="marc-overlay-rules">
74
                    <table id="marc-overlay-rules">
85
                        <thead><tr>
75
                        <thead><tr>
86
                            <th>Rule</th>
76
                            <th>Rule</th>
Lines 229-235 Link Here
229
                                    </td>
219
                                    </td>
230
                                    <td class="actions">
220
                                    <td class="actions">
231
                                        <button class="btn btn-default btn-xs" title="Save" id="doedit" value="[% rule.id | html %]"><i class="fa fa-check"></i> Save</button>
221
                                        <button class="btn btn-default btn-xs" title="Save" id="doedit" value="[% rule.id | html %]"><i class="fa fa-check"></i> Save</button>
232
                                        <button type="submit" class="btn btn-default btn-xs" title="Cancel" ><i class="fa fa-times"></i> Cancel</button>
222
                                        <a href="/cgi-bin/koha/admin/marc-overlay-rules.pl" class="btn btn-default btn-xs" title="Cancel"><i class="fa fa-times"></i> Cancel</a>
233
                                    </td>
223
                                    </td>
234
                                    <td></td>
224
                                    <td></td>
235
                                [% ELSE %]
225
                                [% ELSE %]
Lines 270-284 Link Here
270
                                    <td class="rule-operation-action" data-operation="remove" data-value="[% rule.remove | html %]">[% IF rule.remove %]Remove[% ELSE %]Skip[% END %]</td>
260
                                    <td class="rule-operation-action" data-operation="remove" data-value="[% rule.remove | html %]">[% IF rule.remove %]Remove[% ELSE %]Skip[% END %]</td>
271
                                    <td class="rule-operation-action" data-operation="delete" data-value="[% rule.delete | html %]">[% IF rule.delete %]Delete[% ELSE %]Skip[% END %]</td>
261
                                    <td class="rule-operation-action" data-operation="delete" data-value="[% rule.delete | html %]">[% IF rule.delete %]Delete[% ELSE %]Skip[% END %]</td>
272
                                    <td class="actions">
262
                                    <td class="actions">
273
                                        <a href="?op=remove&id=[% rule.id | uri %]" title="Delete" class="btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Delete</a>
263
                                        <a title="Delete" class="btn btn-default btn-xs btn_remove"><i class="fa fa-trash-can"></i> Delete</a>
274
                                        <a href="?op=edit&id=[% rule.id | uri %]" title="Edit" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
264
                                        <a href="?op=edit&id=[% rule.id | uri %]" title="Edit" class="btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
275
                                    </td>
265
                                    </td>
276
                                    <td>
266
                                    <td>
277
                                        [% IF rule.removemarked %]
267
                                        <input type="checkbox" name="batchremove" value="[% rule.id | html %]"/>
278
                                            <input type="checkbox" name="batchremove" value="[% rule.id | html %]" checked="checked"/>
279
                                        [% ELSE %]
280
                                            <input type="checkbox" name="batchremove" value="[% rule.id | html %]"/>
281
                                        [% END %]
282
                                    </td>
268
                                    </td>
283
                                [% END %]
269
                                [% END %]
284
                                </tr>
270
                                </tr>
Lines 288-298 Link Here
288
                </form>
274
                </form>
289
                </div> <!-- /.page-section -->
275
                </div> <!-- /.page-section -->
290
276
291
                <form action="/cgi-bin/koha/admin/marc-overlay-rules.pl" method="post">
292
                    [% INCLUDE 'csrf-token.inc' %]
293
                    <input type="hidden" name="op" value="cud-redo-matching" />
294
                </form>
295
296
            </div><!-- /.col-sm-10.col-sm-push-2 -->
277
            </div><!-- /.col-sm-10.col-sm-push-2 -->
297
278
298
            <div class="col-sm-2 col-sm-pull-10">
279
            <div class="col-sm-2 col-sm-pull-10">
Lines 311-320 Link Here
311
    <script>
292
    <script>
312
    $(document).ready(function(){
293
    $(document).ready(function(){
313
        function doSubmit(op, id) {
294
        function doSubmit(op, id) {
314
            $('<input type="hidden"/>')
295
            $('#marc-overlay-rules-form > input[name="op"]').val(op);
315
            .attr('name', 'op')
316
            .attr('value', op)
317
            .appendTo('#marc-overlay-rules-form');
318
296
319
            if(id) {
297
            if(id) {
320
                $('<input type="hidden"/>')
298
                $('<input type="hidden"/>')
Lines 333-338 Link Here
333
                    if (validate[i].length) {
311
                    if (validate[i].length) {
334
                        if(validate[i].val().length == 0) {
312
                        if(validate[i].val().length == 0) {
335
                            validate[i].addClass('required');
313
                            validate[i].addClass('required');
314
                            validate[i].focus();
336
                            valid = false;
315
                            valid = false;
337
                        } else {
316
                        } else {
338
                            validate[i].removeClass('required');
317
                            validate[i].removeClass('required');
Lines 342-367 Link Here
342
            }
321
            }
343
322
344
            if (valid) {
323
            if (valid) {
345
                $('#marc-overlay-rules-form').submit();
324
                return $('#marc-overlay-rules-form').submit();
346
            }
325
            }
347
326
348
            return valid;
327
            return valid;
349
        }
328
        }
350
329
351
        $('#doremove').on('click', function(){
352
            doSubmit('cud-remove');
353
        });
354
        $('#doedit').on('click', function(){
330
        $('#doedit').on('click', function(){
355
            doSubmit('cud-edit', $("#doedit").attr('value'));
331
            doSubmit('cud-edit', $("#doedit").attr('value'));
332
            return false;
356
        });
333
        });
357
        $('#add').on('click', function(){
334
        $('#add').on('click', function(){
358
            doSubmit('cud-add');
335
            doSubmit('cud-add');
359
            return false;
336
            return false;
360
        });
337
        });
338
        $('.btn_remove').on('click', function(el){
339
            // mark delete checkbox in row
340
            $(el.target).closest('tr').find('[name="batchremove"]').prop( "checked", true );
341
            $('#btn_batchremove').removeAttr('disabled');
342
            confirm_remove();
343
            return false;
344
        });
361
        $('#btn_batchremove').on('click', function(){
345
        $('#btn_batchremove').on('click', function(){
362
            doSubmit('cud-remove');
346
            confirm_remove();
347
            return false;
363
        });
348
        });
364
349
350
        function confirm_remove(){
351
            if (confirm("Are you sure you want to remove the selected rule(s)?")){
352
                doSubmit('cud-remove');
353
            }
354
        }
355
365
        /* Disable batch remove unless one or more checkboxes are checked */
356
        /* Disable batch remove unless one or more checkboxes are checked */
366
        $('input[name="batchremove"]').change(function() {
357
        $('input[name="batchremove"]').change(function() {
367
            if($('input[name="batchremove"]:checked').length > 0) {
358
            if($('input[name="batchremove"]:checked').length > 0) {
368
- 

Return to bug 36880