Commit 68ef96c9 authored by Dylan's avatar Dylan
Browse files

#6839

parent 3a51349c
......@@ -91,13 +91,15 @@ class archivalProfile extends \bundle\recordsManagement\Controller\archivalProfi
*
* @return boolean The result of the operation
*/
public function uploadArchivalProfile($profileReference, $archivalProfile, $format = 'rng')
public function uploadArchivalProfile($profileReference, $archivalProfile,$content, $format = 'rng')
{
$profilesDirectory = $this->profilesDirectory;
$profilesDirectory .= DIRECTORY_SEPARATOR.$profileReference.'.'.$format ;
$content = base64_decode($content);
$archivalProfileController = \laabs::newController('recordsManagement/archivalProfile');
$archivalProfileController->create($archivalProfile);
$archivalProfile = base64_decode($archivalProfile);
file_put_contents($profilesDirectory, $archivalProfile);
file_put_contents($profilesDirectory, $content);
$archivalProfile = $this->getByReference($profileReference);
$archivalProfile->descriptionSchema = $profilesDirectory;
......
......@@ -30,12 +30,13 @@ interface archivalProfileInterface extends \bundle\recordsManagement\archivalPro
{
/**
* upload an archival profile
* @param base64 $archivalProfile The profile binary file
* @param recordsManagement/archivalProfile $archivalProfile The profile object
* @param base64 $content The profile binary file
* @param string $format The profile file format
*
* @action recordsManagement/archivalProfile/uploadArchivalProfile
*/
public function createArchivalprofileUpload_profileReference_($archivalProfile, $format="rng");
public function createArchivalprofileUpload_profileReference_($archivalProfile,$content, $format="rng");
/**
* Download the profile file
......
......@@ -44,7 +44,23 @@
<span id="wrongFileFormat">The profile file's extention must be rng or xsd.</span>
</div>
</div>
<div class="modal fade" id="messageSavingModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Enregistrer le profil d'archive</h4>
</div>
<div class="modal-body">
<p>Le profil d'archive sera enregistré afin de pouvoir ajouter le fichier. Voulez-vous continuer ?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" title="Annuler">Non</button>
<button type="button" id="confirmSaving" class="btn btn-success" data-dismiss="modal" title="Enregistrer">Oui</button>
</div>
</div>
</div>
</div>
<style>
#archivalProfile_XMLDropZone {
......@@ -105,8 +121,14 @@
cancelProfileForm();
})
// Submit
$('#archivalProfile_submitImport').on('click', function() {
$('#messageSavingModal').modal();
});
// Submit
$('#confirmSaving').on('click', function() {
var icon = $('<i/>').addClass('fa fa-spinner fa-spin');
var submitButton = $('#messageImport_submit');
var reference = $('#archivalProfile_form').find('input[name="reference"]').val();
......@@ -128,11 +150,13 @@
}
$('.btn').prop('disabled', true);
var archivalProfile = ArchivalProfile.serialize();
var content = $('#archivalProfile_filesBrowser').data('base64');
$.ajax({
ajax($(this), {
type : 'POST',
url : '/archivalProfile/upload/' + reference,
data : JSON.stringify({archivalProfile : $('#archivalProfile_filesBrowser').data('base64'), format: format}),
data : JSON.stringify({archivalProfile: archivalProfile ,content : content, format: format}),
contentType : 'application/json',
dataType : 'json',
success : function (response) {
......@@ -143,6 +167,10 @@
$('#archivalProfile_replaceFile').removeClass('hide');
$("#archivalProfile_download").removeClass('hide');
}
$('#messageSavingModal').modal('hide');
$('#messageSavingModal').one('hidden.bs.modal', function () {
load('/archivalProfiles');
});
$('.btn').prop('disabled', false);
},
error : function(response) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment