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/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 483-557 Link Here
483
[% Asset.css("css/addbiblio.css") | $raw %]
486
[% Asset.css("css/addbiblio.css") | $raw %]
484
487
485
[% INCLUDE 'select2.inc' %]
488
[% INCLUDE 'select2.inc' %]
486
<script>
487
  $(document).ready(function() {
488
      $('.subfield_line select[data-category=""]').select2(); // branches, itemtypes and cn_source
489
490
      [% UNLESS CAN_user_parameters_manage_auth_values %]
491
          $('.subfield_line select[data-category!=""]').select2();
492
      [% ELSE %]
493
          var current_select2;
494
          $('.subfield_line select[data-category!=""]').select2({
495
              tags: true,
496
              createTag: function (tag) {
497
                  return {
498
                      id: tag.term,
499
                      text: tag.term,
500
                      newTag: true
501
                  };
502
              },
503
              templateResult: function(state) {
504
                  if (state.newTag) {
505
                      return state.text + " " + "(select to create)";
506
                  }
507
                  return state.text;
508
              }
509
          }).on("select2:select", function(e) {
510
              if(e.params.data.newTag){
511
512
                  var category = $(this).data("category");
513
                  $("#avCreate #new_av_category").html(category);
514
                  $("#avCreate input[name='category']").val(category);
515
                  $("#avCreate input[name='value']").val(e.params.data.text);
516
                  $("#avCreate input[name='description']").val(e.params.data.text);
517
                  $('#avCreate').modal({show:true});
518
519
                  $(current_select2).val($(current_select2).find("option:first").val()).trigger('change');
520
521
                  current_select2 = this;
522
523
              }
524
          });
525
526
          $("#avCreate").on('hide.bs.modal', function(e){
527
          });
528
529
          $("#add_new_av").on("submit", function(){
530
              var data = {
531
                  category: $(this).find('input[name="category"]').val(),
532
                  value: $(this).find('input[name="value"]').val(),
533
                  description: $(this).find('input[name="description"]').val(),
534
                  opac_description: $(this).find('input[name="opac_description"]').val(),
535
              };
536
              $.ajax({
537
                  type: "POST",
538
                  url: "/api/v1/authorised_values",
539
                  data:JSON.stringify(data),
540
                  success: function(response) {
541
                      $('#avCreate').modal('hide');
542
543
                      $(current_select2).append('<option selected value="'+data['value']+'">'+data['description']+'</option>');
544
                  },
545
                  error: function(err) {
546
                      $("#avCreate .error").html(_("Something went wrong, maybe the value already exists?"))
547
                  }
548
              });
549
              return false;
550
          });
551
      [% END %]
552
  });
553
</script>
554
555
</head>
489
</head>
556
<body id="cat_addbiblio" class="cat">
490
<body id="cat_addbiblio" class="cat">
557
491
Lines 961-1007 Link Here
961
                [%# End of fields for fast cataloging %]
895
                [%# End of fields for fast cataloging %]
962
            </form> <!-- /name=f -->
896
            </form> <!-- /name=f -->
963
897
964
            <div id="avCreate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="avCreateLabel" aria-hidden="true">
898
            [% INCLUDE 'modals/cataloguing_create_av.inc' %]
965
                <div class="modal-dialog">
966
                    <div class="modal-content">
967
                        <div class="modal-header">
968
                            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
969
                            <h3 id="avCreateLabel">Create a new authorised value</h3>
970
                        </div>
971
                        <form id="add_new_av" method="post">
972
                            <div class="modal-body">
973
                                <div class="error"></div>
974
                                <fieldset class="rows">
975
                                    <ol>
976
                                        <li>
977
                                            <span class="label">Category:</span>
978
                                            <input type="hidden" name="category" value="" />
979
                                            <span id="new_av_category"></span>
980
                                        </li>
981
                                        <li>
982
                                            <span class="label" for="value">Authorised value:</span>
983
                                            <input type="text" id="value" name="value" />
984
                                        </li>
985
                                        <li>
986
                                            <span class="label" for="description">Description:</span>
987
                                            <input type="text" id="description" name="description" />
988
                                        </li>
989
                                        <li>
990
                                            <span class="label" for="opac_description">Description (OPAC):</span>
991
                                            <input type="text" id="opac_description" name="opac_description" />
992
                                        </li>
993
                                    </ol>
994
                                </fieldset>
995
                            </div>
996
                            <div class="modal-footer">
997
                                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
998
                                <input type="hidden" name="select2" value="" />
999
                                <input type="submit" class="btn btn-primary" value="Save">
1000
                            </div>
1001
                        </form>
1002
                    </div> <!-- /.modal-content -->
1003
                </div> <!-- /.modal-dialog -->
1004
            </div> <!-- /#avCreate -->
1005
899
1006
        </div> <!-- /.col-md-10.col-md-offset-1 -->
900
        </div> <!-- /.col-md-10.col-md-offset-1 -->
1007
    </div> <!-- /.row -->
901
    </div> <!-- /.row -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +7 lines)
Lines 8-13 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>
11
[% Asset.js("js/cataloging.js") | $raw %]
14
[% Asset.js("js/cataloging.js") | $raw %]
12
[% INCLUDE 'columns_settings.inc' %]
15
[% INCLUDE 'columns_settings.inc' %]
13
[% INCLUDE 'strings.inc' %]
16
[% INCLUDE 'strings.inc' %]
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" readonly="readonly" disabled="disabled">
164
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
162
                    [% ELSE %]
165
                    [% ELSE %]
163
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor">
166
                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" data-category="[% mv.category | html %]">
164
                    [% END %]
167
                    [% END %]
165
                    [% FOREACH aval IN mv.values %]
168
                    [% FOREACH aval IN mv.values %]
166
                        [% IF aval == mv.default %]
169
                        [% IF aval == mv.default %]
Lines 266-271 Link Here
266
269
267
270
268
    </form>
271
    </form>
272
273
    [% INCLUDE 'modals/cataloguing_create_av.inc' %]
274
269
                            </div> <!-- /#cataloguing_additem_newitem -->
275
                            </div> <!-- /#cataloguing_additem_newitem -->
270
                        </div> <!-- /.col-sm-10 -->
276
                        </div> <!-- /.col-sm-10 -->
271
                    </div> <!-- /.row -->
277
                    </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