Commit 688fb0c9 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

add a confirmation dialog when hide/unhide

parent 4bff58db
......@@ -75,6 +75,12 @@ class tx_nG6_pi1 extends tslib_pibase {
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.theme.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.dialog.css"/>';
$content = '<input type="hidden" id="user_group" value="'.$GLOBALS['TSFE']->fe_user->user['usergroup'].'" />';
$content .= '<div id="user_information_dialog" title=""></div>';
$content .= '<input type="hidden" id="cancel_btn_label" value="'.$this->pi_getLL('cancel_btn_label', '[cancel_btn_label]').'" />';
$content .= '<input type="hidden" id="ok_btn_label" value="'.$this->pi_getLL('ok_btn_label', '[ok_btn_label]').'" />';
$content .= '<input type="hidden" id="confirmation_dialog_title" value="'.$this->pi_getLL('confirmation_dialog_title', '[confirmation_dialog_title]').'" />';
$content .= '<input type="hidden" id="hide_confirmation_msg" value="'.$this->pi_getLL('hide_confirmation_msg', '[hide_confirmation_msg]').'" />';
$content .= '<input type="hidden" id="unhide_confirmation_msg" value="'.$this->pi_getLL('unhide_confirmation_msg', '[unhide_confirmation_msg]').'" />';
// If the user is authorized to access the specified project/run, display the page
if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], $this->piVars['run_id'])) {
......
......@@ -35,7 +35,12 @@
<label index="hide_btn">hide</label>
<label index="unhide_btn">unhide</label>
<label index="delete_btn">delete</label>
<label index="cancel_btn_label">Cancel</label>
<label index="ok_btn_label">Ok</label>
<label index="confirmation_dialog_title">Confirmation</label>
<label index="hide_confirmation_msg">Are you sure to hide the selected elements ?</label>
<label index="unhide_confirmation_msg">Are you sure to unhide the selected elements ?</label>
<label index="Analyse_sample">Samples</label>
<label index="Analyse_archives_title">Result file(s)</label>
<label index="Analyse_total">Total</label>
......@@ -281,6 +286,11 @@
<label index="hide_btn">cacher</label>
<label index="unhide_btn">décacher</label>
<label index="delete_btn">supprimer</label>
<label index="cancel_btn_label">Annuler</label>
<label index="ok_btn_label">Ok</label>
<label index="confirmation_dialog_title">Confirmation</label>
<label index="hide_confirmation_msg">Etes vous sure de vouloir cacher la sélection ?</label>
<label index="unhide_confirmation_msg">Etes vous sure de vouloir décacher la sélection ?</label>
<label index="Analyse_sample">Echantillons</label>
<label index="Analyse_archives_title">Fichier(s) résultat</label>
......
......@@ -40,6 +40,20 @@ $(function () {
opacity: 0.5
}
});
$("#user_information_dialog").dialog({
autoOpen: false,
bgiframe: true,
width: 500,
height: 50,
resizable: false,
position: "center",
modal: true,
overlay: {
backgroundColor: "#000",
opacity: 0.5
}
});
$(".tx-nG6-pi1-imglink").click(function() {
jQuery.url.setUrl($(this).attr("href"));
......@@ -54,85 +68,96 @@ $(function () {
/* Hide toolbar option */
$("#table_opt #hide_link").click(function() {
var nb_checked = $('input:checked[name=opt_checkbox]').size();
// First confir with the user if he wants to hide
$("#user_information_dialog").dialog("option", "title", $("#confirmation_dialog_title").val());
$("#user_information_dialog").html($("#hide_confirmation_msg").val()).dialog("open");
var buttons = {};
buttons[$("#cancel_btn_label").val()] = function(){$(this).dialog("close");};
buttons[$("#ok_btn_label").val()] = function(){
if (nb_checked != 0) {
// level
if ($('#table_chk tr:first[id^="project"]').length != 0) {
var hide_level = 'project';
} else if ($('#table_chk tr:first[id^="run"]').length != 0) {
var hide_level = 'run';
} else {
var hide_level = 'analyze';
}
//Adress definition
var val_url = "index.php?eID=tx_nG6&type=hide";
val_url += "&hide_level="+hide_level;
val_url += "&user_group="+$("#user_group").val();
val_url += "&ids=";
$('input:checked[name=opt_checkbox]').each(function(i){
val_url += $(this).val().split("_",2)[1]+";"; // {project/run} id
});
$.ajax({
url: val_url,
success: function(val, status, xhr) {
$('input:checked[name=opt_checkbox]').each(function(i){
$id_tmp = $(this).val().split("_",2)[1]+";"; // {project/run} id
// update gui
// hide rows
$("#table_chk tr#"+hide_level+"_"+$id_tmp+" td").addClass("tx-nG6-pi1-hidden");
// uncheck checkboxes
$("#table_chk input[type='checkbox']").attr('checked',false);
});
}
});
}
var nb_checked = $('input:checked[name=opt_checkbox]').size();
if (nb_checked != 0) {
// level
if ($('#table_chk tr:first[id^="project"]').length != 0) {
var hide_level = 'project';
} else if ($('#table_chk tr:first[id^="run"]').length != 0) {
var hide_level = 'run';
} else {
var hide_level = 'analyze';
}
//Adress definition
var val_url = "index.php?eID=tx_nG6&type=hide";
val_url += "&hide_level="+hide_level;
val_url += "&user_group="+$("#user_group").val();
val_url += "&ids=";
$('input:checked[name=opt_checkbox]').each(function(i){
val_url += $(this).val().split("_",2)[1]+";"; // {project/run} id
});
$.ajax({
url: val_url,
success: function(val, status, xhr) {
$('input:checked[name=opt_checkbox]').each(function(i){
$id_tmp = $(this).val().split("_",2)[1]+";"; // {project/run} id
// update gui
// hide rows
$("#table_chk tr#"+hide_level+"_"+$id_tmp+" td").addClass("tx-nG6-pi1-hidden");
// uncheck checkboxes
$("#table_chk input[type='checkbox']").attr('checked',false);
$("#user_information_dialog").dialog("close");
});
}
});
}
};
// Add the buttons to the dialog
$("#user_information_dialog").dialog('option', 'buttons', buttons);
});
/* Unhide toolbar option */
$("#table_opt #unhide_link").click(function() {
var nb_checked = $('input:checked[name=opt_checkbox]').size();
if (nb_checked != 0) {
// level
if ($('#table_chk tr:first[id^="project"]').length != 0) {
var unhide_level = 'project';
} else if ($('#table_chk tr:first[id^="run"]').length != 0) {
var unhide_level = 'run';
} else {
var unhide_level = 'analyze';
}
// Adress definition
var val_url = "index.php?eID=tx_nG6&type=unhide";
val_url += "&hide_level="+unhide_level;
val_url += "&user_group="+$("#user_group").val();
val_url += "&ids=";
$('input:checked[name=opt_checkbox]').each(function(i){
val_url += $(this).val().split("_",2)[1]+";"; // {project/run} id
});
$.ajax({
url: val_url,
success: function(val, status, xhr) {
$('input:checked[name=opt_checkbox]').each(function(i){
$id_tmp = $(this).val().split("_",2)[1]+";"; // {project/run} id
// update gui
// -- unhide rows
$("#table_chk tr#"+unhide_level+"_"+$id_tmp+" td").removeClass("tx-nG6-pi1-hidden");
// -- uncheck checkboxes
$("#table_chk input[type='checkbox']").attr('checked',false);
});
}
});
}
// First confir with the user if he wants to hide
$("#user_information_dialog").dialog("option", "title", $("#confirmation_dialog_title").val());
$("#user_information_dialog").html($("#unhide_confirmation_msg").val()).dialog("open");
var buttons = {};
buttons[$("#cancel_btn_label").val()] = function(){$(this).dialog("close");};
buttons[$("#ok_btn_label").val()] = function(){
var nb_checked = $('input:checked[name=opt_checkbox]').size();
if (nb_checked != 0) {
// level
if ($('#table_chk tr:first[id^="project"]').length != 0) {
var unhide_level = 'project';
} else if ($('#table_chk tr:first[id^="run"]').length != 0) {
var unhide_level = 'run';
} else {
var unhide_level = 'analyze';
}
// Adress definition
var val_url = "index.php?eID=tx_nG6&type=unhide";
val_url += "&hide_level="+unhide_level;
val_url += "&user_group="+$("#user_group").val();
val_url += "&ids=";
$('input:checked[name=opt_checkbox]').each(function(i){
val_url += $(this).val().split("_",2)[1]+";"; // {project/run} id
});
$.ajax({
url: val_url,
success: function(val, status, xhr) {
$('input:checked[name=opt_checkbox]').each(function(i){
$id_tmp = $(this).val().split("_",2)[1]+";"; // {project/run} id
// update gui
// -- unhide rows
$("#table_chk tr#"+unhide_level+"_"+$id_tmp+" td").removeClass("tx-nG6-pi1-hidden");
// -- uncheck checkboxes
$("#table_chk input[type='checkbox']").attr('checked',false);
$("#user_information_dialog").dialog("close");
});
}
});
}
};
// Add the buttons to the dialog
$("#user_information_dialog").dialog('option', 'buttons', buttons);
});
/* Checked or unchecked all checkboxes (master checkbox) */
......
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