Finalize ticket relations (closes issue 638)

- IssueUpdate.php: use dynamically set field validators for dynamically
  created fields; let relation_type0 and relation_issue0 exist at any time;
  check the validity of a user selection and combine the various input fields
  if possible; do the database updates for links; change the "change" format
  for labels to a more precise structure and no longer trust on a leading
  dash for removed labels
- IssueCreate.php: change the validator calls and field names
- Issue.php (getGroupedRelatedIssues): make it possible to return only a
  flat list of integers for easier processing
- 17AddIssueRelations.php: migrate the previous serialized "changes" format
  for issue comments to the new, more structured format (up and down)
- js-autocomplete.html: add support for multiple input fields
- view.html: output relation changes and wrap the related issues stanzas into
  paragraphs
- NEWS.mdtext: note the addition and the need for a specific version of Pluf
This commit is contained in:
Thomas Keller
2011-05-30 14:02:10 +02:00
parent 16dda0743c
commit 0aa5999bb3
10 changed files with 279 additions and 60 deletions

View File

@@ -113,14 +113,14 @@ class IDF_Form_IssueCreate extends Pluf_Form
),
));
$this->fields['relation_type'] = new Pluf_Form_Field_Varchar(
$this->fields['relation_type0'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('This issue'),
'initial' => current($this->relation_types),
'widget_attrs' => array('size' => 15),
));
$this->fields['relation_issue'] = new Pluf_Form_Field_Varchar(
$this->fields['relation_issue0'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => null,
'initial' => '',
@@ -253,9 +253,11 @@ class IDF_Form_IssueCreate extends Pluf_Form
return $this->cleaned_data['status'];
}
function clean_relation_type()
// this method is not called from Pluf_Form directly, but shared for
// among all similar fields
function clean_relation_type($value)
{
$relation_type = trim($this->cleaned_data['relation_type']);
$relation_type = trim($value);
if (empty($relation_type))
return '';
@@ -272,9 +274,16 @@ class IDF_Form_IssueCreate extends Pluf_Form
return $relation_type;
}
function clean_relation_issue()
function clean_relation_type0()
{
$issues = trim($this->cleaned_data['relation_issue']);
return $this->clean_relation_type($this->cleaned_data['relation_type0']);
}
// this method is not called from Pluf_Form directly, but shared for
// among all similar fields
function clean_relation_issue($value)
{
$issues = trim($value);
if (empty($issues))
return '';
@@ -296,6 +305,11 @@ class IDF_Form_IssueCreate extends Pluf_Form
return implode(', ', $issue_ids);
}
function clean_relation_issue0()
{
return $this->clean_relation_issue($this->cleaned_data['relation_issue0']);
}
/**
* Clean the attachments post failure.
*/
@@ -360,9 +374,9 @@ class IDF_Form_IssueCreate extends Pluf_Form
$issue->setAssoc($tag);
}
// add relations
$verb = $this->cleaned_data['relation_type'];
$verb = $this->cleaned_data['relation_type0'];
$other_verb = $this->relation_types[$verb];
$related_issues = preg_split('/\s*,\s*/', $this->cleaned_data['relation_issue'], -1, PREG_SPLIT_NO_EMPTY);
$related_issues = preg_split('/\s*,\s*/', $this->cleaned_data['relation_issue0'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($related_issues as $related_issue_id) {
$related_issue = new IDF_Issue($related_issue_id);
$rel = new IDF_IssueRelation();