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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/create.inc (-206 / +198 lines)
Lines 1-215 Link Here
1
[% SET koha_version = Koha.Version %]
1
[% SET koha_version = Koha.Version %]
2
[% PROCESS "ill/backends/Standard/inc/form_input_helpers.inc" %]
2
[% PROCESS "ill/backends/Standard/inc/form_input_helpers.inc" %]
3
[% IF whole.error %]
3
[% IF whole.error %]
4
[% IF whole.status == 'missing_identifier' %]
4
    [% IF whole.status == 'missing_identifier' %]
5
<p><em>Please note:</em> Mandatory field Identifier is missing.</p>
5
        <p><em>Please note:</em> Mandatory field Identifier is missing.</p>
6
[% ELSIF whole.status == 'missing_branch' %]
6
    [% ELSIF whole.status == 'missing_branch' %]
7
<p><em>Please note:</em> Library is a mandatory field.</p>
7
        <p><em>Please note:</em> Library is a mandatory field.</p>
8
[% ELSIF whole.status == 'invalid_borrower' %]
8
    [% ELSIF whole.status == 'invalid_borrower' %]
9
<p><em>Please note:</em> The patron details you entered are invalid.</p>
9
        <p><em>Please note:</em> The patron details you entered are invalid.</p>
10
[% ELSIF whole.status == 'invalid_branch' %]
10
    [% ELSIF whole.status == 'invalid_branch' %]
11
<p><em>Please note:</em> The library you chose is invalid.</p>
11
        <p><em>Please note:</em> The library you chose is invalid.</p>
12
[% ELSE %]
12
    [% ELSE %]
13
<p>Unhandled error</p>
13
        <p>Unhandled error</p>
14
[% END %]
14
    [% END %]
15
[% END %]
15
[% END %]
16
16
17
[% IF whole.stage == "form" %]
17
[% IF whole.stage == "form" %]
18
<h2>Create a manual ILL request</h2>
18
    <h2>Create a manual ILL request</h2>
19
<form id="create_form" method="POST" action="">
19
    <form id="create_form" method="POST" action="">
20
  [% INCLUDE 'csrf-token.inc' %]
20
        [% INCLUDE 'csrf-token.inc' %]
21
  <fieldset class="rows">
21
        <fieldset class="rows">
22
    <legend>General details</legend>
22
            <legend>General details</legend>
23
    <ol id="general-standard-fields">
23
            <ol id="general-standard-fields">
24
      <li>
24
                <li>
25
        <label class="required" for="type">Type:</label>
25
                    <label class="required" for="type">Type:</label>
26
        <select name="type" id="type">
26
                    <select name="type" id="type">
27
          <option value=""/>
27
                        <option value="" />
28
          [% IF whole.value.other.type.lower == "book" %]
28
                        [% IF whole.value.other.type.lower == "book" %]
29
          <option value="book" selected="selected">Book</option>
29
                            <option value="book" selected="selected">Book</option>
30
          [% ELSE %]
30
                        [% ELSE %]
31
          <option value="book">Book</option>
31
                            <option value="book">Book</option>
32
          [% END %]
32
                        [% END %]
33
          [% IF whole.value.other.type.lower == "chapter" %]
33
                        [% IF whole.value.other.type.lower == "chapter" %]
34
          <option value="chapter" selected="selected">Chapter</option>
34
                            <option value="chapter" selected="selected">Chapter</option>
35
          [% ELSE %]
35
                        [% ELSE %]
36
          <option value="chapter">Chapter</option>
36
                            <option value="chapter">Chapter</option>
37
          [% END %]
37
                        [% END %]
38
          [% IF whole.value.other.type.lower == "journal" %]
38
                        [% IF whole.value.other.type.lower == "journal" %]
39
          <option value="journal" selected="selected">Journal</option>
39
                            <option value="journal" selected="selected">Journal</option>
40
          [% ELSE %]
40
                        [% ELSE %]
41
          <option value="journal">Journal</option>
41
                            <option value="journal">Journal</option>
42
          [% END %]
42
                        [% END %]
43
          [% IF whole.value.other.type.lower == "article" %]
43
                        [% IF whole.value.other.type.lower == "article" %]
44
          <option value="article" selected="selected">Journal article</option>
44
                            <option value="article" selected="selected">Journal article</option>
45
          [% ELSE %]
45
                        [% ELSE %]
46
          <option value="article">Journal article</option>
46
                            <option value="article">Journal article</option>
47
          [% END %]
47
                        [% END %]
48
          [% IF whole.value.other.type.lower == "thesis" %]
48
                        [% IF whole.value.other.type.lower == "thesis" %]
49
          <option value="thesis" selected="selected">Thesis</option>
49
                            <option value="thesis" selected="selected">Thesis</option>
50
          [% ELSE %]
50
                        [% ELSE %]
51
          <option value="thesis">Thesis</option>
51
                            <option value="thesis">Thesis</option>
52
          [% END %]
52
                        [% END %]
53
          [% IF whole.value.other.type.lower == "conference" %]
53
                        [% IF whole.value.other.type.lower == "conference" %]
54
          <option value="conference" selected="selected">Conference</option>
54
                            <option value="conference" selected="selected">Conference</option>
55
          [% ELSE %]
55
                        [% ELSE %]
56
          <option value="conference">Conference</option>
56
                            <option value="conference">Conference</option>
57
          [% END %]
57
                        [% END %]
58
          [% IF whole.value.other.type.lower == "dvd" %]
58
                        [% IF whole.value.other.type.lower == "dvd" %]
59
          <option value="dvd" selected="selected">DVD</option>
59
                            <option value="dvd" selected="selected">DVD</option>
60
          [% ELSE %]
60
                        [% ELSE %]
61
          <option value="dvd">DVD</option>
61
                            <option value="dvd">DVD</option>
62
          [% END %]
62
                        [% END %]
63
          [% IF whole.value.other.type.lower == "other" %]
63
                        [% IF whole.value.other.type.lower == "other" %]
64
          <option value="other" selected="selected">Other</option>
64
                            <option value="other" selected="selected">Other</option>
65
          [% ELSE %]
65
                        [% ELSE %]
66
          <option value="other">Other</option>
66
                            <option value="other">Other</option>
67
          [% END %]
67
                        [% END %]
68
          [% IF whole.value.other.type.lower == "resource" %]
68
                        [% IF whole.value.other.type.lower == "resource" %]
69
          <option value="resource" selected="selected">Generic resource</option>
69
                            <option value="resource" selected="selected">Generic resource</option>
70
          [% ELSE %]
70
                        [% ELSE %]
71
          <option value="resource">Generic resource</option>
71
                            <option value="resource">Generic resource</option>
72
          [% END %]
72
                        [% END %]
73
        </select>
73
                    </select>
74
      </li>
74
                </li>
75
    </ol>
75
            </ol>
76
  </fieldset>
76
        </fieldset>
77
  [% type = whole.value.other.type %]
77
        [% type = whole.value.other.type %]
78
  [% IF type %]
78
        [% IF type %]
79
      [% INCLUDE "ill/backends/Standard/inc/forms/${type}.inc" %]
79
            [% INCLUDE "ill/backends/Standard/inc/forms/${type}.inc" %]
80
  [% END %]
80
        [% END %]
81
  [% INCLUDE "ill/backends/Standard/inc/custom_fields.inc" %]
81
        [% INCLUDE "ill/backends/Standard/inc/custom_fields.inc" %]
82
  <fieldset class="rows">
82
        <fieldset class="rows">
83
    <legend>Patron options</legend>
83
            <legend>Patron options</legend>
84
    <ol>
84
            <ol>
85
      <li>
85
                <li>
86
        <label class="required" for="cardnumber">
86
                    <label class="required" for="cardnumber"> Card number, username or surname: </label>
87
          Card number, username or surname:
87
                    <input type="text" name="cardnumber" id="cardnumber" autocomplete="off" type="text" value="[% whole.value.other.cardnumber | html %]" />
88
        </label>
88
                    <span class="required">Required</span>
89
        <input type="text" name="cardnumber" id="cardnumber" autocomplete="off" type="text" value="[% whole.value.other.cardnumber | html %]" />
89
                </li>
90
        <span class="required">Required</span>
90
                <li>
91
      </li>
91
                    <label class="required" for="branchcode">Destination library:</label>
92
      <li>
92
                    <select id="branchcode" name="branchcode">
93
        <label class="required" for="branchcode">Destination library:</label>
93
                        <option value="" />
94
        <select id="branchcode" name="branchcode">
94
                        [% FOREACH branch IN branches %]
95
          <option value="" />
95
                            [% IF branch.branchcode == whole.value.other.branchcode %]
96
          [% FOREACH branch IN branches %]
96
                                <option value="[% branch.branchcode | html %]" selected="selected">[% branch.branchname | html %]</option>
97
            [% IF branch.branchcode == whole.value.other.branchcode %]
97
                            [% ELSE %]
98
              <option value="[% branch.branchcode | html %]" selected="selected">
98
                                <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
99
            [% ELSE %]
99
                            [% END %]
100
              <option value="[% branch.branchcode | html %]">
100
                        [% END %]
101
            [% END %]
101
                    </select>
102
              [% branch.branchname | html %]
102
                    <span class="required">Required</span>
103
            </option>
103
                </li>
104
          [% END %]
104
            </ol>
105
        </select>
105
        </fieldset>
106
        <span class="required">Required</span>
106
        <fieldset class="action">
107
      </li>
107
            <input id="ill-submit" class="btn btn-primary" type="submit" value="Create" disabled />
108
    </ol>
108
            <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl">Cancel</a>
109
  </fieldset>
109
        </fieldset>
110
  <fieldset class="action">
110
        <input type="hidden" name="method" value="create" />
111
    <input id="ill-submit" class="btn btn-primary" type="submit" value="Create" disabled />
111
        <input type="hidden" name="stage" value="form" />
112
    <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl">Cancel</a>
112
        <input type="hidden" name="backend" value="Standard" />
113
  </fieldset>
113
    </form>
114
  <input type="hidden" name="method" value="create" />
114
    [% BLOCK backend_jsinclude %]
115
  <input type="hidden" name="stage" value="form" />
115
        <script>
116
  <input type="hidden" name="backend" value="Standard" />
116
            // <![CDATA[]
117
</form>
117
            var core = [ [% whole.core | $raw %] ];
118
[% BLOCK backend_jsinclude %]
118
            [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
119
<script>
119
            // Require a username and branch selection
120
    // <![CDATA[]
120
            document.addEventListener('DOMContentLoaded', function(){
121
    [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
121
              let cardnumber_input = '#create_form #cardnumber';
122
    // Require a username and branch selection
122
              let branchcode_input = '#create_form #branchcode';
123
    document.addEventListener('DOMContentLoaded', function(){
123
              updateCreateButtonStatus();
124
      let cardnumber_input = '#create_form #cardnumber';
124
              $(cardnumber_input + ',' + branchcode_input).change(function() {
125
      let branchcode_input = '#create_form #branchcode';
125
                  updateCreateButtonStatus();
126
      updateCreateButtonStatus();
126
              });
127
      $(cardnumber_input + ',' + branchcode_input).change(function() {
127
              function updateCreateButtonStatus(){
128
          updateCreateButtonStatus();
128
                var comp = [cardnumber_input,branchcode_input].filter(function(id) {
129
      });
129
                    return $(id).val().length > 0;
130
      function updateCreateButtonStatus(){
130
                });
131
        var comp = [cardnumber_input,branchcode_input].filter(function(id) {
131
                $('#ill-submit').attr('disabled', comp.length < 2);
132
            return $(id).val().length > 0;
132
              }
133
        });
133
              /* Maintain patron autocomplete compatibility across versions */
134
        $('#ill-submit').attr('disabled', comp.length < 2);
134
              [% IF koha_version.major <= 22 && koha_version.minor < 11 %]
135
      }
135
              $('#create_form #cardnumber').autocomplete({
136
      /* Maintain patron autocomplete compatibility across versions */
136
                  source: "/cgi-bin/koha/circ/ysearch.pl",
137
      [% IF koha_version.major <= 22 && koha_version.minor < 11 %]
137
                  minLength: 3,
138
      $('#create_form #cardnumber').autocomplete({
138
                  select: function( event, ui ) {
139
          source: "/cgi-bin/koha/circ/ysearch.pl",
139
                      var field = ui.item.cardnumber;
140
          minLength: 3,
140
                      $('#create_form #cardnumber').val(field)
141
          select: function( event, ui ) {
141
                      return false;
142
              var field = ui.item.cardnumber;
142
                  }
143
              $('#create_form #cardnumber').val(field)
143
              })
144
              return false;
144
              .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
145
          }
145
                  return $( "<li></li>" )
146
      })
146
                  .data( "ui-autocomplete-item", item )
147
      .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
147
                  .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
148
          return $( "<li></li>" )
148
                  .appendTo( ul );
149
          .data( "ui-autocomplete-item", item )
149
              };
150
          .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
150
              [% ELSE %]
151
          .appendTo( ul );
151
              patron_autocomplete(
152
      };
152
                $('#create_form #cardnumber'),
153
      [% ELSE %]
153
                {
154
      patron_autocomplete(
154
                  'on-select-callback': function( event, ui ) {
155
        $('#create_form #cardnumber'),
155
                    $("#create_form #cardnumber").val( ui.item.cardnumber );
156
        {
156
                    return false;
157
          'on-select-callback': function( event, ui ) {
157
                  }
158
            $("#create_form #cardnumber").val( ui.item.cardnumber );
158
                }
159
            return false;
159
              );
160
          }
160
              [% END %]
161
        }
161
            });
162
      );
162
            // ]]>
163
      [% END %]
163
        </script>
164
    });
165
    // ]]>
166
</script>
167
[% END %]
168
169
[% ELSIF whole.stage == "borrowers" %]
170
<!-- We need to clarify the borrower that has been requested. -->
171
<h2>Borrower selection</h2>
172
<form method="POST" action="">
173
  [% FOREACH prop IN whole.value.other.keys %]
174
    [% IF prop != 'custom_key' &&  prop != 'custom_value' && prop != 'cardnumber' %]
175
    <input type="hidden" name="[% prop | html %]" value="[% whole.value.other.$prop | html %]">
176
    [% END %]
164
    [% END %]
177
  [% END %]
165
[% ELSIF whole.stage == "borrowers" %]
178
  [% keys = whole.value.other.custom_key.split('\0') %]
166
    <!-- We need to clarify the borrower that has been requested. -->
179
  [% values = whole.value.other.custom_value.split('\0') %]
167
    <h2>Borrower selection</h2>
180
  [% i = 0 %]
168
    <form method="POST" action="">
181
  [% FOREACH key IN keys %]
169
        [% FOREACH prop IN whole.value.other.keys %]
182
    <input type="hidden" name="custom_key" value="[% key | html %]">
170
            [% IF prop != 'custom_key' &&  prop != 'custom_value' && prop != 'cardnumber' %]
183
    <input type="hidden" name="custom_value" value="[% values.$i | html %]">
171
                <input type="hidden" name="[% prop | html %]" value="[% whole.value.other.$prop | html %]" />
184
  [% i = i + 1 %]
172
            [% END %]
185
  [% END %]
173
        [% END %]
186
  <fieldset class="rows">
174
        [% keys = whole.value.other.custom_key.split('\0') %]
187
    <legend>Available borrowers for surname [% surname | html %]</legend>
175
        [% values = whole.value.other.custom_value.split('\0') %]
188
    [% FOREACH opt IN whole.value %]
176
        [% i = 0 %]
189
    [% IF opt.key == "brw" %]
177
        [% FOREACH key IN keys %]
190
    <ol>
178
            <input type="hidden" name="custom_key" value="[% key | html %]" />
191
      <li>
179
            <input type="hidden" name="custom_value" value="[% values.$i | html %]" />
192
        <label class="required" for="brw">Borrower</label>
180
            [% i = i + 1 %]
193
        <select name="cardnumber" id="cardnumber">
181
        [% END %]
194
          <option value=""></option>
182
        <fieldset class="rows">
195
          [% FOREACH brw IN opt.value %]
183
            <legend>Available borrowers for surname [% surname | html %]</legend>
196
          <option value="[% brw.cardnumber | html %]">
184
            [% FOREACH opt IN whole.value %]
197
            [% brw.firstname | html %] [% brw.surname | html %] ([% brw.cardnumber | html %])
185
                [% IF opt.key == "brw" %]
198
          </option>
186
                    <ol>
199
          [% END %]
187
                        <li>
200
        </select>
188
                            <label class="required" for="brw">Borrower</label>
201
      </li>
189
                            <select name="cardnumber" id="cardnumber">
202
    </ol>
190
                                <option value=""></option>
203
    [% END %]
191
                                [% FOREACH brw IN opt.value %]
204
    [% END %]
192
                                    <option value="[% brw.cardnumber | html %]"> [% brw.firstname | html %] [% brw.surname | html %] ([% brw.cardnumber | html %]) </option>
205
  </fieldset>
193
                                [% END %]
206
  <fieldset class="action">
194
                            </select>
207
    <input type="submit" value="Select"/>
195
                        </li>
208
    <a class="cancel" href=[% parent | url %]>Cancel</a>
196
                    </ol>
209
  </fieldset>
197
                [% END %]
210
</form>
198
            [% END %]
211
199
        </fieldset>
200
        <fieldset class="action">
201
            <input type="submit" value="Select" />
202
            <a class="cancel" href="[% parent | url %]">Cancel</a>
203
        </fieldset>
204
    </form>
212
[% ELSE %]
205
[% ELSE %]
213
<p>Unknown stage.  This should not have happened.
206
    <p>Unknown stage. This should not have happened. </p>
214
215
[% END %]
207
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/edititem.inc (+1 lines)
Lines 84-89 Link Here
84
    [% BLOCK backend_jsinclude %]
84
    [% BLOCK backend_jsinclude %]
85
        <script>
85
        <script>
86
            // <![CDATA[]
86
            // <![CDATA[]
87
            var core = [ [% whole.core %] ];
87
            [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
88
            [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
88
            // ]]>
89
            // ]]>
89
        </script>
90
        </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/inc/shared.js (-28 / +32 lines)
Lines 1-44 Link Here
1
var core = [ [% whole.core %] ];
1
document.addEventListener("DOMContentLoaded", function () {
2
var opac = [% opac || 0 %];
2
    $("#add-new-fields").click(function (e) {
3
document.addEventListener('DOMContentLoaded', function() {
4
    $('#add-new-fields').click(function(e) {
5
        e.preventDefault();
3
        e.preventDefault();
6
        var row = '<li class="form-horizontal">' +
4
        var row =
5
            '<li class="form-horizontal">' +
7
            '<input type="text" class="custom-name ' +
6
            '<input type="text" class="custom-name ' +
8
            ( opac ? 'form-control input-fluid custom-field-input' : '') +
7
            "" +
9
            '" name="custom_key" placeholder="'+__('key')+'">' +
8
            '" name="custom_key" placeholder="' +
10
            ' ' +
9
            __("key") +
10
            '">' +
11
            " " +
11
            '<input type="text" id="custom-value" name="custom_value" class="' +
12
            '<input type="text" id="custom-value" name="custom_value" class="' +
12
            ( opac ? 'form-control input-fluid custom-field-input' : '') +'" placeholder="'+__('value')+'"> ' +
13
            "" +
14
            '" placeholder="' +
15
            __("value") +
16
            '"> ' +
13
            '<button type="button" class="btn btn-danger btn-sm ' +
17
            '<button type="button" class="btn btn-danger btn-sm ' +
14
            'delete-new-field">' +
18
            'delete-new-field">' +
15
            '<span class="fa fa-trash-can"></span> ' +
19
            '<span class="fa fa-trash-can"></span> ' +
16
            __('Delete') +
20
            __("Delete") +
17
            '</button></li>';
21
            "</button></li>";
18
        $('#standard-fields').append(row);
22
        $("#standard-fields").append(row);
19
    });
23
    });
20
    $('#standard-fields').on('click', '.delete-new-field',
24
    $("#standard-fields").on("click", ".delete-new-field", function (event) {
21
        function(event) {
25
        event.preventDefault();
22
            event.preventDefault();
26
        $(event.target).parent().remove();
23
            $(event.target).parent().remove();
27
    });
24
        }
28
    $("#type").change(function () {
25
    );
29
        $("#create_form").prepend(
26
    $('#type').change(function() {
27
        $('#create_form').prepend(
28
            '<input type="hidden" name="change_type" value="1" />'
30
            '<input type="hidden" name="change_type" value="1" />'
29
        );
31
        );
30
        $('#create_form').submit();
32
        $("#create_form").submit();
31
    });
33
    });
32
    $('#standard-fields').on('keyup', '.custom-name', function() {
34
    $("#standard-fields").on("keyup", ".custom-name", function () {
33
        var val = $(this).val();
35
        var val = $(this).val();
34
        if (core.indexOf(val.toLowerCase()) > -1) {
36
        if (core.indexOf(val.toLowerCase()) > -1) {
35
            $('#custom-warning').text(__("The name '%s' is not permitted").format(val)).show();
37
            $("#custom-warning")
36
            $('#ill-submit').attr('disabled', true);
38
                .text(__("The name '%s' is not permitted").format(val))
37
            $('#add-new-fields').attr('disabled', true);
39
                .show();
40
            $("#ill-submit").attr("disabled", true);
41
            $("#add-new-fields").attr("disabled", true);
38
        } else {
42
        } else {
39
            $('#custom-warning').hide();
43
            $("#custom-warning").hide();
40
            $('#ill-submit').attr('disabled', false);
44
            $("#ill-submit").attr("disabled", false);
41
            $('#add-new-fields').attr('disabled', false);
45
            $("#add-new-fields").attr("disabled", false);
42
        }
46
        }
43
    });
47
    });
44
});
48
});
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/ill/backends/Standard/migrate.inc (+1 lines)
Lines 107-112 Link Here
107
    [% BLOCK backend_jsinclude %]
107
    [% BLOCK backend_jsinclude %]
108
        <script>
108
        <script>
109
            // <![CDATA[]
109
            // <![CDATA[]
110
            var core = [ [% whole.core %] ];
110
            [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
111
            [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
111
            // ]]>
112
            // ]]>
112
        </script>
113
        </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/create.inc (+1 lines)
Lines 108-113 Link Here
108
[% BLOCK backend_jsinclude %]
108
[% BLOCK backend_jsinclude %]
109
    <script>
109
    <script>
110
        // <![CDATA[]
110
        // <![CDATA[]
111
        var core = [ [% whole.core | $raw %] ];
111
        [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
112
        [% INCLUDE "ill/backends/Standard/inc/shared.js" %]
112
        // ]]>
113
        // ]]>
113
    </script>
114
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/ill/backends/Standard/inc/shared.js (-29 / +32 lines)
Lines 1-44 Link Here
1
var core = [ [% whole.core %] ];
1
document.addEventListener("DOMContentLoaded", function () {
2
var opac = [% opac || 0 %];
2
    $("#add-new-fields").click(function (e) {
3
document.addEventListener('DOMContentLoaded', function() {
4
    $('#add-new-fields').click(function(e) {
5
        e.preventDefault();
3
        e.preventDefault();
6
        var row = '<li class="form-horizontal">' +
4
        var row =
5
            '<li class="form-horizontal">' +
7
            '<input type="text" class="custom-name ' +
6
            '<input type="text" class="custom-name ' +
8
            ( opac ? 'form-control input-fluid custom-field-input' : '') +
7
            "form-control input-fluid custom-field-input" +
9
            '" name="custom_key" placeholder="'+__('key')+'">' +
8
            '" name="custom_key" placeholder="' +
10
            ' ' +
9
            __("key") +
10
            '">' +
11
            " " +
11
            '<input type="text" id="custom-value" name="custom_value" class="' +
12
            '<input type="text" id="custom-value" name="custom_value" class="' +
12
            ( opac ? 'form-control input-fluid custom-field-input' : '') +'" placeholder="'+__('value')+'"> ' +
13
            "form-control input-fluid custom-field-input" +
14
            '" placeholder="' +
15
            __("value") +
16
            '"> ' +
13
            '<button type="button" class="btn btn-danger btn-sm ' +
17
            '<button type="button" class="btn btn-danger btn-sm ' +
14
            'delete-new-field">' +
18
            'delete-new-field">' +
15
            '<span class="fa fa-trash-can"></span> ' +
19
            '<span class="fa fa-trash-can"></span> ' +
16
            __('Delete') +
20
            __("Delete") +
17
            '</button></li>';
21
            "</button></li>";
18
        $('#standard-fields').append(row);
22
        $("#standard-fields").append(row);
19
    });
23
    });
20
    $('#standard-fields').on('click', '.delete-new-field',
24
    $("#standard-fields").on("click", ".delete-new-field", function (event) {
21
        function(event) {
25
        event.preventDefault();
22
            event.preventDefault();
26
        $(event.target).parent().remove();
23
            $(event.target).parent().remove();
27
    });
24
        }
28
    $("#type").change(function () {
25
    );
29
        $("#create_form").prepend(
26
    $('#type').change(function() {
27
        $('#create_form').prepend(
28
            '<input type="hidden" name="change_type" value="1" />'
30
            '<input type="hidden" name="change_type" value="1" />'
29
        );
31
        );
30
        $('#create_form').submit();
32
        $("#create_form").submit();
31
    });
33
    });
32
    $('#standard-fields').on('keyup', '.custom-name', function() {
34
    $("#standard-fields").on("keyup", ".custom-name", function () {
33
        var val = $(this).val();
35
        var val = $(this).val();
34
        if (core.indexOf(val.toLowerCase()) > -1) {
36
        if (core.indexOf(val.toLowerCase()) > -1) {
35
            $('#custom-warning').text(__("The name '%s' is not permitted").format(val)).show();
37
            $("#custom-warning")
36
            $('#ill-submit').attr('disabled', true);
38
                .text(__("The name '%s' is not permitted").format(val))
37
            $('#add-new-fields').attr('disabled', true);
39
                .show();
40
            $("#ill-submit").attr("disabled", true);
41
            $("#add-new-fields").attr("disabled", true);
38
        } else {
42
        } else {
39
            $('#custom-warning').hide();
43
            $("#custom-warning").hide();
40
            $('#ill-submit').attr('disabled', false);
44
            $("#ill-submit").attr("disabled", false);
41
            $('#add-new-fields').attr('disabled', false);
45
            $("#add-new-fields").attr("disabled", false);
42
        }
46
        }
43
    });
47
    });
44
});
48
});
45
- 

Return to bug 38340