From dab7e45c7456fb5b4e9a9235507dba934b995c1e Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Mon, 31 Aug 2015 14:40:21 +0300 Subject: [PATCH] Fix for the broken header's dropdowns for both v0.11.2 and v0.13 The dropdownToggle directive from angular-ui/bootstrap v0.11.2 conflicts with the native Bootstrap data-toggle="dropdown" attribute (see https:github.com/angular-ui/bootstrap/issues/2156). This is fixed in 0.13, but before that it'd be valuable to ensure that the same html markup works the same way with both versions of angular-ui/bootstrap (0.11.2 and 0.13). The decorator code could be safely deleted once Horizon migrates to angular-ui/bootstrap v0.13. Also fix dropdowns in material theme templates. Closes-Bug: #1466146 Change-Id: I8f01c1ce7b0a5dc29bf9d8aba23c9ea7e6e1ec35 --- horizon/static/framework/framework.module.js | 22 ++++++++++++++++++- .../horizon/common/_region_selector.html | 2 +- openstack_dashboard/templates/_header.html | 4 ++-- .../themes/material/templates/_header.html | 4 ++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/horizon/static/framework/framework.module.js b/horizon/static/framework/framework.module.js index 2785622843..5d5617d7f0 100644 --- a/horizon/static/framework/framework.module.js +++ b/horizon/static/framework/framework.module.js @@ -10,13 +10,14 @@ .config(config); config.$inject = [ + '$injector', '$provide', '$interpolateProvider', '$httpProvider', '$windowProvider' ]; - function config($provide, $interpolateProvider, $httpProvider, $windowProvider) { + function config($injector, $provide, $interpolateProvider, $httpProvider, $windowProvider) { var path = $windowProvider.$get().STATIC_URL + 'framework/'; $provide.constant('horizon.framework.basePath', path); @@ -32,6 +33,25 @@ $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; $httpProvider.defaults.headers.common['Content-Type'] = 'application/json;charset=utf-8'; + // NOTE(tsufiev): angular-ui/bootstrap v0.11.2 dropdownToggle directive + // conflicts with the native Bootstrap data-toggle="dropdown" attribute + // (see https://github.com/angular-ui/bootstrap/issues/2156). + // This is fixed in 0.13, but before that it'd be valuable to ensure that + // the same html markup works the same way with both versions of + // angular-ui/bootstrap (0.11.2 and 0.13). Could be safely deleted once + // Horizon migrates to angular-ui/bootstra v0.13 + if ($injector.has('dropdownToggleDirective')) { + $provide.decorator('dropdownToggleDirective', patchDropdowns); + } + + patchDropdowns.$inject = ['$delegate']; + + function patchDropdowns($delegate) { + var directive = $delegate[0]; + directive.restrict = 'A'; + return $delegate; + } + // Global http error handler // if user is not authorized, log user out // this can happen when session expires diff --git a/horizon/templates/horizon/common/_region_selector.html b/horizon/templates/horizon/common/_region_selector.html index bbcd9f6dcf..63762eb957 100644 --- a/horizon/templates/horizon/common/_region_selector.html +++ b/horizon/templates/horizon/common/_region_selector.html @@ -1,5 +1,5 @@ {% if regions.support %} - diff --git a/openstack_dashboard/templates/_header.html b/openstack_dashboard/templates/_header.html index 8d0a115800..8e20473c7b 100644 --- a/openstack_dashboard/templates/_header.html +++ b/openstack_dashboard/templates/_header.html @@ -20,7 +20,7 @@