Merge lp:~rharding/launchpad/regjs into lp:launchpad
- regjs
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Richard Harding |
Approved revision: | no longer in the source branch. |
Merged at revision: | 16031 |
Proposed branch: | lp:~rharding/launchpad/regjs |
Merge into: | lp:launchpad |
Prerequisite: | lp:~rharding/launchpad/clean_information_type |
Diff against target: |
954 lines (+826/-16) 6 files modified
lib/lp/app/javascript/choice.js (+1/-1) lib/lp/app/javascript/tests/test_choice.html (+41/-0) lib/lp/app/javascript/tests/test_choice.js (+84/-0) lib/lp/registry/javascript/product_views.js (+62/-4) lib/lp/registry/javascript/tests/test_product_views.html (+557/-0) lib/lp/registry/javascript/tests/test_product_views.js (+81/-11) |
To merge this branch: | bzr merge lp:~rharding/launchpad/regjs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York (community) | code | Approve | |
Review via email: mp+125780@code.launchpad.net |
Commit message
Add UI updates during project registration based on type of information type chosen.
Description of the change
= Summary =
This code is behind the feature flag enabling choosing a private project since
it only comes into play if the information type input is on the page.
When a user selects a non-public information type for the project we auto
choose their license to be other/commercial and hide the field. We also make
sure to show the driver and bug supervisor fields since we're going to be
enabling bugs, code, and such automatically for private projects.
== Pre Implementation ==
Talked with Deryck on the UI for the interaction.
== Implementation Notes ==
We're hooking into the event that the ChoiceSource widget will fire whenever
someone selects a new value for the InformationType choice widget. Then we
decide what bits of the input to show/hide.
From here we'll be adding events to hook up the privacy banner to show if a
non-public type is shown.
Note: along the way we hit some pita to debug code around the choice.js since
I was new to this layout of the information type data cache. I've started a
file for tests for choices.js and added some simple sanity checks and tests
for the method we're using here.
== Q/A ==
With the private projects feature flag enabled register a project. Choose a
non-public information type from the choice widget and the license input
should disappear and the bug supervisor and driver fields should appear.
Go back to PUBLIC and the reverse will occur.
== Tests ==
test_choice.html
test_product_
Benji York (benji) wrote : | # |
Benji York (benji) wrote : | # |
When I put myself in the position of a person that would have to update the HTML blob in the future, an edited one is worse than one that is just a copy-paste away.
I'm not trying to be difficult, I'm just worried about the maintenance overhead.
I would be OK with a non-edited blob and good instructions on how and when to freshen it or an edited blob with good, simple instructions on updating it.
Richard Harding (rharding) wrote : | # |
I've added the notes and description about the copied html output. See #272 and #353 for the comment and the note on the start of the pasted html.
There's a specific note because copying the html causes a script block to get copied. We're putting this inside of a mustache template (a script block itself) which breaks dom parsing correctly and the tests fail. Because the tests fail there should be no way to 'break' things in future pastes. You'll get failing tests and hopefully see the NOTE: part of the comment.
Benji York (benji) wrote : | # |
Much improved.
I would still like to see more step-by-step instructions on how to update the code. In particular, how do I find the page the code is on?
Richard Harding (rharding) wrote : | # |
> Much improved.
>
> I would still like to see more step-by-step instructions on how to update the
> code. In particular, how do I find the page the code is on?
Thanks, added a note in the comment that it's copied from the dev tools during project registration step two view.
Preview Diff
1 | === modified file 'lib/lp/app/javascript/choice.js' |
2 | --- lib/lp/app/javascript/choice.js 2012-09-19 16:11:37 +0000 |
3 | +++ lib/lp/app/javascript/choice.js 2012-09-25 15:14:24 +0000 |
4 | @@ -160,7 +160,7 @@ |
5 | * @param cfg |
6 | */ |
7 | namespace.addPopupChoiceForRadioButtons = function(field_name, choices, cfg) { |
8 | - if (!choices) { |
9 | + if (!choices || choices.length === 0) { |
10 | throw 'No choices for the popup.'; |
11 | } |
12 | cfg = Y.merge(default_popup_choice_config, cfg); |
13 | |
14 | === added file 'lib/lp/app/javascript/tests/test_choice.html' |
15 | --- lib/lp/app/javascript/tests/test_choice.html 1970-01-01 00:00:00 +0000 |
16 | +++ lib/lp/app/javascript/tests/test_choice.html 2012-09-25 15:14:24 +0000 |
17 | @@ -0,0 +1,41 @@ |
18 | +<!DOCTYPE html> |
19 | +<!-- |
20 | +Copyright 2012 Canonical Ltd. This software is licensed under the |
21 | +GNU Affero General Public License version 3 (see the file LICENSE). |
22 | +--> |
23 | + |
24 | +<html> |
25 | + <head> |
26 | + <title>app.choice Tests</title> |
27 | + |
28 | + <!-- YUI and test setup --> |
29 | + <script type="text/javascript" |
30 | + src="../../../../../build/js/yui/yui/yui.js"> |
31 | + </script> |
32 | + <link rel="stylesheet" |
33 | + href="../../../../../build/js/yui/console/assets/console-core.css" /> |
34 | + <link rel="stylesheet" |
35 | + href="../../../../../build/js/yui/console/assets/skins/sam/console.css" /> |
36 | + <link rel="stylesheet" |
37 | + href="../../../../../build/js/yui/test/assets/skins/sam/test.css" /> |
38 | + |
39 | + <script type="text/javascript" |
40 | + src="../../../../../build/js/lp/app/testing/testrunner.js"></script> |
41 | + <script type="text/javascript" |
42 | + src="../../../../build/js/lp/app/testing/helpers.js"></script> |
43 | + |
44 | + <link rel="stylesheet" href="../../../app/javascript/testing/test.css" /> |
45 | + |
46 | + <!-- The module under test. --> |
47 | + <script type="text/javascript" src="../choice.js"></script> |
48 | + |
49 | + <!-- The test suite --> |
50 | + <script type="text/javascript" src="test_choice.js"></script> |
51 | + |
52 | + </head> |
53 | + <body class="yui3-skin-sam"> |
54 | + <ul id="suites"> |
55 | + <li>lp.app.choice.test</li> |
56 | + </ul> |
57 | + </body> |
58 | +</html> |
59 | |
60 | === added file 'lib/lp/app/javascript/tests/test_choice.js' |
61 | --- lib/lp/app/javascript/tests/test_choice.js 1970-01-01 00:00:00 +0000 |
62 | +++ lib/lp/app/javascript/tests/test_choice.js 2012-09-25 15:14:24 +0000 |
63 | @@ -0,0 +1,84 @@ |
64 | +/* Copyright (c) 2012 Canonical Ltd. All rights reserved. */ |
65 | + |
66 | +YUI.add('lp.app.choice.test', function (Y) { |
67 | + |
68 | + // Shortcut to the namespace we're testing against. |
69 | + var choice = Y.namespace('lp.app.choice'); |
70 | + |
71 | + var tests = Y.namespace('lp.app.choice.test'); |
72 | + tests.suite = new Y.Test.Suite('app.choice Tests'); |
73 | + |
74 | + tests.suite.add(new Y.Test.Case({ |
75 | + name: 'app.choice_tests', |
76 | + |
77 | + test_library_exists: function () { |
78 | + Y.Assert.isObject(Y.lp.app.choice, |
79 | + "Could not locate the lp.app.choice module"); |
80 | + } |
81 | + })); |
82 | + |
83 | + |
84 | + tests.suite.add(new Y.Test.Case({ |
85 | + name: 'radio_popup_choice', |
86 | + |
87 | + _should: { |
88 | + error: { |
89 | + test_error_undefined_data: true, |
90 | + test_error_empty_array: true |
91 | + } |
92 | + }, |
93 | + |
94 | + setUp: function () { |
95 | + window.LP = { |
96 | + cache: { |
97 | + context: { |
98 | + web_link: '' |
99 | + }, |
100 | + information_type_data: { |
101 | + PUBLIC: { |
102 | + value: 'PUBLIC', name: 'Public', |
103 | + is_private: false, order: 1, |
104 | + description: 'Public Description' |
105 | + }, |
106 | + PUBLICSECURITY: { |
107 | + value: 'PUBLICSECURITY', name: 'Public Security', |
108 | + is_private: false, order: 2, |
109 | + description: 'Public Security Description' |
110 | + }, |
111 | + PROPRIETARY: { |
112 | + value: 'PROPRIETARY', name: 'Proprietary', |
113 | + is_private: true, order: 3, |
114 | + description: 'Private Description' |
115 | + }, |
116 | + USERDATA: { |
117 | + value: 'USERDATA', name: 'Private', |
118 | + is_private: true, order: 4, |
119 | + description: 'Private Description' |
120 | + } |
121 | + } |
122 | + } |
123 | + }; |
124 | + }, |
125 | + |
126 | + tearDown: function () { |
127 | + window.LP = {}; |
128 | + }, |
129 | + |
130 | + test_error_undefined_data: function () { |
131 | + // An exception should be raised if you create a button with |
132 | + // undefined options. |
133 | + choice.addPopupChoiceForRadioButtons('information_type', |
134 | + undefined); |
135 | + }, |
136 | + |
137 | + test_error_empty_array: function () { |
138 | + // An exception should be raised if you create a button with no |
139 | + // options. |
140 | + choice.addPopupChoiceForRadioButtons('information_type', |
141 | + []); |
142 | + } |
143 | + })); |
144 | + |
145 | +}, '0.1', { |
146 | + requires: ['test', 'console', 'lp.app.choice'] |
147 | +}); |
148 | |
149 | === modified file 'lib/lp/registry/javascript/product_views.js' |
150 | --- lib/lp/registry/javascript/product_views.js 2012-09-18 15:10:36 +0000 |
151 | +++ lib/lp/registry/javascript/product_views.js 2012-09-25 15:14:24 +0000 |
152 | @@ -8,6 +8,8 @@ |
153 | */ |
154 | YUI.add('registry.product-views', function (Y) { |
155 | var ns = Y.namespace('registry.views'); |
156 | + var info_type = Y.lp.app.information_type; |
157 | + var COMMERCIAL_LICENSE = "OTHER_PROPRIETARY"; |
158 | |
159 | /** |
160 | * Handle setting up the JS for the new project View |
161 | @@ -29,12 +31,28 @@ |
162 | /** |
163 | * Process binding the UI for the information type choice widget. |
164 | * |
165 | - * @method _bind_information-type |
166 | + * @method _bind_information_type |
167 | * @private |
168 | */ |
169 | _bind_information_type: function () { |
170 | - Y.lp.app.choice.addPopupChoiceForRadioButtons( |
171 | - 'information_type', LP.cache.information_type_data, true); |
172 | + var that = this; |
173 | + var widget = Y.lp.app.choice.addPopupChoiceForRadioButtons( |
174 | + 'information_type', |
175 | + info_type.cache_to_choicesource( |
176 | + LP.cache.information_type_data)); |
177 | + |
178 | + // When the information type changes, check if we should show/hide |
179 | + // UI components. |
180 | + widget.on('save', function (ev) { |
181 | + that._information_type_change(ev.target.get('value')); |
182 | + }); |
183 | + |
184 | + // And on first render, the information type is PUBLIC. |
185 | + that._information_type_change('PUBLIC'); |
186 | + |
187 | + // Hold onto the reference to the information type widget so we |
188 | + // can test with it. |
189 | + this._information_type_widget = widget; |
190 | }, |
191 | |
192 | /** |
193 | @@ -171,6 +189,45 @@ |
194 | }, |
195 | |
196 | /** |
197 | + * Update the UI when the information type changes. |
198 | + * |
199 | + * @method _information_type_change |
200 | + * @param {String} information_type value |
201 | + * |
202 | + */ |
203 | + _information_type_change: function (value) { |
204 | + var driver_cont = Y.one('input[name="field.driver"]').ancestor('td'); |
205 | + var bug_super_cont = Y.one('input[name="field.bug_supervisor"]').ancestor('td'); |
206 | + |
207 | + // The license code is nested in another table. |
208 | + var license = Y.one('input[name="field.licenses"]'); |
209 | + var license_cont = license.ancestor('td').ancestor('td'); |
210 | + |
211 | + if (info_type.get_cache_data_from_key(value, 'value', |
212 | + 'is_private')) { |
213 | + // Hide the driver and bug supervisor fields. |
214 | + driver_cont.show(); |
215 | + bug_super_cont.show(); |
216 | + |
217 | + // Hide the license field and set it to commercial. |
218 | + license_cont.hide(); |
219 | + |
220 | + // We have to set both checked and the value because value is |
221 | + // a DOM object property, but the UI is updated based on the |
222 | + // 'checked' attribute. |
223 | + var commercial = 'input[value="' + COMMERCIAL_LICENSE + '"]'; |
224 | + Y.one(commercial).set('checked', 'checked'); |
225 | + license.set('value', COMMERCIAL_LICENSE); |
226 | + } else { |
227 | + driver_cont.hide(); |
228 | + bug_super_cont.hide(); |
229 | + |
230 | + // Show the license field. |
231 | + license_cont.show(); |
232 | + } |
233 | + }, |
234 | + |
235 | + /** |
236 | * Handle the reveals when there are search results. |
237 | * |
238 | * @method _show_separator |
239 | @@ -365,5 +422,6 @@ |
240 | }); |
241 | |
242 | }, '0.1', { |
243 | - 'requires': ['base', 'node', 'lp.ui.effects', 'lp.app.choice'] |
244 | + 'requires': ['base', 'node', 'lp.ui.effects', 'lp.app.choice', |
245 | + 'lp.ui.choiceedit', 'lp.app.information_type'] |
246 | }); |
247 | |
248 | === modified file 'lib/lp/registry/javascript/tests/test_product_views.html' |
249 | --- lib/lp/registry/javascript/tests/test_product_views.html 2012-09-18 15:10:36 +0000 |
250 | +++ lib/lp/registry/javascript/tests/test_product_views.html 2012-09-25 15:14:24 +0000 |
251 | @@ -1,4 +1,5 @@ |
252 | <!DOCTYPE html> |
253 | + |
254 | <!-- |
255 | Copyright 2012 Canonical Ltd. This software is licensed under the |
256 | GNU Affero General Public License version 3 (see the file LICENSE). |
257 | @@ -30,7 +31,9 @@ |
258 | <script type="text/javascript" src="../../../../../build/js/lp/app/ellipsis.js"></script> |
259 | <script type="text/javascript" src="../../../../../build/js/lp/app/expander.js"></script> |
260 | <script type="text/javascript" src="../../../../../build/js/lp/app/errors.js"></script> |
261 | + <script type="text/javascript" src="../../../../../build/js/lp/app/information_type.js"></script> |
262 | <script type="text/javascript" src="../../../../../build/js/lp/app/lp.js"></script> |
263 | + <script type="text/javascript" src="../../../../../build/js/lp/app/mustache.js"></script> |
264 | <script type="text/javascript" src="../../../../../build/js/lp/app/anim/anim.js"></script> |
265 | <script type="text/javascript" src="../../../../../build/js/lp/app/extras/extras.js"></script> |
266 | <script type="text/javascript" src="../../../../../build/js/lp/app/choiceedit/choiceedit.js"></script> |
267 | @@ -54,5 +57,559 @@ |
268 | <li>registry.product-views.test</li> |
269 | </ul> |
270 | <div id="testdom"></div> |
271 | + |
272 | + <!-- |
273 | + This html is to bootstrap the form you fill out and represent the |
274 | + license choices and such. |
275 | + |
276 | + The license field is a nested table that needs special JS to |
277 | + show/hide correctly. In order to test this, we've just copied the |
278 | + whole html out of the running site. It's easier than trying to |
279 | + 'mock' up the html representation. |
280 | + |
281 | + NOTE: There's a <script> tag in the html for setting up the |
282 | + license widget that needs to be removed. Nested script tags won't |
283 | + function correctly as mustache output. |
284 | + |
285 | + --> |
286 | + |
287 | + <script id="tpl_information_type" type="text/template"> |
288 | + <table> |
289 | + <tr> |
290 | + <td> |
291 | + <input type="text" id="field.name" name="field.name" /> |
292 | + </td> |
293 | + </tr> |
294 | + <tr> |
295 | + <td> |
296 | + <input type="text" id="field.displayname" name="field.displayname" /> |
297 | + </td> |
298 | + </tr> |
299 | + <tr> |
300 | + <td> |
301 | + <div> |
302 | + <label for="field.information_type">Information Type:</label> |
303 | + </div> |
304 | + <table class="radio-button-widget"> |
305 | + <tbody> |
306 | + <tr> |
307 | + <td rowspan="2"> |
308 | + <input class="radioType" id="field.information_type.0" name="field.information_type" type="radio" value="PUBLIC"/> |
309 | + </td> |
310 | + <td> |
311 | + <label for="field.information_type.0">Public</label> |
312 | + </td> |
313 | + </tr> |
314 | + <tr> |
315 | + <td class="formHelp">Everyone can see this information.</td> |
316 | + </tr> |
317 | + <tr> |
318 | + <td rowspan="2"> |
319 | + <input class="radioType" id="field.information_type.4" name="field.information_type" type="radio" value="PROPRIETARY" /> |
320 | + </td> |
321 | + <td><label for="field.information_type.4">Proprietary</label></td> |
322 | + </tr> |
323 | + <tr> |
324 | + <td class="formHelp">Only shared with users permitted to see proprietary information.</td> |
325 | + </tr> |
326 | + <tr> |
327 | + <td rowspan="2"> |
328 | + <input class="radioType" id="field.information_type.5" name="field.information_type" type="radio" value="EMBARGOED" /> |
329 | + </td> |
330 | + <td><label for="field.information_type.5">Embargoed</label></td> |
331 | + </tr> |
332 | + <tr> |
333 | + <td class="formHelp">Only shared with users permitted to see embargoed information.</td> |
334 | + </tr> |
335 | + </tbody> |
336 | + </table> |
337 | + <input name="field.information_type-empty-marker" type="hidden" value="1" /> |
338 | + <p class="formHelp">The type of of data contained in this project.</p> |
339 | + </td> |
340 | + </tr> |
341 | + <tr> |
342 | + <td> |
343 | + <input type="text" name="field.driver" id="field.driver" /> |
344 | + </td> |
345 | + </tr> |
346 | + <tr> |
347 | + <td> |
348 | + <input type="text" name="field.bug_supervisor" id="field.bug_supervisor" /> |
349 | + </td> |
350 | + </tr> |
351 | + <tr> |
352 | + <td> |
353 | + <!-- Begin copied html from the license input. |
354 | + |
355 | + To copy right-click on the license node in the project |
356 | + registration step two and use the dev tools to 'Copy as |
357 | + HTML'. |
358 | + |
359 | + --> |
360 | + |
361 | + <div id="yui_3_5_1_1_1348577791671_254"> |
362 | + <label for="field.licenses">Licences:</label> |
363 | + <div id="yui_3_5_1_1_1348577791671_253"> |
364 | + <div style="color: black" id="yui_3_5_1_1_1348577791671_252"> |
365 | + Select the licence(s) under which you release your project. |
366 | + <div id="pending-div" style="padding-left: 20px"> |
367 | + <div class="collapsible" id="yui_3_5_1_1_1348577791671_67"> |
368 | + <legend class="treeExpanded sprite" style= |
369 | + "cursor: pointer;"><a class="js-action" href= |
370 | + "#">Recommended open source licences</a></legend> |
371 | + |
372 | + <div id="recommended" class="expanded lazr-closed" style= |
373 | + "height: auto; overflow: hidden;"> |
374 | + <table id="yui_3_5_1_1_1348577791671_251"> |
375 | + <tbody id="yui_3_5_1_1_1348577791671_250"> |
376 | + <tr id="yui_3_5_1_1_1348577791671_249"> |
377 | + <td id="yui_3_5_1_1_1348577791671_247"> |
378 | + <label for="field.licenses.1" style= |
379 | + "font-weight: normal" id= |
380 | + "yui_3_5_1_1_1348577791671_246"><input class="checkboxType" |
381 | + id="field.licenses.1" name= |
382 | + "field.licenses" type="checkbox" value= |
383 | + "APACHE"> Apache |
384 | + Licence <a href= |
385 | + "http://www.opensource.org/licenses/apache2.0.php" |
386 | + class= |
387 | + "sprite external-link action-icon">view |
388 | + licence</a></label> |
389 | + </td> |
390 | + |
391 | + <td><label for="field.licenses.11" style= |
392 | + "font-weight: normal"><input class= |
393 | + "checkboxType" id="field.licenses.11" |
394 | + name="field.licenses" type="checkbox" |
395 | + value="AFFERO"> GNU Affero GPL |
396 | + v3 <a href= |
397 | + "http://www.opensource.org/licenses/agpl-v3.html" |
398 | + class= |
399 | + "sprite external-link action-icon">view |
400 | + licence</a></label> |
401 | + </td> |
402 | + |
403 | + <td><label for="field.licenses.15" style= |
404 | + "font-weight: normal"><input class= |
405 | + "checkboxType" id="field.licenses.15" |
406 | + name="field.licenses" type="checkbox" |
407 | + value="GNU_LGPL_V2_1"> GNU LGPL |
408 | + v2.1 <a href= |
409 | + "http://www.opensource.org/licenses/lgpl-2.1.php" |
410 | + class= |
411 | + "sprite external-link action-icon">view |
412 | + licence</a></label> |
413 | + </td> |
414 | + </tr> |
415 | + |
416 | + |
417 | + <tr> |
418 | + <td><label for="field.licenses.4" style= |
419 | + "font-weight: normal"><input class= |
420 | + "checkboxType" id="field.licenses.4" |
421 | + name="field.licenses" type="checkbox" |
422 | + value="BSD"> Simplified BSD |
423 | + Licence <a href= |
424 | + "http://www.opensource.org/licenses/bsd-license.php" |
425 | + class= |
426 | + "sprite external-link action-icon">view |
427 | + licence</a></label> |
428 | + </td> |
429 | + |
430 | + <td><label for="field.licenses.13" style= |
431 | + "font-weight: normal"><input class= |
432 | + "checkboxType" id="field.licenses.13" |
433 | + name="field.licenses" type="checkbox" |
434 | + value="GNU_GPL_V2"> GNU GPL |
435 | + v2 <a href= |
436 | + "http://www.opensource.org/licenses/gpl-2.0.php" |
437 | + class= |
438 | + "sprite external-link action-icon">view |
439 | + licence</a></label> |
440 | + </td> |
441 | + |
442 | + <td><label for="field.licenses.16" style= |
443 | + "font-weight: normal"><input class= |
444 | + "checkboxType" id="field.licenses.16" |
445 | + name="field.licenses" type="checkbox" |
446 | + value="GNU_LGPL_V3"> GNU LGPL |
447 | + v3 <a href= |
448 | + "http://www.opensource.org/licenses/lgpl-3.0.html" |
449 | + class= |
450 | + "sprite external-link action-icon">view |
451 | + licence</a></label> |
452 | + </td> |
453 | + </tr> |
454 | + |
455 | + |
456 | + <tr> |
457 | + <td><label for="field.licenses.8" style= |
458 | + "font-weight: normal"><input class= |
459 | + "checkboxType" id="field.licenses.8" |
460 | + name="field.licenses" type="checkbox" |
461 | + value="CC_0"> Creative Commons - No |
462 | + Rights Reserved <a href= |
463 | + "http://creativecommons.org/about/cc0" |
464 | + class= |
465 | + "sprite external-link action-icon">view |
466 | + licence</a></label> |
467 | + </td> |
468 | + |
469 | + <td><label for="field.licenses.14" style= |
470 | + "font-weight: normal"><input class= |
471 | + "checkboxType" id="field.licenses.14" |
472 | + name="field.licenses" type="checkbox" |
473 | + value="GNU_GPL_V3"> GNU GPL |
474 | + v3 <a href= |
475 | + "http://www.opensource.org/licenses/gpl-3.0.html" |
476 | + class= |
477 | + "sprite external-link action-icon">view |
478 | + licence</a></label> |
479 | + </td> |
480 | + |
481 | + <td><label for="field.licenses.17" style= |
482 | + "font-weight: normal"><input class= |
483 | + "checkboxType" id="field.licenses.17" |
484 | + name="field.licenses" type="checkbox" |
485 | + value="MIT"> MIT / X / Expat |
486 | + Licence <a href= |
487 | + "http://www.opensource.org/licenses/mit-license.php" |
488 | + class= |
489 | + "sprite external-link action-icon">view |
490 | + licence</a></label> |
491 | + </td> |
492 | + </tr> |
493 | + </tbody> |
494 | + </table> |
495 | + </div> |
496 | + </div> |
497 | + |
498 | + |
499 | + <div class="collapsible" id="yui_3_5_1_1_1348577791671_96"> |
500 | + <legend class="treeCollapsed sprite" style= |
501 | + "cursor: pointer;"><a class="js-action" href="#">More |
502 | + open source licences</a></legend> |
503 | + |
504 | + <div id="more" class="hidden lazr-closed" style= |
505 | + "height: 0px; overflow: hidden;"> |
506 | + <table> |
507 | + <tbody> |
508 | + <tr> |
509 | + <td><label for="field.licenses.0" style= |
510 | + "font-weight: normal"><input class= |
511 | + "checkboxType" id="field.licenses.0" |
512 | + name="field.licenses" type="checkbox" |
513 | + value="ACADEMIC"> Academic Free |
514 | + Licence <a href= |
515 | + "http://www.opensource.org/licenses/afl-3.0.php" |
516 | + class= |
517 | + "sprite external-link action-icon">view |
518 | + licence</a></label> |
519 | + </td> |
520 | + |
521 | + <td><label for="field.licenses.9" style= |
522 | + "font-weight: normal"><input class= |
523 | + "checkboxType" id="field.licenses.9" |
524 | + name="field.licenses" type="checkbox" |
525 | + value="ECLIPSE"> Eclipse Public |
526 | + Licence <a href= |
527 | + "http://www.opensource.org/licenses/eclipse-1.0.php" |
528 | + class= |
529 | + "sprite external-link action-icon">view |
530 | + licence</a></label> |
531 | + </td> |
532 | + |
533 | + <td><label for="field.licenses.22" style= |
534 | + "font-weight: normal"><input class= |
535 | + "checkboxType" id="field.licenses.22" |
536 | + name="field.licenses" type="checkbox" |
537 | + value="PHP"> PHP |
538 | + Licence <a href= |
539 | + "http://www.opensource.org/licenses/php.php" |
540 | + class= |
541 | + "sprite external-link action-icon">view |
542 | + licence</a></label> |
543 | + </td> |
544 | + </tr> |
545 | + |
546 | + |
547 | + <tr> |
548 | + <td><label for="field.licenses.2" style= |
549 | + "font-weight: normal"><input class= |
550 | + "checkboxType" id="field.licenses.2" |
551 | + name="field.licenses" type="checkbox" |
552 | + value="ARTISTIC"> Artistic Licence |
553 | + 1.0 <a href= |
554 | + "http://opensource.org/licenses/artistic-license-1.0.php" |
555 | + class= |
556 | + "sprite external-link action-icon">view |
557 | + licence</a></label> |
558 | + </td> |
559 | + |
560 | + <td><label for="field.licenses.10" style= |
561 | + "font-weight: normal"><input class= |
562 | + "checkboxType" id="field.licenses.10" |
563 | + name="field.licenses" type="checkbox" |
564 | + value= |
565 | + "EDUCATIONAL_COMMUNITY"> Educational |
566 | + Community Licence <a href= |
567 | + "http://www.opensource.org/licenses/ecl2.php" |
568 | + class= |
569 | + "sprite external-link action-icon">view |
570 | + licence</a></label> |
571 | + </td> |
572 | + |
573 | + <td><label for="field.licenses.23" style= |
574 | + "font-weight: normal"><input class= |
575 | + "checkboxType" id="field.licenses.23" |
576 | + name="field.licenses" type="checkbox" |
577 | + value="PUBLIC_DOMAIN"> Public |
578 | + Domain <a href= |
579 | + "https://answers.launchpad.net/launchpad/+faq/564" |
580 | + class= |
581 | + "sprite external-link action-icon">view |
582 | + licence</a></label> |
583 | + </td> |
584 | + </tr> |
585 | + |
586 | + |
587 | + <tr> |
588 | + <td><label for="field.licenses.3" style= |
589 | + "font-weight: normal"><input class= |
590 | + "checkboxType" id="field.licenses.3" |
591 | + name="field.licenses" type="checkbox" |
592 | + value="ARTISTIC_2_0"> Artistic |
593 | + Licence 2.0 <a href= |
594 | + "http://www.opensource.org/licenses/artistic-license-2.0.php" |
595 | + class= |
596 | + "sprite external-link action-icon">view |
597 | + licence</a></label> |
598 | + </td> |
599 | + |
600 | + <td><label for="field.licenses.12" style= |
601 | + "font-weight: normal"><input class= |
602 | + "checkboxType" id="field.licenses.12" |
603 | + name="field.licenses" type="checkbox" |
604 | + value="GNU_GFDL_NO_OPTIONS"> GNU |
605 | + GFDL no options <a href= |
606 | + "http://www.gnu.org/copyleft/fdl.html" |
607 | + class= |
608 | + "sprite external-link action-icon">view |
609 | + licence</a></label> |
610 | + </td> |
611 | + |
612 | + <td><label for="field.licenses.24" style= |
613 | + "font-weight: normal"><input class= |
614 | + "checkboxType" id="field.licenses.24" |
615 | + name="field.licenses" type="checkbox" |
616 | + value="PYTHON"> Python |
617 | + Licence <a href= |
618 | + "http://www.opensource.org/licenses/PythonSoftFoundation.php" |
619 | + class= |
620 | + "sprite external-link action-icon">view |
621 | + licence</a></label> |
622 | + </td> |
623 | + </tr> |
624 | + |
625 | + |
626 | + <tr> |
627 | + <td><label for="field.licenses.5" style= |
628 | + "font-weight: normal"><input class= |
629 | + "checkboxType" id="field.licenses.5" |
630 | + name="field.licenses" type="checkbox" |
631 | + value="COMMON_PUBLIC"> Common Public |
632 | + Licence <a href= |
633 | + "http://www.opensource.org/licenses/cpl1.0.php" |
634 | + class= |
635 | + "sprite external-link action-icon">view |
636 | + licence</a></label> |
637 | + </td> |
638 | + |
639 | + <td><label for="field.licenses.18" style= |
640 | + "font-weight: normal"><input class= |
641 | + "checkboxType" id="field.licenses.18" |
642 | + name="field.licenses" type="checkbox" |
643 | + value="MPL"> Mozilla Public |
644 | + Licence <a href= |
645 | + "http://www.opensource.org/licenses/mozilla1.1.php" |
646 | + class= |
647 | + "sprite external-link action-icon">view |
648 | + licence</a></label> |
649 | + </td> |
650 | + |
651 | + <td><label for="field.licenses.25" style= |
652 | + "font-weight: normal"><input class= |
653 | + "checkboxType" id="field.licenses.25" |
654 | + name="field.licenses" type="checkbox" |
655 | + value="ZPL"> Zope Public |
656 | + Licence <a href= |
657 | + "http://www.opensource.org/licenses/zpl.php" |
658 | + class= |
659 | + "sprite external-link action-icon">view |
660 | + licence</a></label> |
661 | + </td> |
662 | + </tr> |
663 | + |
664 | + |
665 | + <tr> |
666 | + <td><label for="field.licenses.6" style= |
667 | + "font-weight: normal"><input class= |
668 | + "checkboxType" id="field.licenses.6" |
669 | + name="field.licenses" type="checkbox" |
670 | + value="CC_BY"> Creative Commons - |
671 | + Attribution <a href= |
672 | + "http://creativecommons.org/about/licenses" |
673 | + class= |
674 | + "sprite external-link action-icon">view |
675 | + licence</a></label> |
676 | + </td> |
677 | + |
678 | + <td><label for="field.licenses.19" style= |
679 | + "font-weight: normal"><input class= |
680 | + "checkboxType" id="field.licenses.19" |
681 | + name="field.licenses" type="checkbox" |
682 | + value="OFL"> Open Font Licence |
683 | + v1.1 <a href= |
684 | + "http://scripts.sil.org/OFL" class= |
685 | + "sprite external-link action-icon">view |
686 | + licence</a></label> |
687 | + </td> |
688 | + </tr> |
689 | + |
690 | + |
691 | + <tr> |
692 | + <td><label for="field.licenses.7" style= |
693 | + "font-weight: normal"><input class= |
694 | + "checkboxType" id="field.licenses.7" |
695 | + name="field.licenses" type="checkbox" |
696 | + value="CC_BY_SA"> Creative Commons - |
697 | + Attribution Share Alike <a href= |
698 | + "http://creativecommons.org/about/licenses" |
699 | + class= |
700 | + "sprite external-link action-icon">view |
701 | + licence</a></label> |
702 | + </td> |
703 | + |
704 | + <td><label for="field.licenses.20" style= |
705 | + "font-weight: normal"><input class= |
706 | + "checkboxType" id="field.licenses.20" |
707 | + name="field.licenses" type="checkbox" |
708 | + value="OPEN_SOFTWARE"> Open Software |
709 | + Licence v 3.0 <a href= |
710 | + "http://www.opensource.org/licenses/osl-3.0.php" |
711 | + class= |
712 | + "sprite external-link action-icon">view |
713 | + licence</a></label> |
714 | + </td> |
715 | + </tr> |
716 | + </tbody> |
717 | + </table> |
718 | + </div> |
719 | + </div> |
720 | + |
721 | + |
722 | + <div class="collapsible" id="yui_3_5_1_1_1348577791671_121"> |
723 | + <legend class="treeCollapsed sprite" style= |
724 | + "cursor: pointer;"><a class="js-action" href="#">Other |
725 | + choices</a></legend> |
726 | + |
727 | + <div id="special" class="hidden lazr-closed" style= |
728 | + "height: 0px; overflow: hidden;"> |
729 | + <table> |
730 | + <tbody> |
731 | + <tr> |
732 | + <td><label for="field.licenses.26" style= |
733 | + "font-weight: normal"><input class= |
734 | + "checkboxType" id="field.licenses.26" |
735 | + name="field.licenses" type="checkbox" |
736 | + value="DONT_KNOW"> I don't know |
737 | + yet</label> |
738 | + </td> |
739 | + </tr> |
740 | + |
741 | + |
742 | + <tr> |
743 | + <td><label for="field.licenses.27" style= |
744 | + "font-weight: normal"><input class= |
745 | + "checkboxType" id="field.licenses.27" |
746 | + name="field.licenses" type="checkbox" |
747 | + value= |
748 | + "OTHER_PROPRIETARY"> Other/Proprietary</label> |
749 | + </td> |
750 | + </tr> |
751 | + |
752 | + |
753 | + <tr> |
754 | + <td><label for="field.licenses.28" style= |
755 | + "font-weight: normal"><input class= |
756 | + "checkboxType" id="field.licenses.28" |
757 | + name="field.licenses" type="checkbox" |
758 | + value= |
759 | + "OTHER_OPEN_SOURCE"> Other/Open |
760 | + Source</label> |
761 | + </td> |
762 | + </tr> |
763 | + </tbody> |
764 | + </table> |
765 | + </div> |
766 | + </div> |
767 | + |
768 | + |
769 | + <div id="license-details" class="hide-on-load lazr-closed" |
770 | + style="margin-top: 10px; overflow: hidden; height: 0px;"> |
771 | + <label for="field.license_info">Licence details:</label> |
772 | + |
773 | + <textarea cols="44" id="field.license_info" name= |
774 | + "field.license_info" rows="15"> |
775 | + </textarea> |
776 | + |
777 | + <p class="formHelp">Additional licence details are |
778 | + required. Please include the URL to the licence, or other |
779 | + detailed information.</p> |
780 | + </div> |
781 | + </div> |
782 | + |
783 | + |
784 | + <p>Launchpad.net is free to use for software projects that share |
785 | + their source code and comply with these <a href= |
786 | + "https://help.launchpad.net/Legal/ProjectLicensing">licensing |
787 | + policies.</a><br></p> |
788 | + |
789 | + |
790 | + <div id="proprietary" class="lazr-closed" style= |
791 | + "overflow: hidden; height: 0px;"> |
792 | + Commercial and proprietary projects do not qualify for free |
793 | + hosting; therefore a subscription needs to be purchased in |
794 | + order to host this project on Launchpad. |
795 | + |
796 | + <p>Here are the steps to obtain a commercial |
797 | + subscription:</p> |
798 | + |
799 | + |
800 | + <ol> |
801 | + <li>Purchase a Launchpad subscription in the <a href= |
802 | + "http://ubuntu.recycledmania.com/product_info.php?products_id=227"> |
803 | + Canonical Shop</a>.</li> |
804 | + |
805 | + |
806 | + <li>You will receive an email that your order has been |
807 | + processed.</li> |
808 | + |
809 | + |
810 | + <li>Then you may apply the purchased subscription to this |
811 | + project on your <a href="/~mark/+vouchers">voucher |
812 | + management page</a>.</li> |
813 | + </ol> |
814 | + <a href="mailto:commercial@launchpad.net">Contact us</a> for |
815 | + more information regarding commercial subscriptions. |
816 | + </div> |
817 | + </div> |
818 | + </div> |
819 | + </div> |
820 | + <!-- ending copied html --> |
821 | + </td> |
822 | + </tr> |
823 | + </table> |
824 | + </script> |
825 | </body> |
826 | </html> |
827 | |
828 | === modified file 'lib/lp/registry/javascript/tests/test_product_views.js' |
829 | --- lib/lp/registry/javascript/tests/test_product_views.js 2012-09-18 15:10:36 +0000 |
830 | +++ lib/lp/registry/javascript/tests/test_product_views.js 2012-09-25 15:14:24 +0000 |
831 | @@ -9,16 +9,41 @@ |
832 | tests.suite.add(new Y.Test.Case({ |
833 | name: 'registry.product-views.new_tests', |
834 | |
835 | - setUp: function () {}, |
836 | + setUp: function () { |
837 | + window.LP = { |
838 | + cache: { |
839 | + context: { |
840 | + web_link: '' |
841 | + }, |
842 | + information_type_data: { |
843 | + PUBLIC: { |
844 | + value: 'PUBLIC', name: 'Public', |
845 | + is_private: false, order: 1, |
846 | + description: 'Public Description' |
847 | + }, |
848 | + EMBARGOED: { |
849 | + value: 'EMBARGOED', name: 'Embargoed', |
850 | + is_private: true, order: 2, |
851 | + description: 'Something embargoed' |
852 | + }, |
853 | + PROPRIETARY: { |
854 | + value: 'PROPRIETARY', name: 'Proprietary', |
855 | + is_private: true, order: 3, |
856 | + description: 'Private Description' |
857 | + } |
858 | + } |
859 | + } |
860 | + }; |
861 | + |
862 | + var tpl = Y.one('#tpl_information_type'); |
863 | + var html = Y.lp.mustache.to_html(tpl.getContent()); |
864 | + Y.one('#testdom').setContent(html); |
865 | + |
866 | + }, |
867 | + |
868 | tearDown: function () { |
869 | Y.one('#testdom').empty(); |
870 | - }, |
871 | - |
872 | - _setup_url_fields: function () { |
873 | - Y.one('#testdom').setContent( |
874 | - '<input type="text" id="field.name" name="field.name" />' + |
875 | - '<input type="text" id="field.displayname" name="field.displayname" />' |
876 | - ); |
877 | + LP.cache = {}; |
878 | }, |
879 | |
880 | test_library_exists: function () { |
881 | @@ -27,7 +52,6 @@ |
882 | }, |
883 | |
884 | test_url_autofill_sync: function () { |
885 | - this._setup_url_fields(); |
886 | var view = new ns.NewProduct(); |
887 | view.render(); |
888 | |
889 | @@ -42,7 +66,6 @@ |
890 | }, |
891 | |
892 | test_url_autofill_disables: function () { |
893 | - this._setup_url_fields(); |
894 | var view = new ns.NewProduct(); |
895 | view.render(); |
896 | |
897 | @@ -66,9 +89,56 @@ |
898 | 'test2', |
899 | url_field.get('value'), |
900 | 'The url field should not be updated.'); |
901 | + }, |
902 | + |
903 | + test_information_type_widget: function () { |
904 | + // Render will give us a pretty JS choice widget. |
905 | + var view = new ns.NewProduct(); |
906 | + view.render(); |
907 | + Y.Assert.isNotNull(Y.one('#testdom .yui3-ichoicesource')); |
908 | + }, |
909 | + |
910 | + test_information_type_choose_non_public: function () { |
911 | + // Selecting an information type not-public hides the license, |
912 | + // sets it to commercial, and shows the bug supervisor and driver |
913 | + // fields. |
914 | + var view = new ns.NewProduct(); |
915 | + view.render(); |
916 | + |
917 | + var widget = view._information_type_widget; |
918 | + |
919 | + // Force the value to change to a private value and make sure the |
920 | + // UI is updated. |
921 | + widget._saveData('EMBARGOED'); |
922 | + |
923 | + var licenses = Y.one('input[name="field.licenses"]'); |
924 | + var licenses_cont = licenses.ancestor('td').ancestor('td'); |
925 | + Y.Assert.areEqual('none', |
926 | + licenses_cont.getComputedStyle('display'), |
927 | + 'License is hidden when EMBARGOED is selected.'); |
928 | + |
929 | + |
930 | + var bug_super = Y.one('input[name="field.bug_supervisor"]'); |
931 | + var bug_super_cont = bug_super.ancestor('td'); |
932 | + Y.Assert.areNotEqual( |
933 | + 'none', |
934 | + bug_super_cont.getComputedStyle('display'), |
935 | + 'Bug Supervisor is shown when EMBARGOED is selected.'); |
936 | + |
937 | + var driver = Y.one('input[name="field.driver"]'); |
938 | + var driver_cont = driver.ancestor('td'); |
939 | + Y.Assert.areNotEqual( |
940 | + 'none', |
941 | + driver_cont.getComputedStyle('display'), |
942 | + 'Driver is shown when EMBARGOED is selected.'); |
943 | + |
944 | + var new_license = Y.one('input[name="field.licenses"]'); |
945 | + Y.Assert.areEqual('OTHER_PROPRIETARY', new_license.get('value'), |
946 | + 'License is updated to a commercial selection'); |
947 | } |
948 | })); |
949 | |
950 | }, '0.1', { |
951 | - requires: ['test', 'event-simulate', 'console', 'registry.product-views'] |
952 | + requires: ['test', 'event-simulate', 'node-event-simulate', 'console', |
953 | + 'lp.mustache', 'registry.product-views'] |
954 | }); |
This branch looks fine. I have one concern though.
In lib/lp/ registry/ javascript/ tests/test_ product_ views.html, the very
large HTML template makes me worry about maintainability. Will that
have to be carefully hand maintained? Was that generated by something?
If so, can we generate it at runtime instead?