2017-06-19 20:05:37 +08:00
|
|
|
//= require repositories/import/records_importer.js
|
2017-06-22 20:43:01 +08:00
|
|
|
(function(global) {
|
2017-05-30 21:11:28 +08:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-22 20:43:01 +08:00
|
|
|
global.pageReload = function() {
|
|
|
|
animateSpinner();
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
2017-06-21 21:56:07 +08:00
|
|
|
function initImportRecordsModal() {
|
|
|
|
$('#importRecordsButton').off().on('click', function() {
|
|
|
|
$('#modal-import-records').modal('show');
|
|
|
|
_initParseRecordsModal();
|
2017-06-19 20:05:37 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-21 21:56:07 +08:00
|
|
|
function _initParseRecordsModal() {
|
|
|
|
$('#form-records-file').on('ajax:success', function(ev, data) {
|
|
|
|
$('#modal-import-records').modal('hide');
|
|
|
|
$(data.html).appendTo('body').promise().done(function() {
|
2017-06-22 20:43:01 +08:00
|
|
|
$('#parse-records_modal')
|
|
|
|
.modal('show')
|
|
|
|
.on('hidden.bs.modal', function() {
|
|
|
|
animateSpinner();
|
|
|
|
location.reload();
|
|
|
|
});
|
2017-06-21 21:56:07 +08:00
|
|
|
repositoryRecordsImporter();
|
|
|
|
});
|
2017-06-19 20:05:37 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-14 15:11:20 +08:00
|
|
|
function loadRepositoryTab() {
|
2017-06-21 21:56:07 +08:00
|
|
|
var param;
|
2017-06-14 15:11:20 +08:00
|
|
|
$('#repository-tabs a').on("click", function(e) {
|
|
|
|
e.preventDefault();
|
2017-06-21 21:56:07 +08:00
|
|
|
var pane = $(this);
|
2017-06-14 15:11:20 +08:00
|
|
|
$.ajax({
|
2017-06-21 21:56:07 +08:00
|
|
|
url: $(this).attr("data-url"),
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
success: function (data) {
|
|
|
|
var tabBody = $(pane.context.hash).find(".tab-content-body");
|
2017-06-14 15:11:20 +08:00
|
|
|
tabBody.html(data.html);
|
2017-06-19 20:05:37 +08:00
|
|
|
pane.tab('show').promise().done(function() {
|
|
|
|
initImportRecordsModal();
|
|
|
|
});
|
2017-06-14 15:11:20 +08:00
|
|
|
},
|
|
|
|
error: function (error) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// on page load
|
|
|
|
if( param = getParam('repository') ){
|
|
|
|
// load selected tab
|
2017-06-21 21:56:07 +08:00
|
|
|
$('a[href="#custom_repo_'+param+'"]').click();
|
2017-06-14 15:11:20 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// load first tab content
|
|
|
|
$('#repository-tabs a:first').click();
|
|
|
|
}
|
|
|
|
|
|
|
|
// clean tab content
|
2017-06-21 21:56:07 +08:00
|
|
|
$('a[data-toggle="tab"]').on('hide.bs.tab', function (e) {
|
2017-06-14 15:11:20 +08:00
|
|
|
$(".tab-content-body").html("");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-06-21 21:56:07 +08:00
|
|
|
$('.create-repository').initializeModal('#create-repo-modal');
|
2017-06-08 17:44:24 +08:00
|
|
|
|
2017-06-14 15:11:20 +08:00
|
|
|
$(document).ready(function() {
|
|
|
|
loadRepositoryTab();
|
2017-06-21 21:56:07 +08:00
|
|
|
initImportRecordsModal();
|
2017-06-08 17:44:24 +08:00
|
|
|
});
|
2017-06-22 20:43:01 +08:00
|
|
|
})(window);
|