Skip to content

Commit

Permalink
fix(targetticket,targetchange): export / import of conditions
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Mar 23, 2020
1 parent 3a5dab7 commit 65ff5a3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
16 changes: 15 additions & 1 deletion inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public function export($remove_uuid = false) {
}
}

// get conditions
$target_data['_conditions'] = [];
$condition = new PluginFormcreatorCondition();
$all_conditions = $condition->getConditionsFromItem($this);
foreach ($all_conditions as $condition) {
$target_data['_conditions'][] = $condition->export($remove_uuid);
}

// remove ID or UUID
$idToRemove = 'id';
if ($remove_uuid) {
Expand Down Expand Up @@ -225,6 +233,13 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
}
}

// Import submit conditions
if (isset($input['_conditions'])) {
foreach ($input['_conditions'] as $condition) {
PluginFormcreatorCondition::import($linker, $condition, $itemId);
}
}

return $itemId;
}

Expand Down Expand Up @@ -356,7 +371,6 @@ public function showForm($ID, $options = []) {
// -------------------------------------------------------------------------------------------
$this->showPluginTagsSettings($form, $rand);


// -------------------------------------------------------------------------------------------
// Conditions to generate the target
// -------------------------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,13 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
}
}

// Import conditions
if (isset($input['_conditions'])) {
foreach ($input['_conditions'] as $condition) {
PluginFormcreatorCondition::import($linker, $condition, $itemId);
}
}

return $itemId;
}

Expand Down Expand Up @@ -1193,6 +1200,14 @@ public function export($remove_uuid = false) {
$target_data['_ticket_relations'][] = $target_ticketLink->export($remove_uuid);
}

// get conditions
$target_data['_conditions'] = [];
$condition = new PluginFormcreatorCondition();
$all_conditions = $condition->getConditionsFromItem($this);
foreach ($all_conditions as $condition) {
$target_data['_conditions'][] = $condition->export($remove_uuid);
}

// remove ID or UUID
$idToRemove = 'id';
if ($remove_uuid) {
Expand Down

0 comments on commit 65ff5a3

Please sign in to comment.