Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/644#discussion_r52728899
--- Diff: app/addons/documents/sidebar/stores.js ---
@@ -42,62 +54,89 @@ function (app, FauxtonAPI, ActionTypes) {
},
getDatabase: function () {
- if (this.isLoading()) {return {};}
-
+ if (this.isLoading()) {
+ return {};
+ }
return this._database;
},
- toggleContent: function (designDoc, index) {
+ // used to toggle both design docs, and any index groups within them
+ toggleContent: function (designDoc, indexGroup) {
if (!this._toggledSections[designDoc]) {
this._toggledSections[designDoc] = {
visible: true,
- indexes: {}
+ indexGroups: {}
};
return;
}
- if (index) {
- return this.toggleIndex(designDoc, index);
+ if (indexGroup) {
+ return this.toggleIndexGroup(designDoc, indexGroup);
}
this._toggledSections[designDoc].visible =
!this._toggledSections[designDoc].visible;
},
- toggleIndex: function (designDoc, indexName) {
- var index = this._toggledSections[designDoc].indexes[indexName];
+ toggleIndexGroup: function (designDoc, indexGroup) {
+ var expanded =
this._toggledSections[designDoc].indexGroups[indexGroup];
- if (_.isUndefined(index)) {
- this._toggledSections[designDoc].indexes[indexName] = true;
+ if (_.isUndefined(expanded)) {
+ this._toggledSections[designDoc].indexGroups[indexGroup] = true;
return;
}
- this._toggledSections[designDoc].indexes[indexName] = !index;
+ this._toggledSections[designDoc].indexGroups[indexGroup] = !expanded;
},
- isVisible: function (designDoc, index) {
+ isVisible: function (designDoc, indexGroup) {
if (!this._toggledSections[designDoc]) {
return false;
}
-
- if (index) {
- return this._toggledSections[designDoc].indexes[index];
+ if (indexGroup) {
+ return this._toggledSections[designDoc].indexGroups[indexGroup];
}
-
return this._toggledSections[designDoc].visible;
},
- setSelectedTab: function (tab) {
- this._selectedTab = tab;
+ getSelected: function () {
+ return this._selected;
},
- getDatabaseName: function () {
- if (this.isLoading()) { return '';}
+ setSelected: function (params) {
+ this._selected = {
+ navItem: params.navItem,
+ designDocName: params.designDocName,
+ designDocSection: params.designDocSection,
+ indexName: params.indexName
+ };
+
+ if (params.designDocName) {
+ if (!_.has(this._toggledSections, params.designDocName)) {
+ this._toggledSections[params.designDocName] = { visible: true,
indexGroups: {} };
+ }
+ this._toggledSections[params.designDocName].visible = true;
+
+ if (params.designDocSection) {
+
this._toggledSections[params.designDocName].indexGroups[params.designDocSection]
= true;
+ }
+ }
+ },
+
+ getToggledSections: function () {
+ return this._toggledSections;
+ },
+ getDatabaseName: function () {
+ if (this.isLoading()) {
+ return '';
+ }
return this._database.safeID();
},
--- End diff --
maybe make the model have an property called
`this._database.safeId` which is a string, and until it is populated an
empty string
or a variation:
`this._database.name`
don't like the fact that we pass the model to the view and the view calls
getter on the model, if the view thinks it has finished loading.
---
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.
---