Commit a93c8e25bac71379dd345547a48daf8ec99a4dee
Committed by
Igor Kulikov
1 parent
6ba0b943
Hide timewindow when all options are hidden (#2287)
* Hide timewindow when all options are hidden * Disable timewindow button when all options hidden
Showing
3 changed files
with
9 additions
and
4 deletions
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | limitations under the License. |
16 | 16 | |
17 | 17 | --> |
18 | -<md-button ng-disabled="disabled" class="md-raised md-primary" ng-click="openEditMode($event)"> | |
18 | +<md-button ng-disabled="timewindowDisabled" class="md-raised md-primary" ng-click="openEditMode($event)"> | |
19 | 19 | <ng-md-icon icon="query_builder"></ng-md-icon> |
20 | 20 | <span>{{model.displayValue}}</span> |
21 | 21 | </md-button> |
\ No newline at end of file | ... | ... |
... | ... | @@ -97,7 +97,7 @@ function Timewindow($compile, $templateCache, $filter, $mdPanel, $document, $mdM |
97 | 97 | element.html(template); |
98 | 98 | |
99 | 99 | scope.openEditMode = function (event) { |
100 | - if (scope.disabled) { | |
100 | + if (scope.timewindowDisabled) { | |
101 | 101 | return; |
102 | 102 | } |
103 | 103 | var position; |
... | ... | @@ -212,6 +212,10 @@ function Timewindow($compile, $templateCache, $filter, $mdPanel, $document, $mdM |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | + scope.isTimewindowDisabled = function () { | |
216 | + return scope.disabled || (!scope.isEdit && scope.model.hideInterval && scope.model.hideAggregation && scope.model.hideAggInterval); | |
217 | + } | |
218 | + | |
215 | 219 | ngModelCtrl.$render = function () { |
216 | 220 | scope.model = timeService.defaultTimewindow(); |
217 | 221 | if (ngModelCtrl.$viewValue) { |
... | ... | @@ -243,6 +247,7 @@ function Timewindow($compile, $templateCache, $filter, $mdPanel, $document, $mdM |
243 | 247 | model.hideAggregation = value.hideAggregation; |
244 | 248 | model.hideAggInterval = value.hideAggInterval; |
245 | 249 | } |
250 | + scope.timewindowDisabled = scope.isTimewindowDisabled(); | |
246 | 251 | scope.updateDisplayValue(); |
247 | 252 | }; |
248 | 253 | ... | ... |
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | |
17 | 17 | --> |
18 | 18 | <section class="tb-timewindow" layout='row' layout-align="start center"> |
19 | - <md-button ng-if="direction === 'left'" ng-disabled="disabled" class="md-icon-button tb-md-32" aria-label="{{ 'timewindow.edit' | translate }}" ng-click="openEditMode($event)"> | |
19 | + <md-button ng-if="direction === 'left'" ng-disabled="timewindowDisabled" class="md-icon-button tb-md-32" aria-label="{{ 'timewindow.edit' | translate }}" ng-click="openEditMode($event)"> | |
20 | 20 | <md-tooltip md-direction="{{tooltipDirection}}"> |
21 | 21 | {{ 'timewindow.edit' | translate }} |
22 | 22 | </md-tooltip> |
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | </md-tooltip> |
29 | 29 | {{model.displayValue}} |
30 | 30 | </span> |
31 | - <md-button ng-if="direction === 'right'" ng-disabled="disabled" class="md-icon-button tb-md-32" aria-label="{{ 'timewindow.edit' | translate }}" ng-click="openEditMode($event)"> | |
31 | + <md-button ng-if="direction === 'right'" ng-disabled="timewindowDisabled" class="md-icon-button tb-md-32" aria-label="{{ 'timewindow.edit' | translate }}" ng-click="openEditMode($event)"> | |
32 | 32 | <md-tooltip md-direction="{{tooltipDirection}}"> |
33 | 33 | {{ 'timewindow.edit' | translate }} |
34 | 34 | </md-tooltip> | ... | ... |