-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add prev/next links to image tag edit view
- Loading branch information
Showing
7 changed files
with
124 additions
and
91 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
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
77 changes: 77 additions & 0 deletions
77
resources/views/web/rsi/comm_links/images/edit-tags.blade.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,77 @@ | ||
@extends('web.layouts.default') | ||
|
||
@section('title', __('Bild').' - '.$image->id. ' ' . __('(bearbeiten)')) | ||
|
||
@section('content') | ||
<div class="d-flex mb-3 nav-bar justify-content-between"> | ||
@unless($image->prev === null) | ||
<a href="{{ route('web.rsi.comm-links.images.edit-tags', $image->prev) }}" class="btn btn-outline-secondary d-block">@lang('Vorheriges Bild')</a> | ||
@else | ||
<a href="#" class="btn btn-outline-secondary disabled d-block">@lang('Vorheriges Bild')</a> | ||
@endunless | ||
<a href="{{ route('web.rsi.comm-links.images.start-edit') }}" class="btn btn-secondary d-block">@lang('Zufälliges Bild')</a> | ||
@unless($image->next === null) | ||
<a href="{{ route('web.rsi.comm-links.images.edit-tags', $image->next) }}" class="btn btn-outline-secondary d-block">@lang('Nächstes Bild')</a> | ||
@else | ||
<a href="#" class="btn btn-outline-secondary disabled d-block">@lang('Nächstes Bild')</a> | ||
@endunless | ||
</div> | ||
|
||
@component('components.forms.form', [ | ||
'method' => 'PATCH', | ||
'action' => route('web.rsi.comm-links.images.save-tags', $image->getRouteKey()), | ||
'class' => '', | ||
]) | ||
@include('components.errors') | ||
<div class="row"> | ||
<div class="col-12 col-md-7"> | ||
@include('components.comm_links.image_info_card', ['image' => $image, 'noFooter' => true]) | ||
</div> | ||
<div class="col-12 col-md-5 d-flex align-content-stretch flex-column"> | ||
<button type="submit" class="btn btn-block btn-primary mb-3">@lang('Speichern')</button> | ||
<span class="alert alert-warning d-none" id="new-tag-warning"></span> | ||
<span class="help-block d-block mb-2">@lang('Neue Tags können durch Tippen in der Auswahl hinzugefügt werden.')</span> | ||
<select class="form-select custom-select form-control" multiple size="15" name="tags[]" id="tags"> | ||
@foreach($tags as $tag) | ||
<option value="id:{{ $tag->id }}" @php if ($image_tags->contains($tag->name)) echo "selected"; @endphp>{{ $tag->translated_name }}</option> | ||
@endforeach | ||
</select> | ||
</div> | ||
</div> | ||
@endcomponent | ||
@endsection | ||
|
||
|
||
@section('body__after') | ||
@parent | ||
<script> | ||
(()=>{ | ||
const newTags = []; | ||
$('#tags').select2({ | ||
allowClear: true, | ||
closeOnSelect: false, | ||
tags: true | ||
}); | ||
$('#tags').select2('open'); | ||
$('#tags').on('select2:selecting', function(e) { | ||
const datum = e.params.args.data; | ||
if (datum?.id && (datum?.id ?? '').slice(0, 3) !== 'id:') { | ||
if (!newTags.includes(datum.id)) { | ||
newTags.push(datum.id); | ||
} | ||
} | ||
if (newTags.length > 0) { | ||
const container = document.querySelector('#new-tag-warning'); | ||
container.classList.remove('d-none'); | ||
container.innerText = `Die folgenden Tags existieren noch nicht in der Datenbank: ${newTags.join(', ')}.` | ||
} | ||
}); | ||
})(); | ||
</script> | ||
@endsection |
37 changes: 0 additions & 37 deletions
37
resources/views/web/rsi/comm_links/tags/edit-tag.blade.php
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,37 @@ | ||
@extends('web.layouts.default') | ||
|
||
@section('title', __('Bild').' - '.$image->id. ' ' . __('(bearbeiten)')) | ||
@section('title', __('Tag').' - '.$tag->translated_name. ' ' . __('(bearbeiten)')) | ||
|
||
@section('content') | ||
<a href="{{ route('web.rsi.comm-links.images.start-edit') }}" class="btn btn-block btn-secondary mb-3">@lang('Anderes Bild')</a> | ||
@component('components.forms.form', [ | ||
'method' => 'PATCH', | ||
'action' => route('web.rsi.comm-links.images.save-tags', $image->getRouteKey()), | ||
'class' => '', | ||
'action' => route('web.rsi.comm-links.image-tags.update', $tag->getRouteKey()), | ||
'method' => 'POST', | ||
'class' => 'card mb-4' | ||
]) | ||
@include('components.errors') | ||
<div class="row"> | ||
<div class="col-12 col-md-7"> | ||
@include('components.comm_links.image_info_card', ['image' => $image, 'noFooter' => true]) | ||
</div> | ||
<div class="col-12 col-md-5 d-flex align-content-stretch flex-column"> | ||
<button type="submit" class="btn btn-block btn-primary mb-3">@lang('Speichern')</button> | ||
<span class="alert alert-warning d-none" id="new-tag-warning"></span> | ||
<span class="help-block d-block mb-2">@lang('Neue Einträge können durch Tippen in der Auswahl hinzugefügt werden.')</span> | ||
<select class="form-select custom-select form-control" multiple size="15" name="tags[]" id="tags"> | ||
@foreach($tags as $tag) | ||
<option value="id:{{ $tag->id }}" @php if ($image_tags->contains($tag->name)) echo "selected"; @endphp>{{ $tag->translated_name }}</option> | ||
@endforeach | ||
</select> | ||
<div class="wrapper"> | ||
<h4 class="card-header">@lang('Tag Bearbeiten')</h4> | ||
<div class="card-body"> | ||
@include('components.errors') | ||
@include('components.messages') | ||
@component('components.forms.form-group', [ | ||
'inputType' => 'text', | ||
'label' => __('Name'), | ||
'id' => 'name', | ||
'value' => $tag->name, | ||
'required' => true, | ||
])@endcomponent | ||
@component('components.forms.form-group', [ | ||
'inputType' => 'text', | ||
'label' => __('Name') . ' ' . __('Englisch'), | ||
'id' => 'name_en', | ||
'value' => $tag->name_en, | ||
'required' => true, | ||
])@endcomponent | ||
|
||
<button class="btn btn-outline-secondary" type="submit">@lang('Speichern')</button> | ||
</div> | ||
</div> | ||
@endcomponent | ||
@endsection | ||
|
||
|
||
@section('body__after') | ||
@parent | ||
<script> | ||
(()=>{ | ||
const newTags = []; | ||
$('#tags').select2({ | ||
allowClear: true, | ||
closeOnSelect: false, | ||
tags: true | ||
}); | ||
$('#tags').select2('open'); | ||
$('#tags').on('select2:selecting', function(e) { | ||
const datum = e.params.args.data; | ||
if (datum?.id && (datum?.id ?? '').slice(0, 3) !== 'id:') { | ||
if (!newTags.includes(datum.id)) { | ||
newTags.push(datum.id); | ||
} | ||
} | ||
if (newTags.length > 0) { | ||
const container = document.querySelector('#new-tag-warning'); | ||
container.classList.remove('d-none'); | ||
container.innerText = `Die folgenden Tags existieren noch nicht in der Datenbank: ${newTags.join(', ')}.` | ||
} | ||
}); | ||
})(); | ||
</script> | ||
@endsection |