More work on the issue relation infrastructure
- actually query data for the incoming query - exclude the current issue from being linked with itself - allow multiple issues to be given in the second input field - add the form fields to the ticket update view as well
This commit is contained in:
parent
9171bfd1ab
commit
7e226b43d3
@ -69,11 +69,11 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
|
|||||||
// case of someone allowing the upload path to be accessible
|
// case of someone allowing the upload path to be accessible
|
||||||
// to everybody.
|
// to everybody.
|
||||||
for ($i=1;$i<4;$i++) {
|
for ($i=1;$i<4;$i++) {
|
||||||
$filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
|
$filename = substr($md5, 0, 2).'/'.substr($md5, 2, 2).'/'.substr($md5, 4).'/%s.dummy';
|
||||||
$this->fields['attachment'.$i] = new Pluf_Form_Field_File(
|
$this->fields['attachment'.$i] = new Pluf_Form_Field_File(
|
||||||
array('required' => false,
|
array('required' => false,
|
||||||
'label' => __('Attach a file'),
|
'label' => __('Attach a file'),
|
||||||
'move_function_params' =>
|
'move_function_params' =>
|
||||||
array('upload_path' => $upload_path,
|
array('upload_path' => $upload_path,
|
||||||
'upload_path_create' => true,
|
'upload_path_create' => true,
|
||||||
'file_name' => $filename,
|
'file_name' => $filename,
|
||||||
@ -102,6 +102,22 @@ class IDF_Form_IssueUpdate extends IDF_Form_IssueCreate
|
|||||||
'size' => 15,
|
'size' => 15,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$relation_types = $extra['project']->getRelationsFromConfig();
|
||||||
|
$this->fields['relation_type'] = new Pluf_Form_Field_Varchar(
|
||||||
|
array('required' => false,
|
||||||
|
'label' => __('This issue'),
|
||||||
|
'initial' => $relation_types[0],
|
||||||
|
'widget_attrs' => array('size' => 15),
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->fields['relation_issue'] = new Pluf_Form_Field_Varchar(
|
||||||
|
array('required' => false,
|
||||||
|
'label' => null,
|
||||||
|
'initial' => '',
|
||||||
|
'widget_attrs' => array('size' => 10),
|
||||||
|
));
|
||||||
|
|
||||||
$tags = $this->issue->get_tags_list();
|
$tags = $this->issue->get_tags_list();
|
||||||
for ($i=1;$i<7;$i++) {
|
for ($i=1;$i<7;$i++) {
|
||||||
$initial = '';
|
$initial = '';
|
||||||
|
@ -345,6 +345,7 @@ class IDF_Views_Issue
|
|||||||
'form' => $form,
|
'form' => $form,
|
||||||
'page_title' => $title,
|
'page_title' => $title,
|
||||||
'preview' => $preview,
|
'preview' => $preview,
|
||||||
|
'issue' => new IDF_Issue(),
|
||||||
),
|
),
|
||||||
self::autoCompleteArrays($prj)
|
self::autoCompleteArrays($prj)
|
||||||
);
|
);
|
||||||
@ -651,22 +652,60 @@ class IDF_Views_Issue
|
|||||||
public function autoCompleteIssueList($request, $match)
|
public function autoCompleteIssueList($request, $match)
|
||||||
{
|
{
|
||||||
$prj = $request->project;
|
$prj = $request->project;
|
||||||
|
$issue_id = !empty($match[2]) ? intval($match[2]) : 0;
|
||||||
|
$query = trim($request->REQUEST['q']);
|
||||||
|
$limit = !empty($request->REQUEST['limit']) ? intval($request->REQUEST['limit']) : 0;
|
||||||
|
$limit = max(10, $limit);
|
||||||
|
|
||||||
|
$issues = array();
|
||||||
|
|
||||||
|
// empty search, return the most recently updated issues
|
||||||
|
if (empty($query)) {
|
||||||
|
$sql = new Pluf_SQL('project=%s', array($prj->id));
|
||||||
|
$tmp = Pluf::factory('IDF_Issue')->getList(array(
|
||||||
|
'filter' => $sql->gen(),
|
||||||
|
'order' => 'modif_dtime DESC'
|
||||||
|
));
|
||||||
|
$issues += $tmp->getArrayCopy();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// ID-based search
|
||||||
|
if (is_numeric($query)) {
|
||||||
|
$sql = new Pluf_SQL('project=%s AND id LIKE %s', array($prj->id, $query.'%'));
|
||||||
|
$tmp = Pluf::factory('IDF_Issue')->getList(array(
|
||||||
|
'filter' => $sql->gen(),
|
||||||
|
'order' => 'id ASC'
|
||||||
|
));
|
||||||
|
$issues += $tmp->getArrayCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// text-based search
|
||||||
|
$res = new Pluf_Search_ResultSet(
|
||||||
|
IDF_Search::mySearch($query, $prj, 'IDF_Issue')
|
||||||
|
);
|
||||||
|
foreach ($res as $issue)
|
||||||
|
$issues[] = $issue;
|
||||||
|
}
|
||||||
|
|
||||||
// Autocomplete from jQuery UI works with JSON, this old one still
|
// Autocomplete from jQuery UI works with JSON, this old one still
|
||||||
// expects a parsable string; since we'd need to bump jQuery beyond
|
// expects a parsable string; since we'd need to bump jQuery beyond
|
||||||
// 1.2.6 for this to use as well, we're trying to cope with the old format.
|
// 1.2.6 for this to use as well, we're trying to cope with the old format.
|
||||||
// see http://www.learningjquery.com/2010/06/autocomplete-migration-guide
|
// see http://www.learningjquery.com/2010/06/autocomplete-migration-guide
|
||||||
|
|
||||||
$arr = array(
|
|
||||||
'Fo|o' => 110,
|
|
||||||
'Bar' => 111,
|
|
||||||
'Baz' => 112,
|
|
||||||
);
|
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
foreach ($arr as $key => $val)
|
$ids = array();
|
||||||
|
foreach ($issues as $issue)
|
||||||
{
|
{
|
||||||
$out .= str_replace('|', '|', $key).'|'.$val."\n";
|
if ($issue->id == $issue_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (in_array($issue->id, $ids))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (--$limit < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
$out .= str_replace('|', '|', $issue->summary) .'|'.$issue->id."\n";
|
||||||
|
$ids[] = $issue->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pluf_HTTP_Response($out);
|
return new Pluf_HTTP_Response($out);
|
||||||
|
@ -173,7 +173,7 @@ $ctl[] = array('regex' => '#^/watchlist/(\w+)$#',
|
|||||||
'model' => 'IDF_Views_Issue',
|
'model' => 'IDF_Views_Issue',
|
||||||
'method' => 'forgeWatchList');
|
'method' => 'forgeWatchList');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/autocomplete/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/issues/autocomplete/(\d*)$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Issue',
|
'model' => 'IDF_Views_Issue',
|
||||||
'method' => 'autoCompleteIssueList');
|
'method' => 'autoCompleteIssueList');
|
||||||
|
@ -64,11 +64,12 @@
|
|||||||
return row.to;
|
return row.to;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#id_relation_issue").autocomplete("{/literal}{url 'IDF_Views_Issue::autoCompleteIssueList', array($project.shortname)}{literal}", {
|
$("#id_relation_issue").autocomplete("{/literal}{url 'IDF_Views_Issue::autoCompleteIssueList', array($project.shortname, $issue.id)}{literal}", {
|
||||||
minChars: 0,
|
minChars: 0,
|
||||||
width: 310,
|
width: 310,
|
||||||
matchContains: true,
|
matchContains: true,
|
||||||
max: 10,
|
max: 10,
|
||||||
|
multiple: true,
|
||||||
delay: 500,
|
delay: 500,
|
||||||
highlightItem: false,
|
highlightItem: false,
|
||||||
formatItem: function(row, i, max, term) {
|
formatItem: function(row, i, max, term) {
|
||||||
|
@ -120,6 +120,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>{$form.f.relation_type.labelTag}:</th>
|
||||||
|
<td>
|
||||||
|
{if $form.f.relation_type.errors}{$form.f.relation_type.fieldErrors}{/if}
|
||||||
|
{if $form.f.relation_issue.errors}{$form.f.relation_issue.fieldErrors}{/if}
|
||||||
|
{$form.f.relation_type|unsafe}
|
||||||
|
{$form.f.relation_issue|unsafe}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<th>{$form.f.label1.labelTag}:</th>
|
<th>{$form.f.label1.labelTag}:</th>
|
||||||
<td>
|
<td>
|
||||||
{if $form.f.label1.errors}{$form.f.label1.fieldErrors}{/if}{$form.f.label1|unsafe}
|
{if $form.f.label1.errors}{$form.f.label1.fieldErrors}{/if}{$form.f.label1|unsafe}
|
||||||
|
Loading…
Reference in New Issue
Block a user