From 1a030ea4ed1b263817cbcea0b0db4959429dc431 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Tue, 12 Aug 2008 12:46:09 +0200 Subject: [PATCH] Added issue 14, ability to change the interest status. The interest status or watch list is now shown in the list of the issues and can be changed by clicking on the star in front of the title of an issue when looking at an issue. --- logo/star.svg | 172 +++++++++++++++++++++++++++++ src/IDF/Form/IssueCreate.php | 3 - src/IDF/Form/IssueUpdate.php | 1 + src/IDF/Views/Issue.php | 48 +++++++- src/IDF/conf/views.php | 6 + src/IDF/templates/base.html | 2 +- src/IDF/templates/issues/view.html | 1 + www/media/idf/css/style.css | 4 + www/media/idf/img/star-grey.png | Bin 0 -> 744 bytes www/media/idf/img/star.png | Bin 0 -> 819 bytes 10 files changed, 227 insertions(+), 10 deletions(-) create mode 100644 logo/star.svg create mode 100644 www/media/idf/img/star-grey.png create mode 100644 www/media/idf/img/star.png diff --git a/logo/star.svg b/logo/star.svg new file mode 100644 index 0000000..ff0ae76 --- /dev/null +++ b/logo/star.svg @@ -0,0 +1,172 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/IDF/Form/IssueCreate.php b/src/IDF/Form/IssueCreate.php index 8f26c0b..497d910 100644 --- a/src/IDF/Form/IssueCreate.php +++ b/src/IDF/Form/IssueCreate.php @@ -220,9 +220,6 @@ class IDF_Form_IssueCreate extends Pluf_Form foreach ($tags as $tag) { $issue->setAssoc($tag); } - $issue->setAssoc($this->user); // the user is - // automatically - // interested. // add the first comment $comment = new IDF_IssueComment(); $comment->issue = $issue; diff --git a/src/IDF/Form/IssueUpdate.php b/src/IDF/Form/IssueUpdate.php index ae4b274..1fb186f 100644 --- a/src/IDF/Form/IssueUpdate.php +++ b/src/IDF/Form/IssueUpdate.php @@ -253,6 +253,7 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate $comment->changes = $changes; $comment->create(); $this->issue->update(); + $this->issue->setAssoc($this->user); // interested user. return $this->issue; } throw new Exception(__('Cannot save the model from an invalid form.')); diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index eaee67d..3a99df2 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -46,7 +46,8 @@ class IDF_Views_Issue $pag = new Pluf_Paginator(new IDF_Issue()); $pag->class = 'recent-issues'; $pag->item_extra_props = array('project_m' => $prj, - 'shortname' => $prj->shortname); + 'shortname' => $prj->shortname, + 'current_user' => $request->user); $pag->summary = __('This table shows the open issues.'); $otags = $prj->getTagIdsByStatus('open'); if (count($otags) == 0) $otags[] = 0; @@ -103,7 +104,8 @@ class IDF_Views_Issue $pag = new Pluf_Paginator(new IDF_Issue()); $pag->class = 'recent-issues'; $pag->item_extra_props = array('project_m' => $prj, - 'shortname' => $prj->shortname); + 'shortname' => $prj->shortname, + 'current_user' => $request->user); $pag->summary = __('This table shows the open issues.'); $pag->forced_where = $f_sql; $pag->action = array('IDF_Views_Issue::myIssues', array($prj->shortname, $match[2])); @@ -192,7 +194,9 @@ class IDF_Views_Issue array($prj->shortname, $issue->id)); $title = Pluf_Template::markSafe(sprintf(__('Issue %d: %s'), $url, $issue->id, $issue->summary)); $form = false; // The form is available only if logged in. + $starred = false; if (!$request->user->isAnonymous()) { + $starred = Pluf_Model_InArray($request->user, $issue->get_interested_list()); $params = array( 'project' => $prj, 'user' => $request->user, @@ -248,10 +252,11 @@ class IDF_Views_Issue $arrays = self::autoCompleteArrays($prj); return Pluf_Shortcuts_RenderToResponse('issues/view.html', array_merge( - array('project' => $prj, + array( 'issue' => $issue, 'comments' => $comments, 'form' => $form, + 'starred' => $starred, 'page_title' => $title, ), $arrays), @@ -274,7 +279,8 @@ class IDF_Views_Issue $pag = new Pluf_Paginator(new IDF_Issue()); $pag->class = 'recent-issues'; $pag->item_extra_props = array('project_m' => $prj, - 'shortname' => $prj->shortname); + 'shortname' => $prj->shortname, + 'current_user' => $request->user); $pag->summary = __('This table shows the closed issues.'); $otags = $prj->getTagIdsByStatus('closed'); if (count($otags) == 0) $otags[] = 0; @@ -330,7 +336,8 @@ class IDF_Views_Issue $pag->model_view = 'join_tags'; $pag->class = 'recent-issues'; $pag->item_extra_props = array('project_m' => $prj, - 'shortname' => $prj->shortname); + 'shortname' => $prj->shortname, + 'current_user' => $request->user); $pag->summary = sprintf(__('This table shows the issues with label %s.'), (string) $tag); $otags = $prj->getTagIdsByStatus($status); if (count($otags) == 0) $otags[] = 0; @@ -365,6 +372,31 @@ class IDF_Views_Issue $request); } + /** + * Star/Unstar an issue. + */ + public $star_precond = array('IDF_Precondition::accessIssues', + 'Pluf_Precondition::loginRequired'); + public function star($request, $match) + { + $prj = $request->project; + $issue = Pluf_Shortcuts_GetObjectOr404('IDF_Issue', $match[2]); + $prj->inOr404($issue); + if ($request->method == 'POST') { + $starred = Pluf_Model_InArray($request->user, $issue->get_interested_list()); + if ($starred) { + $issue->delAssoc($request->user); + $request->user->setMessage(__('The issue has been removed from your watch list.')); + } else { + $issue->setAssoc($request->user); + $request->user->setMessage(__('The issue has been added to your watch list.')); + } + } + $url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', + array($prj->shortname, $issue->id)); + return new Pluf_HTTP_Response_Redirect($url); + } + /** * Create the autocomplete arrays for the little AJAX stuff. */ @@ -432,11 +464,15 @@ function IDF_Views_Issue_SummaryAndLabels($field, $issue, $extra='') array($issue->shortname, $tag->id, 'open')); $tags[] = sprintf('%s', $url, Pluf_esc((string) $tag)); } + $s = ''; + if (Pluf_Model_InArray($issue->current_user, $issue->get_interested_list())) { + $s = ' '; + } $out = ''; if (count($tags)) { $out = '
'.implode(', ', $tags).''; } - return sprintf('%s', $edit, Pluf_esc($issue->summary)).$out; + return $s.sprintf('%s', $edit, Pluf_esc($issue->summary)).$out; } /** diff --git a/src/IDF/conf/views.php b/src/IDF/conf/views.php index 1a1b5b8..6fa1a85 100644 --- a/src/IDF/conf/views.php +++ b/src/IDF/conf/views.php @@ -85,6 +85,12 @@ $ctl[] = array('regex' => '#^/p/(\w+)/issues/(\d+)/$#', 'model' => 'IDF_Views_Issue', 'method' => 'view'); +$ctl[] = array('regex' => '#^/p/(\w+)/issues/(\d+)/star/$#', + 'base' => $base, + 'priority' => 4, + 'model' => 'IDF_Views_Issue', + 'method' => 'star'); + $ctl[] = array('regex' => '#^/p/(\w+)/issues/status/(\w+)/$#', 'base' => $base, 'priority' => 4, diff --git a/src/IDF/templates/base.html b/src/IDF/templates/base.html index 34fd3bd..e5a5019 100644 --- a/src/IDF/templates/base.html +++ b/src/IDF/templates/base.html @@ -51,7 +51,7 @@ {block subtabs}{if $user.isAnonymous()} | {aurl 'url', 'IDF_Views::login'}{blocktrans}Sign in or create your account to create issues or add comments{/blocktrans}{/if}{/block} -

{block title}{$page_title}{/block}

+

{block titleicon}{/block}{block title}{$page_title}{/block}

diff --git a/src/IDF/templates/issues/view.html b/src/IDF/templates/issues/view.html index 3926f0a..b4e0f90 100644 --- a/src/IDF/templates/issues/view.html +++ b/src/IDF/templates/issues/view.html @@ -1,4 +1,5 @@ {extends "issues/base.html"} +{block titleicon}{if $form}
{/if}{/block} {block body} {assign $i = 0} {assign $nc = $comments.count()} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 7555c24..8b9e3a0 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -56,6 +56,10 @@ div.context { /** * Form */ +form.star { + display: inline; +} + table.form th, table.form td { border: none; vertical-align: top; diff --git a/www/media/idf/img/star-grey.png b/www/media/idf/img/star-grey.png new file mode 100644 index 0000000000000000000000000000000000000000..20339ac70a315e8eabb54b03ffeed7a4b7b4277f GIT binary patch literal 744 zcmVP)@au|mWI6cgQ& zxN&9TKXB>Rg)aU21#V1Surno=lwc$v(Zr2WkpyU^Ed)wQOM82J@62&g3x!A%J;~Y3 zdFMUPnK=p(p;dhRyzmf&&}i)1qn1Jz=awfCv2cGfh_ULk}*L;w*81jcx|Tt3)vy=ty}P)b*-m2V;t z%Tmhk%EHq8!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