Skip to content

Commit

Permalink
Merge pull request #4811 from carlobeltrame/empty-numbering-scheme
Browse files Browse the repository at this point in the history
Implement empty numbering style
  • Loading branch information
carlobeltrame committed Apr 3, 2024
2 parents fbcc22e + e3c6800 commit 47407d1
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 66 deletions.
8 changes: 0 additions & 8 deletions api/migrations/dev-data/Version202312032018.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ public function getDescription(): string {

public function up(Schema $schema): void {
// START PHP CODE
$this->addSql(createTruncateDatabaseCommand());

$statements = getStatementsForMigrationFile();
foreach ($statements as $statement) {
if (trim($statement)) {
$this->addSql($statement);
}
}
// END PHP CODE
}

Expand Down
31 changes: 31 additions & 0 deletions api/migrations/dev-data/Version202404012013.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DataMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

require_once __DIR__.'/helpers.php';

final class Version202404012013 extends AbstractMigration {
public function getDescription(): string {
return '';
}

public function up(Schema $schema): void {
// START PHP CODE
$this->addSql(createTruncateDatabaseCommand());

$statements = getStatementsForMigrationFile();
foreach ($statements as $statement) {
if (trim($statement)) {
$this->addSql($statement);
}
}
// END PHP CODE
}

public function down(Schema $schema): void {}
}
61 changes: 32 additions & 29 deletions api/migrations/dev-data/data.sql

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion api/src/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Category extends BaseEntity implements BelongsToCampInterface, CopyFromPro
* Specifies whether the schedule entries of the activities in this category should be numbered
* using arabic numbers, roman numerals or letters.
*/
#[Assert\Choice(choices: ['a', 'A', 'i', 'I', '1'])]
#[Assert\Choice(choices: ['a', 'A', 'i', 'I', '1', '-'])]
#[ApiProperty(example: '1')]
#[Groups(['read', 'write'])]
#[ORM\Column(type: 'string', length: 1, nullable: false)]
Expand Down Expand Up @@ -242,6 +242,9 @@ public function getStyledNumber(int $num): string {
case 'I':
return strtoupper($this->getRomanNum($num));

case '-':
return '';

default:
return strval($num);
}
Expand Down
4 changes: 4 additions & 0 deletions api/src/Entity/ScheduleEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ public function getScheduleEntryNumber(): int {
#[ApiProperty(example: '1.b')]
#[Groups(['read'])]
public function getNumber(): string {
if ('-' === $this->getNumberingStyle()) {
return '';
}

$dayNumber = $this->getDayNumber();
$scheduleEntryNumber = $this->getScheduleEntryNumber();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7722,6 +7722,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -7801,6 +7802,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -7884,6 +7886,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -7956,6 +7959,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8012,6 +8016,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8087,6 +8092,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8166,6 +8172,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8249,6 +8256,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8321,6 +8329,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8377,6 +8386,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8461,6 +8471,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8549,6 +8560,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8641,6 +8653,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8722,6 +8735,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8821,6 +8835,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -8923,6 +8938,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -9029,6 +9045,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down Expand Up @@ -9101,6 +9118,7 @@ components:
Specifies whether the schedule entries of the activities in this category should be numbered
using arabic numbers, roman numerals or letters.
enum:
- '-'
- '1'
- A
- I
Expand Down
11 changes: 11 additions & 0 deletions api/tests/Entity/ScheduleEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ public function testGetNumberInDifferentNumberingStyle() {
$this->assertEquals('2.1', $this->scheduleEntry3->getNumber());
}

public function testGetEmptyValueWhenNumberingStyleIsNone() {
$category = new Category();
$category->numberingStyle = '-';
$activity = new Activity();
$activity->category = $category;
$this->scheduleEntry2->activity = $activity;
$this->assertEquals('1.1', $this->scheduleEntry1->getNumber());
$this->assertEquals('', $this->scheduleEntry2->getNumber());
$this->assertEquals('2.1', $this->scheduleEntry3->getNumber());
}

public function testGetNumberOrdersSamePeriodOffsetByLeft() {
$this->scheduleEntry1->startOffset = $this->scheduleEntry2->startOffset;
$this->scheduleEntry1->left = 0.5;
Expand Down
6 changes: 4 additions & 2 deletions common/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
"A": "A, B, C - grosse Buchstaben",
"I": "I, II, III - grosse römische Zahlen",
"a": "a, b, c - kleine Buchstaben",
"i": "i, ii, iii - kleine römische Zahlen"
"i": "i, ii, iii - kleine römische Zahlen",
"-": "keine Nummerierung"
}
},
"contentType": {
Expand Down Expand Up @@ -210,7 +211,8 @@
},
"hourLong": "LT",
"hourShort": "H:mm"
}
},
"shortScheduleEntryDescription": "Tag\u202f{dayNumber} {startTime}"
},
"print": {
"cover": {
Expand Down
6 changes: 4 additions & 2 deletions common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@
"A": "A, B, C - uppercase letters",
"I": "I, II, III - uppercase roman numerals",
"a": "a, b, c - lowercase letters",
"i": "i, ii, iii - lowercase roman numerals"
"i": "i, ii, iii - lowercase roman numerals",
"-": "no numbering"
}
},
"contentType": {
Expand Down Expand Up @@ -217,7 +218,8 @@
},
"hourLong": "LT",
"hourShort": "H:mm"
}
},
"shortScheduleEntryDescription": "day {dayNumber} {startTime}"
},
"print": {
"cover": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/campAdmin/DialogCategoryForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
},
computed: {
numberingStyles() {
return ['1', 'a', 'A', 'i', 'I'].map((i) => ({
return ['1', 'a', 'A', 'i', 'I', '-'].map((i) => ({
value: i,
text: this.$tc('entity.category.numberingStyles.' + i),
}))
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/category/CategoryProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
},
computed: {
numberingStyles() {
return ['1', 'a', 'A', 'i', 'I'].map((i) => ({
return ['1', 'a', 'A', 'i', 'I', '-'].map((i) => ({
value: i,
text: this.$tc('entity.category.numberingStyles.' + i),
}))
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/dashboard/ActivityRow.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<template>
<tr class="row" :class="{ 'row--skeleton': scheduleEntry._meta.loading }">
<th class="tabular-nums text-left" scope="row">
<TextAlignBaseline
><span v-if="!scheduleEntry._meta.loading" class="smaller">{{
scheduleEntry.number
}}</span>
<v-skeleton-loader v-else type="text" width="2ch" class="mb-0 my-6px" />
</TextAlignBaseline>
<br />
<CategoryChip
v-if="!loadingEndpoints?.categories && !scheduleEntry._meta.loading"
small
Expand All @@ -16,6 +9,13 @@
class="d-sm-none"
/>
<CategoryChip v-else class="d-sm-none" small dense skeleton />
<br class="d-sm-none" />
<TextAlignBaseline
><span v-if="!scheduleEntry._meta.loading" class="smaller">{{
scheduleEntry.number
}}</span>
<v-skeleton-loader v-else type="text" width="2ch" class="mb-0 my-6px" />
</TextAlignBaseline>
</th>
<td class="d-none d-sm-table-cell">
<CategoryChip
Expand Down
22 changes: 18 additions & 4 deletions frontend/src/components/material/ScheduleEntryLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
class="e-title-link tabular-nums"
>
<CategoryChip dense :category="activity.category()" />&thinsp;{{
$vuetify.breakpoint.smAndUp
? `${activity.title}: ${items[0].number}`
: items[0].number
$vuetify.breakpoint.smAndUp ? fullDescription(items[0]) : shortDescription(items[0])
}}
</router-link>
<span v-else class="d-inline-flex flex-sm-wrap gap-1 align-center py-sm-1">
Expand All @@ -28,7 +26,9 @@
:to="scheduleEntryRoute(scheduleEntry)"
small
>{{
index < items.length - 1 ? `${scheduleEntry.number},` : scheduleEntry.number
index < items.length - 1
? `${shortDescription(scheduleEntry)},`
: shortDescription(scheduleEntry)
}}</router-link
>
</span>
Expand All @@ -38,6 +38,7 @@
<script>
import { scheduleEntryRoute } from '@/router.js'
import CategoryChip from '@/components/generic/CategoryChip.vue'
import shortScheduleEntryDescription from './shortScheduleEntryDescription.js'
export default {
name: 'ScheduleEntryLinks',
Expand Down Expand Up @@ -65,6 +66,19 @@ export default {
},
methods: {
scheduleEntryRoute,
fullDescription(scheduleEntry) {
if (this.loading) return ''
return (
this.activity.title +
(scheduleEntry.number
? `: ${scheduleEntry.number}`
: ` (${this.shortDescription(scheduleEntry)})`)
)
},
shortDescription(scheduleEntry) {
if (this.loading) return ''
return shortScheduleEntryDescription(scheduleEntry, this.$tc.bind(this))
},
},
}
</script>

0 comments on commit 47407d1

Please sign in to comment.