From 7b1a39fb68f153daf2f48c7aa7198d4deaab95d3 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 23 Mar 2018 20:59:26 +0200 Subject: [PATCH 1/2] Rule Chain hover and select improvements. --- ui/src/app/locale/locale.constant.js | 1 + ui/src/app/rulechain/rulechain.controller.js | 11 +++++ ui/src/app/rulechain/rulechain.scss | 51 ++++++++++++++++---- ui/src/app/rulechain/rulechain.tpl.html | 7 +++ ui/src/app/rulechain/rulenode.tpl.html | 1 + 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/ui/src/app/locale/locale.constant.js b/ui/src/app/locale/locale.constant.js index cca2a11648..a7b2b443da 100644 --- a/ui/src/app/locale/locale.constant.js +++ b/ui/src/app/locale/locale.constant.js @@ -1177,6 +1177,7 @@ export default angular.module('thingsboard.locale', []) "type": "Type", "description": "Description", "delete": "Delete rule node", + "delete-selected-objects": "Delete selected nodes and connections", "rulenode-details": "Rule node details", "debug-mode": "Debug mode", "configuration": "Configuration", diff --git a/ui/src/app/rulechain/rulechain.controller.js b/ui/src/app/rulechain/rulechain.controller.js index b792f138f8..565e72b444 100644 --- a/ui/src/app/rulechain/rulechain.controller.js +++ b/ui/src/app/rulechain/rulechain.controller.js @@ -81,6 +81,9 @@ export function RuleChainController($stateParams, $scope, $compile, $q, $mdUtil, vm.saveRuleChain = saveRuleChain; vm.revertRuleChain = revertRuleChain; + vm.objectsSelected = objectsSelected; + vm.deleteSelected = deleteSelected; + vm.keyDown = function (evt) { if (evt.keyCode === ctrlKeyCode) { vm.ctrlDown = true; @@ -632,6 +635,14 @@ export function RuleChainController($stateParams, $scope, $compile, $q, $mdUtil, }); } + function objectsSelected() { + return vm.modelservice.nodes.getSelectedNodes().length > 0 || + vm.modelservice.edges.getSelectedEdges().length > 0 + } + + function deleteSelected() { + vm.modelservice.deleteSelected(); + } } /*@ngInject*/ diff --git a/ui/src/app/rulechain/rulechain.scss b/ui/src/app/rulechain/rulechain.scss index 26a5225a68..c1d1376d50 100644 --- a/ui/src/app/rulechain/rulechain.scss +++ b/ui/src/app/rulechain/rulechain.scss @@ -121,10 +121,6 @@ .fc-node { z-index: 1; outline: none; - &.fc-hover, &.fc-selected { - -webkit-filter: brightness(70%); - filter: brightness(70%); - } &.fc-dragging { z-index: 10; } @@ -132,6 +128,26 @@ padding: 0 15px; text-align: center; } + .fc-node-overlay { + position: absolute; + pointer-events: none; + left: 0; + top: 0; + right: 0; + bottom: 0; + background-color: #000; + opacity: 0; + } + &.fc-hover { + .fc-node-overlay { + opacity: 0.25; + } + } + &.fc-selected { + .fc-node-overlay { + opacity: 0.25; + } + } } .fc-leftConnectors, .fc-rightConnectors { @@ -181,6 +197,7 @@ stroke: gray; stroke-width: 4; fill: transparent; + transition: stroke-width .2s; &.fc-selected { stroke: red; stroke-width: 4; @@ -232,20 +249,29 @@ .fc-edge-label { position: absolute; user-select: none; - pointer-events: none; + transition: transform .2s; opacity: 0.8; + &.fc-hover { + transform: scale(1.25); + } + &.fc-selected { + .fc-edge-label-text { + span { + border: solid red; + color: red; + } + } + } } .fc-edge-label-text { position: absolute; - left: 50%; - -webkit-transform: translateX(-50%); - transform: translateX(-50%); + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); white-space: nowrap; text-align: center; font-size: 14px; font-weight: 600; - top: 5px; span { border: solid 2px #003a79; border-radius: 10px; @@ -255,6 +281,13 @@ } } +.fc-select-rectangle { + border: 2px dashed #5262ff; + position: absolute; + background: rgba(20,125,255,0.1); + z-index: 2; +} + @keyframes dash { from { stroke-dashoffset: 500; diff --git a/ui/src/app/rulechain/rulechain.tpl.html b/ui/src/app/rulechain/rulechain.tpl.html index 9f1141e887..eec376ea42 100644 --- a/ui/src/app/rulechain/rulechain.tpl.html +++ b/ui/src/app/rulechain/rulechain.tpl.html @@ -112,6 +112,13 @@