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

(-)a/Koha/MarcMergeRule.pm (-1 / +7 lines)
Lines 23-29 my $cache = Koha::Caches->get_instance(); Link Here
23
23
24
=head1 NAME
24
=head1 NAME
25
25
26
Koha::MarcMergeRule - Koha SearchField Object class
26
Koha::MarcMergeRule - Koha MarcMergeRule Object class
27
28
=cut
29
30
=head2 store
31
32
Override C<store> to clear marc merge rules cache.
27
33
28
=cut
34
=cut
29
35
(-)a/Koha/MarcMergeRules.pm (-9 / +43 lines)
Lines 26-35 use Scalar::Util qw(looks_like_number); Link Here
26
26
27
use parent qw(Koha::Objects);
27
use parent qw(Koha::Objects);
28
28
29
sub operations {
30
    return ('add', 'append', 'remove', 'delete');
31
}
32
33
my $cache = Koha::Caches->get_instance();
29
my $cache = Koha::Caches->get_instance();
34
30
35
=head1 NAME
31
=head1 NAME
Lines 40-45 Koha::MarcMergeRules - Koha MarcMergeRules Object set class Link Here
40
36
41
=head2 Class Methods
37
=head2 Class Methods
42
38
39
=head3 operations
40
41
Returns a list of all valid operations.
42
43
=cut
44
45
sub operations {
46
    return ('add', 'append', 'remove', 'delete');
47
}
48
43
=head3 context_rules
49
=head3 context_rules
44
50
45
    my $rules = Koha::MarcMergeRules->context_rules($context);
51
    my $rules = Koha::MarcMergeRules->context_rules($context);
Lines 287-318 sub _clear_caches { Link Here
287
    $cache->clear_from_cache('marc_merge_rules');
293
    $cache->clear_from_cache('marc_merge_rules');
288
}
294
}
289
295
296
=head2 find_or_create
297
298
Override C<find_or_create> to clear marc merge rules cache.
299
300
=cut
301
290
sub find_or_create {
302
sub find_or_create {
291
    my $self = shift @_;
303
    my $self = shift @_;
292
    $self->_clear_caches();
304
    $self->_clear_caches();
293
    $self->SUPER::find_or_create(@_);
305
    $self->SUPER::find_or_create(@_);
294
}
306
}
295
307
308
=head2 update
309
310
Override C<update> to clear marc merge rules cache.
311
312
=cut
313
296
sub update {
314
sub update {
297
    my $self = shift @_;
315
    my $self = shift @_;
298
    $self->_clear_caches();
316
    $self->_clear_caches();
299
    return $self->SUPER::update(@_);
317
    return $self->SUPER::update(@_);
300
}
318
}
301
319
320
=head2 delete
321
322
Override C<delete> to clear marc merge rules cache.
323
324
=cut
325
302
sub delete {
326
sub delete {
303
    my $self = shift @_;
327
    my $self = shift @_;
304
    $self->_clear_caches();
328
    $self->_clear_caches();
305
    return $self->SUPER::delete(@_);
329
    return $self->SUPER::delete(@_);
306
}
330
}
307
331
332
=head2 validate
333
334
    Koha::MarcMergeRules->validate($rule_data);
335
336
Validates C<$rule_data>. Throws C<Koha::Exceptions::MarcMergeRule::InvalidTagRegExp>
337
if C<$rule_data->{tag}> contains an invalid regular expression. Throws
338
C<Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions> if contains invalid
339
combination of actions for control fields. Otherwise returns true.
340
341
=cut
342
308
sub validate {
343
sub validate {
309
    my ($self, $rule_data) = @_;
344
    my ($self, $rule_data) = @_;
310
345
311
    #use Data::Dumper;
312
    #Koha::Exceptions::MarcMergeRule::InvalidTagRegExp->throw(
313
    #    Dumper($rule_data)
314
    #);
315
316
    if(exists $rule_data->{tag}) {
346
    if(exists $rule_data->{tag}) {
317
        if ($rule_data->{tag} ne '*') {
347
        if ($rule_data->{tag} ne '*') {
318
            eval { qr/$rule_data->{tag}/ };
348
            eval { qr/$rule_data->{tag}/ };
Lines 341-346 sub _type { Link Here
341
    return 'MarcMergeRule';
371
    return 'MarcMergeRule';
342
}
372
}
343
373
374
=head3 object_class
375
376
=cut
377
344
sub object_class {
378
sub object_class {
345
    return 'Koha::MarcMergeRule';
379
    return 'Koha::MarcMergeRule';
346
}
380
}
(-)a/Koha/MarcMergeRulesModule.pm (-5 / +1 lines)
Lines 21-27 use parent qw(Koha::Object); Link Here
21
21
22
=head1 NAME
22
=head1 NAME
23
23
24
Koha::MarcMergeRulesModule - Koha SearchField Object class
24
Koha::MarcMergeRulesModule - Koha MarcMergeRulesModule Object class
25
25
26
=head1 API
26
=head1 API
27
27
Lines 29-38 Koha::MarcMergeRulesModule - Koha SearchField Object class Link Here
29
29
30
=cut
30
=cut
31
31
32
=head3 type
33
34
=cut
35
36
sub _type {
32
sub _type {
37
    return 'MarcMergeRulesModule';
33
    return 'MarcMergeRulesModule';
38
}
34
}
(-)a/Koha/MarcMergeRulesModules.pm (+14 lines)
Lines 20-29 use Koha::MarcMergeRulesModule; Link Here
20
20
21
use parent qw(Koha::Objects);
21
use parent qw(Koha::Objects);
22
22
23
=head1 NAME
24
25
Koha::MarcRulesModules - Koha MarcRulesModules Object set class
26
27
=head1 API
28
29
=head2 Class Methods
30
31
=cut
32
23
sub _type {
33
sub _type {
24
    return 'MarcMergeRulesModule';
34
    return 'MarcMergeRulesModule';
25
}
35
}
26
36
37
=head3 object_class
38
39
=cut
40
27
sub object_class {
41
sub object_class {
28
    return 'Koha::MarcMergeRulesModule';
42
    return 'Koha::MarcMergeRulesModule';
29
}
43
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-merge-rules.tt (-25 / +48 lines)
Lines 2-8 Link Here
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Administration &rsaquo; MARC merge rules</title>
3
<title>Koha &rsaquo; Administration &rsaquo; MARC merge rules</title>
4
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
5
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
5
[% Asset.css("css/datatables.css") %]
6
[% INCLUDE 'datatables.inc' %]
6
[% INCLUDE 'datatables.inc' %]
7
7
8
<style type="text/css">
8
<style type="text/css">
Lines 298-305 $(document).ready(function(){ Link Here
298
                    <option value="1">Delete</option>
298
                    <option value="1">Delete</option>
299
                </select>
299
                </select>
300
            </th>
300
            </th>
301
            <th><button class="btn btn-small" title="Add" id="add"><i class="fa fa-plus"></i> Add rule</button></th>
301
            <th><button class="btn btn-sm" title="Add" id="add"><i class="fa fa-plus"></i> Add rule</button></th>
302
            <th><button id="btn_batchremove" disabled="disabled" class="btn btn-small" title="Batch remove"><i class="fa fa-trash"></i> Delete selected</button></th>
302
            <th><button id="btn_batchremove" disabled="disabled" class="btn btn-sm" title="Batch remove"><i class="fa fa-trash"></i> Delete selected</button></th>
303
        </tr>
303
        </tr>
304
    </tfoot>
304
    </tfoot>
305
    [% END %]
305
    [% END %]
Lines 312-326 $(document).ready(function(){ Link Here
312
                    <select name="module">
312
                    <select name="module">
313
                        [% FOREACH module IN modules %]
313
                        [% FOREACH module IN modules %]
314
                            [% IF module.name == rule.module %]
314
                            [% IF module.name == rule.module %]
315
                                <option value="[% module.id %]" selected="selected">[% module.name %]</option>
315
                                <option value="[% module.id | html %]" selected="selected">[% module.name %]</option>
316
                            [% ELSE %]
316
                            [% ELSE %]
317
                                <option value="[% module.id %]">[% module.name %]</option>
317
                                <option value="[% module.id | html %]">[% module.name %]</option>
318
                            [% END %]
318
                            [% END %]
319
                        [% END %]
319
                        [% END %]
320
                    </select>
320
                    </select>
321
                </td>
321
                </td>
322
                <td><input type="text" size="5" name="filter" value="[% rule.filter %]"/></td>
322
                <td><input type="text" size="5" name="filter" value="[% rule.filter | html %]"/></td>
323
                <td><input type="text" size="3" name="tag" value="[% rule.tag %]"/></td>
323
                <td><input type="text" size="3" name="tag" value="[% rule.tag | html %]"/></td>
324
                <th>
324
                <th>
325
                    <select name="preset">
325
                    <select name="preset">
326
                        <option value="" selected>Custom</option>
326
                        <option value="" selected>Custom</option>
Lines 331-379 $(document).ready(function(){ Link Here
331
                </th>
331
                </th>
332
                <td class="rule-operation-action-edit">
332
                <td class="rule-operation-action-edit">
333
                    <select name="add">
333
                    <select name="add">
334
                        <option value="0"[% IF !rule.add %] selected="selected"[% END %]>Skip</option>
334
                        [% IF rule.add %]
335
                        <option value="1"[% IF rule.add %] selected="selected"[% END %]>Add</option>
335
                            <option value="0">Skip</option>
336
                            <option value="1" selected="selected">Add</option>
337
                        [% ELSE %]
338
                            <option value="0" selected="selected">Skip</option>
339
                            <option value="1">Add</option>
340
                        [% END %]
336
                    </select>
341
                    </select>
337
                </td>
342
                </td>
338
                <td class="rule-operation-action-edit">
343
                <td class="rule-operation-action-edit">
339
                    <select name="append">
344
                    <select name="append">
340
                        <option value="0"[% IF !rule.append %] selected="selected"[% END %]>Skip</option>
345
                        [% IF rule.append %]
341
                        <option value="1"[% IF rule.append %] selected="selected"[% END %]>Append</option>
346
                            <option value="0">Skip</option>
347
                            <option value="1" selected="selected">Append</option>
348
                        [% ELSE %]
349
                            <option value="0" selected="selected">Skip</option>
350
                            <option value="1">Append</option>
351
                        [% END %]
342
                    </select>
352
                    </select>
343
                </td>
353
                </td>
344
                <td class="rule-operation-action-edit">
354
                <td class="rule-operation-action-edit">
345
                    <select name="remove">
355
                    <select name="remove">
346
                        <option value="0"[% IF !rule.remove %] selected="selected"[% END %]>Skip</option>
356
                        [% IF rule.remove %]
347
                        <option value="1"[% IF rule.remove %] selected="selected"[% END %]>Remove</option>
357
                            <option value="0">Skip</option>
358
                            <option value="1" selected="selected">Remove</option>
359
                        [% ELSE %]
360
                            <option value="0" selected="selected">Skip</option>
361
                            <option value="1">Remove</option>
362
                        [% END %]
348
                    </select>
363
                    </select>
349
                </td>
364
                </td>
350
                <td class="rule-operation-action-edit">
365
                <td class="rule-operation-action-edit">
351
                    <select name="delete">
366
                    <select name="delete">
352
                        <option value="0"[% IF !rule.delete %] selected="selected"[% END %]>Skip</option>
367
                        [% IF rule.delete %]
353
                        <option value="1"[% IF rule.delete %] selected="selected"[% END %]>Delete</option>
368
                            <option value="0">Skip</option>
369
                            <option value="1" selected="selected">Delete</option>
370
                        [% ELSE %]
371
                            <option value="0" selected="selected">Skip</option>
372
                            <option value="1">Delete</option>
373
                        [% END %]
354
                    </select>
374
                    </select>
355
                </td>
375
                </td>
356
                <td class="actions">
376
                <td class="actions">
357
                    <button class="btn btn-mini" title="Save" id="doedit" value="[% rule.id %]"><i class="fa fa-check"></i> Save</button>
377
                    <button class="btn btn-sm" title="Save" id="doedit" value="[% rule.id | html %]"><i class="fa fa-check"></i> Save</button>
358
                    <a href="?"><button class="btn btn-mini" title="Cancel" ><i class="fa fa-times"></i> Cancel</button></a>
378
                    <a href="?"><button class="btn btn-sm" title="Cancel" ><i class="fa fa-times"></i> Cancel</button></a>
359
                </td>
379
                </td>
360
                <td></td>
380
                <td></td>
361
            [% ELSE %]
381
            [% ELSE %]
362
                <td>[% rule.id %]</td>
382
                <td>[% rule.id | html %]</td>
363
                <td>[% rule.module %]</td>
383
                <td>[% rule.module | html %]</td>
364
                <td>[% rule.filter %]</td>
384
                <td>[% rule.filter | html %]</td>
365
                <td>[% rule.tag %]</td>
385
                <td>[% rule.tag | html %]</td>
366
                <td class="rule-preset"></td>
386
                <td class="rule-preset"></td>
367
                <td class="rule-operation-action" data-operation="add">[% IF rule.add %]Add[% ELSE %]Skip[% END %]</td>
387
                <td class="rule-operation-action" data-operation="add">[% IF rule.add %]Add[% ELSE %]Skip[% END %]</td>
368
                <td class="rule-operation-action" data-operation="append">[% IF rule.append %]Append[% ELSE %]Skip[% END %]</td>
388
                <td class="rule-operation-action" data-operation="append">[% IF rule.append %]Append[% ELSE %]Skip[% END %]</td>
369
                <td class="rule-operation-action" data-operation="remove">[% IF rule.remove %]Remove[% ELSE %]Skip[% END %]</td>
389
                <td class="rule-operation-action" data-operation="remove">[% IF rule.remove %]Remove[% ELSE %]Skip[% END %]</td>
370
                <td class="rule-operation-action" data-operation="delete">[% IF rule.delete %]Delete[% ELSE %]Skip[% END %]</td>
390
                <td class="rule-operation-action" data-operation="delete">[% IF rule.delete %]Delete[% ELSE %]Skip[% END %]</td>
371
                <td class="actions">
391
                <td class="actions">
372
                    <a href="?op=remove&id=[% rule.id %]" title="Delete" class="btn btn-mini"><i class="fa fa-trash"></i> Delete</a>
392
                    <a href="?op=remove&id=[% rule.id %]" title="Delete" class="btn btn-sm"><i class="fa fa-trash"></i> Delete</a>
373
                    <a href="?op=edit&id=[% rule.id %]" title="Edit" class="btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
393
                    <a href="?op=edit&id=[% rule.id %]" title="Edit" class="btn btn-sm"><i class="fa fa-pencil"></i> Edit</a>
374
                </td>
394
                </td>
375
                <td>
395
                <td>
376
                    <input type="checkbox" name="batchremove" value="[% rule.id %]"[% IF rule.removemarked %] checked="checked"[% END %]/>
396
                    [% IF rule.removemarked %]
397
                        <input type="checkbox" name="batchremove" value="[% rule.id | html %]" checked="checked"/>
398
                    [% ELSE %]
399
                        <input type="checkbox" name="batchremove" value="[% rule.id | html %]"/>
400
                    [% END %]
377
                </td>
401
                </td>
378
            [% END %]
402
            [% END %]
379
            </tr>
403
            </tr>
380
- 

Return to bug 14957