diff --git a/app/resources/locales/en_US/default.po b/app/resources/locales/en_US/default.po index 4caee09a..26730c74 100644 --- a/app/resources/locales/en_US/default.po +++ b/app/resources/locales/en_US/default.po @@ -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" diff --git a/app/src/Model/Table/MatchgridsTable.php b/app/src/Model/Table/MatchgridsTable.php index 83c63ec0..c8ad0a8c 100644 --- a/app/src/Model/Table/MatchgridsTable.php +++ b/app/src/Model/Table/MatchgridsTable.php @@ -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; } @@ -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. diff --git a/app/templates/Matchgrids/columns.inc b/app/templates/Matchgrids/columns.inc index c001f7be..e4cfd69a 100644 --- a/app/templates/Matchgrids/columns.inc +++ b/app/templates/Matchgrids/columns.inc @@ -30,6 +30,9 @@ $indexColumns = [ 'type' => 'link', 'cssClass' => 'row-link' ], + 'description' => [ + 'type' => 'echo' + ], 'status' => [ 'type' => 'enum', 'class' => 'StatusEnum'