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.
This commit is contained in:
Loic d'Anterroches 2008-08-12 12:46:09 +02:00
parent b2356bd157
commit 1a030ea4ed
10 changed files with 227 additions and 10 deletions

172
logo/star.svg Normal file
View File

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="96"
height="48"
id="svg0"
sodipodi:version="0.32"
inkscape:version="0.46"
sodipodi:docname="star.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<metadata
id="metadata2536">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
inkscape:cy="15"
inkscape:cx="49.903061"
inkscape:zoom="4"
inkscape:window-height="755"
inkscape:window-width="969"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
guidetolerance="10.0"
gridtolerance="10.0"
objecttolerance="10.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base"
showgrid="false"
inkscape:window-x="220"
inkscape:window-y="108"
inkscape:current-layer="svg0" />
<defs
id="defs">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 24 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="48 : 24 : 1"
inkscape:persp3d-origin="24 : 16 : 1"
id="perspective2538" />
<linearGradient
id="G0">
<stop
id="s1"
style="stop-color:#e6cf00;stop-opacity:1"
offset="0" />
<stop
id="s2"
style="stop-color:#fde94a;stop-opacity:1"
offset="1" />
</linearGradient>
<linearGradient
id="G1">
<stop
id="s3"
style="stop-color:#fcf9fb;stop-opacity:1"
offset="0" />
<stop
id="s4"
style="stop-color:#fcf9fb;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
id="G2">
<stop
id="s5"
style="stop-color:#000000;stop-opacity:0.63"
offset="0" />
<stop
id="s6"
style="stop-color:#000000;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
x1="14.660452"
y1="7.0243196"
x2="24.030643"
y2="34.826122"
id="G3"
xlink:href="#G1"
gradientUnits="userSpaceOnUse" />
<radialGradient
cx="24"
cy="22"
r="22"
fx="24"
fy="22"
id="R0"
xlink:href="#G0"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,-0.2,0.2,1,-3.8,6.8)" />
<radialGradient
cx="17.3125"
cy="25.53125"
r="9.6875"
fx="17.3125"
fy="25.53125"
id="R1"
xlink:href="#G2"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(2.4,0,0,0.67,-17.1,22.4)" />
<linearGradient
inkscape:collect="always"
xlink:href="#G1"
id="linearGradient2548"
gradientUnits="userSpaceOnUse"
x1="14.660452"
y1="7.0243196"
x2="24.030643"
y2="34.826122"
gradientTransform="translate(47.948863,0.5)" />
</defs>
<path
d="M 37.310531,41.5 L 24.030644,34.826121 L 10.735101,41.471448 L 13.289408,27.369086 L 2.5511635,17.368344 L 17.409702,15.326301 L 24.068641,2.5 L 30.697416,15.340488 L 45.551111,17.414249 L 34.789382,27.392039 L 37.310531,41.5 z"
id="star"
style="fill:url(#R0);stroke:#c4a000"
inkscape:export-xdpi="36"
inkscape:export-ydpi="36" />
<path
d="M 17.731857,15.79089 L 24.06374,3.5868195 L 30.369452,15.794804 L 44.440148,17.761498 L 40.820395,21.121507 C 24.382895,17.434007 31.36502,28.341981 13.251748,30.364721 L 13.819799,27.184324 L 3.6604518,17.718688 C 3.6604518,17.718688 17.731857,15.79089 17.731857,15.79089 z"
id="hl"
style="opacity:0.8;fill:url(#G3);stroke:none"
inkscape:export-filename="/home/loa/Projects/indefero/www/media/idf/img/star.png"
inkscape:export-xdpi="36"
inkscape:export-ydpi="36" />
<path
d="M 35.973752,39.712833 L 24.028333,33.709386 L 12.082531,39.678326 L 14.362768,27.008543 L 4.7776396,18.070249 L 18.056076,16.247921 L 24.062792,4.6783526 L 30.045232,16.255741 L 43.322959,18.11306 L 33.713703,27.034785 L 35.973752,39.712833 z"
id="ol"
style="opacity:0.68999999;fill:none;stroke:#ffffff"
inkscape:export-filename="/home/loa/Projects/indefero/www/media/idf/img/star.png"
inkscape:export-xdpi="36"
inkscape:export-ydpi="36" />
<path
d="M 85.259394,42 L 71.979507,35.326121 L 58.683964,41.971448 L 61.238271,27.869086 L 50.500026,17.868344 L 65.358565,15.826301 L 72.017504,3 L 78.646279,15.840488 L 93.499974,17.914249 L 82.738245,27.892039 L 85.259394,42 z"
id="path2540"
style="fill:#d3d7cf;stroke:#babdb6"
inkscape:export-filename="/home/loa/Projects/indefero/www/media/idf/img/star-grey.png"
inkscape:export-xdpi="36"
inkscape:export-ydpi="36" />
<path
d="M 65.68072,16.29089 L 72.012603,4.08682 L 78.318315,16.294804 L 92.389011,18.261498 L 88.769258,21.621507 C 72.331758,17.934007 79.313883,28.841981 61.200611,30.864721 L 61.768662,27.684324 L 51.609315,18.218688 C 51.609315,18.218688 65.68072,16.29089 65.68072,16.29089 z"
id="path2542"
style="opacity:0.8;fill:url(#linearGradient2548);stroke:none"
inkscape:export-filename="/home/loa/Projects/indefero/www/media/idf/img/star-grey.png"
inkscape:export-xdpi="36"
inkscape:export-ydpi="36" />
<path
d="M 83.922615,40.212833 L 71.977196,34.209386 L 60.031394,40.178326 L 62.311631,27.508543 L 52.726502,18.570249 L 66.004939,16.747921 L 72.011655,5.178353 L 77.994095,16.755741 L 91.271822,18.61306 L 81.662566,27.534785 L 83.922615,40.212833 z"
id="path2544"
style="opacity:0.68999999;fill:none;stroke:#ffffff"
inkscape:export-filename="/home/loa/Projects/indefero/www/media/idf/img/star-grey.png"
inkscape:export-xdpi="36"
inkscape:export-ydpi="36" />
</svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -220,9 +220,6 @@ class IDF_Form_IssueCreate extends Pluf_Form
foreach ($tags as $tag) { foreach ($tags as $tag) {
$issue->setAssoc($tag); $issue->setAssoc($tag);
} }
$issue->setAssoc($this->user); // the user is
// automatically
// interested.
// add the first comment // add the first comment
$comment = new IDF_IssueComment(); $comment = new IDF_IssueComment();
$comment->issue = $issue; $comment->issue = $issue;

View File

@ -253,6 +253,7 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
$comment->changes = $changes; $comment->changes = $changes;
$comment->create(); $comment->create();
$this->issue->update(); $this->issue->update();
$this->issue->setAssoc($this->user); // interested user.
return $this->issue; return $this->issue;
} }
throw new Exception(__('Cannot save the model from an invalid form.')); throw new Exception(__('Cannot save the model from an invalid form.'));

View File

@ -46,7 +46,8 @@ class IDF_Views_Issue
$pag = new Pluf_Paginator(new IDF_Issue()); $pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues'; $pag->class = 'recent-issues';
$pag->item_extra_props = array('project_m' => $prj, $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->summary = __('This table shows the open issues.');
$otags = $prj->getTagIdsByStatus('open'); $otags = $prj->getTagIdsByStatus('open');
if (count($otags) == 0) $otags[] = 0; if (count($otags) == 0) $otags[] = 0;
@ -103,7 +104,8 @@ class IDF_Views_Issue
$pag = new Pluf_Paginator(new IDF_Issue()); $pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues'; $pag->class = 'recent-issues';
$pag->item_extra_props = array('project_m' => $prj, $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->summary = __('This table shows the open issues.');
$pag->forced_where = $f_sql; $pag->forced_where = $f_sql;
$pag->action = array('IDF_Views_Issue::myIssues', array($prj->shortname, $match[2])); $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)); array($prj->shortname, $issue->id));
$title = Pluf_Template::markSafe(sprintf(__('Issue <a href="%s">%d</a>: %s'), $url, $issue->id, $issue->summary)); $title = Pluf_Template::markSafe(sprintf(__('Issue <a href="%s">%d</a>: %s'), $url, $issue->id, $issue->summary));
$form = false; // The form is available only if logged in. $form = false; // The form is available only if logged in.
$starred = false;
if (!$request->user->isAnonymous()) { if (!$request->user->isAnonymous()) {
$starred = Pluf_Model_InArray($request->user, $issue->get_interested_list());
$params = array( $params = array(
'project' => $prj, 'project' => $prj,
'user' => $request->user, 'user' => $request->user,
@ -248,10 +252,11 @@ class IDF_Views_Issue
$arrays = self::autoCompleteArrays($prj); $arrays = self::autoCompleteArrays($prj);
return Pluf_Shortcuts_RenderToResponse('issues/view.html', return Pluf_Shortcuts_RenderToResponse('issues/view.html',
array_merge( array_merge(
array('project' => $prj, array(
'issue' => $issue, 'issue' => $issue,
'comments' => $comments, 'comments' => $comments,
'form' => $form, 'form' => $form,
'starred' => $starred,
'page_title' => $title, 'page_title' => $title,
), ),
$arrays), $arrays),
@ -274,7 +279,8 @@ class IDF_Views_Issue
$pag = new Pluf_Paginator(new IDF_Issue()); $pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues'; $pag->class = 'recent-issues';
$pag->item_extra_props = array('project_m' => $prj, $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.'); $pag->summary = __('This table shows the closed issues.');
$otags = $prj->getTagIdsByStatus('closed'); $otags = $prj->getTagIdsByStatus('closed');
if (count($otags) == 0) $otags[] = 0; if (count($otags) == 0) $otags[] = 0;
@ -330,7 +336,8 @@ class IDF_Views_Issue
$pag->model_view = 'join_tags'; $pag->model_view = 'join_tags';
$pag->class = 'recent-issues'; $pag->class = 'recent-issues';
$pag->item_extra_props = array('project_m' => $prj, $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); $pag->summary = sprintf(__('This table shows the issues with label %s.'), (string) $tag);
$otags = $prj->getTagIdsByStatus($status); $otags = $prj->getTagIdsByStatus($status);
if (count($otags) == 0) $otags[] = 0; if (count($otags) == 0) $otags[] = 0;
@ -365,6 +372,31 @@ class IDF_Views_Issue
$request); $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. * 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')); array($issue->shortname, $tag->id, 'open'));
$tags[] = sprintf('<a class="label" href="%s">%s</a>', $url, Pluf_esc((string) $tag)); $tags[] = sprintf('<a class="label" href="%s">%s</a>', $url, Pluf_esc((string) $tag));
} }
$s = '';
if (Pluf_Model_InArray($issue->current_user, $issue->get_interested_list())) {
$s = '<img style="vertical-align: text-bottom;" src="'.Pluf_Template_Tag_MediaUrl::url('/idf/img/star.png').'" title="'.__('On your watch list.').'" /> ';
}
$out = ''; $out = '';
if (count($tags)) { if (count($tags)) {
$out = '<br /><span class="note">'.implode(', ', $tags).'</span>'; $out = '<br /><span class="note">'.implode(', ', $tags).'</span>';
} }
return sprintf('<a href="%s">%s</a>', $edit, Pluf_esc($issue->summary)).$out; return $s.sprintf('<a href="%s">%s</a>', $edit, Pluf_esc($issue->summary)).$out;
} }
/** /**

View File

@ -85,6 +85,12 @@ $ctl[] = array('regex' => '#^/p/(\w+)/issues/(\d+)/$#',
'model' => 'IDF_Views_Issue', 'model' => 'IDF_Views_Issue',
'method' => 'view'); '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+)/$#', $ctl[] = array('regex' => '#^/p/(\w+)/issues/status/(\w+)/$#',
'base' => $base, 'base' => $base,
'priority' => 4, 'priority' => 4,

View File

@ -51,7 +51,7 @@
{block subtabs}{if $user.isAnonymous()} | {aurl 'url', 'IDF_Views::login'}{blocktrans}<a href="{$url}">Sign in or create your account</a> to create issues or add comments{/blocktrans}{/if}{/block} {block subtabs}{if $user.isAnonymous()} | {aurl 'url', 'IDF_Views::login'}{blocktrans}<a href="{$url}">Sign in or create your account</a> to create issues or add comments{/blocktrans}{/if}{/block}
</div> </div>
<h1 class="title">{block title}{$page_title}{/block}</h1> <h1 class="title">{block titleicon}{/block}{block title}{$page_title}{/block}</h1>
</div> </div>
<div id="bd"> <div id="bd">

View File

@ -1,4 +1,5 @@
{extends "issues/base.html"} {extends "issues/base.html"}
{block titleicon}{if $form}<form class="star" method="post" action="{url 'IDF_Views_Issue::star', array($project.shortname, $issue.id)}"><input type="image" src="{if $starred}{media '/idf/img/star.png'}{else}{media '/idf/img/star-grey.png'}{/if}" name="submit" /></form> {/if}{/block}
{block body} {block body}
{assign $i = 0} {assign $i = 0}
{assign $nc = $comments.count()} {assign $nc = $comments.count()}

View File

@ -56,6 +56,10 @@ div.context {
/** /**
* Form * Form
*/ */
form.star {
display: inline;
}
table.form th, table.form td { table.form th, table.form td {
border: none; border: none;
vertical-align: top; vertical-align: top;

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

BIN
www/media/idf/img/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B