Ignore:
Timestamp:
07/16/12 16:27:40 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Selector can be clicked on whole line now.
Question editor in survey page does lazy loading per
category and displays total number of questions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/store.js

    r359 r362  
    9797                if ( query === undefined ) {
    9898                    query = '_all_docs';
    99                     queryOpts.include_docs = true;
    10099                }
    101100
     
    126125
    127126                // Custom options
    128                 if (options.key) {
     127                if (options.key !== undefined) {
    129128                    queryOpts.key = options.key;
    130                 } else if (options.keys) {
     129                } else if (options.keys !== undefined) {
    131130                    queryOpts.keys = options.keys;
    132                 } else if (options.startkey || options.endkey) {
     131                } else if (options.startkey !== undefined || options.endkey !== undefined) {
    133132                    queryOpts.startkey = options.startkey;
    134133                    queryOpts.endkey = options.endkey;
     134                }
     135                if (options.include_docs !== undefined) {
     136                    queryOpts.include_docs = options.include_docs;
     137                }
     138                if (options.reduce !== undefined) {
     139                    queryOpts.reduce = options.reduce;
     140                }
     141                if (options.group !== undefined) {
     142                    queryOpts.group = options.group;
     143                    if (options.group_level !== undefined) {
     144                        queryOpts.group_level = options.group_level;
     145                    }
    135146                }
    136147
     
    152163                        dfd.resolve(
    153164                            array.map(result.rows,
    154                                       function(result){ return result.value; }));
     165                                      function(result){
     166                                          return [result.key, options.include_docs === true ? result.doc : result.value];
     167                                      }));
    155168                    }
    156169                },function(err){
    157170                    dfd.reject(err);
    158171                });
    159                         return QueryResults(dfd.promise);
     172                        return CouchResults(dfd.promise);
    160173            }
    161174        });
    162175
     176        function CouchResults(results) {
     177            if (!results) {
     178                return results;
     179            }
     180
     181                if(results.then){
     182                        results = lang.delegate(results);
     183                }
     184
     185            if (!results.forEach) {
     186                results.forEach = function(callback) {
     187                    return Deferred.when(results, function(results) {
     188                        array.forEach(results, function(result) {
     189                            callback(result[1],result[0]);
     190                        });
     191                    });
     192                }
     193            }
     194
     195            return results;
     196        }
     197
    163198        return new CouchStore({target: 'data/rft/'});
    164199
Note: See TracChangeset for help on using the changeset viewer.