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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-59 / +7 lines)
Lines 1-74 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
3
[% PROCESS 'i18n.inc' %]
4
[% PROCESS 'i18n.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Administration &rsaquo; Search engine configuration (Elasticsearch)</title>
6
<title>Koha &rsaquo; Administration &rsaquo; Search engine configuration (Elasticsearch)</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
7
[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
8
<script>
9
    function clean_line( line ) {
10
        $(line).find('input[type="text"]').val("");
11
        $(line).find('select').find('option:first').attr("selected", "selected");
12
    }
13
14
    function clone_line( line ) {
15
        var new_line = $(line).clone();
16
        $(new_line).removeClass("nodrag nodrop");
17
        $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html(_("Delete"));
18
        $(new_line).find('[data-id]').each( function() {
19
            $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id');
20
        } );
21
        $(new_line).find("select").each( function() {
22
            var attr = $(this).attr('name');
23
            var val = $(line).find('[data-id="' + attr + '"]').val();
24
            $(this).find('option[value="' + val + '"]').attr("selected", "selected");
25
        } );
26
        return new_line;
27
    }
28
29
    $(document).ready(function() {
30
        $("#tabs").tabs();
31
        $('.delete').click(function() {
32
            if( $(this).hasClass('mandatory') && $(".mandatory[data-field_name="+$(this).attr('data-field_name')+"]").length < 2 ){
33
                alert("This field is mandatory and must have at least one mapping");
34
                return;
35
            } else {
36
                $(this).parents('tr').remove();
37
            }
38
        });
39
40
        $("table.mappings").tableDnD( {
41
            onDragClass: "dragClass",
42
        } );
43
        $('.add').click(function() {
44
            var table = $(this).closest('table');
45
            var index_name   = $(table).attr('data-index_name');
46
            var line = $(this).closest("tr");
47
            var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val();
48
            if ( marc_field.length > 0 ) {
49
                var new_line = clone_line( line );
50
                new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody'));
51
                $('.delete').click(function() {
52
                    $(this).parents('tr').remove();
53
                });
54
                clean_line(line);
55
56
                $(table).tableDnD( {
57
                    onDragClass: "dragClass",
58
                } );
59
            }
60
        });
61
        $("#facet_biblios > table").tableDnD( {
62
            onDragClass: "dragClass",
63
        } );
64
    });
65
</script>
66
<style>
8
<style>
67
a.add, a.delete {
9
a.add, a.delete {
68
    cursor: pointer;
10
    cursor: pointer;
69
}
11
}
70
</style>
12
</style>
71
</head>
13
</head>
14
72
<body id="admin_searchengine_mappings" class="admin">
15
<body id="admin_searchengine_mappings" class="admin">
73
[% INCLUDE 'header.inc' %]
16
[% INCLUDE 'header.inc' %]
74
[% INCLUDE 'prefs-admin-search.inc' %]
17
[% INCLUDE 'prefs-admin-search.inc' %]
Lines 521-524 a.add, a.delete { Link Here
521
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
464
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
522
     </div> <!-- /.row -->
465
     </div> <!-- /.row -->
523
466
467
[% MACRO jsinclude BLOCK %]
468
    [% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %]
469
    [% Asset.js("js/elasticsearch-mappings.js") | $raw %]
470
[% END %]
471
524
[% INCLUDE 'intranet-bottom.inc' %]
472
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/elasticsearch-mappings.js (-1 / +58 lines)
Line 0 Link Here
0
- 
1
/* global __ */
2
3
function clean_line(line) {
4
    $(line).find('input[type="text"]').val("");
5
    $(line).find('select').find('option:first').attr("selected", "selected");
6
}
7
8
function clone_line(line) {
9
    var new_line = $(line).clone();
10
    $(new_line).removeClass("nodrag nodrop");
11
    $(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html( __("Delete") );
12
    $(new_line).find('[data-id]').each(function () {
13
        $(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id');
14
    });
15
    $(new_line).find("select").each(function () {
16
        var attr = $(this).attr('name');
17
        var val = $(line).find('[data-id="' + attr + '"]').val();
18
        $(this).find('option[value="' + val + '"]').attr("selected", "selected");
19
    });
20
    return new_line;
21
}
22
23
$(document).ready(function () {
24
    $("#tabs").tabs();
25
    $('.delete').click(function () {
26
        if ($(this).hasClass('mandatory') && $(".mandatory[data-field_name=" + $(this).attr('data-field_name') + "]").length < 2) {
27
            alert( __("This field is mandatory and must have at least one mapping") );
28
            return;
29
        } else {
30
            $(this).parents('tr').remove();
31
        }
32
    });
33
34
    $("table.mappings").tableDnD({
35
        onDragClass: "dragClass",
36
    });
37
    $('.add').click(function () {
38
        var table = $(this).closest('table');
39
        var index_name = $(table).attr('data-index_name');
40
        var line = $(this).closest("tr");
41
        var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val();
42
        if (marc_field.length > 0) {
43
            var new_line = clone_line(line);
44
            new_line.appendTo($('table[data-index_name="' + index_name + '"]>tbody'));
45
            $('.delete').click(function () {
46
                $(this).parents('tr').remove();
47
            });
48
            clean_line(line);
49
50
            $(table).tableDnD({
51
                onDragClass: "dragClass",
52
            });
53
        }
54
    });
55
    $("#facet_biblios > table").tableDnD({
56
        onDragClass: "dragClass",
57
    });
58
});

Return to bug 26958