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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to