Skip to content

Commit

Permalink
fix(target): distinguish fields content
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Mar 5, 2018
1 parent b10134e commit 326315c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 0 additions & 4 deletions front/targetticket.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@

// Edit an existing target ticket
if (isset($_POST["update"])) {
$target = new PluginFormcreatorTarget();
$found = $target->find('items_id = ' . (int) $_POST['id']);
$found = array_shift($found);
$target->update(['id' => $found['id'], 'name' => $_POST['name']]);
$targetticket->update($_POST);
Html::back();

Expand Down
11 changes: 10 additions & 1 deletion inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,13 @@ public function prepareInputForUpdate($input) {
$input['uuid'] = plugin_formcreator_getUuid();
}

$target = new PluginFormcreatorTarget();
$found = $target->find('items_id = ' . $this->getID());
$found = array_shift($found);
$target->update(['id' => $found['id'], 'name' => $input['name']]);
$input['name'] = $input['title'];
unset($input['title']);

return $input;
}

Expand Down Expand Up @@ -1469,7 +1476,7 @@ public static function import($targetitems_id = 0, $target_data = []) {
foreach ($rows as $id => $question_line) {
$uuid = $question_line['uuid'];

$content = $target_data['name'];
$content = $target_data['title'];
$content = str_replace("##question_$uuid##", "##question_$id##", $content);
$content = str_replace("##answer_$uuid##", "##answer_$id##", $content);
$target_data['name'] = $content;
Expand Down Expand Up @@ -1561,6 +1568,8 @@ public function export() {
unset($target_data['id'],
$target_data['tickettemplates_id']);

$target_data['title'] = $target_data['name'];
unset($target_data['name']);
return $target_data;
}
}
2 changes: 1 addition & 1 deletion tests/0010_Integration/ExportImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function _checkTarget($target = []) {
public function _checkTargetTicket($targetticket = []) {
$this->assertArrayNotHasKey('id', $targetticket);
$this->assertArrayNotHasKey('tickettemplates_id', $targetticket);
$this->assertArrayHasKey('name', $targetticket);
$this->assertArrayHasKey('title', $targetticket);
$this->assertArrayHasKey('comment', $targetticket);
$this->assertArrayHasKey('due_date_rule', $targetticket);
$this->assertArrayHasKey('due_date_question', $targetticket);
Expand Down

0 comments on commit 326315c

Please sign in to comment.