partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 628824ae4b07738aa1d99ab7f989b28664a8fa8a
parent 62c43d4396e501b61af23bd1c98a7bcbf065b769
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed,  7 Sep 2011 03:41:53 +0200

Added missing implementation for "Mark all tips unread"

Diffstat:
Mfrontend/js/Components/User/TipOfTheDayPreferences.js | 27++++++++++++++++++++++++---
Msrc/de/RaumZeitLabor/PartKeepr/TipOfTheDay/TipOfTheDayService.php | 12++++++++++++
2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/frontend/js/Components/User/TipOfTheDayPreferences.js b/frontend/js/Components/User/TipOfTheDayPreferences.js @@ -8,20 +8,41 @@ Ext.define('PartKeepr.TipOfTheDayPreferencesPanel', { handler: Ext.bind(this.showTipsHandler, this) }); + if (PartKeepr.getApplication().getUserPreference("partkeepr.tipoftheday.showtips") === false) { + this.displayTipsOnLoginCheckbox.setValue(false); + } else { + this.displayTipsOnLoginCheckbox.setValue(true); + } + + this.resetTipsButton = Ext.create("Ext.button.Button", { - text: i18n("Mark Tips at ") + text: i18n("Mark all tips unread"), + handler: this.onMarkAllTipsUnreadClick, + scope: this }); this.items = [ this.displayTipsOnLoginCheckbox, this.resetTipsButton ]; this.callParent(); - }, - /** + }, + /** * Handler when the "show tips" checkbox was clicked. */ showTipsHandler: function (checkbox, checked) { PartKeepr.getApplication().setUserPreference("partkeepr.tipoftheday.showtips", checked); + }, + /** + * Marks all tips as unread + */ + onMarkAllTipsUnreadClick: function () { + var call = new PartKeepr.ServiceCall("TipOfTheDay", "markAllTipsAsUnread"); + call.setLoadMessage(i18n("Marking all tips as unerad...")); + call.setHandler(function () { + var msg = i18n("All tips have been marked as unread"); + Ext.Msg.alert(msg, msg); + }); + call.doCall(); } }); \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/TipOfTheDay/TipOfTheDayService.php b/src/de/RaumZeitLabor/PartKeepr/TipOfTheDay/TipOfTheDayService.php @@ -63,6 +63,8 @@ class TipOfTheDayService extends Service implements RestfulService { * Uses the parameter "name" to identify the tip. */ public function markTipAsRead () { + $this->requireParameter("name"); + $th = new TipOfTheDayHistory; $th->setUser($this->getUser()); $th->setName($this->getParameter("name")); @@ -70,4 +72,14 @@ class TipOfTheDayService extends Service implements RestfulService { PartKeepr::getEM()->persist($th); PartKeepr::getEM()->flush(); } + + /** + * Marks all tips as unread for the current user + */ + public function markAllTipsAsUnread () { + $dql = "DELETE FROM de\RaumZeitLabor\PartKeepr\TipOfTheDay\TipOfTheDayHistory th WHERE th.user = :user"; + $query = PartKeepr::getEM()->createQuery($dql); + $query->setParameter("user", $this->getUser()); + $query->execute(); + } } \ No newline at end of file