From 9fff560cbde5519fb2af0a6f933f2da68430b48d Mon Sep 17 00:00:00 2001 From: Ke Wu Date: Fri, 17 Aug 2012 14:20:32 -0700 Subject: [PATCH] High-light selected container in browser Fixed bug #1038264 Change-Id: I46c1d2faf58872d9ed72ee9f6f0f9c4d61d20756 --- horizon/browsers/base.py | 10 ++++++---- horizon/tables/base.py | 8 +++++++- openstack_dashboard/static/dashboard/less/horizon.less | 5 +++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/horizon/browsers/base.py b/horizon/browsers/base.py index 802b635364..30a7b15146 100644 --- a/horizon/browsers/base.py +++ b/horizon/browsers/base.py @@ -127,12 +127,14 @@ class ResourceBrowser(html.HTMLElement): """ self.navigation_table = tables[self.navigation_table_class._meta.name] self.content_table = tables[self.content_table_class._meta.name] - if self.has_breadcrumb: - self.prepare_breadcrumb(tables) - - def prepare_breadcrumb(self, tables): navigation_item = self.kwargs.get(self.navigation_kwarg_name) content_path = self.kwargs.get(self.content_kwarg_name) + # Tells the navigation table what is selected. + self.navigation_table.current_item_id = navigation_item + if self.has_breadcrumb: + self.prepare_breadcrumb(tables, navigation_item, content_path) + + def prepare_breadcrumb(self, tables, navigation_item, content_path): if self.has_breadcrumb and navigation_item and content_path: for table in tables.values(): table.breadcrumb = Breadcrumb(self.request, diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 126af4f1b1..600d797c10 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -407,6 +407,7 @@ class Row(html.HTMLElement): super(Row, self).__init__() self.table = table self.datum = datum + self.selected = False if self.datum: self.load_cells() else: @@ -882,6 +883,7 @@ class DataTable(object): self._needs_form_wrapper = needs_form_wrapper self._no_data_message = self._meta.no_data_message self.breadcrumb = None + self.current_item_id = None # Create a new set columns = [] @@ -1292,7 +1294,11 @@ class DataTable(object): rows = [] try: for datum in self.filtered_data: - rows.append(self._meta.row_class(self, datum)) + row = self._meta.row_class(self, datum) + if self.get_object_id(datum) == self.current_item_id: + self.selected = True + row.classes.append('current_selected') + rows.append(row) except: # Exceptions can be swallowed at the template level here, # re-raising as a TemplateSyntaxError makes them visible. diff --git a/openstack_dashboard/static/dashboard/less/horizon.less b/openstack_dashboard/static/dashboard/less/horizon.less index 7f7225ce3b..9abdbf2705 100644 --- a/openstack_dashboard/static/dashboard/less/horizon.less +++ b/openstack_dashboard/static/dashboard/less/horizon.less @@ -1452,6 +1452,9 @@ label.log-length { max-width: 200px; } } + tr.current_selected td { + background-color: #E9F5FA; + } tfoot td { border-right: 0 none; border-bottom-right-radius: 0; @@ -1464,6 +1467,7 @@ label.log-length { white-space: nowrap; } tbody td { + border-right: @dataTableBorderWidth solid @dataTableBorderColor; background-color: @white; } } @@ -1475,6 +1479,7 @@ label.log-length { border-top-left-radius: 0; } td{ + border-bottom: @dataTableBorderWidth solid @dataTableBorderColor; &:last-child { border-right: 0 none; }