sismics / docs

Lightweight document management system packed with all the features you can expect from big expensive solutions
https://teedy.io
GNU General Public License v2.0
1.98k stars 489 forks source link

Document title typeahead results #744

Open terba opened 10 months ago

terba commented 10 months ago

The results for the document title typeahead search are most of the time not what I was expecting. So I changed the sort order to descending, the sort column to 3 and the limit to 10 in DocumentEdit.js. It is much better now, as it offers the latest documents matching the typed text.

  /**
   * Returns a promise for typeahead title.
   */
  $scope.getTitleTypeahead = function($viewValue) {
    var deferred = $q.defer();
    Restangular.one('document/list')
    .get({
      limit: 10,
      sort_column: 3,
      asc: false,
      search: $viewValue
    }).then(function(data) {
      deferred.resolve(_.uniq(_.pluck(data.documents, 'title'), true));
    });
    return deferred.promise;
  };