mirror of
https://github.com/sismics/docs.git
synced 2025-12-21 05:31:42 +00:00
Search on creation date (server), edit creation date (client)
This commit is contained in:
@@ -26,6 +26,9 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
|
||||
$scope.edit = function() {
|
||||
var promise = null;
|
||||
var document = angular.copy($scope.document);
|
||||
if (document.create_date instanceof Date) {
|
||||
document.create_date = document.create_date.getTime();
|
||||
}
|
||||
|
||||
// Extract ids from tags
|
||||
document.tags = _.pluck(document.tags, 'id');
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Document view controller.
|
||||
*/
|
||||
App.controller('DocumentView', function($rootScope, $scope, $state, $stateParams, $dialog, Restangular) {
|
||||
App.controller('DocumentView', function($scope, $state, $stateParams, $dialog, Restangular) {
|
||||
// Load data from server
|
||||
$scope.document = Restangular.one('document', $stateParams.id).get();
|
||||
|
||||
@@ -25,7 +25,7 @@ App.controller('DocumentView', function($rootScope, $scope, $state, $stateParams
|
||||
*/
|
||||
$scope.loadFiles = function() {
|
||||
Restangular.one('file').getList('list', { id: $stateParams.id }).then(function(data) {
|
||||
$rootScope.files = data.files;
|
||||
$scope.files = data.files;
|
||||
});
|
||||
};
|
||||
$scope.loadFiles();
|
||||
|
||||
@@ -7,23 +7,28 @@ App.controller('FileView', function($dialog, $state, $stateParams) {
|
||||
var dialog = $dialog.dialog({
|
||||
keyboard: true,
|
||||
templateUrl: 'partial/file.view.html',
|
||||
controller: function($rootScope, $scope, $state, $stateParams) {
|
||||
controller: function($scope, $state, $stateParams, Restangular) {
|
||||
$scope.id = $stateParams.fileId;
|
||||
|
||||
// Search current file
|
||||
_.each($rootScope.files, function(value, key, list) {
|
||||
if (value.id == $scope.id) {
|
||||
$scope.file = value;
|
||||
}
|
||||
// Load files
|
||||
Restangular.one('file').getList('list', { id: $stateParams.id }).then(function(data) {
|
||||
$scope.files = data.files;
|
||||
|
||||
// Search current file
|
||||
_.each($scope.files, function(value, key, list) {
|
||||
if (value.id == $scope.id) {
|
||||
$scope.file = value;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Navigate to the next file.
|
||||
*/
|
||||
$scope.nextFile = function() {
|
||||
_.each($rootScope.files, function(value, key, list) {
|
||||
_.each($scope.files, function(value, key, list) {
|
||||
if (value.id == $scope.id) {
|
||||
var next = $rootScope.files[key + 1];
|
||||
var next = $scope.files[key + 1];
|
||||
if (next) {
|
||||
dialog.close({});
|
||||
$state.transitionTo('document.view.file', { id: $stateParams.id, fileId: next.id });
|
||||
@@ -36,9 +41,9 @@ App.controller('FileView', function($dialog, $state, $stateParams) {
|
||||
* Navigate to the previous file.
|
||||
*/
|
||||
$scope.previousFile = function() {
|
||||
_.each($rootScope.files, function(value, key, list) {
|
||||
_.each($scope.files, function(value, key, list) {
|
||||
if (value.id == $scope.id) {
|
||||
var previous = $rootScope.files[key - 1];
|
||||
var previous = $scope.files[key - 1];
|
||||
if (previous) {
|
||||
dialog.close({});
|
||||
$state.transitionTo('document.view.file', { id: $stateParams.id, fileId: previous.id });
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
/**
|
||||
* Login controller.
|
||||
*/
|
||||
App.controller('Login', function($scope, $state, $dialog, User) {
|
||||
App.controller('Login', function($scope, $rootScope, $state, $dialog, User) {
|
||||
$scope.login = function() {
|
||||
User.login($scope.user).then(function() {
|
||||
$rootScope.userInfo = User.userInfo(true);
|
||||
$state.transitionTo('document.default');
|
||||
}, function() {
|
||||
var title = 'Login failed';
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
/**
|
||||
* Navigation controller.
|
||||
*/
|
||||
App.controller('Navigation', function($scope, User) {
|
||||
$scope.userInfo = User.userInfo();
|
||||
App.controller('Navigation', function($scope, $rootScope, User) {
|
||||
$rootScope.userInfo = User.userInfo();
|
||||
});
|
||||
@@ -12,17 +12,7 @@ App.factory('Tag', function(Restangular) {
|
||||
* @param force If true, force reloading data
|
||||
*/
|
||||
tags: function(force) {
|
||||
if (tags == null || force) {
|
||||
tags = Restangular.one('tag/list').get();
|
||||
}
|
||||
return tags;
|
||||
},
|
||||
|
||||
/**
|
||||
* Login an user.
|
||||
*/
|
||||
login: function(user) {
|
||||
return Restangular.one('user').post('login', user);
|
||||
return Restangular.one('tag/list').get();
|
||||
}
|
||||
}
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,12 @@
|
||||
<textarea ng-maxlength="4000" class="input-block-level" rows="5" id="inputDescription" name="description" ng-model="document.description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCreateDate">Creation date</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputCreateDate" datepicker-popup="yyyy-MM-dd" ng-model="document.create_date" starting-day="1" show-weeks="false" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputFiles">New files</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tbody>
|
||||
<tr ng-click="viewDocument(document.id)" ng-repeat="document in documents.documents">
|
||||
<td>{{ document.title }}</td>
|
||||
<td>{{ document.create_date | date: 'short' }}</td>
|
||||
<td>{{ document.create_date | date: 'yyyy-MM-dd' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
|
||||
<div class="page-header">
|
||||
<h1>{{ document.title }} <small>{{ document.create_date | date: 'short' }}</small></h1>
|
||||
<h1>{{ document.title }} <small>{{ document.create_date | date: 'yyyy-MM-dd' }}</small></h1>
|
||||
<ul class="inline">
|
||||
<li ng-repeat="tag in document.tags"><span class="label label-info">{{ tag.name }}</span></li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user