Added explicit count for all cards

This commit is contained in:
Giulio Cesare Solaroli 2015-02-06 17:24:31 +01:00
parent 782d7102c9
commit 6c021b5772
2 changed files with 30 additions and 5 deletions

View File

@ -75,7 +75,7 @@ Clipperz.PM.UI.Components.Selections = React.createClass({
var filterType; var filterType;
var filterValue; var filterValue;
//console.log("SELECTIONS PROPS", this.props); console.log("SELECTIONS PROPS", this.props);
tagInfo = this.props['tags'] ? this.props['tags'] : {}; tagInfo = this.props['tags'] ? this.props['tags'] : {};
tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, MochiKit.Base.keys(tagInfo)).sort(Clipperz.Base.caseInsensitiveCompare); tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, MochiKit.Base.keys(tagInfo)).sort(Clipperz.Base.caseInsensitiveCompare);
archivedCardsCount = this.props['archivedCardsCount']; archivedCardsCount = this.props['archivedCardsCount'];
@ -86,10 +86,19 @@ Clipperz.PM.UI.Components.Selections = React.createClass({
return React.DOM.div({'key':'selections', 'id':'selections', 'className':filterType}, [ return React.DOM.div({'key':'selections', 'id':'selections', 'className':filterType}, [
React.DOM.ul({'className':'defaultSet'}, [ React.DOM.ul({'className':'defaultSet'}, [
React.DOM.li({'className':'allCards', 'onClick': this.selectAll}, "All"), React.DOM.li({'className':'allCards', 'onClick': this.selectAll}, [
React.DOM.li({'className':'recentCards', 'onClick': this.selectRecent}, "Recent"), "All",
React.DOM.span({'className':'count'}, this.props['allCardsCount'])
]),
React.DOM.li({'className':'recentCards', 'onClick': this.selectRecent}, [
"Recent",
React.DOM.span({'className':'count'}, "10")
]),
// React.DOM.li({'className':'untaggedCards', 'onClick': this.selectUntaggedCards}, "Untagged - " + this.props['untaggedCardsCount']) // React.DOM.li({'className':'untaggedCards', 'onClick': this.selectUntaggedCards}, "Untagged - " + this.props['untaggedCardsCount'])
React.DOM.li({'className':'untaggedCards', 'onClick': this.selectUntaggedCards}, "Untagged") React.DOM.li({'className':'untaggedCards', 'onClick': this.selectUntaggedCards}, [
"Untagged",
React.DOM.span({'className':'count'}, this.props['untaggedCardsCount'])
])
]), ]),
React.DOM.div({'className':'search'}, [ React.DOM.div({'className':'search'}, [
React.DOM.form({'className':'searchForm'}, [ React.DOM.form({'className':'searchForm'}, [

View File

@ -590,7 +590,7 @@ console.log("THE BROWSER IS OFFLINE");
} else if (aFilter['type'] == 'RECENT') { } else if (aFilter['type'] == 'RECENT') {
filterCriteria = MochiKit.Base.operator.truth; filterCriteria = MochiKit.Base.operator.truth;
sortCriteria = Clipperz.Base.reverseComparator(MochiKit.Base.keyComparator('accessDate')); sortCriteria = Clipperz.Base.reverseComparator(MochiKit.Base.keyComparator('accessDate'));
rangeFilter = function (someCards) { return someCards.slice(0, 9)}; rangeFilter = function (someCards) { return someCards.slice(0, 10)};
} else if (aFilter['type'] == 'SEARCH') { } else if (aFilter['type'] == 'SEARCH') {
filterCriteria = this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForSearch(aFilter['value'])); filterCriteria = this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForSearch(aFilter['value']));
sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label'); sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label');
@ -666,6 +666,20 @@ console.log("THE BROWSER IS OFFLINE");
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
getAllCardsCount: function () {
var archivedCardsFilter = this.shouldIncludeArchivedCards()
? MochiKit.Async.succeed
: MochiKit.Base.partial(MochiKit.Base.filter, function (someRecordInfo) { return ! someRecordInfo['_isArchived']; });
return Clipperz.Async.callbacks("MainController.getUntaggedCardsCount", [
MochiKit.Base.method(this.user(), 'getRecords'),
MochiKit.Base.partial(MochiKit.Base.map, Clipperz.Async.collectResults("collectResults", {'_fullLabel':MochiKit.Base.methodcaller('fullLabel'), '_isArchived':MochiKit.Base.methodcaller('isArchived')}, {trace:false})),
Clipperz.Async.collectAll,
archivedCardsFilter,
function (someCards) { return someCards.length; },
], {trace:false});
},
getArchivedCardsCount: function () { getArchivedCardsCount: function () {
return Clipperz.Async.callbacks("MainController.getArchivedCardsCount", [ return Clipperz.Async.callbacks("MainController.getArchivedCardsCount", [
MochiKit.Base.method(this.user(), 'getRecords'), MochiKit.Base.method(this.user(), 'getRecords'),
@ -711,6 +725,8 @@ console.log("THE BROWSER IS OFFLINE");
// MochiKit.Base.method(this.user(), 'getTags', this.shouldIncludeArchivedCards()), // MochiKit.Base.method(this.user(), 'getTags', this.shouldIncludeArchivedCards()),
MochiKit.Base.method(this, 'allTags', this.shouldIncludeArchivedCards()), MochiKit.Base.method(this, 'allTags', this.shouldIncludeArchivedCards()),
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'tags'), MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'tags'),
MochiKit.Base.method(this, 'getAllCardsCount'),
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'allCardsCount'),
MochiKit.Base.method(this, 'getArchivedCardsCount'), MochiKit.Base.method(this, 'getArchivedCardsCount'),
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'archivedCardsCount'), MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'archivedCardsCount'),
MochiKit.Base.method(this, 'getUntaggedCardsCount'), MochiKit.Base.method(this, 'getUntaggedCardsCount'),