From fbc83a726d9d0149815f3a39f6ef7899bec79173 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 4 Dec 2017 16:43:13 +0200 Subject: [PATCH] UI: Fix home page layout. --- ui/src/app/home/home-links.controller.js | 39 ++++++++++++++++++++++-- ui/src/app/home/home-links.tpl.html | 16 +++++----- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/ui/src/app/home/home-links.controller.js b/ui/src/app/home/home-links.controller.js index 799a0bc0b2..32ae0919a3 100644 --- a/ui/src/app/home/home-links.controller.js +++ b/ui/src/app/home/home-links.controller.js @@ -17,7 +17,42 @@ import './home-links.scss'; /*@ngInject*/ -export default function HomeLinksController($scope, menu) { +export default function HomeLinksController($scope, $mdMedia, menu) { + var vm = this; - vm.model = menu.getHomeSections(); + + vm.sectionColspan = sectionColspan; + + $scope.$watch(function() { return $mdMedia('lg'); }, function() { + updateColumnCount(); + }); + + $scope.$watch(function() { return $mdMedia('gt-lg'); }, function() { + updateColumnCount(); + }); + + updateColumnCount(); + + menu.getHomeSections().then((homeSections) => { + vm.model = homeSections; + }); + + function updateColumnCount() { + vm.cols = 2; + if ($mdMedia('lg')) { + vm.cols = 3; + } + if ($mdMedia('gt-lg')) { + vm.cols = 4; + } + } + + function sectionColspan(section) { + var colspan = vm.cols; + if (section && section.places && section.places.length <= colspan) { + colspan = section.places.length; + } + return colspan; + } + } diff --git a/ui/src/app/home/home-links.tpl.html b/ui/src/app/home/home-links.tpl.html index e27f20a820..f0e558257f 100644 --- a/ui/src/app/home/home-links.tpl.html +++ b/ui/src/app/home/home-links.tpl.html @@ -15,8 +15,8 @@ limitations under the License. --> - - + + @@ -25,12 +25,12 @@ - - - {{place.icon}} - {{place.name}} - - + + + {{place.icon}} + {{place.name}} + +