couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garrensmith <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Part 2/2 for Mango:
Date Tue, 21 Apr 2015 13:26:27 GMT
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.
---

Mime
View raw message