Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/230#discussion_r23400037
--- Diff: app/addons/documents/views.js ---
@@ -564,15 +591,79 @@ function(app, FauxtonAPI, Components, Documents,
Databases, Views, QueryOptions)
this.toggleTrash();
this.maybeHighlightAllButton();
+ this.updateExpandButtonLabel();
},
perPage: function () {
return this.allDocsNumber.perPage();
+ },
+
+ // a bit dense, but necessary. It decides on what the Expand/Collapse
button label should be and takes into
+ // account the default expand/collapse state, what rows are checked
and their states
+ updateExpandButtonLabel: function () {
+
+ if (this.defaultDocsStateExpanded) {
+ this.setExpandButtonLabel(false);
+
+ // override the default label and show "Expand" if ALL checked
rows have state === collapse (false)
+ if (this.numSelectedOnPage() &&
this.allCheckedRowsHaveState(false)) {
+ this.setExpandButtonLabel(true);
+ }
+ } else {
+ this.setExpandButtonLabel(true); // default show "Expand"
+
+ // show "Collapse" if ALL checked rows have state === expanded
(true)
+ if (this.numSelectedOnPage() &&
this.allCheckedRowsHaveState(true)) {
+ this.setExpandButtonLabel(false);
+ }
+ }
+ },
+
+ setExpandButtonLabel: function(expanded) {
+ if (expanded) {
+ this.$('#collapse').html('<i class="icon-plus"></i> Expand');
--- End diff --
What do you suggest here? So I removed the actual rendering of the
#collapse element entirely out of the template and into this function here. I
could change it to use a View instead (much nicer)? But I do need it to be
separate from the rest of the template.
Honestly, w.r.t. React, I'm going to want to refactor a LOT of this code,
so I wasn't too worried about
---
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 [email protected] or file a JIRA ticket
with INFRA.
---