launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12395
[Merge] lp:~rharding/launchpad/regjs into lp:launchpad
Richard Harding has proposed merging lp:~rharding/launchpad/regjs into lp:launchpad with lp:~rharding/launchpad/clean_information_type as a prerequisite.
Commit message:
Add UI updates during project registration based on type of information type chosen.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rharding/launchpad/regjs/+merge/125780
= 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_views.html
--
https://code.launchpad.net/~rharding/launchpad/regjs/+merge/125780
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rharding/launchpad/regjs into lp:launchpad.
=== modified file 'lib/lp/app/javascript/choice.js'
--- lib/lp/app/javascript/choice.js 2012-09-19 16:11:37 +0000
+++ lib/lp/app/javascript/choice.js 2012-09-24 14:25:28 +0000
@@ -160,7 +160,7 @@
* @param cfg
*/
namespace.addPopupChoiceForRadioButtons = function(field_name, choices, cfg) {
- if (!choices) {
+ if (!choices || choices.length === 0) {
throw 'No choices for the popup.';
}
cfg = Y.merge(default_popup_choice_config, cfg);
=== added file 'lib/lp/app/javascript/tests/test_choice.html'
--- lib/lp/app/javascript/tests/test_choice.html 1970-01-01 00:00:00 +0000
+++ lib/lp/app/javascript/tests/test_choice.html 2012-09-24 14:25:28 +0000
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<!--
+Copyright 2012 Canonical Ltd. This software is licensed under the
+GNU Affero General Public License version 3 (see the file LICENSE).
+-->
+
+<html>
+ <head>
+ <title>app.choice Tests</title>
+
+ <!-- YUI and test setup -->
+ <script type="text/javascript"
+ src="../../../../../build/js/yui/yui/yui.js">
+ </script>
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/console/assets/console-core.css" />
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/console/assets/skins/sam/console.css" />
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/test/assets/skins/sam/test.css" />
+
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/testing/testrunner.js"></script>
+ <script type="text/javascript"
+ src="../../../../build/js/lp/app/testing/helpers.js"></script>
+
+ <link rel="stylesheet" href="../../../app/javascript/testing/test.css" />
+
+ <!-- The module under test. -->
+ <script type="text/javascript" src="../choice.js"></script>
+
+ <!-- The test suite -->
+ <script type="text/javascript" src="test_choice.js"></script>
+
+ </head>
+ <body class="yui3-skin-sam">
+ <ul id="suites">
+ <li>lp.app.choice.test</li>
+ </ul>
+ </body>
+</html>
=== added file 'lib/lp/app/javascript/tests/test_choice.js'
--- lib/lp/app/javascript/tests/test_choice.js 1970-01-01 00:00:00 +0000
+++ lib/lp/app/javascript/tests/test_choice.js 2012-09-24 14:25:28 +0000
@@ -0,0 +1,84 @@
+/* Copyright (c) 2012 Canonical Ltd. All rights reserved. */
+
+YUI.add('lp.app.choice.test', function (Y) {
+
+ // Shortcut to the namespace we're testing against.
+ var choice = Y.namespace('lp.app.choice');
+
+ var tests = Y.namespace('lp.app.choice.test');
+ tests.suite = new Y.Test.Suite('app.choice Tests');
+
+ tests.suite.add(new Y.Test.Case({
+ name: 'app.choice_tests',
+
+ test_library_exists: function () {
+ Y.Assert.isObject(Y.lp.app.choice,
+ "Could not locate the lp.app.choice module");
+ }
+ }));
+
+
+ tests.suite.add(new Y.Test.Case({
+ name: 'radio_popup_choice',
+
+ _should: {
+ error: {
+ test_error_undefined_data: true,
+ test_error_empty_array: true
+ }
+ },
+
+ setUp: function () {
+ window.LP = {
+ cache: {
+ context: {
+ web_link: ''
+ },
+ information_type_data: {
+ PUBLIC: {
+ value: 'PUBLIC', name: 'Public',
+ is_private: false, order: 1,
+ description: 'Public Description'
+ },
+ PUBLICSECURITY: {
+ value: 'PUBLICSECURITY', name: 'Public Security',
+ is_private: false, order: 2,
+ description: 'Public Security Description'
+ },
+ PROPRIETARY: {
+ value: 'PROPRIETARY', name: 'Proprietary',
+ is_private: true, order: 3,
+ description: 'Private Description'
+ },
+ USERDATA: {
+ value: 'USERDATA', name: 'Private',
+ is_private: true, order: 4,
+ description: 'Private Description'
+ }
+ }
+ }
+ };
+ },
+
+ tearDown: function () {
+ window.LP = {};
+ },
+
+ test_error_undefined_data: function () {
+ // An exception should be raised if you create a button with
+ // undefined options.
+ choice.addPopupChoiceForRadioButtons('information_type',
+ undefined);
+ },
+
+ test_error_empty_array: function () {
+ // An exception should be raised if you create a button with no
+ // options.
+ choice.addPopupChoiceForRadioButtons('information_type',
+ []);
+ }
+ }));
+
+}, '0.1', {
+ requires: ['test', 'console', 'lp.app.choice']
+});
=== modified file 'lib/lp/registry/javascript/product_views.js'
--- lib/lp/registry/javascript/product_views.js 2012-09-18 15:10:36 +0000
+++ lib/lp/registry/javascript/product_views.js 2012-09-24 14:25:28 +0000
@@ -8,6 +8,8 @@
*/
YUI.add('registry.product-views', function (Y) {
var ns = Y.namespace('registry.views');
+ var info_type = Y.lp.app.information_type;
+ var COMMERCIAL_LICENSE = "OTHER_PROPRIETARY";
/**
* Handle setting up the JS for the new project View
@@ -29,12 +31,28 @@
/**
* Process binding the UI for the information type choice widget.
*
- * @method _bind_information-type
+ * @method _bind_information_type
* @private
*/
_bind_information_type: function () {
- Y.lp.app.choice.addPopupChoiceForRadioButtons(
- 'information_type', LP.cache.information_type_data, true);
+ var that = this;
+ var widget = Y.lp.app.choice.addPopupChoiceForRadioButtons(
+ 'information_type',
+ info_type.cache_to_choicesource(
+ LP.cache.information_type_data));
+
+ // When the information type changes, check if we should show/hide
+ // UI components.
+ widget.on('save', function (ev) {
+ that._information_type_change(ev.target.get('value'));
+ });
+
+ // And on first render, the information type is PUBLIC.
+ that._information_type_change('PUBLIC');
+
+ // Hold onto the reference to the information type widget so we
+ // can test with it.
+ this._information_type_widget = widget;
},
/**
@@ -171,6 +189,45 @@
},
/**
+ * Update the UI when the information type changes.
+ *
+ * @method _information_type_change
+ * @param {String} information_type value
+ *
+ */
+ _information_type_change: function (value) {
+ var driver_cont = Y.one('input[name="field.driver"]').ancestor('td');
+ var bug_super_cont = Y.one('input[name="field.bug_supervisor"]').ancestor('td');
+
+ // The license code is nested in another table.
+ var license = Y.one('input[name="field.licenses"]');
+ var license_cont = license.ancestor('td').ancestor('td');
+
+ if (info_type.get_cache_data_from_key(value, 'value',
+ 'is_private')) {
+ // Hide the driver and bug supervisor fields.
+ driver_cont.show();
+ bug_super_cont.show();
+
+ // Hide the license field and set it to commercial.
+ license_cont.hide();
+
+ // We have to set both checked and the value because value is
+ // a DOM object property, but the UI is updated based on the
+ // 'checked' attribute.
+ var commercial = 'input[value="' + COMMERCIAL_LICENSE + '"]';
+ Y.one(commercial).set('checked', 'checked');
+ license.set('value', COMMERCIAL_LICENSE);
+ } else {
+ driver_cont.hide();
+ bug_super_cont.hide();
+
+ // Show the license field.
+ license_cont.show();
+ }
+ },
+
+ /**
* Handle the reveals when there are search results.
*
* @method _show_separator
@@ -365,5 +422,6 @@
});
}, '0.1', {
- 'requires': ['base', 'node', 'lp.ui.effects', 'lp.app.choice']
+ 'requires': ['base', 'node', 'lp.ui.effects', 'lp.app.choice',
+ 'lp.ui.choiceedit', 'lp.app.information_type']
});
=== modified file 'lib/lp/registry/javascript/tests/test_product_views.html'
--- lib/lp/registry/javascript/tests/test_product_views.html 2012-09-18 15:10:36 +0000
+++ lib/lp/registry/javascript/tests/test_product_views.html 2012-09-24 14:25:28 +0000
@@ -30,7 +30,9 @@
<script type="text/javascript" src="../../../../../build/js/lp/app/ellipsis.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/expander.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/errors.js"></script>
+ <script type="text/javascript" src="../../../../../build/js/lp/app/information_type.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/lp.js"></script>
+ <script type="text/javascript" src="../../../../../build/js/lp/app/mustache.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/anim/anim.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/extras/extras.js"></script>
<script type="text/javascript" src="../../../../../build/js/lp/app/choiceedit/choiceedit.js"></script>
@@ -54,5 +56,184 @@
<li>registry.product-views.test</li>
</ul>
<div id="testdom"></div>
+
+ <script id="tpl_information_type" type="text/template">
+ <table>
+ <tr>
+ <td>
+ <input type="text" id="field.name" name="field.name" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="text" id="field.displayname" name="field.displayname" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div>
+ <label for="field.information_type">Information Type:</label>
+ </div>
+ <table class="radio-button-widget">
+ <tbody>
+ <tr>
+ <td rowspan="2">
+ <input class="radioType" id="field.information_type.0" name="field.information_type" type="radio" value="PUBLIC"/>
+ </td>
+ <td>
+ <label for="field.information_type.0">Public</label>
+ </td>
+ </tr>
+ <tr>
+ <td class="formHelp">Everyone can see this information.</td>
+ </tr>
+ <tr>
+ <td rowspan="2">
+ <input class="radioType" id="field.information_type.1" name="field.information_type" type="radio" value="PUBLICSECURITY" /> </td>
+ <td>
+ <label for="field.information_type.1">Public Security</label>
+ </td>
+ </tr>
+ <tr>
+ <td class="formHelp">Everyone can see this security related information.</td>
+ </tr>
+ <tr>
+ <td rowspan="2">
+ <input class="radioType" id="field.information_type.2" name="field.information_type" type="radio" value="PRIVATESECURITY" /> </td>
+ <td>
+ <label for="field.information_type.2">Private Security</label>
+ </td>
+ </tr>
+ <tr>
+ <td class="formHelp">Only the security group can see this information.</td>
+ </tr>
+ <tr>
+ <td rowspan="2">
+ <input class="radioType" id="field.information_type.3" name="field.information_type" type="radio" value="USERDATA" />
+ </td>
+ <td><label for="field.information_type.3">Private</label></td>
+ </tr>
+ <tr>
+ <td class="formHelp">Only shared with users permitted to see private user information.</td>
+ </tr>
+ <tr>
+ <td rowspan="2">
+ <input class="radioType" id="field.information_type.4" name="field.information_type" type="radio" value="PROPRIETARY" />
+ </td>
+ <td><label for="field.information_type.4">Proprietary</label></td>
+ </tr>
+ <tr>
+ <td class="formHelp">Only shared with users permitted to see proprietary information.</td>
+ </tr>
+ <tr>
+ <td rowspan="2">
+ <input class="radioType" id="field.information_type.5" name="field.information_type" type="radio" value="EMBARGOED" />
+ </td>
+ <td><label for="field.information_type.5">Embargoed</label></td>
+ </tr>
+ <tr>
+ <td class="formHelp">Only shared with users permitted to see embargoed information.</td>
+ </tr>
+ </tbody>
+ </table>
+ <input name="field.information_type-empty-marker" type="hidden" value="1" />
+ <p class="formHelp">The type of of data contained in this project.</p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="text" name="field.driver" id="field.driver" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="text" name="field.bug_supervisor" id="field.bug_supervisor" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="pending-div" style="padding-left: 20px">
+ <div class="collapsible" id="yui_3_3_0_1_134824396501461">
+ <legend class="treeExpanded sprite" style="cursor: pointer;"><a class="js-action" href="#">Recommended open source licences</a></legend>
+ <div id="recommended" class="expanded lazr-closed" style="height: auto; overflow: hidden;"><table id="yui_3_3_0_1_1348243965014257">
+ <tbody id="yui_3_3_0_1_1348243965014256"><tr id="yui_3_3_0_1_1348243965014255">
+ <td id="yui_3_3_0_1_1348243965014252"><label for="field.licenses.1" style="font-weight: normal" id="yui_3_3_0_1_1348243965014251"><input class="checkboxType" id="field.licenses.1" name="field.licenses" type="checkbox" value="APACHE"> Apache Licence <a href="http://www.opensource.org/licenses/apache2.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.11" style="font-weight: normal"><input class="checkboxType" id="field.licenses.11" name="field.licenses" type="checkbox" value="AFFERO"> GNU Affero GPL v3 <a href="http://www.opensource.org/licenses/agpl-v3.html" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.15" style="font-weight: normal"><input class="checkboxType" id="field.licenses.15" name="field.licenses" type="checkbox" value="GNU_LGPL_V2_1"> GNU LGPL v2.1 <a href="http://www.opensource.org/licenses/lgpl-2.1.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.4" style="font-weight: normal"><input class="checkboxType" id="field.licenses.4" name="field.licenses" type="checkbox" value="BSD"> Simplified BSD Licence <a href="http://www.opensource.org/licenses/bsd-license.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.13" style="font-weight: normal"><input class="checkboxType" id="field.licenses.13" name="field.licenses" type="checkbox" value="GNU_GPL_V2"> GNU GPL v2 <a href="http://www.opensource.org/licenses/gpl-2.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.16" style="font-weight: normal"><input class="checkboxType" id="field.licenses.16" name="field.licenses" type="checkbox" value="GNU_LGPL_V3"> GNU LGPL v3 <a href="http://www.opensource.org/licenses/lgpl-3.0.html" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.8" style="font-weight: normal"><input class="checkboxType" id="field.licenses.8" name="field.licenses" type="checkbox" value="CC_0"> Creative Commons - No Rights Reserved <a href="http://creativecommons.org/about/cc0" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.14" style="font-weight: normal"><input class="checkboxType" id="field.licenses.14" name="field.licenses" type="checkbox" value="GNU_GPL_V3"> GNU GPL v3 <a href="http://www.opensource.org/licenses/gpl-3.0.html" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.17" style="font-weight: normal"><input class="checkboxType" id="field.licenses.17" name="field.licenses" type="checkbox" value="MIT"> MIT / X / Expat Licence <a href="http://www.opensource.org/licenses/mit-license.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ </tbody></table></div>
+ </div>
+
+ <div class="collapsible" id="yui_3_3_0_1_134824396501493">
+ <legend class="treeCollapsed sprite" style="cursor: pointer;"><a class="js-action" href="#">More open source licences</a></legend>
+ <div id="more" class="hidden lazr-closed" style="height: 0px; overflow: hidden;"><table>
+ <tbody><tr>
+ <td><label for="field.licenses.0" style="font-weight: normal"><input class="checkboxType" id="field.licenses.0" name="field.licenses" type="checkbox" value="ACADEMIC"> Academic Free Licence <a href="http://www.opensource.org/licenses/afl-3.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.9" style="font-weight: normal"><input class="checkboxType" id="field.licenses.9" name="field.licenses" type="checkbox" value="ECLIPSE"> Eclipse Public Licence <a href="http://www.opensource.org/licenses/eclipse-1.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.22" style="font-weight: normal"><input class="checkboxType" id="field.licenses.22" name="field.licenses" type="checkbox" value="PHP"> PHP Licence <a href="http://www.opensource.org/licenses/php.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.2" style="font-weight: normal"><input class="checkboxType" id="field.licenses.2" name="field.licenses" type="checkbox" value="ARTISTIC"> Artistic Licence 1.0 <a href="http://opensource.org/licenses/artistic-license-1.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.10" style="font-weight: normal"><input class="checkboxType" id="field.licenses.10" name="field.licenses" type="checkbox" value="EDUCATIONAL_COMMUNITY"> Educational Community Licence <a href="http://www.opensource.org/licenses/ecl2.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.23" style="font-weight: normal"><input class="checkboxType" id="field.licenses.23" name="field.licenses" type="checkbox" value="PUBLIC_DOMAIN"> Public Domain <a href="https://answers.launchpad.net/launchpad/+faq/564" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.3" style="font-weight: normal"><input class="checkboxType" id="field.licenses.3" name="field.licenses" type="checkbox" value="ARTISTIC_2_0"> Artistic Licence 2.0 <a href="http://www.opensource.org/licenses/artistic-license-2.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.12" style="font-weight: normal"><input class="checkboxType" id="field.licenses.12" name="field.licenses" type="checkbox" value="GNU_GFDL_NO_OPTIONS"> GNU GFDL no options <a href="http://www.gnu.org/copyleft/fdl.html" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.24" style="font-weight: normal"><input class="checkboxType" id="field.licenses.24" name="field.licenses" type="checkbox" value="PYTHON"> Python Licence <a href="http://www.opensource.org/licenses/PythonSoftFoundation.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.5" style="font-weight: normal"><input class="checkboxType" id="field.licenses.5" name="field.licenses" type="checkbox" value="COMMON_PUBLIC"> Common Public Licence <a href="http://www.opensource.org/licenses/cpl1.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.18" style="font-weight: normal"><input class="checkboxType" id="field.licenses.18" name="field.licenses" type="checkbox" value="MPL"> Mozilla Public Licence <a href="http://www.opensource.org/licenses/mozilla1.1.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.25" style="font-weight: normal"><input class="checkboxType" id="field.licenses.25" name="field.licenses" type="checkbox" value="ZPL"> Zope Public Licence <a href="http://www.opensource.org/licenses/zpl.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.6" style="font-weight: normal"><input class="checkboxType" id="field.licenses.6" name="field.licenses" type="checkbox" value="CC_BY"> Creative Commons - Attribution <a href="http://creativecommons.org/about/licenses" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.19" style="font-weight: normal"><input class="checkboxType" id="field.licenses.19" name="field.licenses" type="checkbox" value="OFL"> Open Font Licence v1.1 <a href="http://scripts.sil.org/OFL" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.7" style="font-weight: normal"><input class="checkboxType" id="field.licenses.7" name="field.licenses" type="checkbox" value="CC_BY_SA"> Creative Commons - Attribution Share Alike <a href="http://creativecommons.org/about/licenses" class="sprite external-link action-icon">view licence</a></label> </td>
+ <td><label for="field.licenses.20" style="font-weight: normal"><input class="checkboxType" id="field.licenses.20" name="field.licenses" type="checkbox" value="OPEN_SOFTWARE"> Open Software Licence v 3.0 <a href="http://www.opensource.org/licenses/osl-3.0.php" class="sprite external-link action-icon">view licence</a></label> </td>
+ </tr>
+ </tbody></table></div>
+ </div>
+
+
+ <div class="collapsible" id="yui_3_3_0_1_1348243965014121">
+ <legend class="treeCollapsed sprite" style="cursor: pointer;"><a class="js-action" href="#">Other choices</a></legend>
+ <div id="special" class="hidden lazr-closed" style="height: 0px; overflow: hidden;"><table>
+ <tbody><tr>
+ <td><label for="field.licenses.26" style="font-weight: normal"><input class="checkboxType" id="field.licenses.26" name="field.licenses" type="checkbox" value="DONT_KNOW"> I don't know yet</label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.27" style="font-weight: normal"><input class="checkboxType" id="field.licenses.27" name="field.licenses" type="checkbox" value="OTHER_PROPRIETARY"> Other/Proprietary</label> </td>
+ </tr>
+ <tr>
+ <td><label for="field.licenses.28" style="font-weight: normal"><input class="checkboxType" id="field.licenses.28" name="field.licenses" type="checkbox" value="OTHER_OPEN_SOURCE"> Other/Open Source</label> </td>
+ </tr>
+ </tbody></table></div>
+ </div>
+ <div id="license-details" class="hide-on-load lazr-closed" style="margin-top: 10px; overflow: hidden; height: 0px;">
+ <label for="field.license_info">Licence details:</label>
+ <textarea cols="44" id="field.license_info" name="field.license_info" rows="15"></textarea>
+ <p class="formHelp">Additional licence details are required.
+ Please include the URL to the licence, or other
+ detailed information.</p>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </script>
</body>
</html>
=== modified file 'lib/lp/registry/javascript/tests/test_product_views.js'
--- lib/lp/registry/javascript/tests/test_product_views.js 2012-09-18 15:10:36 +0000
+++ lib/lp/registry/javascript/tests/test_product_views.js 2012-09-24 14:25:28 +0000
@@ -9,16 +9,41 @@
tests.suite.add(new Y.Test.Case({
name: 'registry.product-views.new_tests',
- setUp: function () {},
+ setUp: function () {
+ window.LP = {
+ cache: {
+ context: {
+ web_link: ''
+ },
+ information_type_data: {
+ PUBLIC: {
+ value: 'PUBLIC', name: 'Public',
+ is_private: false, order: 1,
+ description: 'Public Description'
+ },
+ EMBARGOED: {
+ value: 'EMBARGOED', name: 'Embargoed',
+ is_private: true, order: 2,
+ description: 'Something embargoed'
+ },
+ PROPRIETARY: {
+ value: 'PROPRIETARY', name: 'Proprietary',
+ is_private: true, order: 3,
+ description: 'Private Description'
+ }
+ }
+ }
+ };
+
+ var tpl = Y.one('#tpl_information_type');
+ var html = Y.lp.mustache.to_html(tpl.getContent());
+ Y.one('#testdom').setContent(html);
+
+ },
+
tearDown: function () {
Y.one('#testdom').empty();
- },
-
- _setup_url_fields: function () {
- Y.one('#testdom').setContent(
- '<input type="text" id="field.name" name="field.name" />' +
- '<input type="text" id="field.displayname" name="field.displayname" />'
- );
+ LP.cache = {};
},
test_library_exists: function () {
@@ -27,7 +52,6 @@
},
test_url_autofill_sync: function () {
- this._setup_url_fields();
var view = new ns.NewProduct();
view.render();
@@ -42,7 +66,6 @@
},
test_url_autofill_disables: function () {
- this._setup_url_fields();
var view = new ns.NewProduct();
view.render();
@@ -66,9 +89,56 @@
'test2',
url_field.get('value'),
'The url field should not be updated.');
+ },
+
+ test_information_type_widget: function () {
+ // Render will give us a pretty JS choice widget.
+ var view = new ns.NewProduct();
+ view.render();
+ Y.Assert.isNotNull(Y.one('#testdom .yui3-ichoicesource'));
+ },
+
+ test_information_type_choose_non_public: function () {
+ // Selecting an information type not-public hides the license,
+ // sets it to commercial, and shows the bug supervisor and driver
+ // fields.
+ var view = new ns.NewProduct();
+ view.render();
+
+ var widget = view._information_type_widget;
+
+ // Force the value to change to a private value and make sure the
+ // UI is updated.
+ widget._saveData('EMBARGOED');
+
+ var licenses = Y.one('input[name="field.licenses"]');
+ var licenses_cont = licenses.ancestor('td').ancestor('td');
+ Y.Assert.areEqual('none',
+ licenses_cont.getComputedStyle('display'),
+ 'License is hidden when EMBARGOED is selected.');
+
+
+ var bug_super = Y.one('input[name="field.bug_supervisor"]');
+ var bug_super_cont = bug_super.ancestor('td');
+ Y.Assert.areNotEqual(
+ 'none',
+ bug_super_cont.getComputedStyle('display'),
+ 'Bug Supervisor is shown when EMBARGOED is selected.');
+
+ var driver = Y.one('input[name="field.driver"]');
+ var driver_cont = driver.ancestor('td');
+ Y.Assert.areNotEqual(
+ 'none',
+ driver_cont.getComputedStyle('display'),
+ 'Driver is shown when EMBARGOED is selected.');
+
+ var new_license = Y.one('input[name="field.licenses"]');
+ Y.Assert.areEqual('OTHER_PROPRIETARY', new_license.get('value'),
+ 'License is updated to a commercial selection');
}
}));
}, '0.1', {
- requires: ['test', 'event-simulate', 'console', 'registry.product-views']
+ requires: ['test', 'event-simulate', 'node-event-simulate', 'console',
+ 'lp.mustache', 'registry.product-views']
});
Follow ups