Skip to content

Commit

Permalink
update bindle form
Browse files Browse the repository at this point in the history
  • Loading branch information
HolgerHatGarKeineNode committed Aug 2, 2023
1 parent 90f789c commit d67fc51
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
20 changes: 18 additions & 2 deletions app/Http/Livewire/Library/Form/LibraryItemForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ class LibraryItemForm extends Component

public bool $lecturer = false;

public bool $isBindle = false;

public ?string $fromUrl = '';

protected $queryString = [
'fromUrl' => ['except' => ''],
'lecturer' => ['except' => false],
'isBindle' => ['except' => false],
];

public function rules()
Expand All @@ -57,7 +60,13 @@ public function rules()
&& $this->libraryItem->type !== LibraryItemType::DownloadableFile(), ['url']
),
],
'libraryItem.subtitle' => 'required',
'libraryItem.subtitle' =>
[
Rule::when(
$this->libraryItem->type !== 'bindle',
'required',
)
],
'libraryItem.excerpt' =>
[
Rule::when(
Expand Down Expand Up @@ -95,7 +104,7 @@ public function mount()
$this->libraryItem = new LibraryItem([
'approved' => true,
'read_time' => 1,
'value' => '',
'value' => ''
]);
if ($this->lecturer) {
$this->library = Library::query()
Expand All @@ -114,6 +123,13 @@ public function mount()
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
if ($this->isBindle) {
$this->library = 21;
$this->libraryItem->lecturer_id = 125;
$this->libraryItem->type = 'bindle';
$this->libraryItem->language_code = 'de';
$this->selectedTags = ['Bindle'];
}
}

public function save()
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/bindle/gallery.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="py-6">
@if(auth()->id() == config('portal.bonus.fiat-tracker-user-id'))
<x-button icon="plus"
:href="route('library.libraryItem.form', ['country' => 'de'])">
:href="route('library.libraryItem.form', ['country' => 'de', 'isBindle' => true])">
{{ __('Neues Bindle hochladen') }}
</x-button>
@endif
Expand Down
64 changes: 36 additions & 28 deletions resources/views/livewire/library/form/library-item-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,38 +133,43 @@
@error('image') <span class="text-red-500">{{ $message }}</span> @enderror
</x-input.group>

<x-input.group :for="md5('libraryItem.main_image_caption')" :label="__('Main image caption')">
<x-input autocomplete="off" wire:model.debounce="libraryItem.main_image_caption"
:placeholder="__('Main image caption')"
:cornerHint="__('Ex: Photo by Timothy Vollmer/ CC BY')"/>
</x-input.group>
@if(!$isBindle)
<x-input.group :for="md5('libraryItem.main_image_caption')"
:label="__('Main image caption')">
<x-input autocomplete="off" wire:model.debounce="libraryItem.main_image_caption"
:placeholder="__('Main image caption')"
:cornerHint="__('Ex: Photo by Timothy Vollmer/ CC BY')"/>
</x-input.group>
@endif

<x-input.group :for="md5('libraryItem.name')" :label="__('Title')">
<x-input autocomplete="off" wire:model.debounce="libraryItem.name"
:placeholder="__('Title')"/>
</x-input.group>

<x-input.group :for="md5('libraryItem.subtitle')" :label="__('Subtitle')">
<x-input autocomplete="off" wire:model.debounce="libraryItem.subtitle"
:placeholder="__('Subtitle')"/>
</x-input.group>
@if(!$isBindle)
<x-input.group :for="md5('libraryItem.subtitle')" :label="__('Subtitle')">
<x-input autocomplete="off" wire:model.debounce="libraryItem.subtitle"
:placeholder="__('Subtitle')"/>
</x-input.group>

<x-input.group :for="md5('libraryItem.excerpt')" :label="__('Excerpt')">
<x-textarea autocomplete="off" wire:model.debounce="libraryItem.excerpt"
:placeholder="__('Excerpt')"/>
</x-input.group>
<x-input.group :for="md5('libraryItem.excerpt')" :label="__('Excerpt')">
<x-textarea autocomplete="off" wire:model.debounce="libraryItem.excerpt"
:placeholder="__('Excerpt')"/>
</x-input.group>

<x-input.group :for="md5('libraryItem.language_code')" :label="__('Language Code')">
<x-select
placeholder="{{ __('Choose language') }}"
wire:model="libraryItem.language_code"
:clearable="false"
:searchable="true"
:async-data="route('api.languages.index')"
option-label="name"
option-value="language"
/>
</x-input.group>
<x-input.group :for="md5('libraryItem.language_code')" :label="__('Language Code')">
<x-select
placeholder="{{ __('Choose language') }}"
wire:model="libraryItem.language_code"
:clearable="false"
:searchable="true"
:async-data="route('api.languages.index')"
option-label="name"
option-value="language"
/>
</x-input.group>
@endif

@if($libraryItem->type === App\Enums\LibraryItemType::MarkdownArticleExtern())
<x-input.group :for="md5('libraryItem.value')" :label="__('Article as Markdown')">
Expand All @@ -186,10 +191,13 @@ class="text-red-500 py-2">{{ $message }}</span> @enderror
</x-input.group>
@endif

<x-input.group :for="md5('libraryItem.read_time')" :label="__('Time to read')">
<x-inputs.number min="1" autocomplete="off" wire:model.debounce="libraryItem.read_time"
:placeholder="__('Time to read')" :hint="__('How many minutes to read?')"/>
</x-input.group>
@if(!$isBindle)
<x-input.group :for="md5('libraryItem.read_time')" :label="__('Time to read')">
<x-inputs.number min="1" autocomplete="off" wire:model.debounce="libraryItem.read_time"
:placeholder="__('Time to read')"
:hint="__('How many minutes to read?')"/>
</x-input.group>
@endif

<x-input.group :for="md5('meetupEvent.link')" label="">
<x-button primary wire:click="save">
Expand Down

0 comments on commit d67fc51

Please sign in to comment.