-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace layout and overlay to proper Enum types (#2015)
* replace layout and overlay to proper Enum types * sync Lychee-front
- Loading branch information
Showing
13 changed files
with
201 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
/** | ||
* Enum AlbumLayoutType. | ||
* | ||
* All the allowed layout possibilities on Album | ||
*/ | ||
enum AlbumLayoutType: string | ||
{ | ||
case SQUARE = 'square'; | ||
case JUSTIFIED = 'justified'; | ||
case UNJUSTIFIED = 'unjustified'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
/** | ||
* Enum ImageOverlayType. | ||
* | ||
* All the allowed overlay info on Photos | ||
*/ | ||
enum ImageOverlayType: string | ||
{ | ||
case NONE = 'none'; | ||
case DESC = 'desc'; | ||
case DATE = 'date'; | ||
case EXIF = 'exif'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
database/migrations/2023_09_16_070405_refactor_type_layout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
return new class() extends Migration { | ||
public const SQUARE = 'square'; | ||
public const JUSTIFIED = 'justified'; | ||
public const UNJUSTIFIED = 'unjustified'; | ||
|
||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
/** @var int $layout */ | ||
$layout = DB::table('configs')->select('value')->where('key', '=', 'layout')->first()->value; | ||
DB::table('configs')->where('key', '=', 'layout')->delete(); | ||
DB::table('configs')->insert([ | ||
[ | ||
'key' => 'layout', | ||
'value' => $this->toEnum($layout), | ||
'confidentiality' => 0, | ||
'cat' => 'Gallery', | ||
'type_range' => self::SQUARE . '|' . self::JUSTIFIED . '|' . self::UNJUSTIFIED, | ||
'description' => 'Layout for pictures', | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
/** @var string $layout */ | ||
$layout = DB::table('configs')->select('value')->where('key', '=', 'layout')->first()->value; | ||
DB::table('configs')->where('key', '=', 'layout')->delete(); | ||
DB::table('configs')->insert([ | ||
[ | ||
'key' => 'layout', | ||
'value' => $this->fromEnum($layout), | ||
'confidentiality' => 0, | ||
'cat' => 'Gallery', | ||
'type_range' => '0|1|2', | ||
'description' => 'Layout for pictures', | ||
], | ||
]); | ||
} | ||
|
||
private function toEnum(int $layout): string | ||
{ | ||
return match ($layout) { | ||
0 => self::SQUARE, | ||
1 => self::JUSTIFIED, | ||
2 => self::UNJUSTIFIED, | ||
default => self::JUSTIFIED, | ||
}; | ||
} | ||
|
||
private function fromEnum(string $layout): int | ||
{ | ||
return match ($layout) { | ||
self::SQUARE => 0, | ||
self::JUSTIFIED => 1, | ||
self::UNJUSTIFIED => 2, | ||
default => 1, | ||
}; | ||
} | ||
}; |
Submodule Lychee-front
updated
5 files
+1 −1 | scripts/3rd-party/backend.js | |
+1 −1 | scripts/main/build.js | |
+6 −7 | scripts/main/lychee.js | |
+2 −2 | scripts/main/search.js | |
+8 −8 | scripts/main/view.js |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters