diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-18 01:23:10 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-18 01:23:28 +0400 |
commit | 4bb2de9bac0a6d0cd2fb196725f072da9856d39f (patch) | |
tree | a4bedd27dedc0ddbca887e76c92f4ed73838d276 /plugins/CoreVisualizations | |
parent | 27941440415dac2e4aa449eac1094baeb29d35dd (diff) |
Refs #4041, remove subtable_template property and _dataTableActions_subDataTable.twig file.
Diffstat (limited to 'plugins/CoreVisualizations')
-rw-r--r-- | plugins/CoreVisualizations/Visualizations/HtmlTable.php | 19 | ||||
-rw-r--r-- | plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig | 72 |
2 files changed, 54 insertions, 37 deletions
diff --git a/plugins/CoreVisualizations/Visualizations/HtmlTable.php b/plugins/CoreVisualizations/Visualizations/HtmlTable.php index 8c048ed01f..03120461ed 100644 --- a/plugins/CoreVisualizations/Visualizations/HtmlTable.php +++ b/plugins/CoreVisualizations/Visualizations/HtmlTable.php @@ -32,12 +32,12 @@ class HtmlTable extends DataTableVisualization const ID = 'table'; /** - * Custom template used if displaying a subtable. - * - * TODO: Should be replaced w/ allowing custom visualization for - * subtables. Should not directly touch template. + * If this property is set to true, subtables will be shown as embedded in the original table. + * If false, subtables will be shown as whole tables between rows. + * + * Default value: false */ - const SUBTABLE_TEMPLATE = 'subtable_template'; + const SHOW_EMBEDDED_SUBTABLE = 'show_embedded_subtable'; /** * Controls whether the entire DataTable should be rendered (including subtables) or just one @@ -135,9 +135,9 @@ class HtmlTable extends DataTableVisualization public function __construct($view) { if (Common::getRequestVar('idSubtable', false) - && $view->visualization_properties->subtable_template + && $view->visualization_properties->show_embedded_subtable ) { - $view->datatable_template = $view->visualization_properties->subtable_template; + $view->show_visualization_only = true; } if ($view->visualization_properties->show_extra_columns) { @@ -161,6 +161,7 @@ class HtmlTable extends DataTableVisualization $view = new View("@CoreVisualizations/_dataTableViz_htmlTable.twig"); $view->properties = $properties; $view->dataTable = $dataTable; + $view->idSubtable = Common::getRequestVar('idSubtable', false); return $view->render(); } @@ -174,13 +175,13 @@ class HtmlTable extends DataTableVisualization 'table' => array( 'disable_row_evolution' => false, 'disable_row_actions' => false, - 'subtable_template' => "@CoreHome/_dataTable.twig", 'show_extra_columns' => false, 'show_goals_columns' => false, 'disable_subtable_when_show_goals' => false, 'keep_summary_row' => false, 'highlight_summary_row' => false, - 'show_expanded' => false + 'show_expanded' => false, + 'show_embedded_subtable' => false ), ), ); diff --git a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig index a5ba98ac72..67a0d71c0f 100644 --- a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig +++ b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable.twig @@ -1,34 +1,50 @@ {%- set subtablesAreDisabled = properties.visualization_properties.show_goals_columns|default(false) and properties.visualization_properties.disable_subtable_when_show_goals|default(false) -%} -<table cellspacing="0" class="dataTable"> - {% include "@CoreHome/_dataTableHead.twig" %} +{%- set showingEmbeddedSubtable = properties.visualization_properties.show_embedded_subtable is not empty + and idSubtable is not empty -%} +{% if error is defined %} + {{ error.message }} +{% else %} + {%- if not showingEmbeddedSubtable -%} + <table cellspacing="0" class="dataTable"> + {% include "@CoreHome/_dataTableHead.twig" %} - <tbody> - {% for rowId, row in dataTable.getRows() %} - {%- set rowHasSubtable = not subtablesAreDisabled and row.getIdSubDataTable() and properties.subtable_controller_action is not null -%} - {%- set shouldHighlightRow = rowId == constant('Piwik\\DataTable::ID_SUMMARY_ROW') and properties.highlight_summary_row -%} + <tbody> + {%- endif -%} + {% if showingEmbeddedSubtable and dataTable.getRowsCount() == 0 %} + <tr> + <td colspan="{{ properties.columns_to_display|length }}">{{ 'CoreHome_CategoryNoData'|translate }}</td> + </tr> + {% else %} + {%- for rowId, row in dataTable.getRows() -%} + {%- set rowHasSubtable = not subtablesAreDisabled and row.getIdSubDataTable() and properties.subtable_controller_action is not null -%} + {%- set shouldHighlightRow = rowId == constant('Piwik\\DataTable::ID_SUMMARY_ROW') and properties.highlight_summary_row -%} - {# display this row if it doesn't have a subtable or if we don't replace the row with the subtable #} - {%- set showRow = subtablesAreDisabled - or not rowHasSubtable - or not properties.visualization_properties.show_expanded|default(false) - or not properties.visualization_properties.replace_row_with_subtable|default(false) -%} + {# display this row if it doesn't have a subtable or if we don't replace the row with the subtable #} + {%- set showRow = subtablesAreDisabled + or not rowHasSubtable + or not properties.visualization_properties.show_expanded|default(false) + or not properties.visualization_properties.replace_row_with_subtable|default(false) -%} - {% if showRow %} - <tr {% if rowHasSubtable %}id="{{ row.getIdSubDataTable() }}"{% endif %} - class="{{ row.getMetadata('css_class') }} {% if rowHasSubtable %}subDataTable{% endif %}{% if shouldHighlightRow %} highlight{% endif %}"> - {% for column in properties.columns_to_display %} - <td> - {% include "@CoreHome/_dataTableCell.twig" with properties %} - </td> - {% endfor %} - </tr> + {% if showRow %} + <tr {% if rowHasSubtable %}id="{{ row.getIdSubDataTable() }}"{% endif %} + class="{{ row.getMetadata('css_class') }} {% if rowHasSubtable %}subDataTable{% endif %}{% if shouldHighlightRow %} highlight{% endif %}"> + {% for column in properties.columns_to_display %} + <td> + {% include "@CoreHome/_dataTableCell.twig" with properties %} + </td> + {% endfor %} + </tr> + {% endif %} + + {# display subtable if present and showing expanded datatable #} + {% if properties.visualization_properties.show_expanded|default(false) and rowHasSubtable %} + {% include "@CoreVisualizations/_dataTableViz_htmlTable.twig" with {'dataTable': row.getSubtable(), 'idSubtable': row.getIdSubDataTable()} %} + {% endif %} + {%- endfor -%} {% endif %} - - {# display subtable if present and showing expanded datatable #} - {% if properties.visualization_properties.show_expanded|default(false) and rowHasSubtable %} - {% include properties.visualization_properties.subtable_template with {'dataTable': row.getSubtable()} %} - {% endif %} - {% endfor %} - </tbody> -</table>
\ No newline at end of file + {%- if not showingEmbeddedSubtable -%} + </tbody> + </table> + {%- endif -%} +{% endif %}
\ No newline at end of file |