mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Autocomplete on document title edition
This commit is contained in:
parent
210f0dcc27
commit
05683ef81e
@ -1,4 +1,3 @@
|
|||||||
- Autocomplete on document title (client/server)
|
|
||||||
- List opened sessions and ability to close them (client/server)
|
- List opened sessions and ability to close them (client/server)
|
||||||
- Display logs (client)
|
- Display logs (client)
|
||||||
- Reordering files and add new files to the end (server)
|
- Reordering files and add new files to the end (server)
|
||||||
|
@ -14,6 +14,23 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
|
|||||||
$scope.alerts.splice(index, 1);
|
$scope.alerts.splice(index, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise for typeahead title.
|
||||||
|
*/
|
||||||
|
$scope.getTitleTypeahead = function($viewValue) {
|
||||||
|
var deferred = $q.defer();
|
||||||
|
Restangular.one('document')
|
||||||
|
.getList('list', {
|
||||||
|
limit: 5,
|
||||||
|
sort_column: 1,
|
||||||
|
asc: true,
|
||||||
|
search: $viewValue
|
||||||
|
}).then(function(data) {
|
||||||
|
deferred.resolve(_.pluck(data.documents, 'title'));
|
||||||
|
});
|
||||||
|
return deferred.promise;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if in edit mode (false in add mode).
|
* Returns true if in edit mode (false in add mode).
|
||||||
*/
|
*/
|
||||||
@ -38,6 +55,8 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
|
|||||||
$scope.edit = function() {
|
$scope.edit = function() {
|
||||||
var promise = null;
|
var promise = null;
|
||||||
var document = angular.copy($scope.document);
|
var document = angular.copy($scope.document);
|
||||||
|
|
||||||
|
// Transform date to timestamp
|
||||||
if (document.create_date instanceof Date) {
|
if (document.create_date instanceof Date) {
|
||||||
document.create_date = document.create_date.getTime();
|
document.create_date = document.create_date.getTime();
|
||||||
}
|
}
|
||||||
@ -57,7 +76,6 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
|
|||||||
|
|
||||||
// Upload files after edition
|
// Upload files after edition
|
||||||
promise.then(function(data) {
|
promise.then(function(data) {
|
||||||
var promises = [];
|
|
||||||
$scope.fileProgress = 0;
|
$scope.fileProgress = 0;
|
||||||
|
|
||||||
// When all files upload are over, move on
|
// When all files upload are over, move on
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
<div class="control-group" ng-class="{ error: !documentForm.title.$valid }">
|
<div class="control-group" ng-class="{ error: !documentForm.title.$valid }">
|
||||||
<label class="control-label" for="inputTitle">Title</label>
|
<label class="control-label" for="inputTitle">Title</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input required ng-maxlength="100" class="input-block-level" type="text" id="inputTitle" placeholder="Title" name="title" ng-model="document.title" />
|
<input required ng-maxlength="100" class="input-block-level" type="text" id="inputTitle"
|
||||||
|
placeholder="Title" name="title" ng-model="document.title" autocomplete="off"
|
||||||
|
typeahead="document for document in getTitleTypeahead($viewValue) | filter: $viewValue"
|
||||||
|
typeahead-wait-ms="200" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group" ng-class="{ error: !documentForm.description.$valid }">
|
<div class="control-group" ng-class="{ error: !documentForm.description.$valid }">
|
||||||
|
Loading…
Reference in New Issue
Block a user