|
Lines 103-120
Link Here
|
| 103 |
<select name="profile" id="profile"> |
103 |
<select name="profile" id="profile"> |
| 104 |
<option value="">Do not use profile</option> |
104 |
<option value="">Do not use profile</option> |
| 105 |
</select> |
105 |
</select> |
| 106 |
</li> |
106 |
<div class="hint">When you select a profile it pre-fills your form with profile values.</div> |
| 107 |
<li> |
107 |
<div class="hint">Later you can modify your form and that's what matters on import.</div> |
| 108 |
<label for="profile_name">Profile name</label> |
|
|
| 109 |
<input type="text" id="profile_name" name="profile_name" /> |
| 110 |
|
| 111 |
</li> |
108 |
</li> |
| 112 |
</ol> |
109 |
</ol> |
| 113 |
<fieldset class="action"> |
|
|
| 114 |
<button id="add_profile" disabled>Add profile</button> |
| 115 |
<button id="mod_profile" disabled>Update profile</button> |
| 116 |
<button id="del_profile" disabled>Remove profile</button> |
| 117 |
</fieldset> |
| 118 |
</fieldset> |
110 |
</fieldset> |
| 119 |
|
111 |
|
| 120 |
<form method="post" id="processfile" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data"> |
112 |
<form method="post" id="processfile" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data"> |
|
Lines 216-222
Link Here
|
| 216 |
</li> |
208 |
</li> |
| 217 |
</ol> |
209 |
</ol> |
| 218 |
</fieldset> |
210 |
</fieldset> |
| 219 |
<fieldset class="action"><input type="button" id="mainformsubmit" value="Stage for import" /></fieldset> |
211 |
<fieldset class="action"> |
|
|
212 |
<input type="button" id="mainformsubmit" value="Stage for import" /> |
| 213 |
<button id="add_profile" disabled>Save profile</button> |
| 214 |
<input type="text" id="profile_name" name="profile_name" placeholder="Profile name"/> |
| 215 |
<button id="del_profile" disabled>Remove profile</button> |
| 216 |
</fieldset> |
| 220 |
|
217 |
|
| 221 |
<div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> |
218 |
<div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> |
| 222 |
<div id="jobfailed"></div></div> |
219 |
<div id="jobfailed"></div></div> |
|
Lines 241-246
Link Here
|
| 241 |
[% Asset.js("js/file-upload.js") | $raw %] |
238 |
[% Asset.js("js/file-upload.js") | $raw %] |
| 242 |
<script> |
239 |
<script> |
| 243 |
var xhr; |
240 |
var xhr; |
|
|
241 |
var PROFILE_SAVE_MSG = _("Profile saved"); |
| 242 |
var PROFILE_DEL_MSG = _("Profile deleted"); |
| 244 |
$(document).ready(function(){ |
243 |
$(document).ready(function(){ |
| 245 |
$("#processfile").hide(); |
244 |
$("#processfile").hide(); |
| 246 |
$('#profile_fieldset').hide(); |
245 |
$('#profile_fieldset').hide(); |
|
Lines 298-307
Link Here
|
| 298 |
|
297 |
|
| 299 |
$("#profile_name").keyup(function(){ |
298 |
$("#profile_name").keyup(function(){ |
| 300 |
$("#add_profile").prop("disabled", this.value.trim()==''); |
299 |
$("#add_profile").prop("disabled", this.value.trim()==''); |
| 301 |
$("#mod_profile").prop("disabled", this.value.trim()=='' || !$("#profile").val()) |
|
|
| 302 |
}); |
300 |
}); |
| 303 |
|
301 |
|
| 304 |
$("#add_profile").click(function() { |
302 |
$("#add_profile").click(function(event) { |
|
|
303 |
event.preventDefault(); |
| 305 |
var name = $("#profile_name").val().trim(); |
304 |
var name = $("#profile_name").val().trim(); |
| 306 |
if(!name) { |
305 |
if(!name) { |
| 307 |
alert(_("Profile must have a name")); |
306 |
alert(_("Profile must have a name")); |
|
Lines 317-323
Link Here
|
| 317 |
}); |
316 |
}); |
| 318 |
|
317 |
|
| 319 |
if(profile.length) { |
318 |
if(profile.length) { |
| 320 |
if(!confirm(_("There is another profile with this name.")+"\n\n"+_("Do you want to replace it?"))) { |
319 |
if(!confirm(_("There is another profile with this name.")+"\n\n"+_("Do you want to update it with new values?"))) { |
| 321 |
return; |
320 |
return; |
| 322 |
} |
321 |
} |
| 323 |
} |
322 |
} |
|
Lines 340-346
Link Here
|
| 340 |
|
339 |
|
| 341 |
if(profile.length) { |
340 |
if(profile.length) { |
| 342 |
$.ajax({ |
341 |
$.ajax({ |
| 343 |
url: "/api/v1/import-batch-profiles/"+profile[0].profile_id, |
342 |
url: "/api/v1/import_batch_profiles/"+profile[0].profile_id, |
| 344 |
method: "PUT", |
343 |
method: "PUT", |
| 345 |
data: JSON.stringify(params), |
344 |
data: JSON.stringify(params), |
| 346 |
contentType: 'application/json' |
345 |
contentType: 'application/json' |
|
Lines 349-355
Link Here
|
| 349 |
.fail(reject); |
348 |
.fail(reject); |
| 350 |
} else { |
349 |
} else { |
| 351 |
$.ajax({ |
350 |
$.ajax({ |
| 352 |
url: "/api/v1/import-batch-profiles/", |
351 |
url: "/api/v1/import_batch_profiles/", |
| 353 |
method: "POST", |
352 |
method: "POST", |
| 354 |
data: JSON.stringify(params), |
353 |
data: JSON.stringify(params), |
| 355 |
contentType: 'application/json' |
354 |
contentType: 'application/json' |
|
Lines 359-364
Link Here
|
| 359 |
} |
358 |
} |
| 360 |
}) |
359 |
}) |
| 361 |
.then(function(profile) { |
360 |
.then(function(profile) { |
|
|
361 |
humanMsg.displayAlert(PROFILE_SAVE_MSG); |
| 362 |
return getProfiles(profile.profile_id); |
362 |
return getProfiles(profile.profile_id); |
| 363 |
}) |
363 |
}) |
| 364 |
.catch(function(error) { |
364 |
.catch(function(error) { |
|
Lines 366-435
Link Here
|
| 366 |
}) |
366 |
}) |
| 367 |
}); |
367 |
}); |
| 368 |
|
368 |
|
| 369 |
$("#mod_profile").click(function() { |
369 |
$("#del_profile").click(function(event) { |
| 370 |
var name = $("#profile_name").val().trim(); |
370 |
event.preventDefault(); |
| 371 |
var id = $("#profile").val(); |
|
|
| 372 |
if(!id) return; |
| 373 |
if(!name) { |
| 374 |
alert(_("Profile must have a name")); |
| 375 |
return; |
| 376 |
} |
| 377 |
var profile = $("#profile option[value!='']") |
| 378 |
.map(function() { |
| 379 |
return $(this).data('profile'); |
| 380 |
}) |
| 381 |
.filter(function() { |
| 382 |
return this.name == name && this.profile_id != id; |
| 383 |
}); |
| 384 |
|
| 385 |
if(profile.length) { |
| 386 |
if(!confirm(_("There is another profile with this name.")+"\n\n"+_("Do you want to replace it?"))) { |
| 387 |
return; |
| 388 |
} |
| 389 |
} |
| 390 |
new Promise(function(resolve, reject) { |
| 391 |
if(!profile.length) return resolve(); |
| 392 |
$.ajax({ |
| 393 |
url: "/api/v1/import-batch-profiles/"+profile[0].profile_id, |
| 394 |
method: "DELETE" |
| 395 |
}) |
| 396 |
.done(resolve) |
| 397 |
.fail(reject); |
| 398 |
}) |
| 399 |
.then(function(){ |
| 400 |
const params = { |
| 401 |
comments: $("#comments").val() || null, |
| 402 |
record_type: $("#record_type").val() || null, |
| 403 |
encoding: $("#encoding").val() || null, |
| 404 |
format: $("#format").val() || null, |
| 405 |
template_id: $("#marc_modification_template_id").val() || null, |
| 406 |
matcher_id: $("#matcher").val() || null, |
| 407 |
overlay_action: $("#overlay_action").val() || null, |
| 408 |
nomatch_action: $("#nomatch_action").val() || null, |
| 409 |
parse_items: !!parseInt($("input[name='parse_items']:checked").val()) || null, |
| 410 |
item_action: $("#item_action").val() || null, |
| 411 |
name: name |
| 412 |
}; |
| 413 |
return new Promise(function(resolve, reject) { |
| 414 |
$.ajax({ |
| 415 |
url: "/api/v1/import-batch-profiles/"+id, |
| 416 |
method: "PUT", |
| 417 |
data: JSON.stringify(params), |
| 418 |
contentType: 'application/json' |
| 419 |
}) |
| 420 |
.done(resolve) |
| 421 |
.fail(reject); |
| 422 |
}); |
| 423 |
}) |
| 424 |
.then(function() { |
| 425 |
return getProfiles(id); |
| 426 |
}) |
| 427 |
.catch(function(error) { |
| 428 |
alert(_("An error occurred")+"\n\n"+error.message); |
| 429 |
}) |
| 430 |
}); |
| 431 |
|
| 432 |
$("#del_profile").click(function() { |
| 433 |
var id = $("#profile").val(); |
371 |
var id = $("#profile").val(); |
| 434 |
if(!id) return; |
372 |
if(!id) return; |
| 435 |
if(!confirm(_("Are you sure you want to delete this profile?"))) { |
373 |
if(!confirm(_("Are you sure you want to delete this profile?"))) { |
|
Lines 437-457
Link Here
|
| 437 |
} |
375 |
} |
| 438 |
new Promise(function(resolve, reject) { |
376 |
new Promise(function(resolve, reject) { |
| 439 |
$.ajax({ |
377 |
$.ajax({ |
| 440 |
url: "/api/v1/import-batch-profiles/"+id, |
378 |
url: "/api/v1/import_batch_profiles/"+id, |
| 441 |
method: "DELETE" |
379 |
method: "DELETE" |
| 442 |
}) |
380 |
}) |
| 443 |
.done(resolve) |
381 |
.done(resolve) |
| 444 |
.fail(reject); |
382 |
.fail(reject); |
| 445 |
}) |
383 |
}) |
| 446 |
.then(function() { |
384 |
.then(function() { |
|
|
385 |
humanMsg.displayAlert(PROFILE_DEL_MSG); |
| 447 |
return getProfiles(); |
386 |
return getProfiles(); |
| 448 |
}) |
387 |
}) |
| 449 |
.catch(function(error) { |
388 |
.catch(function(error) { |
| 450 |
alert(_("An error occurred")+"\n\n"+error); |
389 |
alert(_("An error occurred")+"\n\n"+error); |
| 451 |
}) |
390 |
}) |
| 452 |
}); |
391 |
}); |
| 453 |
|
|
|
| 454 |
}); |
392 |
}); |
|
|
393 |
|
| 455 |
function CheckForm(f) { |
394 |
function CheckForm(f) { |
| 456 |
if ($("#fileToUpload").value == '') { |
395 |
if ($("#fileToUpload").value == '') { |
| 457 |
alert(_("Please upload a file first.")); |
396 |
alert(_("Please upload a file first.")); |
|
Lines 510-516
Link Here
|
| 510 |
const select = $("#profile"); |
449 |
const select = $("#profile"); |
| 511 |
$("option[value!='']", select).remove(); |
450 |
$("option[value!='']", select).remove(); |
| 512 |
return new Promise(function(resolve, reject) { |
451 |
return new Promise(function(resolve, reject) { |
| 513 |
$.ajax("/api/v1/import-batch-profiles") |
452 |
$.ajax("/api/v1/import_batch_profiles") |
| 514 |
.then(resolve, reject); |
453 |
.then(resolve, reject); |
| 515 |
}) |
454 |
}) |
| 516 |
.then(function(profiles) { |
455 |
.then(function(profiles) { |
| 517 |
- |
|
|