Merge lp:~makyo/juju-gui/add-rel-improvements into lp:juju-gui/experimental

Proposed by Madison Scott-Clary
Status: Merged
Merged at revision: 233
Proposed branch: lp:~makyo/juju-gui/add-rel-improvements
Merge into: lp:juju-gui/experimental
Diff against target: 183 lines (+55/-37)
2 files modified
app/views/environment.js (+52/-37)
test/test_environment_view.js (+3/-0)
To merge this branch: bzr merge lp:~makyo/juju-gui/add-rel-improvements
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+131542@code.launchpad.net

Description of the change

Add-relation improvements

UX improvements per Jovan: draglines should start with the long-click as an indicator that the user will be dragging a line; draglines should be on top of all services/lines, as they are currently the most important thing the user is working with; and draglines should be used when adding a relation from the service menu as well, showing that a relation will be created.

https://codereview.appspot.com/6786050/

To post a comment you must log in.
Revision history for this message
Madison Scott-Clary (makyo) wrote :
Download full text (5.2 KiB)

Reviewers: mp+131542_code.launchpad.net,

Message:
Please take a look.

Description:
Add-relation improvements

UX improvements per Jovan: draglines should start with the long-click as
an indicator that the user will be dragging a line; draglines should be
on top of all services/lines, as they are currently the most important
thing the user is working with; and draglines should be used when adding
a relation from the service menu as well, showing that a relation will
be created.

https://code.launchpad.net/~makyo/juju-gui/add-rel-improvements/+merge/131542

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/6786050/

Affected files:
   A [revision details]
   M app/views/environment.js
   M test/test_environment_view.js

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: test/test_environment_view.js
=== modified file 'test/test_environment_view.js'
--- test/test_environment_view.js 2012-10-20 18:16:19 +0000
+++ test/test_environment_view.js 2012-10-26 07:54:00 +0000
@@ -339,6 +339,9 @@
           container.all('.selectable-service')
                 .size()
                 .should.equal(2);
+ container.all('.dragline')
+ .size()
+ .should.equal(1);
           service.next().simulate('click');
           container.all('.selectable-service').size()
              .should.equal(0);

Index: app/views/environment.js
=== modified file 'app/views/environment.js'
--- app/views/environment.js 2012-10-26 06:35:16 +0000
+++ app/views/environment.js 2012-10-26 07:48:26 +0000
@@ -33,6 +33,8 @@
                var box = this.get('active_service'),
                    service = this.serviceForBox(box),
                    context = this.get('active_context');
+ this.addRelationDragStart.call(this, box, context);
+ this.clickAddRelation = true;
                this.service_click_actions
                          .toggleControlPanel(box, this, context);
                this.service_click_actions
@@ -81,6 +83,12 @@
                if (!d.containsPoint(mouse_coords, self.zoom)) {
                  return;
                }
+
+ // Do not fire if we're on the same service.
+ if (d === self.get('addRelationStart_service')) {
+ return;
+ }
+
                self.set('potential_drop_point_service', d);
                self.set('potential_drop_point_rect', rect);
                self.addSVGClass(rect, 'hover');
@@ -162,6 +170,17 @@

container.all('.environment-menu.active').removeClass('active');
                self.service_click_actions.toggleControlPanel(null, self);
                self.cancelRelationBuild();
+ },
+ mousemove: function(d, self) {
+ // If we're clicking to add a relation, make sure a dragline
+ // follows the mouse cursor.
+ ...

Read more...

208. By Madison Scott-Clary

Add-relation improvements

209. By Madison Scott-Clary

Add-relation improvements

210. By Madison Scott-Clary

Add-relation improvements

Revision history for this message
Madison Scott-Clary (makyo) wrote :
Revision history for this message
Gary Poster (gary) wrote :

Hi Matt. This looks like it will be a step in a good direction. I just went for a cruise around the UX for a second before I looked at the code, and I saw a few things that you might want to address, or at least run past Jovan, before a more thorough review.

 - the two experiences of starting from long-click and starting from the service menu are different in ways that surprise me, and in at least one case seems like at error. In general I prefer the long-click behavior.
   * lines started from the service menu can go crazy when you hover over things that are not a target service. For example, try hovering over a relationship name. For me, the line then goes from the service start point to [0, 0]. I see other similar issues that I won't clarify now, but if you can't dupe I'll be happy to provide more details and screenshots. (This does not happen with long-click.)
   * lines started from the service menu cannot go over the service, unlike the change you made for long-click. I think they ought to be the same.

Also, unrelatedly but concerningly, I discovered bug 1072433. That looks pretty critical, but it is in the trunk. I put that in the kanban board.

I'm going to stop the review for now until I hear back from you on how you want to handle my UX observations.

Thanks,

Gary

Revision history for this message
Madison Scott-Clary (makyo) wrote :

On 10/28/2012 08:53 PM, Gary Poster wrote:
> Hi Matt. This looks like it will be a step in a good direction. I just went for a cruise around the UX for a second before I looked at the code, and I saw a few things that you might want to address, or at least run past Jovan, before a more thorough review.
>
> - the two experiences of starting from long-click and starting from the service menu are different in ways that surprise me, and in at least one case seems like at error. In general I prefer the long-click behavior.
> * lines started from the service menu can go crazy when you hover over things that are not a target service. For example, try hovering over a relationship name. For me, the line then goes from the service start point to [0, 0]. I see other similar issues that I won't clarify now, but if you can't dupe I'll be happy to provide more details and screenshots. (This does not happen with long-click.)
> * lines started from the service menu cannot go over the service, unlike the change you made for long-click. I think they ought to be the same.
>
> Also, unrelatedly but concerningly, I discovered bug 1072433. That looks pretty critical, but it is in the trunk. I put that in the kanban board.
>
> I'm going to stop the review for now until I hear back from you on how you want to handle my UX observations.
>
> Thanks,
>
> Gary
Thanks for the catch - looks like mousemove events aren't bubbling how I
thought they would, and I was working on a mostly empty environment.
I'll investigate all these points.

211. By Madison Scott-Clary

Add-relation improvements

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/views/environment.js'
2--- app/views/environment.js 2012-10-29 10:01:29 +0000
3+++ app/views/environment.js 2012-10-30 08:16:22 +0000
4@@ -33,6 +33,8 @@
5 var box = this.get('active_service'),
6 service = this.serviceForBox(box),
7 context = this.get('active_context');
8+ this.addRelationDragStart.call(this, box, context);
9+ this.clickAddRelation = true;
10 this.service_click_actions
11 .toggleControlPanel(box, this, context);
12 this.service_click_actions
13@@ -81,6 +83,12 @@
14 if (!d.containsPoint(mouse_coords, self.zoom)) {
15 return;
16 }
17+
18+ // Do not fire if we're on the same service.
19+ if (d === self.get('addRelationStart_service')) {
20+ return;
21+ }
22+
23 self.set('potential_drop_point_service', d);
24 self.set('potential_drop_point_rect', rect);
25 self.addSVGClass(rect, 'hover');
26@@ -121,6 +129,13 @@
27 self.dragline.attr('class',
28 'relation pending-relation dragline dragging');
29 }
30+ },
31+ mousemove: function(d, self) {
32+ if (self.clickAddRelation) {
33+ var container = self.get('container'),
34+ node = container.one('#canvas rect:first-child');
35+ self.rectMousemove.call(node.getDOMNode(), d, self);
36+ }
37 }
38 },
39 '.sub-rel-block': {
40@@ -152,7 +167,14 @@
41
42 // Relation Related
43 '.rel-label': {
44- click: 'relationClick'
45+ click: 'relationClick',
46+ mousemove: function(d, self) {
47+ if (self.clickAddRelation) {
48+ var container = self.get('container'),
49+ node = container.one('#canvas rect:first-child');
50+ self.rectMousemove.call(node.getDOMNode(), d, self);
51+ }
52+ }
53 },
54
55 // Canvas related
56@@ -162,7 +184,8 @@
57 container.all('.environment-menu.active').removeClass('active');
58 self.service_click_actions.toggleControlPanel(null, self);
59 self.cancelRelationBuild();
60- }
61+ },
62+ mousemove: 'rectMousemove'
63 }
64 },
65
66@@ -184,19 +207,6 @@
67 // we have the correct event in d3.event for d3.mouse().
68 d3.event = e;
69
70- // Flash an indicator around the center of the service block.
71- var center = d.getCenter();
72- self.vis.append('circle')
73- .attr('cx', center[0])
74- .attr('cy', center[1])
75- .attr('r', 100)
76- .attr('class', 'mouse-down-indicator')
77- .transition()
78- .duration(750)
79- .ease('bounce')
80- .attr('r', 0)
81- .remove();
82-
83 // Start the process of adding a relation
84 self.addRelationDragStart.call(self, d, this);
85 }, [d, evt], false);
86@@ -409,6 +419,18 @@
87 self.removeRelationConfirm(d, this, self);
88 },
89
90+ rectMousemove: function(d, self) {
91+ // If we're clicking to add a relation, make sure a dragline
92+ // follows the mouse cursor.
93+ if (self.clickAddRelation) {
94+ var mouse = d3.mouse(this);
95+ d3.event.x = mouse[0];
96+ d3.event.y = mouse[1];
97+ self.addRelationDrag
98+ .call(self, self.get('addRelationStart_service'), this);
99+ }
100+ },
101+
102 /*
103 * Sync view models with current db.models.
104 */
105@@ -1030,22 +1052,25 @@
106
107 addRelationDragStart: function(d, context) {
108 // Create a pending drag-line behind services.
109- var dragline = this.vis.insert('line', '.service')
110+ var dragline = this.vis.append('line')
111 .attr('class', 'relation pending-relation dragline dragging'),
112 self = this;
113
114- // Start the line in the middle of the service.
115- var point = d.getCenter();
116- dragline.attr('x1', point[0])
117- .attr('y1', point[1])
118- .attr('x2', point[0])
119- .attr('y2', point[1]);
120+ // Start the line between the cursor and the nearest connector
121+ // point on the service.
122+ var mouse = d3.mouse(Y.one('svg').getDOMNode());
123+ self.cursorBox = views.BoundingBox();
124+ self.cursorBox.pos = {x: mouse[0], y: mouse[1], w: 0, h: 0};
125+ var point = self.cursorBox.getConnectorPair(d);
126+ dragline.attr('x1', point[0][0])
127+ .attr('y1', point[0][1])
128+ .attr('x2', point[1][0])
129+ .attr('y2', point[1][1]);
130 self.dragline = dragline;
131- self.cursorBox = views.BoundingBox();
132
133 // Start the add-relation process.
134 self.service_click_actions
135- .addRelationStart(d, self, context);
136+ .addRelationStart(d, self, context);
137 },
138
139 addRelationDrag: function(d, context) {
140@@ -1142,6 +1167,7 @@
141 this.dragline.remove();
142 this.dragline = null;
143 }
144+ this.clickAddRelation = null;
145 this.set('currentServiceClickAction', 'toggleControlPanel');
146 this.show(this.vis.selectAll('.service'))
147 .classed('selectable-service', false);
148@@ -1500,19 +1526,8 @@
149 return a[0].name + a[1].name < b[0].name + b[1].name;
150 });
151
152- // Create a pending line if it doesn't exist, as in the case of
153- // clicking to add relation.
154- if (!view.dragline) {
155- var dragline = view.vis.insert('line', '.service')
156- .attr('class', 'relation pending-relation dragline'),
157- points = m.getConnectorPair(
158- view.get('addRelationStart_service'));
159- dragline.attr('x1', points[0][0])
160- .attr('y1', points[0][1])
161- .attr('x2', points[1][0])
162- .attr('y2', points[1][1]);
163- view.dragline = dragline;
164- }
165+ // Stop rubberbanding on mousemove.
166+ view.clickAddRelation = null;
167
168 // Display menu with available endpoints.
169 var menu = container.one('#ambiguous-relation-menu');
170
171=== modified file 'test/test_environment_view.js'
172--- test/test_environment_view.js 2012-10-25 09:52:10 +0000
173+++ test/test_environment_view.js 2012-10-30 08:16:22 +0000
174@@ -339,6 +339,9 @@
175 container.all('.selectable-service')
176 .size()
177 .should.equal(2);
178+ container.all('.dragline')
179+ .size()
180+ .should.equal(1);
181 service.next().simulate('click');
182 container.all('.selectable-service').size()
183 .should.equal(0);

Subscribers

People subscribed via source and target branches