Commit 1534549d859591d70b73c5b2b8e03028b89e6b3b

Authored by oleg
1 parent c5b03cb5

UI:Improvement. "Widget auto focus on search input"

... ... @@ -111,8 +111,15 @@ function ManageWidgetActionsController($rootScope, $scope, $document, $mdDialog,
111 111 }
112 112 });
113 113
114   - function enterFilterMode () {
  114 + function enterFilterMode (event) {
  115 + let $button = angular.element(event.currentTarget);
  116 + let $toolbarsContainer = $button.closest('.toolbarsContainer');
  117 +
115 118 vm.query.search = '';
  119 +
  120 + $timeout(()=>{
  121 + $toolbarsContainer.find('.searchInput').focus();
  122 + })
116 123 }
117 124
118 125 function exitFilterMode () {
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<div ng-form="manageWidgetActionsForm" class="tb-manage-widget-actions md-whiteframe-z1" layout="column">
  18 +<div ng-form="manageWidgetActionsForm" class="tb-manage-widget-actions md-whiteframe-z1 toolbarsContainer" layout="column">
19 19 <md-toolbar class="md-table-toolbar md-default" ng-show="vm.query.search === null">
20 20 <div class="md-toolbar-tools">
21 21 <span translate>widget-config.actions</span>
... ... @@ -26,7 +26,7 @@
26 26 {{ 'widget-config.add-action' | translate }}
27 27 </md-tooltip>
28 28 </md-button>
29   - <md-button class="md-icon-button" ng-click="vm.enterFilterMode()">
  29 + <md-button class="md-icon-button" ng-click="vm.enterFilterMode($event)">
30 30 <md-icon>search</md-icon>
31 31 <md-tooltip md-direction="top">
32 32 {{ 'action.search' | translate }}
... ... @@ -44,7 +44,7 @@
44 44 </md-button>
45 45 <md-input-container flex>
46 46 <label>&nbsp;</label>
47   - <input ng-model="vm.query.search" name="querySearchInput" placeholder="{{ 'widget-config.search-actions' | translate }}"/>
  47 + <input ng-model="vm.query.search" class="searchInput" name="querySearchInput" placeholder="{{ 'widget-config.search-actions' | translate }}"/>
48 48 </md-input-container>
49 49 <md-button class="md-icon-button" aria-label="Close" ng-click="vm.exitFilterMode()">
50 50 <md-icon aria-label="Close" class="material-icons">close</md-icon>
... ...
... ... @@ -30,7 +30,7 @@ import AliasController from '../../api/alias-controller';
30 30
31 31 /*@ngInject*/
32 32 export default function AttributeTableDirective($compile, $templateCache, $rootScope, $q, $mdEditDialog, $mdDialog,
33   - $mdUtil, $document, $translate, $filter, utils, types, dashboardUtils,
  33 + $mdUtil, $document, $translate, $filter, $timeout, utils, types, dashboardUtils,
34 34 entityService, attributeService, widgetService) {
35 35
36 36 var linker = function (scope, element, attrs) {
... ... @@ -110,8 +110,15 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS
110 110 scope.attributeScope = getAttributeScopeByValue(attrs.defaultAttributeScope);
111 111 }
112 112
113   - scope.enterFilterMode = function() {
  113 + scope.enterFilterMode = function(event) {
  114 + let $button = angular.element(event.currentTarget);
  115 + let $toolbarsContainer = $button.closest('.toolbarsContainer');
  116 +
114 117 scope.query.search = '';
  118 +
  119 + $timeout(()=>{
  120 + $toolbarsContainer.find('.searchInput').focus();
  121 + })
115 122 }
116 123
117 124 scope.exitFilterMode = function() {
... ...
... ... @@ -26,7 +26,7 @@
26 26 </md-select>
27 27 </md-input-container>
28 28 </section>
29   - <div class="md-whiteframe-z1" ng-class="{flex: mode==='widget'}">
  29 + <div class="md-whiteframe-z1 toolbarsContainer" ng-class="{flex: mode==='widget'}">
30 30 <md-toolbar class="md-table-toolbar md-default" ng-show="mode==='default'
31 31 && !selectedAttributes.length
32 32 && query.search === null">
... ... @@ -39,7 +39,7 @@
39 39 {{ 'action.add' | translate }}
40 40 </md-tooltip>
41 41 </md-button>
42   - <md-button class="md-icon-button" ng-click="enterFilterMode()">
  42 + <md-button class="md-icon-button" ng-click="enterFilterMode($event)">
43 43 <md-icon>search</md-icon>
44 44 <md-tooltip md-direction="top">
45 45 {{ 'action.search' | translate }}
... ... @@ -65,7 +65,7 @@
65 65 </md-button>
66 66 <md-input-container flex>
67 67 <label>&nbsp;</label>
68   - <input ng-model="query.search" placeholder="{{ 'common.enter-search' | translate }}"/>
  68 + <input ng-model="query.search" class="searchInput" placeholder="{{ 'common.enter-search' | translate }}"/>
69 69 </md-input-container>
70 70 <md-button class="md-icon-button" aria-label="{{ 'action.back' | translate }}" ng-click="exitFilterMode()">
71 71 <md-icon aria-label="{{ 'action.close' | translate }}" class="material-icons">close</md-icon>
... ...
... ... @@ -41,7 +41,7 @@ export default function RelationTable() {
41 41 }
42 42
43 43 /*@ngInject*/
44   -function RelationTableController($scope, $q, $mdDialog, $document, $translate, $filter, utils, types, entityRelationService) {
  44 +function RelationTableController($scope, $q, $mdDialog, $document, $translate, $filter, $timeout, utils, types, entityRelationService) {
45 45
46 46 let vm = this;
47 47
... ... @@ -90,8 +90,15 @@ function RelationTableController($scope, $q, $mdDialog, $document, $translate, $
90 90 }
91 91 });
92 92
93   - function enterFilterMode () {
  93 + function enterFilterMode (event) {
  94 + let $button = angular.element(event.currentTarget);
  95 + let $toolbarsContainer = $button.closest('.toolbarsContainer');
  96 +
94 97 vm.query.search = '';
  98 +
  99 + $timeout(()=>{
  100 + $toolbarsContainer.find('.searchInput').focus();
  101 + })
95 102 }
96 103
97 104 function exitFilterMode () {
... ...
... ... @@ -26,7 +26,7 @@
26 26 </md-select>
27 27 </md-input-container>
28 28 </section>
29   - <div layout="column" class="md-whiteframe-z1">
  29 + <div layout="column" class="md-whiteframe-z1 toolbarsContainer">
30 30 <md-toolbar class="md-table-toolbar md-default" ng-show="!vm.selectedRelations.length
31 31 && vm.query.search === null">
32 32 <div class="md-toolbar-tools">
... ... @@ -39,7 +39,7 @@
39 39 {{ 'action.add' | translate }}
40 40 </md-tooltip>
41 41 </md-button>
42   - <md-button class="md-icon-button" ng-click="vm.enterFilterMode()">
  42 + <md-button class="md-icon-button" ng-click="vm.enterFilterMode($event)">
43 43 <md-icon>search</md-icon>
44 44 <md-tooltip md-direction="top">
45 45 {{ 'action.search' | translate }}
... ... @@ -64,7 +64,7 @@
64 64 </md-button>
65 65 <md-input-container flex>
66 66 <label>&nbsp;</label>
67   - <input ng-model="vm.query.search" placeholder="{{ 'common.enter-search' | translate }}"/>
  67 + <input ng-model="vm.query.search" class="searchInput" placeholder="{{ 'common.enter-search' | translate }}"/>
68 68 </md-input-container>
69 69 <md-button class="md-icon-button" aria-label="{{ 'action.back' | translate }}" ng-click="vm.exitFilterMode()">
70 70 <md-icon aria-label="{{ 'action.close' | translate }}" class="material-icons">close</md-icon>
... ...
... ... @@ -45,7 +45,7 @@ export default function ExtensionTableDirective() {
45 45 }
46 46
47 47 /*@ngInject*/
48   -function ExtensionTableController($scope, $filter, $document, $translate, types, $mdDialog, attributeService, telemetryWebsocketService, importExport) {
  48 +function ExtensionTableController($scope, $filter, $document, $translate, $timeout, $mdDialog, types, attributeService, telemetryWebsocketService, importExport) {
49 49
50 50 let vm = this;
51 51
... ... @@ -141,11 +141,17 @@ function ExtensionTableController($scope, $filter, $document, $translate, types,
141 141 }
142 142 });
143 143
144   - function enterFilterMode() {
  144 + function enterFilterMode(event) {
  145 + let $button = angular.element(event.currentTarget);
  146 + let $toolbarsContainer = $button.closest('.toolbarsContainer');
  147 +
145 148 vm.query.search = '';
146 149 if(vm.inWidget) {
147 150 vm.ctx.hideTitlePanel = true;
148 151 }
  152 + $timeout(()=>{
  153 + $toolbarsContainer.find('.searchInput').focus();
  154 + })
149 155 }
150 156
151 157 function exitFilterMode() {
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <md-content flex class="md-padding tb-absolute-fill tb-data-table extension-table" layout="column">
19   - <div layout="column" class="md-whiteframe-z1" ng-class="{'tb-absolute-fill' : vm.inWidget}">
  19 + <div layout="column" class="md-whiteframe-z1 toolbarsContainer" ng-class="{'tb-absolute-fill' : vm.inWidget}">
20 20 <md-toolbar ng-if="!vm.inWidget" class="md-table-toolbar md-default" ng-show="!vm.selectedExtensions.length
21 21 && vm.query.search === null">
22 22 <div class="md-toolbar-tools">
... ... @@ -41,7 +41,7 @@
41 41 {{ 'action.add' | translate }}
42 42 </md-tooltip>
43 43 </md-button>
44   - <md-button class="md-icon-button" ng-click="vm.enterFilterMode()">
  44 + <md-button class="md-icon-button" ng-click="vm.enterFilterMode($event)">
45 45 <md-icon>search</md-icon>
46 46 <md-tooltip md-direction="top">
47 47 {{ 'action.search' | translate }}
... ... @@ -66,7 +66,7 @@
66 66 </md-button>
67 67 <md-input-container flex>
68 68 <label>&nbsp;</label>
69   - <input ng-model="vm.query.search" placeholder="{{ 'common.enter-search' | translate }}"/>
  69 + <input ng-model="vm.query.search" class="searchInput" placeholder="{{ 'common.enter-search' | translate }}"/>
70 70 </md-input-container>
71 71 <md-button class="md-icon-button" aria-label="{{ 'action.back' | translate }}" ng-click="vm.exitFilterMode()">
72 72 <md-icon aria-label="{{ 'action.close' | translate }}" class="material-icons">close</md-icon>
... ...
... ... @@ -45,7 +45,7 @@ function AlarmsTableWidget() {
45 45 }
46 46
47 47 /*@ngInject*/
48   -function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDialog, $document, $translate, $q, alarmService, utils, types) {
  48 +function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDialog, $document, $translate, $q, $timeout, alarmService, utils, types) {
49 49 var vm = this;
50 50
51 51 vm.stylesInfo = {};
... ... @@ -266,6 +266,9 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia
266 266 function enterFilterMode () {
267 267 vm.query.search = '';
268 268 vm.ctx.hideTitlePanel = true;
  269 + $timeout(()=>{
  270 + angular.element(vm.ctx.$container).find('.searchInput').focus();
  271 + })
269 272 }
270 273
271 274 function exitFilterMode () {
... ...
... ... @@ -28,7 +28,7 @@
28 28 </md-button>
29 29 <md-input-container flex>
30 30 <label>&nbsp;</label>
31   - <input ng-model="vm.query.search" placeholder="{{'alarm.search' | translate}}"/>
  31 + <input ng-model="vm.query.search" class="searchInput" placeholder="{{'alarm.search' | translate}}"/>
32 32 </md-input-container>
33 33 <md-button class="md-icon-button" aria-label="Close" ng-click="vm.exitFilterMode()">
34 34 <md-icon aria-label="Close" class="material-icons">close</md-icon>
... ...
... ... @@ -45,7 +45,7 @@ function EntitiesTableWidget() {
45 45 }
46 46
47 47 /*@ngInject*/
48   -function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $translate, utils, types) {
  48 +function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $translate, $timeout, utils, types) {
49 49 var vm = this;
50 50
51 51 vm.stylesInfo = {};
... ... @@ -254,6 +254,9 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $tra
254 254 function enterFilterMode () {
255 255 vm.query.search = '';
256 256 vm.ctx.hideTitlePanel = true;
  257 + $timeout(()=>{
  258 + angular.element(vm.ctx.$container).find('.searchInput').focus();
  259 + })
257 260 }
258 261
259 262 function exitFilterMode () {
... ...
... ... @@ -27,7 +27,7 @@
27 27 </md-button>
28 28 <md-input-container flex>
29 29 <label>&nbsp;</label>
30   - <input ng-model="vm.query.search" placeholder="{{'entity.search' | translate}}"/>
  30 + <input ng-model="vm.query.search" class="searchInput" placeholder="{{'entity.search' | translate}}"/>
31 31 </md-input-container>
32 32 <md-button class="md-icon-button" aria-label="Close" ng-click="vm.exitFilterMode()">
33 33 <md-icon aria-label="Close" class="material-icons">close</md-icon>
... ...
... ... @@ -44,7 +44,7 @@ function TimeseriesTableWidget() {
44 44 }
45 45
46 46 /*@ngInject*/
47   -function TimeseriesTableWidgetController($element, $scope, $filter) {
  47 +function TimeseriesTableWidgetController($element, $scope, $filter, $timeout) {
48 48 var vm = this;
49 49 let dateFormatFilter = 'yyyy-MM-dd HH:mm:ss';
50 50
... ... @@ -62,6 +62,9 @@ function TimeseriesTableWidgetController($element, $scope, $filter) {
62 62 function enterFilterMode () {
63 63 vm.query.search = '';
64 64 vm.ctx.hideTitlePanel = true;
  65 + $timeout(()=>{
  66 + angular.element(vm.ctx.$container).find('.searchInput').focus();
  67 + })
65 68 }
66 69
67 70 function exitFilterMode () {
... ...
... ... @@ -27,7 +27,7 @@
27 27 </md-button>
28 28 <md-input-container flex>
29 29 <label>&nbsp;</label>
30   - <input ng-model="vm.query.search" placeholder="{{'widget.search-data' | translate}}" md-autofocus/>
  30 + <input ng-model="vm.query.search" class="searchInput" placeholder="{{'widget.search-data' | translate}}" md-autofocus/>
31 31 </md-input-container>
32 32 <md-button class="md-icon-button" aria-label="Close" ng-click="vm.exitFilterMode()">
33 33 <md-icon aria-label="Close" class="material-icons">close</md-icon>
... ...