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 4 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];
}
}
1 change: 1 addition & 0 deletions app/Locale/ChineseSimplified.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ 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.)


'SETTINGS_SUCCESS_LOGIN' => '登录信息已更新.',
'SETTINGS_SUCCESS_SORT' => '排序顺序已更新。',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/ChineseTraditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => '搜索功能已在設為停用。',
'SUCCESS' => '好',
'RETRY' => '重試',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => '登錄信息已更新',
'SETTINGS_SUCCESS_SORT' => '排序順序已更新。',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Czech.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Funkce hledání byla v nastavení deaktivována.',
'SUCCESS' => 'OK',
'RETRY' => 'Opakovat',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Přihlašovací údaje byly aktualizovány.',
'SETTINGS_SUCCESS_SORT' => 'Stav řazení byl aktulizován.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Dutch.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Probeer opnieuw',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Login Info updated.',
'SETTINGS_SUCCESS_SORT' => 'Sorting order updated.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/English.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'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
1 change: 1 addition & 0 deletions app/Locale/French.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ 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',

'SETTINGS_SUCCESS_LOGIN' => 'Informations de connexions mise à jour.',
'SETTINGS_SUCCESS_SORT' => 'Ordre d’affichage mis à jour.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/German.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Suchfunktion wurde unter Einstellungen deaktiviert.',
'SUCCESS' => 'OK',
'RETRY' => 'Noch einmal versuchen',
'OVERRIDE' => 'Überschreiben',

'SETTINGS_SUCCESS_LOGIN' => 'Benutzerdaten aktualisiert',
'SETTINGS_SUCCESS_SORT' => 'Sortierreihenfolge aktualisiert',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Greek.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Προσπάθεια ξανά',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Τα στοιχεία εισόδου ενημερώθηκαν.',
'SETTINGS_SUCCESS_SORT' => 'Η Ταξινόμηση ενημερώθηκε.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Italian.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Riprova',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Informazioni di Login Aggiornate.',
'SETTINGS_SUCCESS_SORT' => 'Modalità di ordinamento aggiornate.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/NorwegianBokmal.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Søkefunksjoner har blitt deaktivert under innstillinger',
'SUCCESS' => 'OK',
'RETRY' => 'Prøv igjen',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Innlogging oppdatert.',
'SETTINGS_SUCCESS_SORT' => 'Sorteringsrekkefølge oppdatert.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Polish.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Funkcja wyszkukiwania została wyłączona w ustawieniach.',
'SUCCESS' => 'OK',
'RETRY' => 'Ponów',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Zaktualizowano informacje o loginie.',
'SETTINGS_SUCCESS_SORT' => 'Zaktualizowano kolejność sortowania.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Portuguese.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ 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',

'SETTINGS_SUCCESS_LOGIN' => 'Informação de Login atualizada.',
'SETTINGS_SUCCESS_SORT' => 'Ordenação atualizada.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Russian.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'Ок',
'RETRY' => 'Повторить',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Учётные данные обновлены.',
'SETTINGS_SUCCESS_SORT' => 'Порядок сортировки обновлён.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Slovak.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Opakovať',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Užívateľské dáta aktualizované',
'SETTINGS_SUCCESS_SORT' => 'Triedenie aktualizované',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Spanish.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ 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',

'SETTINGS_SUCCESS_LOGIN' => 'Información de inicio de sesión actualizada',
'SETTINGS_SUCCESS_SORT' => 'Orden de clasificación actualizado',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Swedish.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public function get_locale(): array
'ERROR_SEARCH_DEACTIVATED' => 'Search functionality has been deactivated under settings.',
'SUCCESS' => 'OK',
'RETRY' => 'Försök igen',
'OVERRIDE' => 'Override',

'SETTINGS_SUCCESS_LOGIN' => 'Login Info updated.',
'SETTINGS_SUCCESS_SORT' => 'Sorting order updated.',
Expand Down
1 change: 1 addition & 0 deletions app/Locale/Vietnamese.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ 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',

'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
Loading