From 2f82bb7e65e006a6f1c7e44a7637086d92cb3b44 Mon Sep 17 00:00:00 2001 From: Leo Depriester Date: Tue, 1 Aug 2017 19:20:40 +0200 Subject: [PATCH 1/4] Fix design search form --- static/search.html | 114 +++++++++++++++++++++++------------------- static/terraboard.css | 4 ++ 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/static/search.html b/static/search.html index 79e240ba..c6870841 100644 --- a/static/search.html +++ b/static/search.html @@ -1,63 +1,73 @@ -
-
+
+
- - {{$parent.resType}} - - {{k}} - -
-
+
- - {{$parent.resID}} - - {{k}} - -
-
+
- - {{$parent.attrKey}} - - {{k}} - -
-
-
- +
+
-
- +
+
+
+
+ + {{$parent.resType}} + + {{k}} + + +
+
+ + {{$parent.resID}} + + {{k}} + + +
+
+ + {{$parent.attrKey}} + + {{k}} + + +
+
+ +
+
- +

-
+
- -
+ + +

diff --git a/static/terraboard.css b/static/terraboard.css index c08b7527..44b256e1 100644 --- a/static/terraboard.css +++ b/static/terraboard.css @@ -197,3 +197,15 @@ pre.sh_sourceCode .sh_oldfile { .form-inline .ui-select-container .ui-select-search { width: 100%; } +.ui-select-match-text{ + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + padding-right: 40px; +} +.ui-select-toggle > .btn.btn-link { + margin-right: 10px; + top: 6px; + position: absolute; + right: 10px; +} diff --git a/static/terraboard.js b/static/terraboard.js index 35644657..50576eaf 100644 --- a/static/terraboard.js +++ b/static/terraboard.js @@ -255,7 +255,7 @@ app.controller("tbStateCtrl", ['$scope', '$http', '$location', function($scope, }); }]); -app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', function($scope, $http) { +app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', function($scope, $http, $location) { $http.get('api/resource/types').then(function(response){ $scope.resource_keys = response.data; }); @@ -304,6 +304,18 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', } // On page load + if ($location.search().type != "") { + $scope.resType = $location.search().type; + } + if ($location.search().name != "") { + $scope.resID = $location.search().name; + } + if ($location.search().key != "") { + $scope.attrKey = $location.search().key; + } + if ($location.search().val != "") { + $scope.attrVal = $location.search().value; + } $scope.doSearch(1); $scope.clearForm = function() { @@ -312,6 +324,27 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', $scope.attrKey = undefined; $scope.attrVal = undefined; $scope.results = undefined; - $scope.doSearch(1); + $location.url('/search'); + } + + $scope.createPermalink = function(page) { + var params = {}; + if ($scope.resType != "") { + params.type = $scope.resType; + } + if ($scope.resID != "") { + params.name = $scope.resID; + } + if ($scope.attrKey != "") { + params.key = $scope.attrKey; + } + if ($scope.attrVal != "") { + params.value = $scope.attrVal; + } + if (page != undefined) { + params.page = page; + } + var query = $.param(params); + $location.url('/search?'+query); } }]); From 190045182ecd5ae0453f99e97250f592f90e4053 Mon Sep 17 00:00:00 2001 From: Leo Depriester Date: Tue, 1 Aug 2017 21:22:43 +0200 Subject: [PATCH 3/4] Remove absolute urls, fix attrVal bug --- static/search.html | 21 ++++++++++----------- static/terraboard.js | 44 +++++++++++++------------------------------- 2 files changed, 23 insertions(+), 42 deletions(-) diff --git a/static/search.html b/static/search.html index 480f6822..7789d6d1 100644 --- a/static/search.html +++ b/static/search.html @@ -1,20 +1,20 @@
-
+
-
+
-
+
-
+
-
-
+ +
-
+
-
+
-
- +
+
-
diff --git a/static/terraboard.js b/static/terraboard.js index 50576eaf..d2048fdf 100644 --- a/static/terraboard.js +++ b/static/terraboard.js @@ -9,7 +9,8 @@ var app = angular.module("terraboard", ['ngRoute', 'ngSanitize', 'ui.select', 'c controller: "tbStateCtrl" }).when("/search", { templateUrl: "static/search.html", - controller: "tbSearchCtrl" + controller: "tbSearchCtrl", + reloadOnSearch: false }).otherwise({ redirectTo: "/" }); @@ -276,22 +277,24 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', $scope.doSearch = function(page) { var params = {}; - if ($scope.resType != "") { + if ($scope.resType != undefined) { params.type = $scope.resType; } - if ($scope.resID != "") { + if ($scope.resID != undefined) { params.name = $scope.resID; } - if ($scope.attrKey != "") { + if ($scope.attrKey != undefined) { params.key = $scope.attrKey; } - if ($scope.attrVal != "") { + if ($scope.attrVal != undefined) { params.value = $scope.attrVal; } if (page != undefined) { params.page = page; } var query = $.param(params); + console.log(params); + $location.path($location.path()).search(params); $http.get('api/search/attribute?'+query).then(function(response){ $scope.results = response.data; $scope.pages = Math.ceil($scope.results.total / $scope.itemsPerPage); @@ -304,16 +307,16 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', } // On page load - if ($location.search().type != "") { + if ($location.search().type != undefined) { $scope.resType = $location.search().type; } - if ($location.search().name != "") { + if ($location.search().name != undefined) { $scope.resID = $location.search().name; } - if ($location.search().key != "") { + if ($location.search().key != undefined) { $scope.attrKey = $location.search().key; } - if ($location.search().val != "") { + if ($location.search().value != undefined) { $scope.attrVal = $location.search().value; } $scope.doSearch(1); @@ -324,27 +327,6 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', $scope.attrKey = undefined; $scope.attrVal = undefined; $scope.results = undefined; - $location.url('/search'); - } - - $scope.createPermalink = function(page) { - var params = {}; - if ($scope.resType != "") { - params.type = $scope.resType; - } - if ($scope.resID != "") { - params.name = $scope.resID; - } - if ($scope.attrKey != "") { - params.key = $scope.attrKey; - } - if ($scope.attrVal != "") { - params.value = $scope.attrVal; - } - if (page != undefined) { - params.page = page; - } - var query = $.param(params); - $location.url('/search?'+query); + $location.url($location.path()); } }]); From 85f2e57a820aeb0aa0bcb0a9d9eaf2413568f10d Mon Sep 17 00:00:00 2001 From: Leo Depriester Date: Wed, 2 Aug 2017 07:36:14 +0200 Subject: [PATCH 4/4] Fix attrVal bug --- static/search.html | 4 ++-- static/terraboard.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/static/search.html b/static/search.html index 7789d6d1..6b8b8cf1 100644 --- a/static/search.html +++ b/static/search.html @@ -13,7 +13,7 @@
-
+
- +
diff --git a/static/terraboard.js b/static/terraboard.js index d2048fdf..417e5a42 100644 --- a/static/terraboard.js +++ b/static/terraboard.js @@ -293,7 +293,6 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', params.page = page; } var query = $.param(params); - console.log(params); $location.path($location.path()).search(params); $http.get('api/search/attribute?'+query).then(function(response){ $scope.results = response.data; @@ -319,6 +318,7 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams', if ($location.search().value != undefined) { $scope.attrVal = $location.search().value; } + $scope.doSearch(1); $scope.clearForm = function() {