Fixed error dashboard draw multiple widget services

This commit is contained in:
daniel 2020-06-09 10:37:29 +02:00 committed by Alejandro Fraguas
parent a30f73d6c2
commit a59cdec545
2 changed files with 83 additions and 9 deletions

View File

@ -104,6 +104,27 @@ class ServiceMapWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Widget ID.
*
* @var integer
*/
protected $widgetId;
/**
* Dashboard ID.
*
* @var integer
*/
protected $dashboardId;
/** /**
* Construct. * Construct.
@ -145,6 +166,15 @@ class ServiceMapWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Widget ID.
$this->widgetId = $widgetId;
// Dashboard ID.
$this->dashboardId = $dashboardId;
// Options. // Options.
$this->values = $this->decoders($this->getOptionsWidget()); $this->values = $this->decoders($this->getOptionsWidget());
@ -236,6 +266,14 @@ class ServiceMapWidget extends Widget
); );
} }
$inputs[] = [
'label' => \ui_print_info_message(
__('ZOOM functionality is only available when there is only one such widget in the dashboard'),
'',
true
),
];
$inputs[] = [ $inputs[] = [
'label' => __('Service'), 'label' => __('Service'),
'arguments' => [ 'arguments' => [
@ -249,8 +287,10 @@ class ServiceMapWidget extends Widget
], ],
]; ];
// Show legend. // TODO refactoriced services: Hidden legend.
$inputs[] = [ /*
// Show legend.
$inputs[] = [
'label' => __('Show legend'), 'label' => __('Show legend'),
'arguments' => [ 'arguments' => [
'name' => 'showLegend', 'name' => 'showLegend',
@ -258,7 +298,8 @@ class ServiceMapWidget extends Widget
'type' => 'switch', 'type' => 'switch',
'value' => $values['showLegend'], 'value' => $values['showLegend'],
], ],
]; ];
*/
return $inputs; return $inputs;
} }
@ -275,8 +316,7 @@ class ServiceMapWidget extends Widget
$values = parent::getPost(); $values = parent::getPost();
$values['serviceId'] = \get_parameter('serviceId', 0); $values['serviceId'] = \get_parameter('serviceId', 0);
$values['showLegend'] = \get_parameter_switch('showLegend'); // $values['showLegend'] = \get_parameter_switch('showLegend');
return $values; return $values;
} }
@ -314,10 +354,14 @@ class ServiceMapWidget extends Widget
return $output; return $output;
} }
$output .= "<div id='container_servicemap' style='position: relative; text-align: center;'>"; $containerId = 'container_servicemap_'.$this->values['serviceId'].'_'.$this->cellId;
$style = 'position: relative; text-align: center;';
$output .= "<div id='".$containerId."' style='".$style."'>";
if ($this->values['showLegend'] === 1) { // TODO refactoriced services: Hidden legend.
$output .= "<div id='container_servicemap_legend'>"; /*
if ($this->values['showLegend'] === 1) {
$output .= "<div id='container_servicemap_legend".$this->values['serviceId'].'_'.$this->cellId."'>";
$output .= '<table>'; $output .= '<table>';
$output .= "<tr class='legend_servicemap_title'><td colspan='3' style='padding-bottom: 10px; min-width: 177px;'><b>".__('Legend').'</b></td>'; $output .= "<tr class='legend_servicemap_title'><td colspan='3' style='padding-bottom: 10px; min-width: 177px;'><b>".__('Legend').'</b></td>';
$output .= "<td><img class='legend_servicemap_toggle' style='padding-bottom: 10px;' src='images/darrowup.png'></td></tr>"; $output .= "<td><img class='legend_servicemap_toggle' style='padding-bottom: 10px;' src='images/darrowup.png'></td></tr>";
@ -347,6 +391,22 @@ class ServiceMapWidget extends Widget
$output .= '</tr>'; $output .= '</tr>';
$output .= '</table>'; $output .= '</table>';
$output .= '</div>'; $output .= '</div>';
}
*/
// TODO: removed refactoriced services. Only 1 widget Zoom.
$sql = sprintf(
'SELECT COUNT(*)
FROM twidget_dashboard
WHERE id_dashboard = %s
AND id_widget = %s',
$this->dashboardId,
$this->widgetId
);
$countDashboardServices = \db_get_value_sql($sql);
$disableZoom = false;
if ($countDashboardServices > 1) {
$disableZoom = true;
} }
$output .= html_print_input_hidden( $output .= html_print_input_hidden(
@ -360,7 +420,9 @@ class ServiceMapWidget extends Widget
$this->values['serviceId'], $this->values['serviceId'],
false, false,
$size['width'], $size['width'],
$size['height'] $size['height'],
$this->cellId,
$disableZoom
); );
$output .= ob_get_clean(); $output .= ob_get_clean();
$output .= '</div>'; $output .= '</div>';

View File

@ -477,17 +477,29 @@ div#main_pure {
margin-top: 30px; margin-top: 30px;
} }
#form-config-widget .info_box,
.content-widget .info_box { .content-widget .info_box {
border-radius: 5px; border-radius: 5px;
width: 90%; width: 90%;
} }
#form-config-widget .info_box {
margin: 0 auto;
}
#form-config-widget .info_box tbody tr td,
.content-widget .info_box tbody tr td { .content-widget .info_box tbody tr td {
padding: 10px; padding: 10px;
} }
#form-config-widget .info_box tbody tr td.icon,
.content-widget .info_box tbody tr td.icon { .content-widget .info_box tbody tr td.icon {
padding-right: 10px !important; padding-right: 10px !important;
} }
#form-config-widget .info_box tbody tr td {
font-family: "lato-bolder", "Open Sans", sans-serif;
font-size: 8pt;
}
.content-widget .databox.filters > tbody > tr > td { .content-widget .databox.filters > tbody > tr > td {
padding-right: 30px; padding-right: 30px;
} }