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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-6 / +2 lines)
Lines 161-173 Link Here
161
                    <input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
161
                    <input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
162
                [% ELSIF ( mv.type == 'select' ) %]
162
                [% ELSIF ( mv.type == 'select' ) %]
163
                    [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
163
                    [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
164
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2" readonly="readonly" disabled="disabled">
164
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
165
                    [% ELSE %]
165
                    [% ELSE %]
166
                        [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
166
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" data-category="[% mv.category | html %]">
167
                            <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" data-category="[% mv.category | html %]">
168
                        [% ELSE %]
169
                            <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2">
170
                        [% END %]
171
                    [% END %]
167
                    [% END %]
172
                    [% FOREACH aval IN mv.values %]
168
                    [% FOREACH aval IN mv.values %]
173
                        [% IF aval == mv.default %]
169
                        [% IF aval == mv.default %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js (-32 / +47 lines)
Lines 90-131 var Select2Utils = { Link Here
90
    initSelect2: function(selects) {
90
    initSelect2: function(selects) {
91
        if ($.fn.select2) {
91
        if ($.fn.select2) {
92
            if ( window.CAN_user_parameters_manage_auth_values === undefined || ! CAN_user_parameters_manage_auth_values ) {
92
            if ( window.CAN_user_parameters_manage_auth_values === undefined || ! CAN_user_parameters_manage_auth_values ) {
93
                $(selects).select2();
93
                $(selects).select2().on("select2:clear", function () {
94
            } else {
95
                $(selects).select2({
96
                    tags: true,
97
                    createTag: function (tag) {
98
                        return {
99
                            id: tag.term,
100
                            text: tag.term,
101
                            newTag: true
102
                        };
103
                    },
104
                    templateResult: function(state) {
105
                        if (state.newTag) {
106
                            return state.text + " " + __("(select to create)");
107
                        }
108
                        return state.text;
109
                    }
110
                }).on("select2:select", function(e) {
111
                    if(e.params.data.newTag){
112
                        current_select2 = this;
113
                        var category = $(this).data("category");
114
                        $("#avCreate #new_av_category").html(category);
115
                        $("#avCreate input[name='category']").val(category);
116
                        $("#avCreate input[name='value']").val(e.params.data.text);
117
                        $("#avCreate input[name='description']").val(e.params.data.text);
118
119
                        $(this).val($(this).find("option:first").val()).trigger('change');
120
                        $('#avCreate').modal({show:true});
121
                    }
122
                }).on("select2:clear", function () {
123
                    $(this).on("select2:opening.cancelOpen", function (evt) {
94
                    $(this).on("select2:opening.cancelOpen", function (evt) {
124
                        evt.preventDefault();
95
                        evt.preventDefault();
125
126
                        $(this).off("select2:opening.cancelOpen");
96
                        $(this).off("select2:opening.cancelOpen");
127
                    });
97
                    });
128
                });
98
                });
99
            } else {
100
                $(selects).each(function(){
101
                    if ( !$(this).data("category") ) {
102
                        $(this).select2().on("select2:clear", function () {
103
                            $(this).on("select2:opening.cancelOpen", function (evt) {
104
                                evt.preventDefault();
105
                                $(this).off("select2:opening.cancelOpen");
106
                            });
107
                        });
108
                    } else {
109
                        $(this).select2({
110
                            tags: true,
111
                            createTag: function (tag) {
112
                                return {
113
                                    id: tag.term,
114
                                    text: tag.term,
115
                                    newTag: true
116
                                };
117
                            },
118
                            templateResult: function(state) {
119
                                if (state.newTag) {
120
                                    return state.text + " " + __("(select to create)");
121
                                }
122
                                return state.text;
123
                            }
124
                        }).on("select2:select", function(e) {
125
                            if(e.params.data.newTag){
126
                                current_select2 = this;
127
                                var category = $(this).data("category");
128
                                $("#avCreate #new_av_category").html(category);
129
                                $("#avCreate input[name='category']").val(category);
130
                                $("#avCreate input[name='value']").val(e.params.data.text);
131
                                $("#avCreate input[name='description']").val(e.params.data.text);
132
133
                                $(this).val($(this).find("option:first").val()).trigger('change');
134
                                $('#avCreate').modal({show:true});
135
                            }
136
                        }).on("select2:clear", function () {
137
                            $(this).on("select2:opening.cancelOpen", function (evt) {
138
                                evt.preventDefault();
139
140
                                $(this).off("select2:opening.cancelOpen");
141
                            });
142
                        });
143
                    }
144
                });
129
            }
145
            }
130
        }
146
        }
131
    }
147
    }
132
- 

Return to bug 25728