Lines 42-50
Link Here
|
42 |
|
42 |
|
43 |
Sticky = $("#toolbar"); |
43 |
Sticky = $("#toolbar"); |
44 |
Sticky.hcSticky({ |
44 |
Sticky.hcSticky({ |
45 |
stickTo: ".main", |
45 |
stickTo: "#f", |
46 |
stickyClass: "floating" |
46 |
stickyClass: "floating" |
47 |
}); |
47 |
}); |
|
|
48 |
|
48 |
$("#addauth").click(function(){ |
49 |
$("#addauth").click(function(){ |
49 |
if(Check()){ |
50 |
if(Check()){ |
50 |
$("#f").submit(); |
51 |
$("#f").submit(); |
Lines 91-96
Link Here
|
91 |
f.authtypecode.value = authtypecode; |
92 |
f.authtypecode.value = authtypecode; |
92 |
f.submit(); |
93 |
f.submit(); |
93 |
}); |
94 |
}); |
|
|
95 |
|
96 |
$("body").on("click", ".linkfield", function(e){ |
97 |
e.preventDefault(); |
98 |
var tab = $(this).data("tab"); |
99 |
var field = $(this).data("field"); |
100 |
var tablink = $("a[data-tabname='tab" + tab + "XX']" ).get(0).hash; |
101 |
selectTab( tablink ); |
102 |
window.scrollTo( 0, getScrollto( field, "toolbar" ) ); |
103 |
}); |
104 |
|
105 |
$("body").on("click", ".show-errors", function(e){ |
106 |
document.getElementById("form-errors").scrollIntoView(); |
107 |
Sticky.hcSticky('refresh'); |
108 |
}); |
109 |
|
94 |
}); |
110 |
}); |
95 |
|
111 |
|
96 |
function selectTab( tablink ){ |
112 |
function selectTab( tablink ){ |
Lines 147-190
Link Here
|
147 |
* check if mandatory subfields are written |
163 |
* check if mandatory subfields are written |
148 |
*/ |
164 |
*/ |
149 |
function AreMandatoriesNotOk(){ |
165 |
function AreMandatoriesNotOk(){ |
150 |
var mandatories = new Array(); |
166 |
var fields = new Array(); |
151 |
var mandatoriesfields = new Array(); |
167 |
var subfields = new Array(); |
152 |
var tab = new Array(); |
168 |
var tab = new Array(); |
153 |
var label = new Array(); |
169 |
var label = new Array(); |
|
|
170 |
var flag = false; |
171 |
var tabflag= new Array(); |
172 |
var StrAlert = "<div id='form-errors' class='dialog alert list'>"; |
173 |
var notFilledClass = "subfield_not_filled"; |
174 |
|
154 |
[% FOREACH BIG_LOO IN BIG_LOOP %] |
175 |
[% FOREACH BIG_LOO IN BIG_LOOP %] |
155 |
[% FOREACH innerloo IN BIG_LOO.innerloop %] |
176 |
[% FOREACH innerloo IN BIG_LOO.innerloop %] |
156 |
[% IF ( innerloo.mandatory ) %] |
177 |
[% IF ( innerloo.mandatory ) %] |
157 |
mandatoriesfields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]")); |
178 |
fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]", "[% BIG_LOO.number | html %]")); |
158 |
[% END %] |
179 |
[% END %] |
159 |
[% FOREACH subfield_loo IN innerloo.subfield_loop %] |
180 |
[% FOREACH subfield_loo IN innerloo.subfield_loop %] |
160 |
[% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id | html %]"); |
181 |
[% IF ( subfield_loo.mandatory ) %]subfields.push("[% subfield_loo.id | html %]"); |
161 |
tab.push("[% BIG_LOO.number | html %]"); |
182 |
tab.push("[% BIG_LOO.number | html %]"); |
162 |
label.push("[% To.json(subfield_loo.marc_lib) | html %]"); |
183 |
label.push("[% subfield_loo.marc_lib | $raw %]"); |
163 |
[% END %] |
184 |
[% END %] |
164 |
[% END %] |
185 |
[% END %] |
165 |
[% END %] |
186 |
[% END %] |
166 |
[% END %] |
187 |
[% END %] |
167 |
var StrAlert = ""; |
188 |
|
168 |
for(var i=0,len=mandatories.length; i<len ; i++){ |
189 |
StrAlert += "<h4>" + _("The following mandatory subfields aren't filled:") + "</h4>"; |
169 |
var id_string = mandatories[i]; |
190 |
StrAlert += "<ul>"; |
170 |
// alert (id_string); |
191 |
|
171 |
if( ! $("#" + id_string).val() ){ |
192 |
for(var i=0,len=subfields.length; i<len ; i++){ |
172 |
var elt = document.getElementById(id_string); |
193 |
var tag=subfields[i].substr(4,3); |
|
|
194 |
var subfield=subfields[i].substr(17,1); |
195 |
var tagnumber=subfields[i].substr(19,subfields[i].lastIndexOf("_")-19); |
196 |
if (tabflag[tag+subfield+tagnumber] == null) { |
197 |
tabflag[tag+subfield+tagnumber]=new Array(); |
198 |
tabflag[tag+subfield+tagnumber][0]=0; |
199 |
} |
200 |
if( tabflag[tag+subfield+tagnumber][0] != 1 && (document.getElementById(subfields[i]) != null && ! document.getElementById(subfields[i]).value || document.getElementById(subfields[i]) == null)){ |
201 |
tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ; |
202 |
|
203 |
var elt = document.getElementById(subfields[i]); |
173 |
if ( elt.nodeName == 'SELECT' ) { |
204 |
if ( elt.nodeName == 'SELECT' ) { |
174 |
$(elt).siblings('.select2').find("span[role='combobox']").addClass('subfield_not_filled'); |
205 |
$(elt).siblings('.select2').find("span[role='combobox']").addClass(notFilledClass); |
175 |
} else { |
206 |
} else { |
176 |
$(elt).addClass('subfield_not_filled'); |
207 |
elt.setAttribute('class','input_marceditor noEnterSubmit ' + notFilledClass); |
177 |
} |
208 |
} |
|
|
209 |
$('#' + subfields[i]).focus(); |
210 |
tabflag[tag+subfield+tagnumber][1]=label[i]; |
211 |
tabflag[tag+subfield+tagnumber][2]=tab[i]; |
212 |
} else { |
213 |
tabflag[tag+subfield+tagnumber][0] = 1; |
214 |
} |
215 |
tabflag[tag+subfield+tagnumber][3] = subfields[i]; |
216 |
} |
178 |
|
217 |
|
179 |
$(elt).focus(); |
218 |
for (var tagsubfieldid in tabflag){ |
180 |
StrAlert += "\t* " + _("%s in tab %s").format(label[i], tab[i]) + "\n"; |
219 |
if (tabflag[tagsubfieldid][0]==0){ |
|
|
220 |
var tag=tagsubfieldid.substr(0,3); |
221 |
var subfield=tagsubfieldid.substr(3,1); |
222 |
StrAlert += "<li>"+_("Tag %s subfield %s %s in tab %s").format(tag, subfield, formatFieldName( tabflag[tagsubfieldid][1] ), tabflag[tagsubfieldid][2]) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + tabflag[tagsubfieldid][2] + '" data-field="' + tabflag[tagsubfieldid][3] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>'; |
223 |
flag = true; |
181 |
} |
224 |
} |
182 |
} |
225 |
} |
183 |
|
226 |
|
|
|
227 |
StrAlert += "</ul>"; |
228 |
mandatoryFields = new Object(); |
229 |
|
184 |
/* Check for mandatories field(not subfields) */ |
230 |
/* Check for mandatories field(not subfields) */ |
185 |
for(var i=0,len=mandatoriesfields.length; i<len; i++){ |
231 |
for(var i=0,len=fields.length; i<len; i++){ |
186 |
isempty = true; |
232 |
isempty = true; |
187 |
arr = mandatoriesfields[i]; |
233 |
arr = fields[i]; |
188 |
divid = "tag_" + arr[0] + "_" + arr[1]; |
234 |
divid = "tag_" + arr[0] + "_" + arr[1]; |
189 |
varegexp = new RegExp("^tag_" + arr[0] + "_code_"); |
235 |
varegexp = new RegExp("^tag_" + arr[0] + "_code_"); |
190 |
|
236 |
|
Lines 198-225
Link Here
|
198 |
inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]); |
244 |
inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]); |
199 |
|
245 |
|
200 |
for( var k=0; k<len2; k++){ |
246 |
for( var k=0; k<len2; k++){ |
201 |
if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){ |
247 |
if( eleminputs[k].id.match(inputregexp) ){ |
|
|
248 |
if( eleminputs[k].value ){ |
249 |
isempty = false |
250 |
} |
251 |
} |
252 |
} |
253 |
|
254 |
elemselect = elem.getElementsByTagName('select'); |
255 |
for( var k=0; k<elemselect.length; k++){ |
256 |
if(elemselect[k].id.match(inputregexp) && elemselect[k].value){ |
202 |
isempty = false |
257 |
isempty = false |
203 |
} |
258 |
} |
204 |
} |
259 |
} |
205 |
} |
260 |
} |
206 |
} |
261 |
} |
207 |
}else{ |
262 |
|
|
|
263 |
elemtextareas = elem.getElementsByTagName('textarea'); |
264 |
for(var j=0,len2=elemtextareas.length; j<len2; j++){ |
265 |
// this bit assumes that the only textareas in this context would be for subfields |
266 |
if (elemtextareas[j].value) { |
267 |
isempty = false; |
268 |
} |
269 |
} |
270 |
|
271 |
} else { |
208 |
isempty = false; |
272 |
isempty = false; |
209 |
} |
273 |
} |
210 |
|
274 |
|
211 |
if(isempty){ |
275 |
if(isempty){ |
212 |
flag = 1; |
276 |
flag = true; |
213 |
StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n"; |
277 |
mandatoryFields[ arr[0] ] = { |
|
|
278 |
importance: "mandatory", |
279 |
elemid: "div_indicator_" + divid, |
280 |
tab: arr[3] |
281 |
} |
214 |
} |
282 |
} |
215 |
|
283 |
|
216 |
} |
284 |
} |
217 |
|
285 |
|
218 |
|
286 |
if( Object.entries(mandatoryFields).length > 0 ){ |
219 |
if(StrAlert){ |
287 |
StrAlert += "<h4>" + _("The following fields aren't filled:") + "</h4>"; |
220 |
return _("Can't save this record because the following field aren't filled :") + "\n\n" + StrAlert; |
288 |
StrAlert += "<ul>"; |
|
|
289 |
for( var prop in mandatoryFields ){ |
290 |
if( mandatoryFields[prop]["importance"] == "mandatory" ){ |
291 |
StrAlert += "<li>" + _("Field %s is mandatory, at least one of its subfields must be filled.").format( prop ) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>'; |
292 |
} else { |
293 |
StrAlert += "<li>" + _("Field %s is important, at least one of its subfields must be filled.").format(prop) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>'; |
294 |
} |
295 |
} |
296 |
StrAlert += "</ul>"; |
297 |
} |
298 |
StrAlert += "</div>"; |
299 |
if ( flag ) { |
300 |
$("#show-errors").html('<button type="button" class="btn btn-danger show-errors"><i class="fa-solid fa-triangle-exclamation"></i> ' + _("Errors") + '</span>'); |
301 |
return StrAlert; |
302 |
} else { |
303 |
return flag; |
221 |
} |
304 |
} |
222 |
return false; |
|
|
223 |
} |
305 |
} |
224 |
|
306 |
|
225 |
function Check(){ |
307 |
function Check(){ |
Lines 228-234
Link Here
|
228 |
document.f.submit(); |
310 |
document.f.submit(); |
229 |
return true; |
311 |
return true; |
230 |
} else { |
312 |
} else { |
231 |
alert(StrAlert); |
313 |
$("#check_errors").html( StrAlert ); |
|
|
314 |
$('html, body').animate({ scrollTop: 0 }, 'fast'); |
315 |
Sticky.hcSticky('refresh'); |
232 |
return false; |
316 |
return false; |
233 |
} |
317 |
} |
234 |
} |
318 |
} |
Lines 253-258
Link Here
|
253 |
$("#confirm_not_duplicate").attr("value","1"); |
337 |
$("#confirm_not_duplicate").attr("value","1"); |
254 |
Check(); |
338 |
Check(); |
255 |
} |
339 |
} |
|
|
340 |
/* Wrap a value in HTML without putting HTML in translatable string */ |
341 |
function formatFieldName( string ){ |
342 |
return "<strong><em>" + string + "</em></strong>"; |
343 |
} |
256 |
</script> |
344 |
</script> |
257 |
[% Asset.css("css/addbiblio.css") | $raw %] |
345 |
[% Asset.css("css/addbiblio.css") | $raw %] |
258 |
|
346 |
|
Lines 295-300
Link Here
|
295 |
<h1>Adding authority [% authtypetext | html %]</h1> |
383 |
<h1>Adding authority [% authtypetext | html %]</h1> |
296 |
[% END %] |
384 |
[% END %] |
297 |
|
385 |
|
|
|
386 |
<div id="check_errors"></div> |
387 |
|
298 |
[% IF ( duplicateauthid ) %] |
388 |
[% IF ( duplicateauthid ) %] |
299 |
<div class="dialog alert"> |
389 |
<div class="dialog alert"> |
300 |
<h3>Duplicate record suspected</h3> |
390 |
<h3>Duplicate record suspected</h3> |
Lines 310-316
Link Here
|
310 |
</div> |
400 |
</div> |
311 |
[% END # /IF duplicateauthid %] |
401 |
[% END # /IF duplicateauthid %] |
312 |
|
402 |
|
313 |
<form method="post" name="f" action="/cgi-bin/koha/authorities/authorities.pl"> |
403 |
<form method="post" id="f" name="f" action="/cgi-bin/koha/authorities/authorities.pl"> |
314 |
<input type="hidden" name="op" value="add" /> |
404 |
<input type="hidden" name="op" value="add" /> |
315 |
<input type="hidden" name="addfield_field" value="" /> |
405 |
<input type="hidden" name="addfield_field" value="" /> |
316 |
<input type="hidden" name="repeat_field" value="" /> |
406 |
<input type="hidden" name="repeat_field" value="" /> |
Lines 364-369
Link Here
|
364 |
<a class="btn btn-default" id="cancel" href="/cgi-bin/koha/authorities/authorities-home.pl">Cancel</a> |
454 |
<a class="btn btn-default" id="cancel" href="/cgi-bin/koha/authorities/authorities-home.pl">Cancel</a> |
365 |
[% END %] |
455 |
[% END %] |
366 |
</div> |
456 |
</div> |
|
|
457 |
<div id="show-errors" class="btn-group"></div> |
367 |
<div class="toolbar-tabs-container"> |
458 |
<div class="toolbar-tabs-container"> |
368 |
[% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %] |
459 |
[% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %] |
369 |
[% WRAPPER tabs_nav %] |
460 |
[% WRAPPER tabs_nav %] |
370 |
- |
|
|