Display and edit language on document (client)

This commit is contained in:
jendib 2013-08-17 01:48:33 +02:00
parent 82682600df
commit 7bb1f48464
8 changed files with 43 additions and 19 deletions

View File

@ -1,4 +1,3 @@
- Add language on document (client)
- Index title and description (server) - Index title and description (server)
- Use Lucene for title and description searching (server) - Use Lucene for title and description searching (server)
- Index OCR-ized content (server) - Index OCR-ized content (server)

View File

@ -89,6 +89,7 @@ public class DocumentResource extends BaseResource {
document.put("title", documentDb.getTitle()); document.put("title", documentDb.getTitle());
document.put("description", documentDb.getDescription()); document.put("description", documentDb.getDescription());
document.put("create_date", documentDb.getCreateDate().getTime()); document.put("create_date", documentDb.getCreateDate().getTime());
document.put("language", documentDb.getLanguage());
// Add tags // Add tags
TagDao tagDao = new TagDao(); TagDao tagDao = new TagDao();

View File

@ -3,7 +3,7 @@
/** /**
* Document controller. * Document controller.
*/ */
App.controller('Document', function($scope, $state, Restangular) { App.controller('Document', function($scope, $timeout, $state, Restangular) {
/** /**
* Documents table sort status. * Documents table sort status.
*/ */
@ -14,6 +14,10 @@ App.controller('Document', function($scope, $state, Restangular) {
$scope.limit = 10; $scope.limit = 10;
$scope.search = ''; $scope.search = '';
// A timeout promise is used to slow down search requests to the server
// We keep track of it for cancellation purpose
var timeoutPromise;
/** /**
* Load new documents page. * Load new documents page.
*/ */
@ -57,7 +61,15 @@ App.controller('Document', function($scope, $state, Restangular) {
* Watch for search scope change. * Watch for search scope change.
*/ */
$scope.$watch('search', function(prev, next) { $scope.$watch('search', function(prev, next) {
if (timeoutPromise) {
// Cancel previous timeout
$timeout.cancel(timeoutPromise);
}
// Call API later
timeoutPromise = $timeout(function () {
$scope.loadDocuments(); $scope.loadDocuments();
}, 200);
}, true); }, true);
/** /**

View File

@ -46,7 +46,10 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
$scope.document = data; $scope.document = data;
}); });
} else { } else {
$scope.document = { tags: [] }; $scope.document = {
tags: [],
language: 'fra'
};
} }
/** /**

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

View File

@ -20,6 +20,15 @@
<input type="text" id="inputCreateDate" ng-readonly="true" datepicker-popup="yyyy-MM-dd" ng-model="document.create_date" starting-day="1" show-weeks="false" /> <input type="text" id="inputCreateDate" ng-readonly="true" datepicker-popup="yyyy-MM-dd" ng-model="document.create_date" starting-day="1" show-weeks="false" />
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label" for="inputCreateDate">Language</label>
<div class="controls">
<select id="inputLanguage" ng-model="document.language">
<option value="fra">French</option>
<option value="eng">English</option>
</select>
</div>
</div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="inputFiles">New files</label> <label class="control-label" for="inputFiles">New files</label>
<div class="controls"> <div class="controls">

View File

@ -1,6 +1,6 @@
<img src="img/loader.gif" ng-show="!document" /> <img src="img/loader.gif" ng-if="!document" />
<div ng-show="document"> <div ng-if="document">
<div class="text-right"> <div class="text-right">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-danger" ng-click="deleteDocument(document)"><span class="icon-trash icon-white"></span> Delete</button> <button class="btn btn-danger" ng-click="deleteDocument(document)"><span class="icon-trash icon-white"></span> Delete</button>
@ -9,7 +9,7 @@
</div> </div>
<div class="page-header"> <div class="page-header">
<h1>{{ document.title }} <small>{{ document.create_date | date: 'yyyy-MM-dd' }}</small></h1> <h1>{{ document.title }} <small>{{ document.create_date | date: 'yyyy-MM-dd' }}</small> <img ng-src="img/flag/{{ document.language }}.png" title="{{ document.language }}" /></h1>
<p> <p>
<button class="btn btn-small btn-inverse" ng-click="share()"><span class="icon-share icon-white"></span> Share</button> <button class="btn btn-small btn-inverse" ng-click="share()"><span class="icon-share icon-white"></span> Share</button>
<button class="btn btn-small" ng-repeat="share in document.shares" ng-click="showShare(share)"><span class="icon-ok"></span> {{ share.name ? share.name : 'shared' }}</button> <button class="btn btn-small" ng-repeat="share in document.shares" ng-click="showShare(share)"><span class="icon-ok"></span> {{ share.name ? share.name : 'shared' }}</button>