You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by benkeen <gi...@git.apache.org> on 2014/11/11 21:53:12 UTC
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
GitHub user benkeen opened a pull request:
https://github.com/apache/couchdb-fauxton/pull/145
Add Option tray now uses generic component
To test this, just click on the Add Option header link on the Config page. Should work as before.
Closes COUCHDB-2453
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/benkeen/couchdb-fauxton 2453-add-option-tray-update
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb-fauxton/pull/145.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #145
----
commit 73a80bff5f6347aaeb789ea6f1a8080a66a0398f
Author: Benjamin Keen <be...@gmail.com>
Date: 2014-11-11T20:50:39Z
Add Option tray now uses generic component
To test this, just click on the Add Option header link on the
Config page.
Closes COUCHDB-2453
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#issuecomment-62922729
Thanks @robertkowalski!
Yeah, I do see your point... I just wish it could be made explicit that the `toggleTrayBtnSelector` had special meaning to the parent View so you wouldn't have to look up the Components.Tray code to understand it. I tend to favour landing on the side of code clarity, even if does mean a little more code.
But point taken. Since that'll require a (small) refactor of all the trays, I'll create a follow-up ticket to this one that cleans it up across the board. :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#discussion_r20426295
--- Diff: app/addons/config/views.js ---
@@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) {
});
- Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
+ Views.AddConfigOptionsButton = Components.Tray.extend({
template: 'addons/config/templates/add_config_option',
events: {
- 'click #add-new-section': 'toggleTray',
'click #js-create-config-section': 'createConfigOption'
},
initialize: function () {
- var hideTray = _.bind(this.hideTray, this),
- trayVisible = _.bind(this.trayVisible, this);
-
- $('body').on('click.add-new-section', function(e) {
- var $clickEl = $(e.target);
-
- if (!trayVisible()) { return; }
- if ($clickEl.closest('.add-new-section').length) { return; }
- if (!$clickEl.closest('.add-section-tray').length) {
- hideTray();
- }
- });
- },
-
- cleanup: function () {
- $('body').off('click.add-new-section');
+ this.initTray({ toggleTrayBtnSelector: '#add-new-section' });
--- End diff --
Hey @benkeen I really like this code reuse. But I also really dislike the `initTray` idea.
I think you can do something like [this instead](https://github.com/apache/couchdb-fauxton/blob/master/assets/js/plugins/cloudant.pagingcollection.js#L54-L72). That way you can pass in the `toggleTrayBtnSelector` on standard construction and not have to have another method to initialize.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#discussion_r20283214
--- Diff: app/addons/config/views.js ---
@@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) {
});
- Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
+ Views.AddConfigOptionsButton = Components.Tray.extend({
template: 'addons/config/templates/add_config_option',
events: {
- 'click #add-new-section': 'toggleTray',
'click #js-create-config-section': 'createConfigOption'
},
initialize: function () {
- var hideTray = _.bind(this.hideTray, this),
- trayVisible = _.bind(this.trayVisible, this);
-
- $('body').on('click.add-new-section', function(e) {
- var $clickEl = $(e.target);
-
- if (!trayVisible()) { return; }
- if ($clickEl.closest('.add-new-section').length) { return; }
- if (!$clickEl.closest('.add-section-tray').length) {
- hideTray();
- }
- });
- },
-
- cleanup: function () {
- $('body').off('click.add-new-section');
+ this.initTray({ toggleTrayBtnSelector: '#add-new-section' });
--- End diff --
still not a big fan of calling a custom-built constructor instead of just passing the options to the extend, like in every other backbone application. main reason is that it is a custom-workaround where there is already a solution provided by the framework and every backbone-dev which is coming from another application has to learn that we build our own custom constructors/initialize
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#discussion_r20452262
--- Diff: app/addons/config/views.js ---
@@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) {
});
- Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
+ Views.AddConfigOptionsButton = Components.Tray.extend({
template: 'addons/config/templates/add_config_option',
events: {
- 'click #add-new-section': 'toggleTray',
'click #js-create-config-section': 'createConfigOption'
},
initialize: function () {
- var hideTray = _.bind(this.hideTray, this),
- trayVisible = _.bind(this.trayVisible, this);
-
- $('body').on('click.add-new-section', function(e) {
- var $clickEl = $(e.target);
-
- if (!trayVisible()) { return; }
- if ($clickEl.closest('.add-new-section').length) { return; }
- if (!$clickEl.closest('.add-section-tray').length) {
- hideTray();
- }
- });
- },
-
- cleanup: function () {
- $('body').off('click.add-new-section');
+ this.initTray({ toggleTrayBtnSelector: '#add-new-section' });
--- End diff --
Hey @garrensmith, thanks! That looks promising, but I don't quite follow... When you say passing that value on standard construction, do you mean whatever code is instantiating the Tray instance (e.g. `Views.AddConfigOptionsButton`)? Since the selector is particular to that particular View, I wouldn't want whatever code is instantiating it to have to know about it to pass it along with the Views.AddConfigOptionsButton instantiation, you know?
I'll cc @robertkowalski on this because we were chatting about it too. :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#issuecomment-62928197
Merged as 6434324157fca8b908ae641a415c181383b7de8f
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by benkeen <gi...@git.apache.org>.
Github user benkeen closed the pull request at:
https://github.com/apache/couchdb-fauxton/pull/145
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#discussion_r20572927
--- Diff: app/addons/config/views.js ---
@@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) {
});
- Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
+ Views.AddConfigOptionsButton = Components.Tray.extend({
template: 'addons/config/templates/add_config_option',
events: {
- 'click #add-new-section': 'toggleTray',
'click #js-create-config-section': 'createConfigOption'
},
initialize: function () {
- var hideTray = _.bind(this.hideTray, this),
- trayVisible = _.bind(this.trayVisible, this);
-
- $('body').on('click.add-new-section', function(e) {
- var $clickEl = $(e.target);
-
- if (!trayVisible()) { return; }
- if ($clickEl.closest('.add-new-section').length) { return; }
- if (!$clickEl.closest('.add-section-tray').length) {
- hideTray();
- }
- });
- },
-
- cleanup: function () {
- $('body').off('click.add-new-section');
+ this.initTray({ toggleTrayBtnSelector: '#add-new-section' });
--- End diff --
Yes thats what I mean. Thanks @robertkowalski
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#discussion_r20572822
--- Diff: app/addons/config/views.js ---
@@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) {
});
- Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
+ Views.AddConfigOptionsButton = Components.Tray.extend({
template: 'addons/config/templates/add_config_option',
events: {
- 'click #add-new-section': 'toggleTray',
'click #js-create-config-section': 'createConfigOption'
},
initialize: function () {
- var hideTray = _.bind(this.hideTray, this),
- trayVisible = _.bind(this.trayVisible, this);
-
- $('body').on('click.add-new-section', function(e) {
- var $clickEl = $(e.target);
-
- if (!trayVisible()) { return; }
- if ($clickEl.closest('.add-new-section').length) { return; }
- if (!$clickEl.closest('.add-section-tray').length) {
- hideTray();
- }
- });
- },
-
- cleanup: function () {
- $('body').off('click.add-new-section');
+ this.initTray({ toggleTrayBtnSelector: '#add-new-section' });
--- End diff --
I think @garrensmith means something like `new NiceView({ customSelector : '.foo' })` with passing a value to standard construction.
The `.apply(arguments)` in the example will then take care of that in the `constructor`. Another example from the Backbone docs is http://backbonejs.org/#Model-constructor
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb-fauxton pull request: Add Option tray now uses generic com...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb-fauxton/pull/145#issuecomment-62873432
I outlined my thoughts to the `initTray` in detail after thinking a bit about it - but I am +1 regarding the change in general, so feel free to merge it :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---