Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to append tags #1564

Merged
merged 9 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/Http/Controllers/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,14 @@ public function setPublic(SetPhotoPublicRequest $request): void
public function setTags(SetPhotosTagsRequest $request): void
{
$tags = $request->tags();

/** @var Photo $photo */
foreach ($request->photos() as $photo) {
$photo->tags = $tags;
if ($request->shallOverride) {
$photo->tags = $tags;
} else {
$photo->tags = array_unique(array_merge($photo->tags, $tags));
}
$photo->save();
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Requests/Photo/SetPhotosTagsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ class SetPhotosTagsRequest extends BaseApiRequest implements HasPhotos, HasTags
use HasTagsTrait;
use AuthorizeCanEditPhotosTrait;

public const SHALL_OVERRIDE_ATTRIBUTE = 'shall_override';
ildyria marked this conversation as resolved.
Show resolved Hide resolved

public bool $shallOverride;

/**
* {@inheritDoc}
*/
public function rules(): array
{
return [
self::SHALL_OVERRIDE_ATTRIBUTE => 'required|boolean',
HasPhotos::PHOTO_IDS_ATTRIBUTE => 'required|array|min:1',
HasPhotos::PHOTO_IDS_ATTRIBUTE . '.*' => ['required', new RandomIDRule(false)],
HasTags::TAGS_ATTRIBUTE => 'present|array',
Expand All @@ -37,5 +42,6 @@ protected function processValidatedValues(array $values, array $files): void
{
$this->photos = Photo::query()->findOrFail($values[HasPhotos::PHOTO_IDS_ATTRIBUTE]);
$this->tags = $values[HasTags::TAGS_ATTRIBUTE];
$this->shallOverride = $values[self::SHALL_OVERRIDE_ATTRIBUTE];
}
}
2 changes: 2 additions & 0 deletions app/Locale/ChineseSimplified.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => '搜索功能已在设置中停用。',
'SUCCESS' => 'OK',
'RETRY' => '重试',
'OVERRIDE' => 'Override',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to check with the frontend where we use this label, but in order to prevent clash of names in the future I would prefer a key which is more specific than only OVERRIDE. I would expect something like CHECKBOX_OVERRIDE_LABEL or whatever is appropriate. (I haven't had a look at the frontend yet, hence I don't know where this key is used.)

'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => '登录信息已更新.',
'SETTINGS_SUCCESS_SORT' => '排序顺序已更新。',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/ChineseTraditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => '搜索功能已在設為停用。',
'SUCCESS' => '好',
'RETRY' => '重試',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => '登錄信息已更新',
'SETTINGS_SUCCESS_SORT' => '排序順序已更新。',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Czech.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Funkce hledání byla v nastavení deaktivována.',
'SUCCESS' => 'OK',
'RETRY' => 'Opakovat',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Přihlašovací údaje byly aktualizovány.',
'SETTINGS_SUCCESS_SORT' => 'Stav řazení byl aktulizován.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Dutch.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Probeer opnieuw',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Login Info updated.',
'SETTINGS_SUCCESS_SORT' => 'Sorting order updated.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/English.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Retry',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Login Info updated.',
'SETTINGS_SUCCESS_SORT' => 'Sorting order updated.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/French.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'La recherche a été désactivée dans les paramètres.',
'SUCCESS' => 'OK',
'RETRY' => 'Réessayer',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Informations de connexions mise à jour.',
'SETTINGS_SUCCESS_SORT' => 'Ordre d’affichage mis à jour.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/German.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Suchfunktion wurde unter Einstellungen deaktiviert.',
'SUCCESS' => 'OK',
'RETRY' => 'Noch einmal versuchen',
'OVERRIDE' => 'Überschreiben',
'TAGS_OVERRIDE_INFO' => 'Wenn das nicht aktiviert ist, werden die Tags zu den vorhandenen Tags des Fotos hinzugefügt.',

'SETTINGS_SUCCESS_LOGIN' => 'Benutzerdaten aktualisiert',
'SETTINGS_SUCCESS_SORT' => 'Sortierreihenfolge aktualisiert',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Greek.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Προσπάθεια ξανά',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Τα στοιχεία εισόδου ενημερώθηκαν.',
'SETTINGS_SUCCESS_SORT' => 'Η Ταξινόμηση ενημερώθηκε.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Italian.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Riprova',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Informazioni di Login Aggiornate.',
'SETTINGS_SUCCESS_SORT' => 'Modalità di ordinamento aggiornate.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/NorwegianBokmal.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Søkefunksjoner har blitt deaktivert under innstillinger',
'SUCCESS' => 'OK',
'RETRY' => 'Prøv igjen',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Innlogging oppdatert.',
'SETTINGS_SUCCESS_SORT' => 'Sorteringsrekkefølge oppdatert.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Polish.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Funkcja wyszkukiwania została wyłączona w ustawieniach.',
'SUCCESS' => 'OK',
'RETRY' => 'Ponów',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Zaktualizowano informacje o loginie.',
'SETTINGS_SUCCESS_SORT' => 'Zaktualizowano kolejność sortowania.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Portuguese.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'A funcionalidade de procura foi desativada nas configurações.',
'SUCCESS' => 'OK',
'RETRY' => 'Tentar de novo',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Informação de Login atualizada.',
'SETTINGS_SUCCESS_SORT' => 'Ordenação atualizada.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Russian.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'Ок',
'RETRY' => 'Повторить',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Учётные данные обновлены.',
'SETTINGS_SUCCESS_SORT' => 'Порядок сортировки обновлён.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Slovak.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Opakovať',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Užívateľské dáta aktualizované',
'SETTINGS_SUCCESS_SORT' => 'Triedenie aktualizované',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Spanish.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'La función de búsqueda se ha desactivado en la configuración.',
'SUCCESS' => 'Vale',
'RETRY' => 'Procesar de nuevo',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Información de inicio de sesión actualizada',
'SETTINGS_SUCCESS_SORT' => 'Orden de clasificación actualizado',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Swedish.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Försök igen',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Login Info updated.',
'SETTINGS_SUCCESS_SORT' => 'Sorting order updated.',
Expand Down
2 changes: 2 additions & 0 deletions app/Locale/Vietnamese.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Tính năng tìm kiếm đã tắt trong phần cài đặt',
'SUCCESS' => 'OK',
'RETRY' => 'Thử lại',
'OVERRIDE' => 'Override',
'TAGS_OVERRIDE_INFO' => 'If this is unchecked, the tags will be added to the existing tags of the photo.',

'SETTINGS_SUCCESS_LOGIN' => 'Thông tin đăng nhập đã được cập nhật.',
'SETTINGS_SUCCESS_SORT' => 'Thứ tự sắp xếp đã được cập nhật.',
Expand Down
2 changes: 1 addition & 1 deletion public/Lychee-front
Empty file modified public/dist/leaflet.markercluster.js.map
100644 → 100755
Empty file.
22 changes: 15 additions & 7 deletions public/dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/dist/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,7 @@ lychee.locale = {
PHOTO_NEW_TAGS: "Enter your tags for this photo. You can add multiple tags by separating them with a comma:",
PHOTOS_NEW_TAGS: "Enter your tags for all %d selected photos. Existing tags will be overwritten. You can add multiple tags by separating them with a comma:",
PHOTO_SET_TAGS: "Set Tags",
TAGS_OVERRIDE_INFO: "If this is unchecked, the tags will be added to the existing tags of the photo.",
PHOTO_CAMERA: "Camera",
PHOTO_CAPTURED: "Captured",
PHOTO_MAKE: "Make",
Expand Down Expand Up @@ -2911,6 +2912,7 @@ lychee.locale = {
ERROR_SEARCH_DEACTIVATED: "Search functionality has been deactivated under settings.",
SUCCESS: "OK",
RETRY: "Retry",
OVERRIDE: "Override",

SETTINGS_SUCCESS_LOGIN: "Login Info updated.",
SETTINGS_SUCCESS_SORT: "Sorting order updated.",
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/Lib/PhotosUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,21 @@ public function set_star(
*
* @param string[] $ids
* @param string[] $tags
* @param bool $override
* @param int $expectedStatusCode
* @param string|null $assertSee
*/
public function set_tag(
array $ids,
array $tags,
bool $override = true,
qwerty287 marked this conversation as resolved.
Show resolved Hide resolved
int $expectedStatusCode = 204,
?string $assertSee = null
): void {
$response = $this->testCase->postJson('/api/Photo::setTags', [
'photoIDs' => $ids,
'tags' => $tags,
'shall_override' => $override,
]);
$response->assertStatus($expectedStatusCode);
if ($assertSee) {
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/PhotosOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function testManyFunctionsAtOnce(): void
$this->photos_tests->set_description($id, 'A night photography');
$this->photos_tests->set_star([$id], true);
$this->photos_tests->set_tag([$id], ['night']);
$this->photos_tests->set_tag([$id], ['trees'], false);
$this->photos_tests->set_public($id, true);
$this->photos_tests->set_license($id, 'WTFPL', 422, 'license must be one out of');
$this->photos_tests->set_license($id, 'CC0');
Expand Down Expand Up @@ -141,7 +142,7 @@ public function testManyFunctionsAtOnce(): void
'license' => 'reserved',
'is_public' => 1,
'is_starred' => true,
'tags' => ['night'],
'tags' => ['night', 'trees'],
]);

/**
Expand Down