Commit 25a6927b6e0987838c98a62acda967d671a1affc
Committed by
Andrew Shvayka
1 parent
6f2c1dec
Fix disable on condition and errors displaying
Showing
3 changed files
with
26 additions
and
24 deletions
@@ -198,7 +198,7 @@ function MultipleInputWidgetController($q, $scope, $translate, attributeService, | @@ -198,7 +198,7 @@ function MultipleInputWidgetController($q, $scope, $translate, attributeService, | ||
198 | var datasource = vm.datasources[0]; | 198 | var datasource = vm.datasources[0]; |
199 | if (datasource.type === types.datasourceType.entity) { | 199 | if (datasource.type === types.datasourceType.entity) { |
200 | for (var i = 0; i < datasource.dataKeys.length; i++) { | 200 | for (var i = 0; i < datasource.dataKeys.length; i++) { |
201 | - if ((datasource.entityType !== types.entityType.device) && (datasource.dataKeys[i].settings.dataKeyType !== 'server')) { | 201 | + if ((datasource.entityType !== types.entityType.device) && (datasource.dataKeys[i].settings.dataKeyType == 'shared')) { |
202 | vm.isAllParametersValid = false; | 202 | vm.isAllParametersValid = false; |
203 | } | 203 | } |
204 | vm.data.push(datasource.dataKeys[i]); | 204 | vm.data.push(datasource.dataKeys[i]); |
@@ -234,18 +234,18 @@ function MultipleInputWidgetController($q, $scope, $translate, attributeService, | @@ -234,18 +234,18 @@ function MultipleInputWidgetController($q, $scope, $translate, attributeService, | ||
234 | currentValue: value, | 234 | currentValue: value, |
235 | originalValue: value | 235 | originalValue: value |
236 | }; | 236 | }; |
237 | + } | ||
237 | 238 | ||
238 | - if (vm.data[i].settings.isEditable === 'editable' && vm.data[i].settings.disabledOnDataKey) { | ||
239 | - var conditions = data.filter((item) => { | ||
240 | - return item.dataKey.name === vm.data[i].settings.disabledOnDataKey; | ||
241 | - }); | ||
242 | - if (conditions && conditions.length) { | ||
243 | - if (conditions[0].data.length) { | ||
244 | - if (conditions[0].data[0][1] === 'false') { | ||
245 | - vm.data[i].settings.disabledOnCondition = true; | ||
246 | - } else { | ||
247 | - vm.data[i].settings.disabledOnCondition = !conditions[0].data[0][1]; | ||
248 | - } | 239 | + if (vm.data[i].settings.isEditable === 'editable' && vm.data[i].settings.disabledOnDataKey) { |
240 | + var conditions = data.filter((item) => { | ||
241 | + return item.dataKey.name === vm.data[i].settings.disabledOnDataKey; | ||
242 | + }); | ||
243 | + if (conditions && conditions.length) { | ||
244 | + if (conditions[0].data.length) { | ||
245 | + if (conditions[0].data[0][1] === 'false') { | ||
246 | + vm.data[i].settings.disabledOnCondition = true; | ||
247 | + } else { | ||
248 | + vm.data[i].settings.disabledOnCondition = !conditions[0].data[0][1]; | ||
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
@@ -16,8 +16,8 @@ | @@ -16,8 +16,8 @@ | ||
16 | 16 | ||
17 | --> | 17 | --> |
18 | <form class="tb-multiple-input" name="multipleInputForm" ng-submit="vm.save()" novalidate autocomplete="off"> | 18 | <form class="tb-multiple-input" name="multipleInputForm" ng-submit="vm.save()" novalidate autocomplete="off"> |
19 | - <div style="padding: 0 8px; margin: auto 0;"> | ||
20 | - <div ng-show="vm.entityDetected" layout="row" layout-wrap ng-class="{'vertical-alignment': vm.isVerticalAlignment || vm.changeAlignment}"> | 19 | + <div style="padding: 0 8px;" ng-if="vm.entityDetected && vm.isAllParametersValid"> |
20 | + <div layout="row" layout-wrap ng-class="{'vertical-alignment': vm.isVerticalAlignment || vm.changeAlignment}"> | ||
21 | <div ng-repeat="key in vm.data" ng-style="{'width': (vm.isVerticalAlignment || vm.changeAlignment) ? '100%' : vm.inputWidthSettings}"> | 21 | <div ng-repeat="key in vm.data" ng-style="{'width': (vm.isVerticalAlignment || vm.changeAlignment) ? '100%' : vm.inputWidthSettings}"> |
22 | <div class="input-field" ng-if="(key.settings.dataKeyValueType === 'string') && !key.settings.dataKeyHidden"> | 22 | <div class="input-field" ng-if="(key.settings.dataKeyValueType === 'string') && !key.settings.dataKeyHidden"> |
23 | <md-input-container class="md-block"> | 23 | <md-input-container class="md-block"> |
@@ -129,7 +129,17 @@ | @@ -129,7 +129,17 @@ | ||
129 | </div> | 129 | </div> |
130 | </div> | 130 | </div> |
131 | </div> | 131 | </div> |
132 | - | 132 | + <div class="md-padding" layout="row" layout-align="end center" ng-if="vm.entityDetected && vm.settings.showActionButtons"> |
133 | + <md-button class="md-primary" ng-click="vm.discardAll()" style="max-height: 50px; margin-right:20px;" ng-disabled="!multipleInputForm.$dirty"> | ||
134 | + {{ 'action.undo' | translate }} | ||
135 | + </md-button> | ||
136 | + <md-button class="md-raised md-primary" type="submit" value="Submit" style="max-height: 50px; margin-right:20px;" | ||
137 | + ng-disabled="!multipleInputForm.$dirty || multipleInputForm.$invalid" ng-click="vm.isFocused = false"> | ||
138 | + {{ 'action.save' | translate }} | ||
139 | + </md-button> | ||
140 | + </div> | ||
141 | + </div> | ||
142 | + <div class="tb-multiple-input__errors" layout="column" layout-align="center center" style="height: 100%;" ng-if="!vm.entityDetected || !vm.isAllParametersValid"> | ||
133 | <div style="text-align: center; font-size: 18px; color: #a0a0a0;" ng-hide="vm.entityDetected"> | 143 | <div style="text-align: center; font-size: 18px; color: #a0a0a0;" ng-hide="vm.entityDetected"> |
134 | {{ 'widgets.input-widgets.no-entity-selected' | translate }} | 144 | {{ 'widgets.input-widgets.no-entity-selected' | translate }} |
135 | </div> | 145 | </div> |
@@ -137,13 +147,4 @@ | @@ -137,13 +147,4 @@ | ||
137 | {{ 'widgets.input-widgets.not-allowed-entity' | translate }} | 147 | {{ 'widgets.input-widgets.not-allowed-entity' | translate }} |
138 | </div> | 148 | </div> |
139 | </div> | 149 | </div> |
140 | - <div class="md-padding" layout="row" layout-align="end center" ng-if="vm.entityDetected && vm.settings.showActionButtons"> | ||
141 | - <md-button class="md-primary" ng-click="vm.discardAll()" style="max-height: 50px; margin-right:20px;" ng-disabled="!multipleInputForm.$dirty"> | ||
142 | - {{ 'action.undo' | translate }} | ||
143 | - </md-button> | ||
144 | - <md-button class="md-raised md-primary" type="submit" value="Submit" style="max-height: 50px; margin-right:20px;" | ||
145 | - ng-disabled="!multipleInputForm.$dirty || multipleInputForm.$invalid" ng-click="vm.isFocused = false"> | ||
146 | - {{ 'action.save' | translate }} | ||
147 | - </md-button> | ||
148 | - </div> | ||
149 | </form> | 150 | </form> |