mirror of
https://git.victorphan.net/basketballcantho/Teedy_custom.git
synced 2026-08-06 06:13:10 +07:00
Unified documents search, tag validation
This commit is contained in:
@@ -12,21 +12,7 @@ App.controller('Document', function($scope, $state, Restangular) {
|
||||
$scope.offset = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.limit = 10;
|
||||
$scope.isAdvancedSearchCollapsed = true;
|
||||
|
||||
/**
|
||||
* Initialize search criterias.
|
||||
*/
|
||||
$scope.initSearch = function() {
|
||||
$scope.search = {
|
||||
query: '',
|
||||
createDateMin: null,
|
||||
createDateMax: null,
|
||||
tags: [],
|
||||
shared: false
|
||||
};
|
||||
};
|
||||
$scope.initSearch();
|
||||
$scope.search = '';
|
||||
|
||||
/**
|
||||
* Load new documents page.
|
||||
@@ -38,11 +24,7 @@ App.controller('Document', function($scope, $state, Restangular) {
|
||||
limit: $scope.limit,
|
||||
sort_column: $scope.sortColumn,
|
||||
asc: $scope.asc,
|
||||
search: $scope.search.query,
|
||||
create_date_min: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMin ? null : $scope.search.createDateMin.getTime(),
|
||||
create_date_max: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMax ? null : $scope.search.createDateMax.getTime(),
|
||||
'tags': $scope.isAdvancedSearchCollapsed ? null : _.pluck($scope.search.tags, 'id'),
|
||||
'shared': $scope.isAdvancedSearchCollapsed ? null : $scope.search.shared
|
||||
search: $scope.search
|
||||
})
|
||||
.then(function(data) {
|
||||
$scope.documents = data.documents;
|
||||
|
||||
@@ -95,7 +95,6 @@ App.controller('DocumentView', function ($scope, $state, $stateParams, $location
|
||||
*/
|
||||
$scope.share = function () {
|
||||
$dialog.dialog({
|
||||
backdrop: false,
|
||||
keyboard: true,
|
||||
templateUrl: 'partial/docs/document.share.html',
|
||||
controller: function ($scope, dialog) {
|
||||
|
||||
@@ -25,6 +25,15 @@ App.controller('Tag', function($scope, $dialog, $state, Tag, Restangular) {
|
||||
}, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate a tag.
|
||||
*/
|
||||
$scope.validateTag = function(name) {
|
||||
return !_.find($scope.tags, function(tag) {
|
||||
return tag.name == name;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a tag.
|
||||
*/
|
||||
@@ -65,7 +74,7 @@ App.controller('Tag', function($scope, $dialog, $state, Tag, Restangular) {
|
||||
*/
|
||||
$scope.updateTag = function(tag) {
|
||||
// Update the server
|
||||
Restangular.one('tag', tag.id).post('', tag).then(function () {
|
||||
return Restangular.one('tag', tag.id).post('', tag).then(function () {
|
||||
// Update the stat object
|
||||
var stat = _.find($scope.stats, function (t) {
|
||||
return tag.id == t.id;
|
||||
|
||||
@@ -47,7 +47,13 @@ App.directive('inlineEdit', function() {
|
||||
// Invoke parent scope callback
|
||||
if (scope.editCallback && scope.oldValue != el.value) {
|
||||
scope.$apply(function() {
|
||||
scope.editCallback();
|
||||
if (scope.value) {
|
||||
scope.editCallback().then(null, function() {
|
||||
scope.value = scope.oldValue;
|
||||
});
|
||||
} else {
|
||||
scope.value = scope.oldValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user