Merge branch 'ent-1888-anadir-nueva-feature-para-poder-cambiar-los-eventos-a-estado-en-proceso' into 'develop'

Ent 1888 anadir nueva feature para poder cambiar los eventos a estado en proceso

See merge request artica/pandorafms!1442
This commit is contained in:
vgilc 2018-05-09 10:24:19 +02:00
commit d746af9c28
4 changed files with 176 additions and 60 deletions

View File

@ -1563,3 +1563,67 @@ function round_with_decimals (value, multiplier = 1) {
} }
return round_with_decimals (value, multiplier * 10); return round_with_decimals (value, multiplier * 10);
} }
/*
$("body").append('<div id="event_delete_confirm_dialog"><h4>' + '<?php echo __('Are you sure?'); ?>' + '</h4></div>');
$("#event_delete_confirm_dialog").dialog({
resizable: false,
draggable: false,
modal: true,
height: 280,
width: 330,
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
*/
/**
* Display a confirm dialog box
*
* @param string Text to display
* @param string Ok button text
* @param string Cancel button text
* @param function Callback to action when ok button is pressed
*/
function display_confirm_dialog (
message = '',
ok_text = '',
cancel_text = '',
ok_function = function () {}
) {
// Clean function to close the dialog
var clean_function = function () {
$("#pandora_confirm_dialog_text").hide();
$("#pandora_confirm_dialog_text").remove();
}
// Modify the ok function to close the dialog too
var ok_function_clean = function () {
ok_function();
clean_function();
}
// Display the dialog
$("body").append('<div id="pandora_confirm_dialog_text"><h3>' + message + '</h3></div>');
$("#pandora_confirm_dialog_text").dialog({
resizable: false,
draggable: true,
modal: true,
dialogClass: "pandora_confirm_dialog",
overlay: {
opacity: 0.5,
background: "black"
},
closeOnEscape: true,
modal: true,
buttons: {
Cancel: clean_function,
"Confirm": ok_function_clean
}
});
}

View File

@ -4634,3 +4634,19 @@ form ul.form_flex li ul li{
width: auto!important; width: auto!important;
} }
.pandora_confirm_dialog .ui-dialog-buttonset {
display: flex;
width: 100%;
margin-left: 10px;
float: none !important;
}
.pandora_confirm_dialog .ui-dialog-buttonset button{
flex: 50%;
}
#pandora_confirm_dialog_text h3{
margin-left: 20px;
margin-right: 20px;
text-align: center;
}

View File

@ -666,7 +666,11 @@ else {
if ($i != 0 && $allow_action) { if ($i != 0 && $allow_action) {
//Actions //Actions
$data[$i] = ''; $data[$i] = '<a href="javascript:" onclick="show_event_dialog(' . $event["id_evento"] . ', '.$group_rep.');">';
$data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - " . strip_tags(io_safe_output($event["evento"])), true);
$data[$i] .= html_print_image ("images/eye.png", true,
array ("title" => __('Show more')));
$data[$i] .= '</a>';
if(!$readonly) { if(!$readonly) {
// Validate event // Validate event
@ -676,6 +680,13 @@ else {
$data[$i] .= html_print_image ("images/ok.png", true, $data[$i] .= html_print_image ("images/ok.png", true,
array ("title" => __('Validate event'))); array ("title" => __('Validate event')));
$data[$i] .= '</a>'; $data[$i] .= '</a>';
// Display the go to in progress status button
if ($event["estado"] != 2) {
$data[$i] .= '<a href="javascript:validate_event_advanced('.$event["id_evento"].', 2)" id="in-progress-'.$event["id_evento"].'">';
$data[$i] .= html_print_image ("images/hourglass.png", true,
array ("title" => __('Change to in progress status')));
$data[$i] .= '</a>';
}
} }
// Delete event // Delete event
@ -688,18 +699,19 @@ else {
$data[$i] .= '</a>'; $data[$i] .= '</a>';
} }
else { else {
$data[$i] .= html_print_image ("images/cross.disabled.png", true, $data[$i] .= html_print_image (
array ("title" => __('Is not allowed delete events in process'))).'&nbsp;'; "images/cross.disabled.png",
true,
array (
"title" => __('Is not allowed delete events in process'),
"id" => "delete-" . $event['id_evento']
)
);
$data[$i] .= '&nbsp;';
} }
} }
} }
$data[$i] .= '<a href="javascript:" onclick="show_event_dialog(' . $event["id_evento"] . ', '.$group_rep.');">';
$data[$i] .= html_print_input_hidden('event_title_'.$event["id_evento"], "#".$event["id_evento"]." - " . strip_tags(io_safe_output($event["evento"])), true);
$data[$i] .= html_print_image ("images/eye.png", true,
array ("title" => __('Show more')));
$data[$i] .= '</a>';
$table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;'; $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3;';
$i++; $i++;

View File

@ -874,16 +874,18 @@ $(document).ready( function() {
); );
}); });
$("a.delete_event").click (function () { $("td").on('click', 'a.delete_event', function () {
confirmation = confirm("<?php echo __('Are you sure?'); ?>"); var click_element = this;
if (!confirmation) { display_confirm_dialog(
return; "<?php echo __('Are you sure?'); ?>",
} "<?php echo __('Confirm'); ?>",
"<?php echo __('Cancel'); ?>",
function () {
meta = $('#hidden-meta').val(); meta = $('#hidden-meta').val();
history_var = $('#hidden-history').val(); history_var = $('#hidden-history').val();
$tr = $(this).parents ("tr"); $tr = $(click_element).parents ("tr");
id = this.id.split ("-").pop (); id = click_element.id.split ("-").pop ();
$("#delete_cross_"+id).attr ("src", "images/spinner.gif"); $("#delete_cross_"+id).attr ("src", "images/spinner.gif");
@ -906,6 +908,8 @@ $(document).ready( function() {
"html" "html"
); );
return false; return false;
}
);
}); });
function toggleDiv (divid) { function toggleDiv (divid) {
@ -941,6 +945,11 @@ function validate_event_advanced(id, new_status) {
var grouped = $('#group_rep').val(); var grouped = $('#group_rep').val();
// Get images url
var hourglass_image = "<?php echo ui_get_full_url("images/hourglass.png", false, false, false); ?>";
var cross_disabled_image = "<?php echo ui_get_full_url("images/cross.disabled.png", false, false, false); ?>";
var cross_image = "<?php echo ui_get_full_url("images/cross.png", false, false, false); ?>";
var similar_ids; var similar_ids;
similar_ids = $('#hidden-similar_ids_'+id).val(); similar_ids = $('#hidden-similar_ids_'+id).val();
meta = $('#hidden-meta').val(); meta = $('#hidden-meta').val();
@ -964,30 +973,45 @@ function validate_event_advanced(id, new_status) {
// Change status description // Change status description
$("#status_row_"+id).html(<?php echo "'" . __('Event validated') . "'"; ?>); $("#status_row_"+id).html(<?php echo "'" . __('Event validated') . "'"; ?>);
// Change state image // Change delete icon
$("#delete-"+id).remove();
$("#validate-"+id).parent().append('<a class="delete_event" href="javascript:" id="delete-' + id + '"></a>');
$("#delete-"+id).append("<img src='" + cross_image + "' />");
$("#delete-"+id + " img").attr ("id", "delete_cross_" + id);
$("#delete-"+id + " img").attr ("data-title", <?php echo "'" . __('Delete event') . "'"; ?>);
$("#delete-"+id + " img").attr ("alt", <?php echo "'" . __('Delete event') . "'"; ?>);
$("#delete-"+id + " img").attr ("data-use_title_for_force_title", 1);
$("#delete-"+id + " img").attr ("class", "forced_title");
// Change other buttons actions
$("#validate-"+id).css("display", "none"); $("#validate-"+id).css("display", "none");
$("#in-progress-"+id).css("display", "none");
$("#status_img_"+id).attr ("src", "images/tick.png"); $("#status_img_"+id).attr ("src", "images/tick.png");
$("#status_img_"+id).attr ("title", <?php echo "'" . __('Event validated') . "'"; ?>); $("#status_img_"+id).attr ("data-title", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event validated') . "'"; ?>); $("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("data-use_title_for_force_title", 1);
$("#status_img_"+id).attr ("class", "forced_title");
} // In process } // In process
else if (new_status == 2) { else if (new_status == 2) {
// Change status description // Change status description
$("#status_row_"+id).html(<?php echo "'" . __('Event in process') . "'"; ?>); $("#status_row_"+id).html(<?php echo "'" . __('Event in process') . "'"; ?>);
// Remove delete link (if event is not grouped and there is more than one event)
if (grouped == 1) {
if (parseInt($("#count_event_group_"+id).text()) <= 1) {
$("#delete-"+id).replaceWith('<img alt="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" title="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" src="images/cross.disabled.png">');
}
}
else { // Remove delete link (if event is not grouped)
$("#delete-"+id).replaceWith('<img alt="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" title="' + <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?> + '" src="images/cross.disabled.png">');
}
// Change state image // Change state image
$("#status_img_"+id).attr ("src", "images/hourglass.png"); $("#status_img_"+id).attr ("src", hourglass_image);
$("#status_img_"+id).attr ("title", <?php echo "'" . __('Event in process') . "'"; ?>); $("#status_img_"+id).attr ("data-title", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>); $("#status_img_"+id).attr ("alt", <?php echo "'" . __('Event in process') . "'"; ?>);
$("#status_img_"+id).attr ("data-use_title_for_force_title", 1);
$("#status_img_"+id).attr ("class", "forced_title");
// Change the actions buttons
$("#delete-"+id).remove();
$("#in-progress-"+id).remove();
// Format the new disabled delete icon.
$("#validate-"+id).parent().append("<img id='delete-" + id + "' src='" + cross_disabled_image + "' />");
$("#delete-"+id).attr ("data-title", <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?>);
$("#delete-"+id).attr ("alt", <?php echo "'" . __('Is not allowed delete events in process') . "'"; ?>);
$("#delete-"+id).attr ("data-use_title_for_force_title", 1);
$("#delete-"+id).attr ("class", "forced_title");
// Remove row due to new state // Remove row due to new state
if (($("#status").val() == 0) if (($("#status").val() == 0)