You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by robertkowalski <gi...@git.apache.org> on 2015/04/07 18:56:55 UTC

[GitHub] couchdb-fauxton pull request: Part 2/2 for Mango:

GitHub user robertkowalski opened a pull request:

    https://github.com/apache/couchdb-fauxton/pull/362

    Part 2/2 for Mango:

    Adds search functionality, makes the feature visible and enables
    deletion of mango-created-indexes.
    
    closes COUCHDB-2627

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/robertkowalski/couchdb-fauxton mango-editor

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-fauxton/pull/362.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 #362
    
----
commit 7f659b5ffe59044f2ea6b0c3edaa50e60f702b33
Author: Robert Kowalski <ro...@apache.org>
Date:   2015-04-01T11:11:15Z

    Part 2/2 for Mango:
    
    Adds search functionality, makes the feature visible and enables
    deletion of mango-created-indexes.
    
    closes COUCHDB-2627

----


---
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: Part 2/2 for Mango:

Posted by michellephung <gi...@git.apache.org>.
Github user michellephung commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#discussion_r30534904
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +137,68 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var selector,
    +          header;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +
    +        header = MangoHelper.getIndexName(doc);
    +
             return {
    -          content: this.getDocContent(doc),
    -          id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          content: this.getMangoDocContent(doc),
    +          header: header,
    +          id: doc.getId(),
    +          keylabel: '',
    --- End diff --
    
    actually i see it might be helpful to be consistent so it matches the objects


---
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: Part 2/2 for Mango:

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/362#discussion_r28773683
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +132,74 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var header = [],
    +          selector,
    +          indexes;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +        header = doc.get('def').fields.reduce(function (acc, el) {
    +          acc.push(Object.keys(el)[0]);
    +          return acc;
    +        }, []);
    +
    +        if (!header.length) {
    +          indexes = FauxtonAPI.getExtensions('mango:additionalIndexes')[0];
    +          header = indexes.createHeader(doc);
    +        }
    +
             return {
    -          content: this.getDocContent(doc),
    +          content: this.getMangoDocContent(doc),
    +          header: header.join(', '),
               id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          keylabel: '',
               url: doc.isFromView() ? doc.url('app') : doc.url('web-index'),
               isDeletable: this.isDeletable(doc),
               isEditable: this.isEditable(doc)
             };
    -      }, this);
    +      }
    +
    +      // we filtered away our content with the fields param
    +      return {
    +        content: ' ',
    +        header: header.join(', '),
    +        id: this.getDocId(doc) + index,
    +        keylabel: '',
    +        url: this.isEditable(doc) ? doc.url('app') : null,
    +        isDeletable: this.isDeletable(doc),
    +        isEditable: this.isEditable(doc)
    +      };
    +
    +    },
    +
    +    getResults: function () {
    +      return this._collection
    +        .filter(function (doc) {
    +          return doc.get('language') !== 'query';
    +        })
    +        .map(function (doc, i) {
    +          if (doc.get('def') || !Object.keys(doc.attributes).length) {
    --- End diff --
    
    Sadly it is not that easy and i would keep it like this (after some additional refactoring)
    
    We have many different collections in this store (mangoIndexResults, AllDocs/Docs, MangoIndexes).
    
    I just took a look how I could move that method to the corresponding collections. Many menthods called in the code that I would have to move to the collection is implemented in this store and depends on state in this store, e.g. `this.isCollapsed`.
    
    Don't say it is impossible but it would be a major refactor of this store which I would like to avoid in this PR for the mango feature.
    
    Maybe we should decide on moving away from collections completely and just use stores for our state/data-layer instead of mixing both collections and stores.


---
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: Part 2/2 for Mango:

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103571018
  
    > Repeating the same index name in "Available Indexes" is okay?
    
    yes, you created the second one, the first one is the special index "all_docs" which is additionally undeletable


---
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: Part 2/2 for Mango:

Posted by michellephung <gi...@git.apache.org>.
Github user michellephung commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-94512554
  
    +1



---
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: Part 2/2 for Mango:

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/362#discussion_r28761654
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +132,74 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var header = [],
    +          selector,
    +          indexes;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +        header = doc.get('def').fields.reduce(function (acc, el) {
    +          acc.push(Object.keys(el)[0]);
    +          return acc;
    +        }, []);
    +
    +        if (!header.length) {
    +          indexes = FauxtonAPI.getExtensions('mango:additionalIndexes')[0];
    +          header = indexes.createHeader(doc);
    +        }
    +
             return {
    -          content: this.getDocContent(doc),
    +          content: this.getMangoDocContent(doc),
    +          header: header.join(', '),
               id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          keylabel: '',
               url: doc.isFromView() ? doc.url('app') : doc.url('web-index'),
               isDeletable: this.isDeletable(doc),
               isEditable: this.isEditable(doc)
             };
    -      }, this);
    +      }
    +
    +      // we filtered away our content with the fields param
    +      return {
    +        content: ' ',
    +        header: header.join(', '),
    +        id: this.getDocId(doc) + index,
    +        keylabel: '',
    +        url: this.isEditable(doc) ? doc.url('app') : null,
    +        isDeletable: this.isDeletable(doc),
    +        isEditable: this.isEditable(doc)
    +      };
    +
    +    },
    +
    +    getResults: function () {
    +      return this._collection
    +        .filter(function (doc) {
    +          return doc.get('language') !== 'query';
    +        })
    +        .map(function (doc, i) {
    +          if (doc.get('def') || !Object.keys(doc.attributes).length) {
    --- End diff --
    
    Is it possible to move this onto a function on the doc, something like `getMangoDoc`?


---
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: Part 2/2 for Mango:

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-94487990
  
    @garrensmith added pagination etc...


---
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: Part 2/2 for Mango:

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103476983
  
    > Also if I edit the query but don't click run. Instead I press the '<' then I get a modal asking me am I sure I should leave the page.
    
    that is a feature all our editors share - if you change the query / document / map function and don't save/run it it will ask you if you are sure to leave...


---
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: Part 2/2 for Mango:

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/362#discussion_r27974839
  
    --- Diff: app/addons/documents/index-results/actions.js ---
    @@ -71,7 +71,49 @@ function (app, FauxtonAPI, ActionTypes, Stores, HeaderStores, HeaderActions, Doc
           });
         },
     
    +    newMangoResultsList: function (options) {
    +      FauxtonAPI.dispatch({
    +        type: ActionTypes.INDEX_RESULTS_NEW_RESULTS,
    +        options: options
    +      });
    +    },
    +
    +    runMangoFindQuery: function (options) {
    +      var query = JSON.parse(options.queryCode),
    +          collection = indexResultsStore.getCollection();
    +
    +      this.clearResults();
    +
    +      return collection
    +        .runQuery(options.queryCode)
    +        .then(function () {
    +          this.resultsListReset();
    +          this.newMangoResultsList({
    +            collection: collection,
    +            isListDeletable: indexResultsStore.isListDeletable(),
    +            query: options.queryCode,
    +            typeOfIndex: 'mango',
    +            textEmptyIndex: 'No Results Found!',
    +            bulkCollection: Documents.BulkDeleteDocCollection
    +          });
    +        }.bind(this), function (res) {
    +          FauxtonAPI.addNotification({
    +            msg: res.reason,
    +            clear:  true,
    +            type: 'error'
    +          });
    +
    +          this.resultsListReset();
    +        }.bind(this));
    +    },
    +
         reloadResultsList: function () {
    +      if (indexResultsStore.getTypeOfIndex() === 'mango') {
    +        return this.runMangoFindQuery({
    --- End diff --
    
    i wish i could!
    
    problem is that it is called internally from our bulkDeleteAction: https://github.com/robertkowalski/couchdb-fauxton/blob/mango-editor/app/addons/documents/index-results/actions.js#L168


---
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: Part 2/2 for Mango:

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103567538
  
    +1 nice work. 


---
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: Part 2/2 for Mango:

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-94713530
  
    @robertkowalski this looks great. One thing I've noticed is if I select __All Mango Indexes__ then the header for databases says Indexes and the cog disappears.


---
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: Part 2/2 for Mango:

Posted by michellephung <gi...@git.apache.org>.
Github user michellephung commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#discussion_r30534473
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +137,68 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var selector,
    +          header;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +
    +        header = MangoHelper.getIndexName(doc);
    +
             return {
    -          content: this.getDocContent(doc),
    -          id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          content: this.getMangoDocContent(doc),
    +          header: header,
    +          id: doc.getId(),
    +          keylabel: '',
    --- End diff --
    
    (the `keylabel:''` line)


---
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: Part 2/2 for Mango:

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103597425
  
    merged as 425fc9b


---
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: Part 2/2 for Mango:

Posted by michellephung <gi...@git.apache.org>.
Github user michellephung commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103579014
  
    +1 on the code and being able to delete documents from the query!! :D :+1: 
    
    although it's working,  it's still a bit unclear how it's supposed to work. Maybe we can make some documentation of a specific example for people to understand better. 


---
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: Part 2/2 for Mango:

Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103570121
  
    Repeating the same index name is okay?
    
    ![double-index](https://cloud.githubusercontent.com/assets/512116/7707868/0e9c7e36-fe07-11e4-9e1e-6daca982b2b9.png)



---
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: Part 2/2 for Mango:

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/362#discussion_r27958049
  
    --- Diff: app/addons/documents/resources.js ---
    @@ -254,6 +339,24 @@ function (app, FauxtonAPI, Documents, PagingCollection) {
         }
       });
     
    +  Documents.MangoBulkDeleteDocCollection = Documents.BulkDeleteDocCollection.extend({
    +    url: function () {
    +      return app.host + '/' + this.databaseId + '/_index/_bulk_delete';
    +    },
    +
    +    createPayload: function (documents) {
    +      var documentList = documents.map(function (doc) {
    +        return '_design/' + doc._id;
    +      });
    +
    +      console.log(documentList);
    --- End diff --
    
    oh debug code


---
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: Part 2/2 for Mango:

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/362#discussion_r28761880
  
    --- Diff: app/addons/documents/mango/mango.components.react.jsx ---
    @@ -121,35 +277,39 @@ function (app, FauxtonAPI, React, Stores, Actions, ReactComponents) {
             return;
           }
     
    -      this.clearNotifications();
    +      this.getMangoEditor().clearNotifications();
     
           Actions.saveQuery({
             database: this.state.database,
    -        queryCode: this.refs.indexQueryEditor.getValue()
    +        queryCode: this.getMangoEditor().getEditorValue()
           });
         }
       });
     
       var Views = {
    -    renderHelpScreen: function (el) {
    +    renderQueryEditor: function (el) {
           React.render(
    -        <HelpScreen title={app.i18n.en_US['mango-help-title']} />,
    +        <MangoQueryEditorController
    +          description={app.i18n.en_US['mango-descripton']}
    +          editorTitle={app.i18n.en_US['mango-title-editor']}
    +          additionalIndexesText={app.i18n.en_US['mango-additional-indexes-heading']} />,
             el
           );
         },
    -    removeHelpScreen: function (el) {
    +    removeQueryEditor: function (el) {
           React.unmountComponentAtNode(el);
         },
         renderMangoIndexEditor: function (el) {
    --- End diff --
    
    Can you update all of these render functions to the new supported `setComponent` in the RouteObjects.


---
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: Part 2/2 for Mango:

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103445865
  
    @robertkowalski this is looking good. Two issue's on the Run a Mango Query. If I edit the query before the list of indexes I have loads then the query is reset. Also if I edit the query but don't click run. Instead I press the '<' then I get a modal asking me am I sure I should leave the page.


---
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: Part 2/2 for Mango:

Posted by michellephung <gi...@git.apache.org>.
Github user michellephung commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#discussion_r30533751
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +137,68 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var selector,
    +          header;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +
    +        header = MangoHelper.getIndexName(doc);
    +
             return {
    -          content: this.getDocContent(doc),
    -          id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          content: this.getMangoDocContent(doc),
    +          header: header,
    +          id: doc.getId(),
    +          keylabel: '',
    --- End diff --
    
    can we take this out?


---
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: Part 2/2 for Mango:

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/362#discussion_r27958293
  
    --- Diff: app/addons/documents/index-results/actions.js ---
    @@ -71,7 +71,49 @@ function (app, FauxtonAPI, ActionTypes, Stores, HeaderStores, HeaderActions, Doc
           });
         },
     
    +    newMangoResultsList: function (options) {
    +      FauxtonAPI.dispatch({
    +        type: ActionTypes.INDEX_RESULTS_NEW_RESULTS,
    +        options: options
    +      });
    +    },
    +
    +    runMangoFindQuery: function (options) {
    +      var query = JSON.parse(options.queryCode),
    +          collection = indexResultsStore.getCollection();
    +
    +      this.clearResults();
    +
    +      return collection
    +        .runQuery(options.queryCode)
    +        .then(function () {
    +          this.resultsListReset();
    +          this.newMangoResultsList({
    +            collection: collection,
    +            isListDeletable: indexResultsStore.isListDeletable(),
    +            query: options.queryCode,
    +            typeOfIndex: 'mango',
    +            textEmptyIndex: 'No Results Found!',
    +            bulkCollection: Documents.BulkDeleteDocCollection
    +          });
    +        }.bind(this), function (res) {
    +          FauxtonAPI.addNotification({
    +            msg: res.reason,
    +            clear:  true,
    +            type: 'error'
    +          });
    +
    +          this.resultsListReset();
    +        }.bind(this));
    +    },
    +
         reloadResultsList: function () {
    +      if (indexResultsStore.getTypeOfIndex() === 'mango') {
    +        return this.runMangoFindQuery({
    --- End diff --
    
    Maybe split this into its own method called `reloadMangoResultsList`


---
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: Part 2/2 for Mango:

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/362#discussion_r27958448
  
    --- Diff: app/addons/documents/resources.js ---
    @@ -254,6 +339,24 @@ function (app, FauxtonAPI, Documents, PagingCollection) {
         }
       });
     
    +  Documents.MangoBulkDeleteDocCollection = Documents.BulkDeleteDocCollection.extend({
    +    url: function () {
    +      return app.host + '/' + this.databaseId + '/_index/_bulk_delete';
    +    },
    +
    +    createPayload: function (documents) {
    +      var documentList = documents.map(function (doc) {
    +        return '_design/' + doc._id;
    +      });
    +
    +      console.log(documentList);
    --- End diff --
    
    debug code


---
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: Part 2/2 for Mango:

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/362#discussion_r28776697
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +132,74 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var header = [],
    +          selector,
    +          indexes;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +        header = doc.get('def').fields.reduce(function (acc, el) {
    +          acc.push(Object.keys(el)[0]);
    +          return acc;
    +        }, []);
    +
    +        if (!header.length) {
    +          indexes = FauxtonAPI.getExtensions('mango:additionalIndexes')[0];
    +          header = indexes.createHeader(doc);
    +        }
    +
             return {
    -          content: this.getDocContent(doc),
    +          content: this.getMangoDocContent(doc),
    +          header: header.join(', '),
               id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          keylabel: '',
               url: doc.isFromView() ? doc.url('app') : doc.url('web-index'),
               isDeletable: this.isDeletable(doc),
               isEditable: this.isEditable(doc)
             };
    -      }, this);
    +      }
    +
    +      // we filtered away our content with the fields param
    +      return {
    +        content: ' ',
    +        header: header.join(', '),
    +        id: this.getDocId(doc) + index,
    +        keylabel: '',
    +        url: this.isEditable(doc) ? doc.url('app') : null,
    +        isDeletable: this.isDeletable(doc),
    +        isEditable: this.isEditable(doc)
    +      };
    +
    +    },
    +
    +    getResults: function () {
    +      return this._collection
    +        .filter(function (doc) {
    +          return doc.get('language') !== 'query';
    +        })
    +        .map(function (doc, i) {
    +          if (doc.get('def') || !Object.keys(doc.attributes).length) {
    --- End diff --
    
    Ok thats fine. Thanks for trying.. I agree with moving away from collections.


---
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: Part 2/2 for Mango:

Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103571441
  
    Ah okay, thanks @robertkowalski - I wasn't clear on what that meant. Other than the missing radio (not clear on that either), looks good. +1


---
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: Part 2/2 for Mango:

Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103569239
  
    One curious thing, when I add I create a new Mango index, the page show two items - the first of which doesn't have an option to select it. See screenshot: 
    
    ![create-mango-index](https://cloud.githubusercontent.com/assets/512116/7707811/97feee44-fe06-11e4-802f-b210b07e579e.png)
    
    [Also, should be a space before the "?" on the Index label :) ]


---
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: Part 2/2 for Mango:

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-95147985
  
    +1 nice work.


---
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: Part 2/2 for Mango:

Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski closed the pull request at:

    https://github.com/apache/couchdb-fauxton/pull/362


---
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: Part 2/2 for Mango:

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/362#discussion_r28761603
  
    --- Diff: app/addons/documents/index-results/stores.js ---
    @@ -96,17 +132,74 @@ function (FauxtonAPI, ActionTypes, HeaderActionTypes, Documents) {
           return '';
         },
     
    -    getResults: function () {
    -      return this._collection.map(function (doc) {
    +    getMangoDocContent: function (originalDoc) {
    +      var doc = originalDoc.toJSON();
    +
    +      delete doc.ddoc;
    +      delete doc.name;
    +
    +      return this.isCollapsed(originalDoc.id) ? '' : JSON.stringify(doc, null, ' ');
    +    },
    +
    +    getMangoDoc: function (doc, index) {
    +      var header = [],
    +          selector,
    +          indexes;
    +
    +      if (doc.get('def') && doc.get('def').fields) {
    +        header = doc.get('def').fields.reduce(function (acc, el) {
    +          acc.push(Object.keys(el)[0]);
    +          return acc;
    +        }, []);
    +
    +        if (!header.length) {
    +          indexes = FauxtonAPI.getExtensions('mango:additionalIndexes')[0];
    +          header = indexes.createHeader(doc);
    +        }
    +
             return {
    -          content: this.getDocContent(doc),
    +          content: this.getMangoDocContent(doc),
    +          header: header.join(', '),
               id: this.getDocId(doc),
    -          keylabel: doc.isFromView() ? 'key' : 'id',
    +          keylabel: '',
               url: doc.isFromView() ? doc.url('app') : doc.url('web-index'),
               isDeletable: this.isDeletable(doc),
               isEditable: this.isEditable(doc)
             };
    -      }, this);
    +      }
    +
    +      // we filtered away our content with the fields param
    +      return {
    +        content: ' ',
    +        header: header.join(', '),
    +        id: this.getDocId(doc) + index,
    +        keylabel: '',
    +        url: this.isEditable(doc) ? doc.url('app') : null,
    +        isDeletable: this.isDeletable(doc),
    +        isEditable: this.isEditable(doc)
    +      };
    +
    +    },
    +
    +    getResults: function () {
    +      return this._collection
    +        .filter(function (doc) {
    --- End diff --
    
    If you break this into a separate function it would make it a lot clearer. Something like `getMangoDocsFromCollection`


---
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: Part 2/2 for Mango:

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-90874750
  
    This is looking good. Tests are failing though 


---
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: Part 2/2 for Mango:

Posted by benkeen <gi...@git.apache.org>.
Github user benkeen commented on the pull request:

    https://github.com/apache/couchdb-fauxton/pull/362#issuecomment-103566176
  
    - there should be a space after the "Mango Query" label and the "?" icon
    - the default mango query uses 2-spaces, but Ace's default behaviour is tabs (e.g. click ENTER - it'll automatically indent using a tab). Bit of an annoyance. 


---
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: Part 2/2 for Mango:

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/362#discussion_r28761814
  
    --- Diff: app/addons/documents/mango/mango.actions.js ---
    @@ -41,18 +55,54 @@ function (app, FauxtonAPI, Documents, ActionTypes, Stores, IndexResultsActions)
           });
     
           mangoIndex.save().then(function (res) {
    -        var msg = res.result === 'created' ? 'Index created' : 'Index already exits',
    -            url = FauxtonAPI.urls('mango', 'index-app', options.database.safeID());
    +        var msg = res.result === 'created' ? 'Index created.' : 'Index already exits.',
    +            url = FauxtonAPI.urls('mango', 'query-app', options.database.safeID());
     
             FauxtonAPI.addNotification({
    -          msg:  msg,
    +          msg:  msg + ' Redirect to search...',
               type: 'success',
               clear: true
             });
     
    -        IndexResultsActions.reloadResultsList();
    +        FauxtonAPI.dispatch({
    +          type: ActionTypes.MANGO_NEW_QUERY_FIND_CODE_FROM_FIELDS,
    +          options: {
    +            fields: queryCode.index.fields
    +          }
    +        });
    +
    +        window.setTimeout(function () {
    +          FauxtonAPI.navigate(url);
    +          FauxtonAPI.addNotification({
    +            msg:  'Feel free to search now.',
    --- End diff --
    
    Maybe we should say something like `Index is ready for querying` or `Index is ready` or something like that. I'm not sure `Feel free to search now.` is the correct tone.


---
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.
---