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

(-)a/cataloguing/additem.pl (+2 lines)
Lines 247-252 sub generate_subfield_form { Link Here
247
                    id          => $subfield_data{id},
247
                    id          => $subfield_data{id},
248
                    maxlength   => $subfield_data{maxlength},
248
                    maxlength   => $subfield_data{maxlength},
249
                    value       => $value,
249
                    value       => $value,
250
                    ( ( grep { $_ eq $subfieldlib->{authorised_value}} ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $subfieldlib->{authorised_value}) ),
250
                };
251
                };
251
            }
252
            }
252
            else {
253
            else {
Lines 256-261 sub generate_subfield_form { Link Here
256
                    values   => \@authorised_values,
257
                    values   => \@authorised_values,
257
                    labels   => \%authorised_lib,
258
                    labels   => \%authorised_lib,
258
                    default  => $value,
259
                    default  => $value,
260
                    ( ( grep { $_ eq $subfieldlib->{authorised_value}} ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $subfieldlib->{authorised_value}) ),
259
                };
261
                };
260
            }
262
            }
261
        }
263
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/cataloguing_create_av.inc (+41 lines)
Line 0 Link Here
1
<div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true">
2
    <div class="modal-dialog">
3
        <div class="modal-content">
4
            <div class="modal-header">
5
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
6
                <h3 id="avCreateLabel">Create a new authorised value</h3>
7
            </div>
8
            <form id="add_new_av" method="post">
9
                <div class="modal-body">
10
                    <div class="error"></div>
11
                    <fieldset class="rows">
12
                        <ol>
13
                            <li>
14
                                <span class="label">Category:</span>
15
                                <input type="hidden" name="category" value="" />
16
                                <span id="new_av_category"></span>
17
                            </li>
18
                            <li>
19
                                <span class="label" for="value">Authorised value:</span>
20
                                <input type="text" id="value" name="value" />
21
                            </li>
22
                            <li>
23
                                <span class="label" for="description">Description:</span>
24
                                <input type="text" id="description" name="description" />
25
                            </li>
26
                            <li>
27
                                <span class="label" for="opac_description">Description (OPAC):</span>
28
                                <input type="text" id="opac_description" name="opac_description" />
29
                            </li>
30
                        </ol>
31
                    </fieldset>
32
                </div>
33
                <div class="modal-footer">
34
                    <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
35
                    <input type="hidden" name="select2" value="" />
36
                    <input type="submit" class="btn btn-primary" value="Save">
37
                </div>
38
            </form>
39
        </div> <!-- /.modal-content -->
40
    </div> <!-- /.modal-dialog -->
41
</div> <!-- /#avCreate -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt (-2 / +1 lines)
Lines 5-10 Link Here
5
<title>Koha &rsaquo; Authorities &rsaquo; [% IF ( authid ) %]Modify authority #[% authid | html %] ([% authtypetext | html %])[% ELSE %]Adding authority ([% authtypetext | html %])[% END %]</title>
5
<title>Koha &rsaquo; Authorities &rsaquo; [% IF ( authid ) %]Modify authority #[% authid | html %] ([% authtypetext | html %])[% ELSE %]Adding authority ([% authtypetext | html %])[% END %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% Asset.js("lib/hc-sticky.js") | $raw %]
7
[% Asset.js("lib/hc-sticky.js") | $raw %]
8
[% INCLUDE 'select2.inc' %]
8
[% Asset.js("js/cataloging.js") | $raw %]
9
[% Asset.js("js/cataloging.js") | $raw %]
9
10
10
<script>
11
<script>
Lines 167-174 function confirmnotdup(redirect){ Link Here
167
</script>
168
</script>
168
[% Asset.css("css/addbiblio.css") | $raw %]
169
[% Asset.css("css/addbiblio.css") | $raw %]
169
170
170
[% INCLUDE 'select2.inc' %]
171
172
</head>
171
</head>
173
<body id="auth_authorities" class="auth">
172
<body id="auth_authorities" class="auth">
174
173
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-110 / +5 lines)
Lines 5-10 Link Here
5
<title>Koha &rsaquo; Cataloging &rsaquo; [% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %]</title>
5
<title>Koha &rsaquo; Cataloging &rsaquo; [% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% Asset.js("lib/hc-sticky.js") | $raw %]
7
[% Asset.js("lib/hc-sticky.js") | $raw %]
8
<script>
9
    var CAN_user_parameters_manage_auth_values = "[% CAN_user_parameters_manage_auth_values | html %]";
10
</script>
11
[% INCLUDE 'select2.inc' %]
8
[% Asset.js("js/cataloging.js") | $raw %]
12
[% Asset.js("js/cataloging.js") | $raw %]
9
[% INCLUDE 'strings.inc' %]
13
[% INCLUDE 'strings.inc' %]
10
[% Asset.js("js/browser.js") | $raw %]
14
[% Asset.js("js/browser.js") | $raw %]
Lines 482-556 Link Here
482
</script>
486
</script>
483
[% Asset.css("css/addbiblio.css") | $raw %]
487
[% Asset.css("css/addbiblio.css") | $raw %]
484
488
485
[% INCLUDE 'select2.inc' %]
486
<script>
487
  $(document).ready(function() {
488
      [% IF CAN_user_parameters_manage_auth_values %]
489
          var current_select2;
490
          $('.subfield_line select[data-category!=""]').select2({
491
              tags: true,
492
              createTag: function (tag) {
493
                  return {
494
                      id: tag.term,
495
                      text: tag.term,
496
                      newTag: true
497
                  };
498
              },
499
              templateResult: function(state) {
500
                  if (state.newTag) {
501
                      return state.text + " " + "(select to create)";
502
                  }
503
                  return state.text;
504
              }
505
          }).on("select2:select", function(e) {
506
              if(e.params.data.newTag){
507
508
                  var category = $(this).data("category");
509
                  $("#avCreate #new_av_category").html(category);
510
                  $("#avCreate input[name='category']").val(category);
511
                  $("#avCreate input[name='value']").val(e.params.data.text);
512
                  $("#avCreate input[name='description']").val(e.params.data.text);
513
                  $('#avCreate').modal({show:true});
514
515
                  $(current_select2).val($(current_select2).find("option:first").val()).trigger('change');
516
517
                  current_select2 = this;
518
519
              }
520
          }).on("select2:clear", function () {
521
              $(this).on("select2:opening.cancelOpen", function (evt) {
522
                  evt.preventDefault();
523
524
                  $(this).off("select2:opening.cancelOpen");
525
              });
526
          });
527
528
          $("#add_new_av").on("submit", function(){
529
              var data = {
530
                  category: $(this).find('input[name="category"]').val(),
531
                  value: $(this).find('input[name="value"]').val(),
532
                  description: $(this).find('input[name="description"]').val(),
533
                  opac_description: $(this).find('input[name="opac_description"]').val(),
534
              };
535
              $.ajax({
536
                  type: "POST",
537
                  url: "/api/v1/authorised_values",
538
                  data:JSON.stringify(data),
539
                  success: function(response) {
540
                      $('#avCreate').modal('hide');
541
542
                      $(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>');
543
                  },
544
                  error: function(err) {
545
                      $("#avCreate .error").html(_("Something went wrong, maybe the value already exists?"))
546
                  }
547
              });
548
              return false;
549
          });
550
      [% END %]
551
  });
552
</script>
553
554
</head>
489
</head>
555
<body id="cat_addbiblio" class="cat">
490
<body id="cat_addbiblio" class="cat">
556
491
Lines 964-1010 Link Here
964
                [%# End of fields for fast cataloging %]
899
                [%# End of fields for fast cataloging %]
965
            </form> <!-- /name=f -->
900
            </form> <!-- /name=f -->
966
901
967
            <div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true">
902
            [% INCLUDE 'modals/cataloguing_create_av.inc' %]
968
                <div class="modal-dialog">
969
                    <div class="modal-content">
970
                        <div class="modal-header">
971
                            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
972
                            <h3 id="avCreateLabel">Create a new authorised value</h3>
973
                        </div>
974
                        <form id="add_new_av" method="post">
975
                            <div class="modal-body">
976
                                <div class="error"></div>
977
                                <fieldset class="rows">
978
                                    <ol>
979
                                        <li>
980
                                            <span class="label">Category:</span>
981
                                            <input type="hidden" name="category" value="" />
982
                                            <span id="new_av_category"></span>
983
                                        </li>
984
                                        <li>
985
                                            <span class="label" for="value">Authorised value:</span>
986
                                            <input type="text" id="value" name="value" />
987
                                        </li>
988
                                        <li>
989
                                            <span class="label" for="description">Description:</span>
990
                                            <input type="text" id="description" name="description" />
991
                                        </li>
992
                                        <li>
993
                                            <span class="label" for="opac_description">Description (OPAC):</span>
994
                                            <input type="text" id="opac_description" name="opac_description" />
995
                                        </li>
996
                                    </ol>
997
                                </fieldset>
998
                            </div>
999
                            <div class="modal-footer">
1000
                                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
1001
                                <input type="hidden" name="select2" value="" />
1002
                                <input type="submit" class="btn btn-primary" value="Save">
1003
                            </div>
1004
                        </form>
1005
                    </div> <!-- /.modal-content -->
1006
                </div> <!-- /.modal-dialog -->
1007
            </div> <!-- /#avCreate -->
1008
903
1009
        </div> <!-- /.col-md-10.col-md-offset-1 -->
904
        </div> <!-- /.col-md-10.col-md-offset-1 -->
1010
    </div> <!-- /.row -->
905
    </div> <!-- /.row -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-2 / +12 lines)
Lines 8-18 Link Here
8
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
9
[% Asset.css("css/addbiblio.css") | $raw %]
9
[% Asset.css("css/addbiblio.css") | $raw %]
10
[% INCLUDE 'datatables.inc' %]
10
[% INCLUDE 'datatables.inc' %]
11
<script>
12
    var CAN_user_parameters_manage_auth_values = "[% CAN_user_parameters_manage_auth_values | html %]";
13
</script>
14
[% INCLUDE 'select2.inc' %]
11
[% Asset.js("js/cataloging.js") | $raw %]
15
[% Asset.js("js/cataloging.js") | $raw %]
12
[% INCLUDE 'columns_settings.inc' %]
16
[% INCLUDE 'columns_settings.inc' %]
13
[% INCLUDE 'strings.inc' %]
17
[% INCLUDE 'strings.inc' %]
14
[% Asset.js("js/browser.js") | $raw %]
18
[% Asset.js("js/browser.js") | $raw %]
15
[% INCLUDE 'select2.inc' %]
16
[% INCLUDE 'calendar.inc' %]
19
[% INCLUDE 'calendar.inc' %]
17
[% INCLUDE 'str/cataloging_additem.inc' %]
20
[% INCLUDE 'str/cataloging_additem.inc' %]
18
[% Asset.js("js/cataloging_additem.js") | $raw %]
21
[% Asset.js("js/cataloging_additem.js") | $raw %]
Lines 160-166 Link Here
160
                    [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
163
                    [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
161
                        <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 select2" readonly="readonly" disabled="disabled">
162
                    [% ELSE %]
165
                    [% ELSE %]
163
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2">
166
                        [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
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 %]
164
                    [% END %]
171
                    [% END %]
165
                    [% FOREACH aval IN mv.values %]
172
                    [% FOREACH aval IN mv.values %]
166
                        [% IF aval == mv.default %]
173
                        [% IF aval == mv.default %]
Lines 266-271 Link Here
266
273
267
274
268
    </form>
275
    </form>
276
277
    [% INCLUDE 'modals/cataloguing_create_av.inc' %]
278
269
                            </div> <!-- /#cataloguing_additem_newitem -->
279
                            </div> <!-- /#cataloguing_additem_newitem -->
270
                        </div> <!-- /.col-sm-10 -->
280
                        </div> <!-- /.col-sm-10 -->
271
                    </div> <!-- /.row -->
281
                    </div> <!-- /.row -->
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js (-2 / +65 lines)
Lines 515-523 function CheckImportantSubfields(p){ Link Here
515
    return total;
515
    return total;
516
}
516
}
517
517
518
 $(document).ready(function() {
518
$(document).ready(function() {
519
    $("input.input_marceditor, input.indicator").addClass('noEnterSubmit');
519
    $("input.input_marceditor, input.indicator").addClass('noEnterSubmit');
520
    $(document).ajaxSuccess(function() {
520
    $(document).ajaxSuccess(function() {
521
        $("input.input_marceditor, input.indicator").addClass('noEnterSubmit');
521
        $("input.input_marceditor, input.indicator").addClass('noEnterSubmit');
522
    });
522
    });
523
524
    if ( CAN_user_parameters_manage_auth_values ) {
525
        var current_select2;
526
        $('.subfield_line select[data-category!=""]').select2({
527
            tags: true,
528
            createTag: function (tag) {
529
                return {
530
                    id: tag.term,
531
                    text: tag.term,
532
                    newTag: true
533
                };
534
            },
535
            templateResult: function(state) {
536
                if (state.newTag) {
537
                    return state.text + " " + __("(select to create)");
538
                }
539
                return state.text;
540
            }
541
        }).on("select2:select", function(e) {
542
            if(e.params.data.newTag){
543
544
                var category = $(this).data("category");
545
                $("#avCreate #new_av_category").html(category);
546
                $("#avCreate input[name='category']").val(category);
547
                $("#avCreate input[name='value']").val(e.params.data.text);
548
                $("#avCreate input[name='description']").val(e.params.data.text);
549
                $('#avCreate').modal({show:true});
550
551
                $(current_select2).val($(current_select2).find("option:first").val()).trigger('change');
552
553
                current_select2 = this;
554
555
            }
556
        }).on("select2:clear", function () {
557
            $(this).on("select2:opening.cancelOpen", function (evt) {
558
                evt.preventDefault();
559
560
                $(this).off("select2:opening.cancelOpen");
561
            });
562
        });
563
564
        $("#add_new_av").on("submit", function(){
565
            var data = {
566
                category: $(this).find('input[name="category"]').val(),
567
                value: $(this).find('input[name="value"]').val(),
568
                description: $(this).find('input[name="description"]').val(),
569
                opac_description: $(this).find('input[name="opac_description"]').val(),
570
            };
571
            $.ajax({
572
                type: "POST",
573
                url: "/api/v1/authorised_values",
574
                data:JSON.stringify(data),
575
                success: function(response) {
576
                    $('#avCreate').modal('hide');
577
578
                    $(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>');
579
                },
580
                error: function(err) {
581
                    $("#avCreate .error").html(_("Something went wrong, maybe the value already exists?"))
582
                }
583
            });
584
            return false;
585
        });
586
    }
523
});
587
});
524
- 

Return to bug 25728