Fix disable on condition and errors displaying
This commit is contained in:
		
							parent
							
								
									6f2c1deca8
								
							
						
					
					
						commit
						25a6927b6e
					
				@ -198,7 +198,7 @@ function MultipleInputWidgetController($q, $scope, $translate, attributeService,
 | 
			
		||||
            var datasource = vm.datasources[0];
 | 
			
		||||
            if (datasource.type === types.datasourceType.entity) {
 | 
			
		||||
                for (var i = 0; i < datasource.dataKeys.length; i++) {
 | 
			
		||||
                    if ((datasource.entityType !== types.entityType.device) && (datasource.dataKeys[i].settings.dataKeyType !== 'server')) {
 | 
			
		||||
                    if ((datasource.entityType !== types.entityType.device) && (datasource.dataKeys[i].settings.dataKeyType == 'shared')) {
 | 
			
		||||
                        vm.isAllParametersValid = false;
 | 
			
		||||
                    }
 | 
			
		||||
                    vm.data.push(datasource.dataKeys[i]);
 | 
			
		||||
@ -234,18 +234,18 @@ function MultipleInputWidgetController($q, $scope, $translate, attributeService,
 | 
			
		||||
                    currentValue: value,
 | 
			
		||||
                    originalValue: value
 | 
			
		||||
                };
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
                if (vm.data[i].settings.isEditable === 'editable' && vm.data[i].settings.disabledOnDataKey) {
 | 
			
		||||
                    var conditions = data.filter((item) => {
 | 
			
		||||
                        return item.dataKey.name === vm.data[i].settings.disabledOnDataKey;
 | 
			
		||||
                    });
 | 
			
		||||
                    if (conditions && conditions.length) {
 | 
			
		||||
                        if (conditions[0].data.length) {
 | 
			
		||||
                            if (conditions[0].data[0][1] === 'false') {
 | 
			
		||||
                                vm.data[i].settings.disabledOnCondition = true;
 | 
			
		||||
                            } else {
 | 
			
		||||
                                vm.data[i].settings.disabledOnCondition = !conditions[0].data[0][1];
 | 
			
		||||
                            }
 | 
			
		||||
            if (vm.data[i].settings.isEditable === 'editable' && vm.data[i].settings.disabledOnDataKey) {
 | 
			
		||||
                var conditions = data.filter((item) => {
 | 
			
		||||
                    return item.dataKey.name === vm.data[i].settings.disabledOnDataKey;
 | 
			
		||||
                });
 | 
			
		||||
                if (conditions && conditions.length) {
 | 
			
		||||
                    if (conditions[0].data.length) {
 | 
			
		||||
                        if (conditions[0].data[0][1] === 'false') {
 | 
			
		||||
                            vm.data[i].settings.disabledOnCondition = true;
 | 
			
		||||
                        } else {
 | 
			
		||||
                            vm.data[i].settings.disabledOnCondition = !conditions[0].data[0][1];
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@
 | 
			
		||||
 | 
			
		||||
  md-switch {
 | 
			
		||||
    margin-top: 20px;
 | 
			
		||||
    white-space: normal;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  .md-icon-button md-icon {
 | 
			
		||||
 | 
			
		||||
@ -16,8 +16,8 @@
 | 
			
		||||
 | 
			
		||||
-->
 | 
			
		||||
<form class="tb-multiple-input" name="multipleInputForm" ng-submit="vm.save()" novalidate autocomplete="off">
 | 
			
		||||
    <div style="padding: 0 8px; margin: auto 0;">
 | 
			
		||||
        <div ng-show="vm.entityDetected" layout="row" layout-wrap ng-class="{'vertical-alignment': vm.isVerticalAlignment || vm.changeAlignment}">
 | 
			
		||||
    <div style="padding: 0 8px;" ng-if="vm.entityDetected && vm.isAllParametersValid">
 | 
			
		||||
        <div layout="row" layout-wrap ng-class="{'vertical-alignment': vm.isVerticalAlignment || vm.changeAlignment}">
 | 
			
		||||
            <div ng-repeat="key in vm.data" ng-style="{'width': (vm.isVerticalAlignment || vm.changeAlignment) ? '100%' : vm.inputWidthSettings}">
 | 
			
		||||
                <div class="input-field" ng-if="(key.settings.dataKeyValueType === 'string') && !key.settings.dataKeyHidden">
 | 
			
		||||
                    <md-input-container class="md-block">
 | 
			
		||||
@ -129,7 +129,17 @@
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <div class="md-padding" layout="row" layout-align="end center" ng-if="vm.entityDetected && vm.settings.showActionButtons">
 | 
			
		||||
            <md-button class="md-primary" ng-click="vm.discardAll()" style="max-height: 50px; margin-right:20px;" ng-disabled="!multipleInputForm.$dirty">
 | 
			
		||||
                {{ 'action.undo' | translate }}
 | 
			
		||||
            </md-button>
 | 
			
		||||
            <md-button class="md-raised md-primary" type="submit" value="Submit" style="max-height: 50px; margin-right:20px;"
 | 
			
		||||
                       ng-disabled="!multipleInputForm.$dirty || multipleInputForm.$invalid" ng-click="vm.isFocused = false">
 | 
			
		||||
                {{ 'action.save' | translate }}
 | 
			
		||||
            </md-button>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="tb-multiple-input__errors" layout="column" layout-align="center center" style="height: 100%;" ng-if="!vm.entityDetected || !vm.isAllParametersValid">
 | 
			
		||||
        <div style="text-align: center; font-size: 18px; color: #a0a0a0;" ng-hide="vm.entityDetected">
 | 
			
		||||
            {{ 'widgets.input-widgets.no-entity-selected' | translate }}
 | 
			
		||||
        </div>
 | 
			
		||||
@ -137,13 +147,4 @@
 | 
			
		||||
            {{ 'widgets.input-widgets.not-allowed-entity' | translate }}
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="md-padding" layout="row" layout-align="end center" ng-if="vm.entityDetected && vm.settings.showActionButtons">
 | 
			
		||||
        <md-button class="md-primary" ng-click="vm.discardAll()" style="max-height: 50px; margin-right:20px;" ng-disabled="!multipleInputForm.$dirty">
 | 
			
		||||
            {{ 'action.undo' | translate }}
 | 
			
		||||
        </md-button>
 | 
			
		||||
        <md-button class="md-raised md-primary" type="submit" value="Submit" style="max-height: 50px; margin-right:20px;"
 | 
			
		||||
                   ng-disabled="!multipleInputForm.$dirty || multipleInputForm.$invalid" ng-click="vm.isFocused = false">
 | 
			
		||||
            {{ 'action.save' | translate }}
 | 
			
		||||
        </md-button>
 | 
			
		||||
    </div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user