UI improvements.

This commit is contained in:
Igor Kulikov 2018-07-04 19:38:57 +03:00
parent f41fabf443
commit 4616823c3b
4 changed files with 38 additions and 14 deletions

View File

@ -41,7 +41,7 @@ import static org.thingsboard.rule.engine.api.TbRelationTypes.SUCCESS;
configClazz = TbMsgDelayNodeConfiguration.class,
nodeDescription = "Delays incoming message",
nodeDetails = "Delays messages for configurable period.",
icon = "repeat",
icon = "pause",
uiResources = {"static/rulenode/rulenode-core-config.js"},
configDirective = "tbActionNodeMsgDelayConfig"
)

View File

@ -62,28 +62,43 @@ export default function EntityTypeListDirective($compile, $templateCache, $q, $m
}
ngModelCtrl.$render = function () {
scope.entityTypeList = [];
if (scope.entityTypeListWatch) {
scope.entityTypeListWatch();
scope.entityTypeListWatch = null;
}
var entityTypeList = [];
var value = ngModelCtrl.$viewValue;
if (value && value.length) {
value.forEach(function(type) {
var entityTypeInfo = {};
entityTypeInfo.value = type;
entityTypeInfo.name = $translate.instant(types.entityTypeTranslations[entityTypeInfo.value].type) + '';
scope.entityTypeList.push(entityTypeInfo);
entityTypeList.push(entityTypeInfo);
});
}
scope.entityTypeList = entityTypeList;
scope.entityTypeListWatch = scope.$watch('entityTypeList', function (newVal, prevVal) {
if (!angular.equals(newVal, prevVal)) {
updateEntityTypeList();
}
}, true);
}
scope.$watch('entityTypeList', function () {
var values = [];
function updateEntityTypeList() {
var values = ngModelCtrl.$viewValue;
if (!values) {
values = [];
ngModelCtrl.$setViewValue(values);
} else {
values.length = 0;
}
if (scope.entityTypeList && scope.entityTypeList.length) {
scope.entityTypeList.forEach(function (entityType) {
values.push(entityType.value);
});
}
ngModelCtrl.$setViewValue(values);
scope.updateValidity();
}, true);
}
$compile(element.contents())(scope);

View File

@ -44,6 +44,10 @@ export default function RelationFilters($compile, $templateCache) {
scope.removeFilter = removeFilter;
ngModelCtrl.$render = function () {
if (scope.relationFiltersWatch) {
scope.relationFiltersWatch();
scope.relationFiltersWatch = null;
}
if (ngModelCtrl.$viewValue) {
var value = ngModelCtrl.$viewValue;
scope.relationFilters.length = 0;
@ -51,7 +55,7 @@ export default function RelationFilters($compile, $templateCache) {
scope.relationFilters.push(filter);
});
}
scope.$watch('relationFilters', function (newVal, prevVal) {
scope.relationFiltersWatch = scope.$watch('relationFilters', function (newVal, prevVal) {
if (!angular.equals(newVal, prevVal)) {
updateValue();
}
@ -74,11 +78,16 @@ export default function RelationFilters($compile, $templateCache) {
}
function updateValue() {
var value = [];
var value = ngModelCtrl.$viewValue;
if (!value) {
value = [];
ngModelCtrl.$setViewValue(value);
} else {
value.length = 0;
}
scope.relationFilters.forEach(function (filter) {
value.push(filter);
});
ngModelCtrl.$setViewValue(value);
}
$compile(element.contents())(scope);
}