266 lines
14 KiB
PHP
266 lines
14 KiB
PHP
<div class="card mb-4">
|
|
<h5 class="card-header">
|
|
<i class="ion ion-md-settings mr-2"></i>
|
|
{{ __('backend.general_settings') }}
|
|
</h5>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label class="custom-control custom-checkbox">
|
|
{!! Form::checkbox('active', 1, $news->active ?? true, ['class'=>'custom-control-input']) !!}
|
|
<span class="custom-control-label">{{ __('backend.news_active') }}</span>
|
|
</label>
|
|
|
|
<small class="form-text text-muted">
|
|
<i class="ion ion-md-information-circle"></i>
|
|
{{ __('backend.news_active_hint') }}<br>
|
|
<strong>{{ __('backend.news_active_single') }}</strong>
|
|
</small>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label class="form-label" for="display_date">{{ __('backend.display_date') }}</label>
|
|
{!! Form::text('display_date', $news->display_date ? $news->display_date->format('d.m.Y') : now()->format('d.m.Y'), ['class'=>'form-control datepicker-base', 'id' => 'display_date']) !!}
|
|
|
|
<small class="form-text text-muted">{{ __('backend.display_date_hint') }}</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- German (Default Language) -->
|
|
<div class="card mb-4">
|
|
<h5 class="card-header bg-primary text-white">
|
|
<i class="ion ion-md-flag mr-2"></i>
|
|
{{ __('backend.german') }} ({{ __('backend.default_language') }})
|
|
</h5>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label" for="title">{{ __('backend.title') }}*</label>
|
|
{{ Form::text('title', $news->title, ['placeholder' => __('backend.title'), 'class' => 'form-control', 'id' => 'title', 'required']) }}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label" for="teaser">{{ __('backend.teaser') }}*</label>
|
|
{{ Form::textarea('teaser', $news->teaser, ['placeholder' => __('backend.teaser'), 'class' => 'form-control', 'id' => 'teaser', 'rows' => 3, 'required']) }}
|
|
<small class="form-text text-muted">{{ __('backend.teaser_hint') }}</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label" for="content">{{ __('backend.content') }}</label>
|
|
{{ Form::textarea('content', $news->content, ['placeholder' => __('backend.content'), 'class' => 'form-control summernote-small', 'id' => 'content', 'rows' => 8]) }}
|
|
<small class="form-text text-muted">{{ __('backend.content_hint') }}</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label">
|
|
<i class="ion ion-md-attach mr-1"></i>
|
|
{{ __('backend.file_links') }}
|
|
</label>
|
|
<div id="file-links-de" class="border p-3 rounded bg-light">
|
|
@php
|
|
$existingLinks = $news->file_links['de'] ?? [];
|
|
@endphp
|
|
@foreach($existingLinks as $index => $link)
|
|
<div class="file-link-item mb-2" data-index="{{ $index }}">
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<input type="text" name="file_links[de][{{ $index }}][label]"
|
|
class="form-control form-control-sm"
|
|
placeholder="{{ __('backend.link_label') }}"
|
|
value="{{ $link['label'] ?? '' }}">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<select name="file_links[de][{{ $index }}][file_id]"
|
|
class="form-control form-control-sm select2-files"
|
|
data-placeholder="{{ __('backend.select_file') }}">
|
|
<option value="">{{ __('backend.select_file') }}</option>
|
|
@foreach(\App\Models\DcFile::where('active', 1)->orderBy('original_name')->get() as $file)
|
|
<option value="{{ $file->id }}"
|
|
{{ ($link['file_id'] ?? null) == $file->id ? 'selected' : '' }}>
|
|
{{ $file->original_name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="button" class="btn btn-sm btn-danger remove-file-link">
|
|
<i class="ion ion-md-trash"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
<button type="button" class="btn btn-sm btn-outline-primary mt-2" id="add-file-link-de">
|
|
<i class="ion ion-md-add-circle"></i> {{ __('backend.add_file_link') }}
|
|
</button>
|
|
<small class="form-text text-muted">{{ __('backend.file_links_hint') }}</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Other Languages -->
|
|
@foreach($languages as $locale => $localeData)
|
|
@if($locale !== 'de')
|
|
<div class="card mb-4">
|
|
<h5 class="card-header">
|
|
<i class="ion ion-md-flag mr-2"></i>
|
|
{{ $localeData['native'] }} ({{ strtoupper($locale) }})
|
|
</h5>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label" for="trans_title_{{ $locale }}">{{ __('backend.title') }}</label>
|
|
{{ Form::text('trans_title_' . $locale, $news->getTrans('title', $locale), ['placeholder' => __('backend.title'), 'class' => 'form-control ', 'id' => 'trans_title_' . $locale]) }}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label" for="trans_teaser_{{ $locale }}">{{ __('backend.teaser') }}</label>
|
|
{{ Form::textarea('trans_teaser_' . $locale, $news->getTrans('teaser', $locale), ['placeholder' => __('backend.teaser'), 'class' => 'form-control', 'id' => 'trans_teaser_' . $locale, 'rows' => 3]) }}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label" for="trans_content_{{ $locale }}">{{ __('backend.content') }}</label>
|
|
{{ Form::textarea('trans_content_' . $locale, $news->getTrans('content', $locale), ['placeholder' => __('backend.content'), 'class' => 'form-control summernote-small', 'id' => 'trans_content_' . $locale, 'rows' => 8]) }}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label class="form-label">
|
|
<i class="ion ion-md-attach mr-1"></i>
|
|
{{ __('backend.file_links') }}
|
|
</label>
|
|
<div id="file-links-{{ $locale }}" class="border p-3 rounded bg-light">
|
|
@php
|
|
$existingLinks = $news->file_links[$locale] ?? [];
|
|
@endphp
|
|
@foreach($existingLinks as $index => $link)
|
|
<div class="file-link-item mb-2" data-index="{{ $index }}">
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<input type="text" name="file_links[{{ $locale }}][{{ $index }}][label]"
|
|
class="form-control form-control-sm"
|
|
placeholder="{{ __('backend.link_label') }}"
|
|
value="{{ $link['label'] ?? '' }}">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<select name="file_links[{{ $locale }}][{{ $index }}][file_id]"
|
|
class="form-control form-control-sm select2-files"
|
|
data-placeholder="{{ __('backend.select_file') }}">
|
|
<option value="">{{ __('backend.select_file') }}</option>
|
|
@foreach(\App\Models\DcFile::where('active', 1)->orderBy('original_name')->get() as $file)
|
|
<option value="{{ $file->id }}"
|
|
{{ ($link['file_id'] ?? null) == $file->id ? 'selected' : '' }}>
|
|
{{ $file->original_name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="button" class="btn btn-sm btn-danger remove-file-link">
|
|
<i class="ion ion-md-trash"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
<button type="button" class="btn btn-sm btn-outline-primary mt-2 add-file-link" data-locale="{{ $locale }}">
|
|
<i class="ion ion-md-add-circle"></i> {{ __('backend.add_file_link') }}
|
|
</button>
|
|
<small class="form-text text-muted">{{ __('backend.file_links_hint') }}</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
let fileOptions = `@foreach(\App\Models\DcFile::where('active', 1)->orderBy('original_name')->get() as $file)<option value="{{ $file->id }}">{{ $file->original_name }}</option>@endforeach`;
|
|
|
|
// Add file link for DE (default language)
|
|
document.getElementById('add-file-link-de')?.addEventListener('click', function() {
|
|
addFileLink('de');
|
|
});
|
|
|
|
// Add file link for other languages
|
|
document.querySelectorAll('.add-file-link').forEach(button => {
|
|
button.addEventListener('click', function() {
|
|
let locale = this.getAttribute('data-locale');
|
|
addFileLink(locale);
|
|
});
|
|
});
|
|
|
|
// Remove file link
|
|
document.addEventListener('click', function(e) {
|
|
if (e.target.closest('.remove-file-link')) {
|
|
e.target.closest('.file-link-item').remove();
|
|
}
|
|
});
|
|
|
|
function addFileLink(locale) {
|
|
let container = document.getElementById('file-links-' + locale);
|
|
let index = container.querySelectorAll('.file-link-item').length;
|
|
|
|
let html = `
|
|
<div class="file-link-item mb-2" data-index="${index}">
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<input type="text" name="file_links[${locale}][${index}][label]"
|
|
class="form-control form-control-sm"
|
|
placeholder="{{ __('backend.link_label') }}">
|
|
</div>
|
|
<div class="col-md-3">
|
|
<select name="file_links[${locale}][${index}][file_id]"
|
|
class="form-control form-control-sm select2-files"
|
|
data-placeholder="{{ __('backend.select_file') }}">
|
|
<option value="">{{ __('backend.select_file') }}</option>
|
|
${fileOptions}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<button type="button" class="btn btn-sm btn-danger remove-file-link">
|
|
<i class="ion ion-md-trash"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
container.insertAdjacentHTML('beforeend', html);
|
|
|
|
// Initialize Select2 on new element
|
|
let newSelect = container.querySelector('.file-link-item:last-child select');
|
|
if (typeof $.fn.select2 !== 'undefined') {
|
|
$(newSelect).select2({
|
|
width: '100%',
|
|
placeholder: '{{ __("backend.select_file") }}'
|
|
});
|
|
}
|
|
}
|
|
|
|
// Initialize Select2 on existing selects
|
|
if (typeof $.fn.select2 !== 'undefined') {
|
|
$('.select2-files').select2({
|
|
width: '100%',
|
|
placeholder: '{{ __("backend.select_file") }}'
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|