scinote-web/app/assets/javascripts/samples/samples.js
Luka Murn 53699193a2 Merge branch 'smart-annotations'
Conflicts:
	app/assets/javascripts/comments.js.erb
	app/assets/javascripts/protocols/index.js
	app/assets/javascripts/protocols/steps.js.erb
	app/assets/javascripts/samples/sample_datatable.js.erb
	app/controllers/my_module_comments_controller.rb
	app/controllers/project_comments_controller.rb
	app/controllers/result_comments_controller.rb
	app/controllers/step_comments_controller.rb
	app/datatables/sample_datatable.rb
	app/views/my_module_comments/_comment.html.erb
	app/views/project_comments/_comment.html.erb
	app/views/projects/show/_experiment.html.erb
	app/views/reports/elements/_experiment_element.html.erb
	app/views/reports/elements/_result_comments_element.html.erb
	app/views/reports/elements/_result_text_element.html.erb
	app/views/reports/elements/_step_checklist_element.html.erb
	app/views/reports/elements/_step_comments_element.html.erb
	app/views/reports/elements/_step_element.html.erb
	app/views/result_comments/_comment.html.erb
	app/views/results/_result_text.html.erb
	app/views/step_comments/_comment.html.erb
	app/views/steps/_step.html.erb
	db/schema.rb
2017-01-24 14:33:23 +01:00

103 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Create import samples ajax
$("#modal-import-samples").on("show.bs.modal", function(event) {
formGroup = $(this).find(".form-group");
formGroup.removeClass("has-error");
formGroup.find(".help-block").remove();
});
$("form#form-samples-file")
.on("ajax:success", function(ev, data, status) {
$("#modal-parse-samples").html(data.html);
$("#modal-import-samples").modal("hide");
$("#modal-parse-samples").modal("show");
})
.on("ajax:error", function(ev, data, status) {
$(this).find(".form-group").addClass("has-error");
$(this).find(".form-group").find(".help-block").remove();
$(this).find(".form-group").append("<span class='help-block'>" + data.responseJSON.message + "</span>");
});
// Fetch samples data and updates the select options fields for
// sample group and sample type column
function updateSamplesTypesandGroups() {
changeToEditMode();
updateButtons();
$.ajax({
url: $("table#samples").data("new-sample"),
type: "GET",
dataType: "json",
success: function (data) {
$("select[name=sample_group_id]").each(function(){
var sample_group = $(this).val();
var selectGroup = createSampleGroupSelect(data.sample_groups, sample_group);
var gtd = $(this).parent("td");
gtd.html(selectGroup[0]);
});
$("select[name=sample_type_id]").each(function(){
var sample_type = $(this).val();
var selectType = createSampleTypeSelect(data.sample_types, sample_type);
var ttd = $(this).parent("td");
ttd.html(selectType[0]);
});
$("select[name=sample_group_id]").selectpicker();
$("select[name=sample_type_id]").selectpicker();
},
error: function (e, eData, status, xhr) {
if (e.status == 403)
showAlertMessage(I18n.t("samples.js.permission_error"));
changeToViewMode();
updateButtons();
}
});
}
function sampleAlertMsg(message, type) {
var alertType;
var glyphSign;
$('#notifications').html('');
if (type === 'success') {
alertType = ' alert-success ';
glyphSign = ' glyphicon-ok-sign ';
} else if (type === 'danger') {
alertType = ' alert-danger ';
glyphSign = ' glyphicon-exclamation-sign ';
}
var htmlSnippet = '<div class="alert alert' + alertType +
'alert-dismissable alert-floating">' +
'<div class="container">' +
'<button type="button" class="close" ' +
'data-dismiss="alert" aria-label="Close">' +
'<span aria-hidden="true">×</span></button>' +
'<span class="glyphicon' + glyphSign + '"></span>' +
'<span>' + message + '</span>' +
'</div>' +
'</div>';
$('#notifications').html(htmlSnippet);
$('#content-wrapper').addClass('alert-shown');
HelperModule.hideFlashMsg();
}
/**
* Initializes tutorial
*/
function initTutorial() {
var stepNum = parseInt(Cookies.get('current_tutorial_step'), 10);
if (stepNum >= 17 && stepNum <= 18) {
var nextPage = $('#reports-nav-tab a').attr('href');
var steps = [{
element: $('#importSamplesButton')[0],
intro: $('#samples-toolbar').attr('data-samples-step-text'),
position: 'right'
}, {
element: $('#secondary-menu')[0],
intro: $('#samples-toolbar').attr('data-breadcrumbs-step-text')
}];
initPageTutorialSteps(17, 18, nextPage,
function() {}, function() {}, steps);
}
}
initTutorial();