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

(-)a/cataloguing/additem.pl (+2 lines)
Lines 231-236 sub generate_subfield_form { Link Here
231
                    id          => $subfield_data{id},
231
                    id          => $subfield_data{id},
232
                    maxlength   => $subfield_data{maxlength},
232
                    maxlength   => $subfield_data{maxlength},
233
                    value       => $value,
233
                    value       => $value,
234
                    ( ( grep { $_ eq $subfieldlib->{authorised_value}} ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $subfieldlib->{authorised_value}) ),
234
                };
235
                };
235
            }
236
            }
236
            else {
237
            else {
Lines 240-245 sub generate_subfield_form { Link Here
240
                    values   => \@authorised_values,
241
                    values   => \@authorised_values,
241
                    labels   => \%authorised_lib,
242
                    labels   => \%authorised_lib,
242
                    default  => $value,
243
                    default  => $value,
244
                    ( ( grep { $_ eq $subfieldlib->{authorised_value}} ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $subfieldlib->{authorised_value}) ),
243
                };
245
                };
244
            }
246
            }
245
        }
247
        }
(-)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/cataloguing/addbiblio.tt (-110 / +4 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>
8
[% Asset.js("js/cataloging.js") | $raw %]
11
[% Asset.js("js/cataloging.js") | $raw %]
9
[% INCLUDE 'strings.inc' %]
12
[% INCLUDE 'strings.inc' %]
10
[% Asset.js("js/browser.js") | $raw %]
13
[% Asset.js("js/browser.js") | $raw %]
Lines 477-551 Link Here
477
[% Asset.css("css/addbiblio.css") | $raw %]
480
[% Asset.css("css/addbiblio.css") | $raw %]
478
481
479
[% INCLUDE 'select2.inc' %]
482
[% INCLUDE 'select2.inc' %]
480
<script>
481
  $(document).ready(function() {
482
      $('.subfield_line select[data-category=""]').select2(); // branches, itemtypes and cn_source
483
484
      [% UNLESS CAN_user_parameters_manage_auth_values %]
485
          $('.subfield_line select[data-category!=""]').select2();
486
      [% ELSE %]
487
          var current_select2;
488
          $('.subfield_line select[data-category!=""]').select2({
489
              tags: true,
490
              createTag: function (tag) {
491
                  return {
492
                      id: tag.term,
493
                      text: tag.term,
494
                      newTag: true
495
                  };
496
              },
497
              templateResult: function(state) {
498
                  if (state.newTag) {
499
                      return state.text + " " + "(select to create)";
500
                  }
501
                  return state.text;
502
              }
503
          }).on("select2:select", function(e) {
504
              if(e.params.data.newTag){
505
506
                  var category = $(this).data("category");
507
                  $("#avCreate #new_av_category").html(category);
508
                  $("#avCreate input[name='category']").val(category);
509
                  $("#avCreate input[name='value']").val(e.params.data.text);
510
                  $("#avCreate input[name='description']").val(e.params.data.text);
511
                  $('#avCreate').modal({show:true});
512
513
                  $(current_select2).val($(current_select2).find("option:first").val()).trigger('change');
514
515
                  current_select2 = this;
516
517
              }
518
          });
519
520
          $("#avCreate").on('hide.bs.modal', function(e){
521
          });
522
523
          $("#add_new_av").on("submit", function(){
524
              var data = {
525
                  category: $(this).find('input[name="category"]').val(),
526
                  value: $(this).find('input[name="value"]').val(),
527
                  description: $(this).find('input[name="description"]').val(),
528
                  opac_description: $(this).find('input[name="opac_description"]').val(),
529
              };
530
              $.ajax({
531
                  type: "POST",
532
                  url: "/api/v1/authorised_values",
533
                  data:JSON.stringify(data),
534
                  success: function(response) {
535
                      $('#avCreate').modal('hide');
536
537
                      $(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>');
538
                  },
539
                  error: function(err) {
540
                      $("#avCreate .error").html(_("Something went wrong, maybe the value already exists?"))
541
                  }
542
              });
543
              return false;
544
          });
545
      [% END %]
546
  });
547
</script>
548
549
</head>
483
</head>
550
<body id="cat_addbiblio" class="cat">
484
<body id="cat_addbiblio" class="cat">
551
485
Lines 955-1001 Link Here
955
                [%# End of fields for fast cataloging %]
889
                [%# End of fields for fast cataloging %]
956
            </form> <!-- /name=f -->
890
            </form> <!-- /name=f -->
957
891
958
            <div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true">
892
            [% INCLUDE 'modals/cataloguing_create_av.inc' %]
959
                <div class="modal-dialog">
960
                    <div class="modal-content">
961
                        <div class="modal-header">
962
                            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
963
                            <h3 id="avCreateLabel">Create a new authorised value</h3>
964
                        </div>
965
                        <form id="add_new_av" method="post">
966
                            <div class="modal-body">
967
                                <div class="error"></div>
968
                                <fieldset class="rows">
969
                                    <ol>
970
                                        <li>
971
                                            <span class="label">Category:</span>
972
                                            <input type="hidden" name="category" value="" />
973
                                            <span id="new_av_category"></span>
974
                                        </li>
975
                                        <li>
976
                                            <span class="label" for="value">Authorised value:</span>
977
                                            <input type="text" id="value" name="value" />
978
                                        </li>
979
                                        <li>
980
                                            <span class="label" for="description">Description:</span>
981
                                            <input type="text" id="description" name="description" />
982
                                        </li>
983
                                        <li>
984
                                            <span class="label" for="opac_description">Description (OPAC):</span>
985
                                            <input type="text" id="opac_description" name="opac_description" />
986
                                        </li>
987
                                    </ol>
988
                                </fieldset>
989
                            </div>
990
                            <div class="modal-footer">
991
                                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
992
                                <input type="hidden" name="select2" value="" />
993
                                <input type="submit" class="btn btn-primary" value="Save">
994
                            </div>
995
                        </form>
996
                    </div> <!-- /.modal-content -->
997
                </div> <!-- /.modal-dialog -->
998
            </div> <!-- /#avCreate -->
999
893
1000
        </div> <!-- /.col-md-10.col-md-offset-1 -->
894
        </div> <!-- /.col-md-10.col-md-offset-1 -->
1001
    </div> <!-- /.row -->
895
    </div> <!-- /.row -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +7 lines)
Lines 7-12 Link Here
7
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% Asset.css("css/addbiblio.css") | $raw %]
8
[% Asset.css("css/addbiblio.css") | $raw %]
9
[% INCLUDE 'datatables.inc' %]
9
[% INCLUDE 'datatables.inc' %]
10
<script>
11
    var CAN_user_parameters_manage_auth_values = "[% CAN_user_parameters_manage_auth_values | html %]";
12
</script>
10
[% Asset.js("js/cataloging.js") | $raw %]
13
[% Asset.js("js/cataloging.js") | $raw %]
11
[% INCLUDE 'columns_settings.inc' %]
14
[% INCLUDE 'columns_settings.inc' %]
12
[% INCLUDE 'strings.inc' %]
15
[% INCLUDE 'strings.inc' %]
Lines 150-156 Link Here
150
                    [% IF ( mv.readonly ) %]
153
                    [% IF ( mv.readonly ) %]
151
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
154
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
152
                    [% ELSE %]
155
                    [% ELSE %]
153
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor">
156
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" data-category="[% mv.category | html %]">
154
                    [% END %]
157
                    [% END %]
155
                    [% FOREACH aval IN mv.values %]
158
                    [% FOREACH aval IN mv.values %]
156
                        [% IF aval == mv.default %]
159
                        [% IF aval == mv.default %]
Lines 252-257 Link Here
252
255
253
256
254
    </form>
257
    </form>
258
259
    [% INCLUDE 'modals/cataloguing_create_av.inc' %]
260
255
                            </div> <!-- /#cataloguing_additem_newitem -->
261
                            </div> <!-- /#cataloguing_additem_newitem -->
256
                        </div> <!-- /.col-sm-10 -->
262
                        </div> <!-- /.col-sm-10 -->
257
                    </div> <!-- /.row -->
263
                    </div> <!-- /.row -->
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js (-1 / +63 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
    $('.subfield_line select[data-category=""]').select2(); // branches, itemtypes and cn_source
525
526
    if ( ! CAN_user_parameters_manage_auth_values ) {
527
        $('.subfield_line select[data-category!=""]').select2();
528
    } else {
529
        var current_select2;
530
        $('.subfield_line select[data-category!=""]').select2({
531
            tags: true,
532
            createTag: function (tag) {
533
                return {
534
                    id: tag.term,
535
                    text: tag.term,
536
                    newTag: true
537
                };
538
            },
539
            templateResult: function(state) {
540
                if (state.newTag) {
541
                    return state.text + " " + "(select to create)";
542
                }
543
                return state.text;
544
            }
545
        }).on("select2:select", function(e) {
546
            if(e.params.data.newTag){
547
548
                var category = $(this).data("category");
549
                $("#avCreate #new_av_category").html(category);
550
                $("#avCreate input[name='category']").val(category);
551
                $("#avCreate input[name='value']").val(e.params.data.text);
552
                $("#avCreate input[name='description']").val(e.params.data.text);
553
                $('#avCreate').modal({show:true});
554
555
                $(current_select2).val($(current_select2).find("option:first").val()).trigger('change');
556
557
                current_select2 = this;
558
559
            }
560
        });
561
562
        $("#add_new_av").on("submit", function(){
563
            var data = {
564
                category: $(this).find('input[name="category"]').val(),
565
                value: $(this).find('input[name="value"]').val(),
566
                description: $(this).find('input[name="description"]').val(),
567
                opac_description: $(this).find('input[name="opac_description"]').val(),
568
            };
569
            $.ajax({
570
                type: "POST",
571
                url: "/api/v1/authorised_values",
572
                data:JSON.stringify(data),
573
                success: function(response) {
574
                    $('#avCreate').modal('hide');
575
576
                    $(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>');
577
                },
578
                error: function(err) {
579
                    $("#avCreate .error").html(_("Something went wrong, maybe the value already exists?"))
580
                }
581
            });
582
            return false;
583
        });
584
    }
523
});
585
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js (-3 lines)
Lines 71-78 $(document).ready(function(){ Link Here
71
        addSingleBlock.toggle();
71
        addSingleBlock.toggle();
72
        multiCopyControl.toggle();
72
        multiCopyControl.toggle();
73
    });
73
    });
74
75
    $('.subfield_line select').select2();
76
});
74
});
77
75
78
function Check(f) {
76
function Check(f) {
79
- 

Return to bug 25728