launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12335
[Merge] lp:~rharding/launchpad/clean_information_type into lp:launchpad
Richard Harding has proposed merging lp:~rharding/launchpad/clean_information_type into lp:launchpad.
Commit message:
Clean naming in information_type js.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rharding/launchpad/clean_information_type/+merge/125755
I just wanted to stop typing information_type a few more times so renamed methods that are already namespaced.
--
https://code.launchpad.net/~rharding/launchpad/clean_information_type/+merge/125755
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rharding/launchpad/clean_information_type into lp:launchpad.
=== modified file 'lib/lp/app/javascript/information_type.js'
--- lib/lp/app/javascript/information_type.js 2012-09-21 02:51:51 +0000
+++ lib/lp/app/javascript/information_type.js 2012-09-21 15:43:20 +0000
@@ -24,7 +24,7 @@
* @param lp_client
* @param validate_change
*/
-ns.save_information_type = function(widget, initial_value, value,
+ns.save = function(widget, initial_value, value,
lp_client, context,
subscribers_list, validate_change) {
var error_handler = new Y.lp.client.FormErrorHandler();
@@ -35,12 +35,12 @@
error_handler.handleError = function(ioId, response) {
if( response.status === 400
&& response.statusText === 'Bug Visibility') {
- ns._confirm_information_type_change(
+ ns._confirm_change(
widget, initial_value, lp_client, context,
subscribers_list);
return true;
}
- var orig_value = ns.information_type_value_from_key(
+ var orig_value = ns.get_cache_data_from_key(
context.information_type, 'name', 'value');
widget.set('value', orig_value);
widget._showFailed();
@@ -78,7 +78,7 @@
{
result_data = Y.JSON.parse(response.responseText);
}
- ns.information_type_save_success(
+ ns.save_success(
widget, context, value, subscribers_list, result_data);
Y.lp.client.display_notifications(
response.getResponseHeader('X-Lazr-Notifications'));
@@ -89,17 +89,16 @@
lp_client.io_provider.io(submit_url, config);
};
-var get_information_type_banner_text = function(value) {
+var get_banner_text = function(value) {
var text_template = "This page contains {info_type} information.";
- var info_type = ns.information_type_value_from_key(value, 'value', 'name');
+ var info_type = ns.get_cache_data_from_key(value, 'value', 'name');
return Y.Lang.sub(text_template, {'info_type': info_type});
};
-ns.information_type_save_success = function(widget, context, value,
- subscribers_list,
- subscribers_data) {
+ns.save_success = function(widget, context, value, subscribers_list,
+ subscribers_data) {
context.information_type =
- ns.information_type_value_from_key(value, 'value', 'name');
+ ns.get_cache_data_from_key(value, 'value', 'name');
ns.update_privacy_banner(value);
widget._showSucceeded();
if (Y.Lang.isObject(subscribers_data)) {
@@ -129,13 +128,12 @@
* @param lp_client
* @private
*/
-ns._confirm_information_type_change = function(widget, initial_value,
- lp_client, context,
- subscribers_list) {
+ns._confirm_change = function(widget, initial_value, lp_client, context,
+ subscribers_list) {
var value = widget.get('value');
var do_save = function() {
ns.update_privacy_portlet(value);
- ns.save_information_type(
+ ns.save(
widget, initial_value, value, lp_client, context, subscribers_list,
false);
};
@@ -154,7 +152,7 @@
' <strong>Please confirm you really want to do this.</strong>',
'</p>'
].join('');
- var title = ns.information_type_value_from_key(value, 'value', 'name');
+ var title = ns.get_cache_data_from_key(value, 'value', 'name');
var confirm_text = Y.Lang.sub(confirm_text_template,
{information_type: title});
var co = new Y.lp.app.confirmationoverlay.ConfirmationOverlay({
@@ -170,14 +168,13 @@
co.show();
};
-ns.setup_information_type_choice = function(privacy_link, lp_client,
- context, subscribers_list,
- skip_anim) {
+ns.setup_choice = function(privacy_link, lp_client, context, subscribers_list,
+ skip_anim) {
skip_animation = skip_anim;
- var initial_value = ns.information_type_value_from_key(
+ var initial_value = ns.get_cache_data_from_key(
context.information_type, 'name', 'value');
var information_type_value = Y.one('#information-type');
- var choice_list = ns.information_type_to_choicesource(
+ var choice_list = ns.cache_to_choicesource(
LP.cache.information_type_data);
var information_type_edit = new Y.ChoiceSource({
@@ -195,7 +192,7 @@
information_type_edit.on("save", function(e) {
var value = information_type_edit.get('value');
ns.update_privacy_portlet(value);
- ns.save_information_type(
+ ns.save(
information_type_edit, initial_value, value, lp_client, context,
subscribers_list, true);
});
@@ -214,7 +211,7 @@
* @param value_property_name the value property name
* @return {*}
*/
-ns.information_type_value_from_key = function(cache_value,
+ns.get_cache_data_from_key = function(cache_value,
cache_field,
data_field) {
var cache = LP.cache.information_type_data;
@@ -226,7 +223,15 @@
};
-ns.information_type_to_choicesource = function (cache) {
+/**
+ * The LP.cache for information type data is an object and needs to be sent to
+ * the choicesource as a list of ordered data.
+ *
+ * @function cache_to_choicesource
+ * @param {Object}
+ *
+ */
+ns.cache_to_choicesource = function (cache) {
var data = [];
for (var key in cache) {
data.push(cache[key]);
@@ -242,7 +247,7 @@
* @param value
*/
ns.update_privacy_portlet = function(value) {
- var description = ns.information_type_value_from_key(
+ var description = ns.get_cache_data_from_key(
value, 'value', 'description');
var desc_node = Y.one('#information-type-description');
if (Y.Lang.isValue(desc_node)) {
@@ -268,7 +273,7 @@
var private_type = LP.cache.information_type_data[value].is_private;
if (private_type) {
body.replaceClass('public', 'private');
- var banner_text = get_information_type_banner_text(value);
+ var banner_text = get_banner_text(value);
privacy_banner.updateText(banner_text);
privacy_banner.show();
} else {
=== modified file 'lib/lp/app/javascript/tests/test_information_type.js'
--- lib/lp/app/javascript/tests/test_information_type.js 2012-09-13 18:27:34 +0000
+++ lib/lp/app/javascript/tests/test_information_type.js 2012-09-21 15:43:20 +0000
@@ -74,7 +74,7 @@
makeWidget: function() {
var privacy_link = Y.one('#privacy-link');
- this.widget = ns.setup_information_type_choice(
+ this.widget = ns.setup_choice(
privacy_link, this.lp_client, LP.cache.bug, null, true);
},
@@ -100,11 +100,11 @@
},
// The save XHR call works as expected.
- test_save_information_type: function() {
+ test_save: function() {
this.makeWidget();
- var orig_save_success = ns.information_type_save_success;
+ var orig_save_success = ns.save_success;
var save_success_called = false;
- ns.information_type_save_success = function(widget, context, value,
+ ns.save_success = function(widget, context, value,
subscribers_list,
subscribers_data) {
Y.Assert.areEqual('USERDATA', value);
@@ -114,7 +114,7 @@
'value', subscribers_data.cache_data.item);
save_success_called = true;
};
- ns.save_information_type(
+ ns.save(
this.widget, 'PUBLIC', 'USERDATA', this.lp_client,
LP.cache.bug, null, true);
this.mockio.success({
@@ -129,11 +129,11 @@
'field.validate_change=on',
this.mockio.last_request.config.data);
Y.Assert.isTrue(save_success_called);
- ns.information_type_save_success = orig_save_success;
+ ns.save_success = orig_save_success;
},
// Setting a private type shows the privacy banner.
- test_information_type_save_success_private: function() {
+ test_save_success_private: function() {
this.makeWidget();
var old_func = this._shim_privacy_banner();
var hide_flag = false;
@@ -145,7 +145,7 @@
update_flag = true;
});
- ns.information_type_save_success(this.widget, LP.cache.bug,
+ ns.save_success(this.widget, LP.cache.bug,
'PROPRIETARY');
var body = Y.one('body');
Y.Assert.isTrue(body.hasClass('private'));
@@ -157,7 +157,7 @@
},
// Setting a public type hides the privacy banner.
- test_information_type_save_success_public: function() {
+ test_save_success_public: function() {
this.makeWidget();
var old_func = this._shim_privacy_banner();
var flag = false;
@@ -167,7 +167,7 @@
var summary = Y.one('#information-type-summary');
summary.replaceClass('public', 'private');
- ns.information_type_save_success(this.widget, 'PUBLIC', 'PUBLIC');
+ ns.save_success(this.widget, 'PUBLIC', 'PUBLIC');
var body = Y.one('body');
Y.Assert.isTrue(body.hasClass('public'));
Y.Assert.isTrue(flag);
@@ -176,7 +176,7 @@
},
// A successful save updates the subscribers portlet.
- test_information_type_save_success_with_subscribers_data: function() {
+ test_save_success_with_subscribers_data: function() {
this.makeWidget();
var old_func = this._shim_privacy_banner();
var flag = false;
@@ -200,7 +200,7 @@
item2: 'value2'
}
};
- ns.information_type_save_success(
+ ns.save_success(
this.widget, LP.cache.bug, 'PUBLIC', subscribers_list,
subscribers_data);
Y.Assert.isTrue(load_subscribers_called);
@@ -237,9 +237,9 @@
this.makeWidget();
// The confirmation popup should be shown so stub out the save
// method and check the behaviour.
- var orig_save_information_type = ns.save_information_type;
+ var orig_save = ns.save;
var function_called = false;
- ns.save_information_type =
+ ns.save =
function(widget, initial_value, value, lp_client,
context, subscribers_list, validate_change) {
// We only care if the function is called with
@@ -260,7 +260,7 @@
var summary = Y.one('#information-type-summary');
Y.Assert.isTrue(summary.hasClass('private'));
Y.Assert.isTrue(function_called);
- ns.save_information_type = orig_save_information_type;
+ ns.save = orig_save;
},
// Selecting a new private information type shows the
@@ -269,9 +269,9 @@
this._assert_save_with_validation_error();
// The confirmation popup should be shown so stub out the save
// method and check the behaviour.
- var orig_save_information_type = ns.save_information_type;
+ var orig_save = ns.save;
var function_called = false;
- ns.save_information_type =
+ ns.save =
function(widget, initial_value, value, lp_client,
context, subscribers_list, validate_change) {
// We only care if the function is called with
@@ -291,14 +291,14 @@
var summary = Y.one('#information-type-summary');
Y.Assert.isFalse(summary.hasClass('private'));
Y.Assert.isFalse(function_called);
- ns.save_information_type = orig_save_information_type;
+ ns.save = orig_save;
},
// Test error handling when a save fails.
test_information_type_save_error: function() {
this.makeWidget();
this.widget.set('value', 'USERDATA');
- ns.save_information_type(
+ ns.save(
this.widget, 'PUBLIC', 'USERDATA', this.lp_client,
LP.cache.bug);
this.mockio.last_request.respond({
=== modified file 'lib/lp/blueprints/javascript/addspec.js'
--- lib/lp/blueprints/javascript/addspec.js 2012-09-19 16:11:37 +0000
+++ lib/lp/blueprints/javascript/addspec.js 2012-09-21 15:43:20 +0000
@@ -9,7 +9,7 @@
YUI.add('lp.blueprints.addspec', function(Y) {
var namespace = Y.namespace('lp.blueprints.addspec');
-var to_choice = Y.lp.app.information_type.information_type_to_choicesource;
+var to_choice = Y.lp.app.information_type.cache_to_choicesource;
namespace.set_up = function () {
var choice_data = to_choice(LP.cache.information_type_data);
=== modified file 'lib/lp/bugs/javascript/bugtask_index.js'
--- lib/lp/bugs/javascript/bugtask_index.js 2012-09-21 02:51:51 +0000
+++ lib/lp/bugs/javascript/bugtask_index.js 2012-09-21 15:43:20 +0000
@@ -52,7 +52,7 @@
var sub_list_node = Y.one('#other-bug-subscribers');
var subscribers_list = sub_list_node.getData(
'subscribers_loader');
- Y.lp.app.information_type.setup_information_type_choice(
+ Y.lp.app.information_type.setup_choice(
privacy_link, lp_client, LP.cache.bug, subscribers_list);
}
setup_add_attachment();
=== modified file 'lib/lp/bugs/javascript/filebug.js'
--- lib/lp/bugs/javascript/filebug.js 2012-09-13 16:56:54 +0000
+++ lib/lp/bugs/javascript/filebug.js 2012-09-21 15:43:20 +0000
@@ -98,7 +98,7 @@
'importance', LP.cache.bugtask_importance_data);
var cache = LP.cache.information_type_data;
var information_helpers = Y.lp.app.information_type
- var choices = information_helpers.information_type_to_choicesource(cache)
+ var choices = information_helpers.cache_to_choicesource(cache)
Y.lp.app.choice.addPopupChoiceForRadioButtons(
'information_type', choices, true);
=== modified file 'lib/lp/code/javascript/branch.information_type_choice.js'
--- lib/lp/code/javascript/branch.information_type_choice.js 2012-09-13 17:07:00 +0000
+++ lib/lp/code/javascript/branch.information_type_choice.js 2012-09-21 15:43:20 +0000
@@ -22,7 +22,7 @@
if (!Y.Lang.isValue(this.privacy_link)) {
return;
}
- var initial_value = information_type.information_type_value_from_key(
+ var initial_value = information_type.get_cache_data_from_key(
LP.cache.context.information_type, 'name', 'value');
var information_type_value = Y.one('#information-type');
this.information_type_edit = new Y.ChoiceSource({
@@ -31,7 +31,7 @@
value_location: information_type_value,
value: initial_value,
title: "Change information type",
- items: information_type.information_type_to_choicesource(
+ items: information_type.cache_to_choicesource(
LP.cache.information_type_data
),
backgroundColor: '#FFFF99',
@@ -66,7 +66,7 @@
Y.one('#information-type'), error_msg);
};
error_handler.handleError = function() {
- var orig_value = information_type.information_type_value_from_key(
+ var orig_value = information_type.get_cache_data_from_key(
LP.cache.context.information_type, 'name', 'value');
widget.set('value', orig_value);
if (that.get('use_animation')) {
@@ -103,7 +103,7 @@
_information_type_save_success: function(value) {
LP.cache.context.information_type =
- information_type.information_type_value_from_key(
+ information_type.get_cache_data_from_key(
value, 'value', 'name');
information_type.update_privacy_banner(value);
if (this.get('use_animation')) {
Follow ups