Fixed issue 131, added ability to preview before submitting an issue.

dev
Loic d'Anterroches 2009-02-27 14:21:09 +01:00
parent 7cc5a2dc58
commit 8da821eef4
3 changed files with 33 additions and 5 deletions

View File

@ -142,11 +142,13 @@ class IDF_Views_Issue
$params = array( $params = array(
'project' => $prj, 'project' => $prj,
'user' => $request->user); 'user' => $request->user);
$preview = (isset($request->POST['preview'])) ?
$request->POST['content'] : false;
if ($request->method == 'POST') { if ($request->method == 'POST') {
$form = new IDF_Form_IssueCreate(array_merge($request->POST, $form = new IDF_Form_IssueCreate(array_merge($request->POST,
$request->FILES), $request->FILES),
$params); $params);
if ($form->isValid()) { if (!isset($request->POST['preview']) and $form->isValid()) {
$issue = $form->save(); $issue = $form->save();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index', $url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index',
array($prj->shortname)); array($prj->shortname));
@ -187,6 +189,7 @@ class IDF_Views_Issue
array('project' => $prj, array('project' => $prj,
'form' => $form, 'form' => $form,
'page_title' => $title, 'page_title' => $title,
'preview' => $preview,
), ),
self::autoCompleteArrays($prj) self::autoCompleteArrays($prj)
); );
@ -252,6 +255,8 @@ class IDF_Views_Issue
$starred = false; $starred = false;
$closed = in_array($issue->status, $prj->getTagIdsByStatus('closed')); $closed = in_array($issue->status, $prj->getTagIdsByStatus('closed'));
$interested = $issue->get_interested_list(); $interested = $issue->get_interested_list();
$preview = (isset($request->POST['preview'])) ?
$request->POST['content'] : false;
if (!$request->user->isAnonymous()) { if (!$request->user->isAnonymous()) {
$starred = Pluf_Model_InArray($request->user, $issue->get_interested_list()); $starred = Pluf_Model_InArray($request->user, $issue->get_interested_list());
$params = array( $params = array(
@ -263,7 +268,7 @@ class IDF_Views_Issue
$form = new IDF_Form_IssueUpdate(array_merge($request->POST, $form = new IDF_Form_IssueUpdate(array_merge($request->POST,
$request->FILES), $request->FILES),
$params); $params);
if ($form->isValid()) { if (!isset($request->POST['preview']) && $form->isValid()) {
$issue = $form->save(); $issue = $form->save();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index', $url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index',
array($prj->shortname)); array($prj->shortname));
@ -324,6 +329,7 @@ class IDF_Views_Issue
'starred' => $starred, 'starred' => $starred,
'page_title' => $title, 'page_title' => $title,
'closed' => $closed, 'closed' => $closed,
'preview' => $preview,
'interested' =>$interested->count(), 'interested' =>$interested->count(),
), ),
$arrays), $arrays),

View File

@ -10,6 +10,14 @@
</div> </div>
{/if} {/if}
{if $preview}
<h2 class="top">{trans 'Preview'}</h2>
<div class="issue-comment issue-comment-first issue-comment-last">
<br /><pre class="issue-comment-text">{issuetext $preview, $request}</pre>
</div>
<hr />
{/if}
<form method="post" enctype="multipart/form-data" action="{url 'IDF_Views_Issue::create', array($project.shortname)}" > <form method="post" enctype="multipart/form-data" action="{url 'IDF_Views_Issue::create', array($project.shortname)}" >
<table class="form" summary=""> <table class="form" summary="">
<tr> <tr>
@ -67,7 +75,10 @@
</tr>{/if} </tr>{/if}
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td><input type="submit" value="{trans 'Submit Issue'}" name="submit" /> | <a href="{url 'IDF_Views_Issue::index', array($project.shortname)}">{trans 'Cancel'}</a> <td>
<input type="submit" value="{trans 'Submit Issue'}" name="submit" />
<input type="submit" value="{trans 'Preview'}" name="preview" /> |
<a href="{url 'IDF_Views_Issue::index', array($project.shortname)}">{trans 'Cancel'}</a>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -50,8 +50,16 @@
{if $closed and (!$isOwner and !$isMember)} {if $closed and (!$isOwner and !$isMember)}
<p><img src="{media '/idf/img/warning.png'}" style="vertical-align: text-bottom;" alt=" " /> {blocktrans}This issue is marked as closed, add a comment only if you think this issue is still valid and more work is needed to fully fix it.{/blocktrans}</p> <p><img src="{media '/idf/img/warning.png'}" style="vertical-align: text-bottom;" alt=" " /> {blocktrans}This issue is marked as closed, add a comment only if you think this issue is still valid and more work is needed to fully fix it.{/blocktrans}</p>
{/if} {/if}
{if $preview}
<h2>{trans 'Preview'}</h2>
<div class="issue-comment issue-comment-first issue-comment-last">
<br /><pre class="issue-comment-text">{issuetext $preview, $request}</pre>
</div>
<hr />
{/if}
<form method="post" enctype="multipart/form-data" action="{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}" > <form method="post" enctype="multipart/form-data" action="{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}" >
<table class="form" summary=""> <table class="form" summary="">
<tr> <tr>
@ -109,7 +117,10 @@
</tr>{/if} </tr>{/if}
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td><input type="submit" value="{trans 'Submit Changes'}" name="submit" /> | <a href="{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}">{trans 'Cancel'}</a> <td>
<input type="submit" value="{trans 'Submit Changes'}" name="submit" />
<input type="submit" value="{trans 'Preview'}" name="preview" /> |
<a href="{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}">{trans 'Cancel'}</a>
</td> </td>
</tr> </tr>
</table> </table>