aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/webapp/apps
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-13 10:14:27 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-13 10:14:27 +0100
commit27d74ce4423d2ec48a9289169c97958526fed77b (patch)
tree38496ea999d9a496729e4a6d07e114876761c265 /src/main/resources/webapp/apps
parent22cb83183828c7a4828c54e9b30597d276cfd73f (diff)
downloadesper-testing-27d74ce4423d2ec48a9289169c97958526fed77b.tar.gz
esper-testing-27d74ce4423d2ec48a9289169c97958526fed77b.tar.bz2
esper-testing-27d74ce4423d2ec48a9289169c97958526fed77b.tar.xz
esper-testing-27d74ce4423d2ec48a9289169c97958526fed77b.zip
o Adding PagingTableService.showNext()/nextDisabled() for better look when searching.
Diffstat (limited to 'src/main/resources/webapp/apps')
-rwxr-xr-xsrc/main/resources/webapp/apps/core/PagingTableService.js41
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/personList.html4
2 files changed, 36 insertions, 9 deletions
diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js
index f550a39..f38b6f1 100755
--- a/src/main/resources/webapp/apps/core/PagingTableService.js
+++ b/src/main/resources/webapp/apps/core/PagingTableService.js
@@ -6,13 +6,16 @@ function PagingTableService() {
rows: [],
query: "",
startIndex: options.startIndex || 0,
- count: options.count || 10
+ count: options.count || 10,
+ currentlySearching: false
};
var update = function(){
+ self.currentlySearching = true;
fetchCallback(self.startIndex, self.count, self.query, function(data) {
self.rows = data.rows;
watcher();
+ self.currentlySearching = false;
});
};
@@ -22,11 +25,17 @@ function PagingTableService() {
};
self.next = function () {
+ if (self.currentlySearching) {
+ return;
+ }
self.startIndex += self.count;
update();
};
self.prev = function () {
+ if (self.currentlySearching) {
+ return;
+ }
if (self.startIndex == 0) {
return;
}
@@ -34,16 +43,35 @@ function PagingTableService() {
update();
};
+ /*
+ * The search functions needs to know if there already is a search in progress and if so, do not send the search
+ * before the previous one completes.
+ */
+
self.onSearch = function () {
- console.log("search: " + self.query);
update();
};
self.onSearchChange = function () {
- console.log("search: " + self.query);
update();
};
+ self.showPrev = function () {
+ return self.startIndex > 0;
+ };
+
+ self.showNext = function () {
+ return true;
+ };
+
+ self.nextDisabled = function () {
+ return self.currentlySearching;
+ };
+
+ self.prevDisabled = function () {
+ return self.currentlySearching;
+ };
+
// Do an initial fetch
update();
@@ -53,7 +81,7 @@ function PagingTableService() {
var defaultCallback = function(Resource, args) {
args = args || {};
return function(startIndex, count, query, cb) {
- if(startIndex) {
+ if(startIndex || startIndex == 0) {
args.startIndex = startIndex;
}
if(count) {
@@ -62,11 +90,10 @@ function PagingTableService() {
if(query) {
args.query = query;
}
- console.log("fetching", args);
+ console.log("Fetching page. args =", args);
Resource.query(args, function(data, headers) {
var totalResults = headers("total-results");
- console.log("totalResults", totalResults);
- console.log("got data", data);
+ console.log("Total results =", totalResults, "Data =", data);
cb({
totalResults: totalResults,
rows: data
diff --git a/src/main/resources/webapp/apps/frontPageApp/personList.html b/src/main/resources/webapp/apps/frontPageApp/personList.html
index 41f2f63..2c14b01 100755
--- a/src/main/resources/webapp/apps/frontPageApp/personList.html
+++ b/src/main/resources/webapp/apps/frontPageApp/personList.html
@@ -46,10 +46,10 @@
</div>
</div>
<ul class="pager">
- <li class="previous" ng-show="persons.startIndex > 0">
+ <li ng-show="persons.showPrev()" class="previous {{{true: 'disabled', false: ''}[persons.prevDisabled()]}}">
<a ng-click="persons.prev()">&larr; Prev</a>
</li>
- <li class="next">
+ <li ng-show="persons.showNext()" class="next {{{true: 'disabled', false: ''}[persons.nextDisabled()]}}">
<a ng-click="persons.next()">Next &rarr;</a>
</li>
</ul>