Skip to content

Commit be4be8e

Browse files
committed
Improve visualization of Degree names.
1 parent 336090d commit be4be8e

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

backend/src/Model/Entity/Degree.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function academic_years() {
6868
return $this['academic_year'] . "/" . ($this['academic_year'] % 100 + 1);
6969
}
7070

71+
public function _getTitle() {
72+
return $this['name'] . " (" . $this['academic_year'] . "/" . ($this['academic_year'] + 1) . ")";
73+
}
74+
7175
public function isSharingEnabled($user = null) {
7276
switch ($this->enable_sharing) {
7377
case 0:
@@ -100,4 +104,4 @@ public function sharingMode() {
100104
break;
101105
}
102106
}
103-
}
107+
}

backend/src/Model/Table/DegreesTable.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public function initialize(array $config): void
5454
parent::initialize($config);
5555

5656
$this->setTable('degrees');
57-
$this->setDisplayField([
58-
'name',
59-
'academic_year']);
57+
$this->setDisplayField('title');
6058
$this->setPrimaryKey('id');
6159

6260
$this->hasMany('Curricula', [

backend/tests/TestCase/Model/Table/DegreesTableTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ public function tearDown(): void
5858
*/
5959
public function testInitialize()
6060
{
61-
$this->markTestIncomplete('Not implemented yet.');
61+
$this->assertSame('title', $this->Degrees->getDisplayField());
62+
}
63+
64+
public function testFindListFormatsDegreeTitle()
65+
{
66+
$degrees = $this->Degrees->find('list')->toArray();
67+
68+
$this->assertSame(
69+
'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis. (2020/2021)',
70+
$degrees[1]
71+
);
6272
}
6373

6474
/**

0 commit comments

Comments
 (0)