mirror of
https://github.com/sismics/docs.git
synced 2025-12-19 12:41:40 +00: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;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,42 +6,11 @@
|
||||
<button class="btn btn-primary" type="button" ng-click="addDocument()"><span class="icon-plus icon-white"></span> Add a document</button>
|
||||
</p>
|
||||
|
||||
<p class="input-prepend input-append text-center input-block-level">
|
||||
<p class="input-prepend text-center input-block-level">
|
||||
<span class="add-on"><span class="icon-search"></span></span>
|
||||
<input type="text" placeholder="Search" ng-model="search.query" />
|
||||
<button class="btn" ng-click="isAdvancedSearchCollapsed = !isAdvancedSearchCollapsed">More <span class="caret"></span></button>
|
||||
<input type="text" placeholder="Search" ng-model="search" />
|
||||
</p>
|
||||
|
||||
<div collapse="isAdvancedSearchCollapsed">
|
||||
<div class="well well-small">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCreateDateMin">Creation date</label>
|
||||
<div class="controls">
|
||||
<input class="span5" ng-readonly="true" ng-change="loadDocuments()" type="text" id="inputCreateDateMin" datepicker-popup="yyyy-MM-dd" ng-model="search.createDateMin" starting-day="1" show-weeks="false" />
|
||||
to
|
||||
<input class="span5" ng-readonly="true" ng-change="loadDocuments()" type="text" id="inputCreateDateMax" datepicker-popup="yyyy-MM-dd" ng-model="search.createDateMax" starting-day="1" show-weeks="false" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputTags">Tags</label>
|
||||
<div class="controls">
|
||||
<select-tag tags="search.tags" class="input-block-level" ref="inputTags" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputShared">Shared</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" ng-model="search.shared" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button ng-click="initSearch()" class="btn btn-warning" type="submit">Reset search</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped table-hover table-documents">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span4 well text-center">
|
||||
<div class="input-prepend input-append input-block-level">
|
||||
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }"> </span>
|
||||
<input type="text" placeholder="Tag name" ng-model="tag.name" ui-keyup="{'enter':'addTag()'}">
|
||||
<button type="submit" class="btn btn-primary" ng-click="addTag()">Add</button>
|
||||
</div>
|
||||
<form name="tagForm" novalidate>
|
||||
<div class="control-group input-prepend input-append input-block-level" ng-class="{ error: !tagForm.name.$valid }">
|
||||
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }"> </span>
|
||||
<input type="text" name="name" placeholder="New tag"
|
||||
ng-maxlength="36" required ng-model="tag.name" ui-validate="'validateTag($value)'">
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="input-prepend input-block-level">
|
||||
<span class="add-on"><span class="icon-search"></span></span>
|
||||
|
||||
Reference in New Issue
Block a user