[Rt-commit] rt branch, 4.6/lifecycle-ui-dev, repushed
Craig Kaiser
craig at bestpractical.com
Mon Dec 9 16:23:18 EST 2019
The branch 4.6/lifecycle-ui-dev was deleted and repushed:
was 47f969304e8f3588cd666dd51e537743f2bc9bbc
now 0d318bb137762e6488b0ac756839508b4ab27d03
1: 47f969304e ! 1: 0d318bb137 Core Lifecycle-UI
@@ -1082,7 +1082,7 @@
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
-+<div class="lifecycle-ui" id="lifecycle-<% $id %>">
++<div class="lifecycle-ui svg-container" id="lifecycle-<% $id %>">
+ <div class="row">
+ <div class="col-md-12">
+ <div id="lifeycycle-ui-edit-node" class="lifeycycle-ui-edit-node collapse card card-body">
@@ -1117,7 +1117,7 @@
+ </div>
+ </div>
+
-+ <svg>
++ <svg class="svg-container">
+ </svg>
+ </div>
+
@@ -1555,6 +1555,25 @@
+.lifeycycle-ui-edit-node {
+ position: absolute;
+}
++
++.svg-container {
++ display: inline-block;
++ position: relative;
++ width: 100%;
++ padding-bottom: 40%; /* aspect ratio */
++ vertical-align: top;
++ overflow: hidden;
++}
++.svg-content-responsive {
++ display: inline-block;
++ position: absolute;
++}
++
++svg .rect {
++ fill: gold;
++ stroke: steelblue;
++ stroke-width: 5px;
++}
diff --git a/share/static/css/elevator-light/main.css b/share/static/css/elevator-light/main.css
--- a/share/static/css/elevator-light/main.css
@@ -1608,9 +1627,11 @@
+ self.svg = d3.select(container).select('svg')
+ .attr("preserveAspectRatio", "xMinYMin meet")
+ .attr("viewBox", "0 0 "+self.width+" "+self.height)
++ .classed("svg-content-responsive", true)
+ .attr("border", 1);
+
+ self.svg.append("rect")
++ .classed("rect", true)
+ .attr("x", 0)
+ .attr("y", 0)
+ .attr("height", self.height)
@@ -1806,7 +1827,8 @@
+ .on('contextmenu', function() { d3.event.preventDefault(); })
+ .on('mousemove', function() { self.Mousemove(this); })
+ .on('mouseup', function() { self.Mouseup(this); })
-+ .on('mousedown', function() { self.Mousedown(this); });
++ .on('mousedown', function() { self.Mousedown(this); })
++ .on('keyup', function() { self.keyup(this) });
+
+ d3.select("body").on("keydown", function (d) {
+ if ( !self.editing_node && self.selected_node && ( d3.event.keyCode == 68 || d3.event.keyCode == 46 ) ) {
@@ -1918,22 +1940,9 @@
+ .attr('d', 'M' + self.mousedown_node.x + ',' + self.mousedown_node.y + 'L' + self.mousedown_node.x + ',' + self.mousedown_node.y);
+
+ self.Refresh();
-+ })
++ })
+ .on('mouseup', function(d) {
-+ self.mouseup_node = d;
-+ // needed by FF
-+ self.drag_line
-+ .classed('hidden', true)
-+ .style('marker-end', '');
-+
-+ self.simulation.stop();
-+ // add link to model
-+ self.AddLink(self.mousedown_node, self.mouseup_node);
-+
-+ self.ExportAsConfiguration();
-+ self.Refresh();
-+
-+ self.ResetMouseVars();
++ self.Mouseup(d);
+ });
+
+ self.node.select("text")
@@ -1958,8 +1967,9 @@
+
+ UpdateNode(element) {
+ var self = this;
-+
+ const nodeInput = jQuery("#lifeycycle-ui-edit-node");
++ nodeInput.css( {position:"absolute", top:event.pageY - 235, left: event.pageX});
++
+ var list = document.getElementById('lifeycycle-ui-edit-node').querySelectorAll('input, select');
+
+ if ( element ) {
@@ -2106,15 +2116,29 @@
+ this.Refresh();
+ }
+
-+ Mouseup() {
++ Mouseup(d) {
+ var self = this;
+
-+ if(self.mousedown_node) {
-+ // hide drag line
-+ self.drag_line
-+ .classed('hidden', true)
-+ .style('marker-end', '');
-+ }
++ if( self.mousedown_node ) {
++ // needed by FF
++ self.drag_line
++ .classed('hidden', true)
++ .style('marker-end', '');
++
++ if ( d.id ) {
++ self.mouseup_node = d;
++ self.simulation.stop();
++ // add link to model
++ self.AddLink(self.mousedown_node, self.mouseup_node);
++
++ self.ExportAsConfiguration();
++ self.Refresh();
++ }
++ self.svg.classed('ctrl', false);
++ }
++ // because :active only works in WebKit?
++ self.svg.classed('active', false);
++ self.ResetMouseVars();
+ }
+
+ Mousedown(d) {
@@ -2236,6 +2260,8 @@
+ // delete link if we have both transitions already
+ if ( link.start && link.end ) {
+ self.links.splice(index, 1);
++
++ self.CheckActions(d);
+ }
+ else if( link.start ) {
+ link.end = true;
@@ -2256,10 +2282,28 @@
+ }
+
+ DeleteNode(d) {
++ var self = this;
++
+ var index = this.nodes.findIndex(x => x.id == d.id);
+ this.DeleteLinksForNode(this.nodes[index]);
+
+ this.nodes.splice(index, 1);
++
++ // defaults
++ jQuery.each(self.config.defaults, function (key, value) {
++ if (value === d.name) {
++ delete self.config.defaults[key];
++ }
++ });
++
++ // rights
++ jQuery.each(self.config.rights, function(key, value) {
++ var pattern = d.name+" ->|-> "+d.name;
++ var re = new RegExp(pattern,"g");
++ if ( re.test(key) ) {
++ delete self.config.rights[key];
++ }
++ });
+ }
+
+ LinksForNode (node) {
@@ -2276,13 +2320,37 @@
+ });
+ }
+
++ CheckActions(d) {
++ var self = this;
++
++ var actions = [];
++ var tempArr = self.config.actions;
++
++ var i = tempArr.length/2;
++ while (i--) {
++ var action, info;
++ [action, info] = tempArr.splice(0, 2);
++
++ var pattern = d.name+" ->|-> "+d.name;
++ var re = new RegExp(pattern,"g");
++ if ( ! re.test(action) ) {
++ actions.push(action);
++ actions.push(info);
++ }
++ }
++ self.config.actions = actions;
++ }
++
+ DeleteLinksForNode(node) {
++ var self = this;
++
+ this.links = jQuery.grep(this.links, function (transition) {
+ if (transition.source.id == node.id || transition.target.id == node.id) {
+ return false;
+ }
+ return true;
+ });
++ self.CheckActions(node);
+ }
+
+ UpdateNodeModel(node, args) {
@@ -2348,7 +2416,7 @@
+ delete config.transitions[transition];
+ }
+ }
-+ self.config = config;
++ self.config = {...self.config, ...config};
+
+ var field = jQuery('input[name="Config"]');
+ field.val(JSON.stringify(self.config));
More information about the rt-commit
mailing list