Skip to content

Commit

Permalink
Disable renaming of Matchgrid table_name (CO-2441)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Mar 31, 2025
1 parent 8b1bc39 commit 21c1329
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ msgstr "A Matchgrid with table name {0} already exists"
msgid "match.er.mg.notfound"
msgstr "Matchgrid table not found, was the Matchgrid built? ({0})"

msgid "match.er.mg.rename"
msgstr "A Matchgrid cannot be renamed"

msgid "match.er.mgid"
msgstr "Could not find Matchgrid ID in request"

Expand Down
24 changes: 24 additions & 0 deletions app/src/Model/Table/MatchgridsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public function buildRules(RulesChecker $rules): RulesChecker {
'isActive',
['errorField' => 'status']);

// The Matchgrid table name cannot be changed once created. For a discussion of
// the complexities of renaming a Matchgrid, see CO-2441.
$rules->addUpdate([$this, 'ruleMatchgridRenamed'],
'matchgridRenamed',
['errorField' => 'table_name']);

return $rules;
}

Expand Down Expand Up @@ -277,6 +283,24 @@ public function ruleIsUnique($entity, array $options): bool|string {

return true;
}

/**
* Application Rule to determine if the Matchgrid is being renamed.
*
* @param Entity $entity Entity to be validated
* @param array $options Application rule options
*
* @return bool|string true if the Rule check passes, false otherwise
* @since COmanage Match v1.2.2
*/

public function ruleMatchgridRenamed($entity, array $options): bool|string {
if($entity->isDirty('table_name')) {
return __('match.er.mg.rename');
}

return true;
}

/**
* Determine if the Matchgrid table exists.
Expand Down
3 changes: 3 additions & 0 deletions app/templates/Matchgrids/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ $indexColumns = [
'type' => 'link',
'cssClass' => 'row-link'
],
'description' => [
'type' => 'echo'
],
'status' => [
'type' => 'enum',
'class' => 'StatusEnum'
Expand Down

0 comments on commit 21c1329

Please sign in to comment.