From 6c021b5772a2360f2813d50445a4fc3909df67de Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Fri, 6 Feb 2015 17:24:31 +0100 Subject: [PATCH] Added explicit count for all cards --- .../js/Clipperz/PM/UI/Components/Selections.js | 17 +++++++++++++---- .../delta/js/Clipperz/PM/UI/MainController.js | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/frontend/delta/js/Clipperz/PM/UI/Components/Selections.js b/frontend/delta/js/Clipperz/PM/UI/Components/Selections.js index f73d2df..73559ad 100644 --- a/frontend/delta/js/Clipperz/PM/UI/Components/Selections.js +++ b/frontend/delta/js/Clipperz/PM/UI/Components/Selections.js @@ -75,7 +75,7 @@ Clipperz.PM.UI.Components.Selections = React.createClass({ var filterType; var filterValue; -//console.log("SELECTIONS PROPS", this.props); +console.log("SELECTIONS PROPS", this.props); tagInfo = this.props['tags'] ? this.props['tags'] : {}; tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, MochiKit.Base.keys(tagInfo)).sort(Clipperz.Base.caseInsensitiveCompare); 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}, [ React.DOM.ul({'className':'defaultSet'}, [ - React.DOM.li({'className':'allCards', 'onClick': this.selectAll}, "All"), - React.DOM.li({'className':'recentCards', 'onClick': this.selectRecent}, "Recent"), + React.DOM.li({'className':'allCards', 'onClick': this.selectAll}, [ + "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") + React.DOM.li({'className':'untaggedCards', 'onClick': this.selectUntaggedCards}, [ + "Untagged", + React.DOM.span({'className':'count'}, this.props['untaggedCardsCount']) + ]) ]), React.DOM.div({'className':'search'}, [ React.DOM.form({'className':'searchForm'}, [ diff --git a/frontend/delta/js/Clipperz/PM/UI/MainController.js b/frontend/delta/js/Clipperz/PM/UI/MainController.js index 7a66237..90ed078 100644 --- a/frontend/delta/js/Clipperz/PM/UI/MainController.js +++ b/frontend/delta/js/Clipperz/PM/UI/MainController.js @@ -590,7 +590,7 @@ console.log("THE BROWSER IS OFFLINE"); } else if (aFilter['type'] == 'RECENT') { filterCriteria = MochiKit.Base.operator.truth; 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') { filterCriteria = this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForSearch(aFilter['value'])); 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 () { return Clipperz.Async.callbacks("MainController.getArchivedCardsCount", [ 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, 'allTags', this.shouldIncludeArchivedCards()), 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, 'setPageProperties', 'mainPage', 'archivedCardsCount'), MochiKit.Base.method(this, 'getUntaggedCardsCount'),