Fixed typos in organization format settings

This commit is contained in:
Constantin Graf
2025-05-06 17:41:14 +02:00
committed by Gregor Vostrak
parent 301d09e830
commit e374d8b3de
9 changed files with 97 additions and 53 deletions

View File

@@ -10,26 +10,26 @@ enum DateFormat: string
{ {
use LaravelEnumHelper; use LaravelEnumHelper;
case PointSeperatedDMYYYY = 'point-seperated-d-m-yyyy'; case PointSeparatedDMYYYY = 'point-separated-d-m-yyyy';
case SlashSeperatedMMDDYYYY = 'slash-seperated-mm-dd-yyyy'; case SlashSeparatedMMDDYYYY = 'slash-separated-mm-dd-yyyy';
case SlashSeperatedDDMMYYYY = 'slash-seperated-dd-mm-yyyy'; case SlashSeparatedDDMMYYYY = 'slash-separated-dd-mm-yyyy';
case HyphenSeperatedDDMMYYY = 'hyphen-seperated-dd-mm-yyyy'; case HyphenSeparatedDDMMYYY = 'hyphen-separated-dd-mm-yyyy';
case HyphenSeperatedMMDDDYYYY = 'hyphen-seperated-mm-dd-yyyy'; case HyphenSeparatedMMDDDYYYY = 'hyphen-separated-mm-dd-yyyy';
case HyphenSeperatedYYYYMMDD = 'hyphen-seperated-yyyy-mm-dd'; case HyphenSeparatedYYYYMMDD = 'hyphen-separated-yyyy-mm-dd';
public function toCarbonFormat(): string public function toCarbonFormat(): string
{ {
return match ($this->value) { return match ($this->value) {
self::PointSeperatedDMYYYY->value => 'j.n.Y', self::PointSeparatedDMYYYY->value => 'j.n.Y',
self::SlashSeperatedMMDDYYYY->value => 'm/d/Y', self::SlashSeparatedMMDDYYYY->value => 'm/d/Y',
self::SlashSeperatedDDMMYYYY->value => 'd/m/Y', self::SlashSeparatedDDMMYYYY->value => 'd/m/Y',
self::HyphenSeperatedDDMMYYY->value => 'd-m-Y', self::HyphenSeparatedDDMMYYY->value => 'd-m-Y',
self::HyphenSeperatedMMDDDYYYY->value => 'm-d-Y', self::HyphenSeparatedMMDDDYYYY->value => 'm-d-Y',
self::HyphenSeperatedYYYYMMDD->value => 'Y-m-d', self::HyphenSeparatedYYYYMMDD->value => 'Y-m-d',
}; };
} }

View File

@@ -13,9 +13,9 @@ enum IntervalFormat: string
case Decimal = 'decimal'; case Decimal = 'decimal';
case HoursMinutes = 'hours-minutes'; case HoursMinutes = 'hours-minutes';
case HoursMinutesColonSeperated = 'hours-minutes-colon-seperated'; case HoursMinutesColonSeparated = 'hours-minutes-colon-separated';
case HoursMinutesSecondsColonSeperated = 'hours-minutes-seconds-colon-seperated'; case HoursMinutesSecondsColonSeparated = 'hours-minutes-seconds-colon-separated';
/** /**
* @return array<string, string> * @return array<string, string>

View File

@@ -85,11 +85,11 @@ class LocalizationService
$interval->cascade(); $interval->cascade();
return ((int) floor($interval->totalHours)).'h '.$interval->format('%I').'m'; return ((int) floor($interval->totalHours)).'h '.$interval->format('%I').'m';
} elseif ($this->intervalFormat === IntervalFormat::HoursMinutesColonSeperated) { } elseif ($this->intervalFormat === IntervalFormat::HoursMinutesColonSeparated) {
$interval->cascade(); $interval->cascade();
return ((int) floor($interval->totalHours)).':'.$interval->format('%I'); return ((int) floor($interval->totalHours)).':'.$interval->format('%I');
} elseif ($this->intervalFormat === IntervalFormat::HoursMinutesSecondsColonSeperated) { } elseif ($this->intervalFormat === IntervalFormat::HoursMinutesSecondsColonSeparated) {
$interval->cascade(); $interval->cascade();
return ((int) floor($interval->totalHours)).':'.$interval->format('%I:%S'); return ((int) floor($interval->totalHours)).':'.$interval->format('%I:%S');

View File

@@ -147,7 +147,7 @@ return [
'default_currency' => env('LOCALIZATION_DEFAULT_CURRENCY', 'EUR'), 'default_currency' => env('LOCALIZATION_DEFAULT_CURRENCY', 'EUR'),
'default_number_format' => env('LOCALIZATION_DEFAULT_NUMBER_FORMAT', NumberFormat::ThousandsPointDecimalComma->value), 'default_number_format' => env('LOCALIZATION_DEFAULT_NUMBER_FORMAT', NumberFormat::ThousandsPointDecimalComma->value),
'default_currency_format' => env('LOCALIZATION_DEFAULT_CURRENCY_FORMAT', CurrencyFormat::ISOCodeAfterWithSpace->value), 'default_currency_format' => env('LOCALIZATION_DEFAULT_CURRENCY_FORMAT', CurrencyFormat::ISOCodeAfterWithSpace->value),
'default_date_format' => env('LOCALIZATION_DEFAULT_DATE_FORMAT', DateFormat::HyphenSeperatedYYYYMMDD->value), 'default_date_format' => env('LOCALIZATION_DEFAULT_DATE_FORMAT', DateFormat::HyphenSeparatedYYYYMMDD->value),
'default_time_format' => env('LOCALIZATION_DEFAULT_TIME_FORMAT', TimeFormat::TwentyFourHours->value), 'default_time_format' => env('LOCALIZATION_DEFAULT_TIME_FORMAT', TimeFormat::TwentyFourHours->value),
'default_interval_format' => env('LOCALIZATION_DEFAULT_INTERVAL_FORMAT', IntervalFormat::HoursMinutes->value), 'default_interval_format' => env('LOCALIZATION_DEFAULT_INTERVAL_FORMAT', IntervalFormat::HoursMinutes->value),
], ],

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// date_format
DB::statement("update organizations set date_format = 'point-separated-d-m-yyyy' where date_format = 'point-seperated-d-m-yyyy'");
DB::statement("update organizations set date_format = 'slash-separated-mm-dd-yyyy' where date_format = 'slash-seperated-mm-dd-yyyy'");
DB::statement("update organizations set date_format = 'slash-separated-dd-mm-yyyy' where date_format = 'slash-seperated-dd-mm-yyyy'");
DB::statement("update organizations set date_format = 'hyphen-separated-dd-mm-yyyy'where date_format = 'hyphen-seperated-dd-mm-yyyy'");
DB::statement("update organizations set date_format = 'hyphen-separated-mm-dd-yyyy' where date_format = 'hyphen-seperated-mm-dd-yyyy'");
DB::statement("update organizations set date_format = 'hyphen-separated-yyyy-mm-dd' where date_format = 'hyphen-seperated-yyyy-mm-dd'");
// interval_format
DB::statement("update organizations set interval_format = 'hours-minutes-colon-separated' where interval_format = 'hours-minutes-colon-seperated'");
DB::statement("update organizations set interval_format = 'hours-minutes-seconds-colon-separated' where interval_format = 'hours-minutes-seconds-colon-seperated'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// date_format
DB::statement("update organizations set date_format = 'point-seperated-d-m-yyyy' where date_format = 'point-separated-d-m-yyyy'");
DB::statement("update organizations set date_format = 'slash-seperated-mm-dd-yyyy' where date_format = 'slash-separated-mm-dd-yyyy'");
DB::statement("update organizations set date_format = 'slash-seperated-dd-mm-yyyy' where date_format = 'slash-separated-dd-mm-yyyy'");
DB::statement("update organizations set date_format = 'hyphen-seperated-dd-mm-yyyy'where date_format = 'hyphen-separated-dd-mm-yyyy'");
DB::statement("update organizations set date_format = 'hyphen-seperated-mm-dd-yyyy' where date_format = 'hyphen-separated-mm-dd-yyyy'");
DB::statement("update organizations set date_format = 'hyphen-seperated-yyyy-mm-dd' where date_format = 'hyphen-separated-yyyy-mm-dd'");
// interval_format
DB::statement("update organizations set interval_format = 'hours-minutes-colon-seperated' where interval_format = 'hours-minutes-colon-separated'");
DB::statement("update organizations set interval_format = 'hours-minutes-seconds-colon-seperated' where interval_format = 'hours-minutes-seconds-colon-separated'");
}
};

View File

@@ -30,12 +30,12 @@ return [
], ],
'date_format' => [ 'date_format' => [
DateFormat::PointSeperatedDMYYYY->value => 'D.M.YYYY', DateFormat::PointSeparatedDMYYYY->value => 'D.M.YYYY',
DateFormat::SlashSeperatedMMDDYYYY->value => 'MM/DD/YYYY', DateFormat::SlashSeparatedMMDDYYYY->value => 'MM/DD/YYYY',
DateFormat::SlashSeperatedDDMMYYYY->value => 'DD/MM/YYYY', DateFormat::SlashSeparatedDDMMYYYY->value => 'DD/MM/YYYY',
DateFormat::HyphenSeperatedDDMMYYY->value => 'DD-MM-YYYY', DateFormat::HyphenSeparatedDDMMYYY->value => 'DD-MM-YYYY',
DateFormat::HyphenSeperatedMMDDDYYYY->value => 'MM-DD-YYYY', DateFormat::HyphenSeparatedMMDDDYYYY->value => 'MM-DD-YYYY',
DateFormat::HyphenSeperatedYYYYMMDD->value => 'YYYY-MM-DD', DateFormat::HyphenSeparatedYYYYMMDD->value => 'YYYY-MM-DD',
], ],
'time_format' => [ 'time_format' => [
@@ -46,8 +46,8 @@ return [
'interval_format' => [ 'interval_format' => [
IntervalFormat::Decimal->value => 'Decimal', IntervalFormat::Decimal->value => 'Decimal',
IntervalFormat::HoursMinutes->value => '12h 3m', IntervalFormat::HoursMinutes->value => '12h 3m',
IntervalFormat::HoursMinutesColonSeperated->value => '12:03', IntervalFormat::HoursMinutesColonSeparated->value => '12:03',
IntervalFormat::HoursMinutesSecondsColonSeperated->value => '12:03:45', IntervalFormat::HoursMinutesSecondsColonSeparated->value => '12:03:45',
], ],
'currency_format' => [ 'currency_format' => [

View File

@@ -11,9 +11,9 @@ import { useMutation, useQueryClient } from '@tanstack/vue-query';
type NumberFormat = 'point-comma' | 'comma-point' | 'space-comma' | 'space-point' | 'apostrophe-point'; type NumberFormat = 'point-comma' | 'comma-point' | 'space-comma' | 'space-point' | 'apostrophe-point';
type CurrencyFormat = 'iso-code-before-with-space' | 'iso-code-after-with-space' | 'symbol-before' | 'symbol-after' | 'symbol-before-with-space' | 'symbol-after-with-space'; type CurrencyFormat = 'iso-code-before-with-space' | 'iso-code-after-with-space' | 'symbol-before' | 'symbol-after' | 'symbol-before-with-space' | 'symbol-after-with-space';
type DateFormat = 'point-seperated-d-m-yyyy' | 'slash-seperated-mm-dd-yyyy' | 'slash-seperated-dd-mm-yyyy' | 'hyphen-seperated-dd-mm-yyyy' | 'hyphen-seperated-mm-dd-yyyy' | 'hyphen-seperated-yyyy-mm-dd'; type DateFormat = 'point-separated-d-m-yyyy' | 'slash-separated-mm-dd-yyyy' | 'slash-separated-dd-mm-yyyy' | 'hyphen-separated-dd-mm-yyyy' | 'hyphen-separated-mm-dd-yyyy' | 'hyphen-separated-yyyy-mm-dd';
type TimeFormat = '12-hours' | '24-hours'; type TimeFormat = '12-hours' | '24-hours';
type IntervalFormat = 'decimal' | 'hours-minutes' | 'hours-minutes-colon-seperated' | 'hours-minutes-seconds-colon-seperated'; type IntervalFormat = 'decimal' | 'hours-minutes' | 'hours-minutes-colon-separated' | 'hours-minutes-seconds-colon-separated';
interface FormValues { interface FormValues {
number_format: NumberFormat | undefined; number_format: NumberFormat | undefined;
@@ -118,12 +118,12 @@ async function submit() {
<SelectValue placeholder="Select date format" /> <SelectValue placeholder="Select date format" />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="point-seperated-d-m-yyyy">D.M.YYYY</SelectItem> <SelectItem value="point-separated-d-m-yyyy">D.M.YYYY</SelectItem>
<SelectItem value="slash-seperated-mm-dd-yyyy">MM/DD/YYYY</SelectItem> <SelectItem value="slash-separated-mm-dd-yyyy">MM/DD/YYYY</SelectItem>
<SelectItem value="slash-seperated-dd-mm-yyyy">DD/MM/YYYY</SelectItem> <SelectItem value="slash-separated-dd-mm-yyyy">DD/MM/YYYY</SelectItem>
<SelectItem value="hyphen-seperated-dd-mm-yyyy">DD-MM-YYYY</SelectItem> <SelectItem value="hyphen-separated-dd-mm-yyyy">DD-MM-YYYY</SelectItem>
<SelectItem value="hyphen-seperated-mm-dd-yyyy">MM-DD-YYYY</SelectItem> <SelectItem value="hyphen-separated-mm-dd-yyyy">MM-DD-YYYY</SelectItem>
<SelectItem value="hyphen-seperated-yyyy-mm-dd">YYYY-MM-DD</SelectItem> <SelectItem value="hyphen-separated-yyyy-mm-dd">YYYY-MM-DD</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
@@ -156,8 +156,8 @@ async function submit() {
<SelectContent> <SelectContent>
<SelectItem value="decimal">Decimal</SelectItem> <SelectItem value="decimal">Decimal</SelectItem>
<SelectItem value="hours-minutes">12h 3m</SelectItem> <SelectItem value="hours-minutes">12h 3m</SelectItem>
<SelectItem value="hours-minutes-colon-seperated">12:03</SelectItem> <SelectItem value="hours-minutes-colon-separated">12:03</SelectItem>
<SelectItem value="hours-minutes-seconds-colon-seperated">12:03:45</SelectItem> <SelectItem value="hours-minutes-seconds-colon-separated">12:03:45</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
@@ -165,11 +165,11 @@ async function submit() {
</template> </template>
<template #actions> <template #actions>
<PrimaryButton <PrimaryButton
:disabled="mutation.isPending.value" :disabled="mutation.isPending.value"
@click="submit"> @click="submit">
{{ mutation.isPending.value ? 'Saving...' : 'Save' }} {{ mutation.isPending.value ? 'Saving...' : 'Save' }}
</PrimaryButton> </PrimaryButton>
</template> </template>
</FormSection> </FormSection>
</template> </template>

View File

@@ -324,18 +324,18 @@ const CurrencyFormat = z.enum([
'symbol-after-with-space', 'symbol-after-with-space',
]); ]);
const DateFormat = z.enum([ const DateFormat = z.enum([
'point-seperated-d-m-yyyy', 'point-separated-d-m-yyyy',
'slash-seperated-mm-dd-yyyy', 'slash-separated-mm-dd-yyyy',
'slash-seperated-dd-mm-yyyy', 'slash-separated-dd-mm-yyyy',
'hyphen-seperated-dd-mm-yyyy', 'hyphen-separated-dd-mm-yyyy',
'hyphen-seperated-mm-dd-yyyy', 'hyphen-separated-mm-dd-yyyy',
'hyphen-seperated-yyyy-mm-dd', 'hyphen-separated-yyyy-mm-dd',
]); ]);
const IntervalFormat = z.enum([ const IntervalFormat = z.enum([
'decimal', 'decimal',
'hours-minutes', 'hours-minutes',
'hours-minutes-colon-seperated', 'hours-minutes-colon-separated',
'hours-minutes-seconds-colon-seperated', 'hours-minutes-seconds-colon-separated',
]); ]);
const TimeFormat = z.enum(['12-hours', '24-hours']); const TimeFormat = z.enum(['12-hours', '24-hours']);
const OrganizationUpdateRequest = z const OrganizationUpdateRequest = z

View File

@@ -29,7 +29,7 @@ class LocalizationServiceTest extends TestCaseWithDatabase
parent::setUp(); parent::setUp();
$this->localizationService = new LocalizationService( $this->localizationService = new LocalizationService(
CurrencyFormat::SymbolAfterWithSpace, CurrencyFormat::SymbolAfterWithSpace,
DateFormat::PointSeperatedDMYYYY, DateFormat::PointSeparatedDMYYYY,
TimeFormat::TwelveHours, TimeFormat::TwelveHours,
NumberFormat::ThousandsPointDecimalComma, NumberFormat::ThousandsPointDecimalComma,
IntervalFormat::Decimal, IntervalFormat::Decimal,
@@ -105,11 +105,11 @@ class LocalizationServiceTest extends TestCaseWithDatabase
$this->assertSame('30001h 03m', $formatted); $this->assertSame('30001h 03m', $formatted);
} }
public function test_format_interval_with_type_hours_minutes_colon_seperated(): void public function test_format_interval_with_type_hours_minutes_colon_separated(): void
{ {
// Arrange // Arrange
$interval = CarbonInterval::seconds(4 + (60 * 3) + (60 * 60 * 30001)); $interval = CarbonInterval::seconds(4 + (60 * 3) + (60 * 60 * 30001));
$this->localizationService->setIntervalFormat(IntervalFormat::HoursMinutesColonSeperated); $this->localizationService->setIntervalFormat(IntervalFormat::HoursMinutesColonSeparated);
// Act // Act
$formatted = $this->localizationService->formatInterval($interval); $formatted = $this->localizationService->formatInterval($interval);
@@ -118,11 +118,11 @@ class LocalizationServiceTest extends TestCaseWithDatabase
$this->assertSame('30001:03', $formatted); $this->assertSame('30001:03', $formatted);
} }
public function test_format_interval_with_type_hours_minutes_seconds_colon_seperated(): void public function test_format_interval_with_type_hours_minutes_seconds_colon_separated(): void
{ {
// Arrange // Arrange
$interval = CarbonInterval::seconds(4 + (60 * 3) + (60 * 60 * 30001)); $interval = CarbonInterval::seconds(4 + (60 * 3) + (60 * 60 * 30001));
$this->localizationService->setIntervalFormat(IntervalFormat::HoursMinutesSecondsColonSeperated); $this->localizationService->setIntervalFormat(IntervalFormat::HoursMinutesSecondsColonSeparated);
// Act // Act
$formatted = $this->localizationService->formatInterval($interval); $formatted = $this->localizationService->formatInterval($interval);
@@ -215,10 +215,10 @@ class LocalizationServiceTest extends TestCaseWithDatabase
$this->assertSame('EUR 1 234 567,89', $formatted); $this->assertSame('EUR 1 234 567,89', $formatted);
} }
public function test_format_date_with_type_slash_seperated_ddmmy(): void public function test_format_date_with_type_slash_separated_ddmmy(): void
{ {
// Arrange // Arrange
$this->localizationService->setDateFormat(DateFormat::SlashSeperatedDDMMYYYY); $this->localizationService->setDateFormat(DateFormat::SlashSeparatedDDMMYYYY);
$date = Carbon::createFromDate(2001, 2, 3); $date = Carbon::createFromDate(2001, 2, 3);
// Act // Act