Skip to content

Commit

Permalink
Improved visual for empty, available to connect and connected ports
Browse files Browse the repository at this point in the history
  • Loading branch information
daniilsavchuk committed Apr 18, 2017
1 parent e0c9320 commit 3b68ddd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/pipeline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $light-gray: #ccc;
// Semantic color mapping
$step-color: $sharp-blue;
$port-color: $graphite;
$port-color-empty: $dark-blue;
$port-color-available: $lime-green;

.joint-type-visualstep.selected {
.body {
Expand Down Expand Up @@ -54,6 +56,16 @@ $port-color: $graphite;
fill: $port-color;
}

.port-body-empty {
stroke: $port-color-empty;
stroke-width: 1.5px;
fill: $white;
}

.available-magnet {
fill: $port-color-available;
}

.port-body:hover {
opacity: 1;
fill: $step-color;
Expand Down
9 changes: 7 additions & 2 deletions src/visual/Paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ export default class Paper extends joint.dia.Paper {
return false;
}
// source
if (!magnetS || magnetS.getAttribute('class') !== 'port-body' ||
if (!magnetS || (magnetS.getAttribute('class') !== 'port-body' &&
magnetS.getAttribute('class') !== 'port-body-empty' &&
magnetS.getAttribute('class') !== 'port-body-empty available-magnet') ||
magnetS.getAttribute('port-group') !== 'out') {
return false;
}
// target
if (!magnetT || magnetT.getAttribute('class') !== 'port-body' ||
if (!magnetT || (magnetT.getAttribute('class') !== 'port-body' &&
magnetT.getAttribute('class') !== 'port-body-empty' &&
magnetT.getAttribute('class') !== 'port-body-empty available-magnet') ||
magnetT.getAttribute('port-group') !== 'in') {
return false;
}
Expand All @@ -61,6 +65,7 @@ export default class Paper extends joint.dia.Paper {

return !portUsed;
},
markAvailable: true,
}));
}

Expand Down
19 changes: 19 additions & 0 deletions src/visual/VisualStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ export default class VisualStep extends joint.shapes.devs.Model {
this.attr('.label', {
text: step.name,
});

const ports = this.getPorts();

_.forEach(ports, (port) => {
let isEmpty = true;
if (port.group === 'in') {
isEmpty = isEmpty && (_.size(step.i[port.id].inputs) === 0 && _.size(step.i[port.id].outputs) === 0);
}

if (port.group === 'out') {
isEmpty = isEmpty && (_.size(step.o[port.id].inputs) === 0 && _.size(step.o[port.id].outputs) === 0);
}

const propVal = this.portProp(port.id, 'attrs/circle/class');
const newVal = isEmpty ? 'port-body-empty' : 'port-body';
if (!propVal || newVal !== propVal) {
this.portProp(port.id, 'attrs/circle/class', newVal);
}
});
}

/**
Expand Down

0 comments on commit 3b68ddd

Please sign in to comment.