forked from eatvio/eatvio-infra
418 lines
26 KiB
PHP
418 lines
26 KiB
PHP
<section class="py-5 diet" id="main">
|
||
<div class="diet__container">
|
||
<div class="diet__header">
|
||
<a href="{{ route('recipe.index') }}" class="diet__back icon-arrow-short-left">
|
||
<span>Мой блог</span>
|
||
</a>
|
||
<h1 class="diet__title">{{ __('recipe.editing') }}</h1>
|
||
</div>
|
||
<div class="diet__form">
|
||
<div class="diet__form-row">
|
||
<label class="label">{{ __('recipe.title') }}</label>
|
||
<input wire:model="title" type="text" class="input" placeholder="Заголовок" />
|
||
</div>
|
||
<div class="diet__form-row">
|
||
<label class="label">{{ __('recipe.type') }}</label>
|
||
<select wire:model="type" class="input">
|
||
<option value="first_meals" @selected($type == 'first_meals')>{{ __('recipe.first_meals') }}</option>
|
||
<option value="second_meals" @selected($type == 'second_meals')>{{ __('recipe.second_meals') }}</option>
|
||
<option value="salads" @selected($type == 'salads')>{{ __('recipe.salads') }}</option>
|
||
<option value="snacks" @selected($type == 'snacks')>{{ __('recipe.snacks') }}</option>
|
||
<option value="sweets" @selected($type == 'sweets')>{{ __('recipe.sweets') }}</option>
|
||
<option value="drinks" @selected($type == 'drinks')>{{ __('recipe.drinks') }}</option>
|
||
<option value="other" @selected($type == 'other')>{{ __('recipe.other') }}</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="diet__form-row">
|
||
<div class="diet__form-columns lg-columns">
|
||
<div class="diet__form-column">
|
||
<div class="label">{{ __('recipe.picture') }}</div>
|
||
<label class="file">
|
||
<input type="file" wire:model="image" name="file" class="file__input hidden" hidden="">
|
||
<span class="file__content">
|
||
<span class="file__formats">
|
||
@if(is_null($image))
|
||
<img src="/img/formats-2.svg" alt="formats">
|
||
@else
|
||
<img src="{{ is_string($image) ? Storage::url($image) : $image->temporaryUrl() }}" />
|
||
@endif
|
||
</span>
|
||
<span class="file__title">
|
||
@if(is_null($image))
|
||
Нажмите для выбора или перетащите изображание
|
||
@endif
|
||
</span>
|
||
</span>
|
||
</label>
|
||
@error('image') <span class="error">{{ $message }}</span> @enderror
|
||
</div>
|
||
<div class="diet__form-column diet__form-column-lg">
|
||
<div class="diet__form-row">
|
||
<div class="label">
|
||
Тип записи
|
||
</div>
|
||
<div class="diary__stats-tablist" role="tablist" aria-labelledby="label">
|
||
<button class="btn" role="tab" type="button" id="tab-1" aria-selected="true" aria-controls="tabpanel-1">Рецепт</button>
|
||
<button class="btn" role="tab" type="button" id="tab-2" aria-selected="false" aria-controls="tabpanel-2" tabindex="-1">Cтатья</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1">
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-row">
|
||
<div class="label">{{ __('recipe.cooking_time') }}</div>
|
||
<div class="dropdown" x-data="{ open: false }" >
|
||
<button
|
||
type="button"
|
||
:class="open ? 'dropdown__button active' : 'dropdown__button'"
|
||
x-on:click="open = ! open">
|
||
{{ __('recipe.t' . $cooking_time . 'm') }}
|
||
</button>
|
||
<ul :class="open ? 'dropdown__list visible' : 'dropdown__list'">
|
||
<li wire:click="$set('cooking_time','10')" @click="open = !open" :class="$wire.cooking_time =='10'? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t10m') }}</li>
|
||
<li wire:click="$set('cooking_time','20')" @click="open = !open" :class="$wire.cooking_time =='20' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t20m') }}</li>
|
||
<li wire:click="$set('cooking_time','30')" @click="open = !open" :class="$wire.cooking_time =='30' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t30m') }}</li>
|
||
<li wire:click="$set('cooking_time','60')" @click="open = !open" :class="$wire.cooking_time =='60' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t60m') }}</li>
|
||
<li wire:click="$set('cooking_time','120')" @click="open = !open" :class="$wire.cooking_time =='120' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t120m') }}</li>
|
||
<li wire:click="$set('cooking_time','14400')" @click="open = !open" :class="$wire.cooking_time =='14400' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.t14400m') }}</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-row">
|
||
<div class="label">{{ __('recipe.record_state') }}</div>
|
||
<div class="dropdown" x-data="{ open: false }">
|
||
<button type="button"
|
||
:class="open ? 'dropdown__button active' : 'dropdown__button'"
|
||
x-on:click="open = ! open"
|
||
>{{ $state == 'active' ? __('recipe.record_state_active') : __('recipe.record_state_not_active') }}
|
||
</button>
|
||
<ul :class="open ? 'dropdown__list visible' : 'dropdown__list'">
|
||
<li wire:click="$set('state','active')" @click="open = !open" :class="$wire.state == 'active' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.record_state_active') }}</li>
|
||
<li wire:click="$set('state','archived')" @click="open = !open" :class="$wire.state == 'archived' ? 'dropdown__list-item active' : 'dropdown__list-item'">{{ __('recipe.record_state_not_active') }}</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="diet__form-column diet__form-column-xl">
|
||
@if(!empty($ingredients))
|
||
<div class="content__table diet__form-row">
|
||
<div class="content__table-wrapper">
|
||
<table class="cabinet__table-content">
|
||
<thead>
|
||
<tr>
|
||
<th>{{ __('recipe.name_of_product')}}</th>
|
||
<th>{{ __('recipe.portion')}}</th>
|
||
<th>{{ __('recipe.units')}}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
@foreach($ingredients as $ingredient)
|
||
<tr>
|
||
<td>{{ $ingredient['name'] }}</td>
|
||
<td>{{ $ingredient['portion'] }}</td>
|
||
<td>{{ __('recipe.' . $ingredient['unit']) }}</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
@endif
|
||
<div class="diet__form-columns">
|
||
<div class="diet__form-column diet__form-column-lg">
|
||
<input wire:model="ingredients_name" type="text" name="name" class="input" placeholder="Введите название продукта">
|
||
</div>
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-adding">
|
||
<div class="diet__form-column">
|
||
<input wire:model="ingredients_portion" type="num" name="portion" class="input" placeholder="Порция">
|
||
<select wire:model="ingredients_unit" name="unit" class="input">
|
||
<option value="gr">гр</option>
|
||
<option value="teespoon">ч. ложек</option>
|
||
<option value="tablespoon">ст. ложек</option>
|
||
<option value="ml">мл</option>
|
||
<option value="pcs">шт</option>
|
||
<option value="clove">зубчик</option>
|
||
<option value="to_taste">по вкусу</option>
|
||
</select>
|
||
<button wire:click="addIngredient" type="button" class="btn btn-primary icon-plus"></button>
|
||
</div>
|
||
<button type="button" class="icon-gear"></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{{-- <div class="tabpanel" role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1">
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-row">
|
||
<div class="label">
|
||
Время приготавления
|
||
</div>
|
||
<div class="dropdown">
|
||
<button type="button" class="dropdown__button">
|
||
1 час
|
||
</button>
|
||
<ul class="dropdown__list">
|
||
<li data-value="1" class="dropdown__list-item active">1 час</li>
|
||
<li data-value="30" class="dropdown__list-item">30 минут</li>
|
||
</ul>
|
||
<input type="text" name="time" class="dropdown__input hidden" hidden="" value="1">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-row">
|
||
<div class="label">
|
||
Статус
|
||
</div>
|
||
<div class="dropdown">
|
||
<button type="button" class="dropdown__button">
|
||
Активна
|
||
</button>
|
||
<ul class="dropdown__list">
|
||
<li data-value="active" class="dropdown__list-item active">Активна</li>
|
||
<li data-value="unactive" class="dropdown__list-item">Неактивна</li>
|
||
</ul>
|
||
<input type="text" name="status" class="dropdown__input hidden" hidden="" value="unactive">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="diet__form-column diet__form-column-xl">
|
||
<div class="diet__form-columns">
|
||
<div class="diet__form-column diet__form-column-lg">
|
||
<input type="text" name="product" class="input" placeholder="Введите название продукта">
|
||
</div>
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-adding">
|
||
<div class="diet__form-column">
|
||
<input type="num" name="ccal" class="input" placeholder="Порция">
|
||
<button type="button" class="btn btn-primary icon-plus"></button>
|
||
</div>
|
||
<button type="button" class="icon-gear"></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div> --}}
|
||
<div class="tabpanel tabpanel--hidden" role="tabpanel" id="tabpanel-2" tabindex="0" aria-labelledby="tab-2">
|
||
<div class="diet__form-column">
|
||
<div class="diet__form-row">
|
||
<div class="label">
|
||
Статус
|
||
</div>
|
||
<div class="dropdown">
|
||
<button type="button" class="dropdown__button">
|
||
Активна
|
||
</button>
|
||
<ul class="dropdown__list">
|
||
<li data-value="active" class="dropdown__list-item active">Активна</li>
|
||
<li data-value="unactive" class="dropdown__list-item">Неактивна</li>
|
||
</ul>
|
||
<input type="text" name="status" class="dropdown__input hidden" hidden="" value="unactive">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="diet__form">
|
||
<div class="row fs-4_5">
|
||
<div class="col-12 col-sm-12 col-xl-4 my-4 dnd_file">
|
||
<label for="form-image">{{ __('recipe.picture') }}</label>
|
||
<div class="form__item mt-3 p-3 --radius --bordered text-center --f_grey">
|
||
<input wire:model="image" type="file" name="form-image" id="form-image">
|
||
@error('image') <span class="error">{{ $message }}</span> @enderror
|
||
|
||
<label for="form-image" class="file-label">
|
||
@if(is_null($image))
|
||
<p><svg width="88" height="88"><use xlink:href="#dndFileIcon"></use></svg></p>
|
||
<div class="px-3">{{ __('recipe.tap_to_select_or_drag_and_drop') }}</div>
|
||
<div id="file-name"></div>
|
||
@else
|
||
<p>
|
||
<img src="{{ is_string($image) ? Storage::url($image) : $image->temporaryUrl() }}" />
|
||
</p>
|
||
@endif
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-sm-7 col-md-8 my-4 d-flex flex-column justify-content-between">
|
||
<div class="mb-4">
|
||
<label>{{ __('recipe.record_type') }}</label>
|
||
<ul class="mt-3 nav nav-pills flex-nowrap w-100 --bordered --radius --tabs_blue overflow-x-xs-scroll" role="radiogroup">
|
||
<li class="nav-item" role="presentation">
|
||
<label class="btn btn-lg nav-link py-3 --radius active">{{ __('recipe.self') }}</label>
|
||
</li>
|
||
<li class="nav-item" role="presentation">
|
||
<a href="{{ route('blog_post.create') }}" class="btn btn-lg nav-link py-3">{{ __('recipe.blog_post') }}</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-12 col-sm-6 d-flex flex-column --reciept">
|
||
<label>{{ __('recipe.cooking_time') }}</label>
|
||
<select wire:model="cooking_time" class="form-select mt-3 ps-4 pe-5 py-3 --f_bold">
|
||
<option value="10" selected>{{ __('recipe.t10m') }}</option>
|
||
<option value="20" selected>{{ __('recipe.t20m') }}</option>
|
||
<option value="30" selected>{{ __('recipe.t30m') }}</option>
|
||
<option value="60">{{ __('recipe.t60m') }}</option>
|
||
<option value="120">{{ __('recipe.t120m') }}</option>
|
||
<option value="14400">{{ __('recipe.t14400m') }}</option>
|
||
</select>
|
||
</div>
|
||
<div class="col-12 col-sm-6 d-flex flex-column mt-3 mt-sm-0">
|
||
<label>{{ __('recipe.record_state') }}</label>
|
||
<select wire:model="state" class="form-select mt-3 ps-4 pe-5 py-3 --f_bold">
|
||
<option value="active">{{ __('recipe.record_state_active') }}</option>
|
||
<option value="archived">{{ __('recipe.record_state_not_active') }}</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="mb-4 fs-4_5 --reciept">
|
||
<div class="tab-pane fade show active">
|
||
@php $lastIngedient = count($ingredients) - 1; @endphp
|
||
@foreach($ingredients as $k => $ingredient)
|
||
<div class="d-flex align-items-top flex-wrap flex-sm-nowrap mb-4" data-row="{{ $k }}">
|
||
<div class="w-100">
|
||
<input type="text" wire:model="ingredients.{{$k}}.name" class="form-control fs-4_5 py-3 w-100" placeholder="Введите название продукта...." required="">
|
||
</div>
|
||
<div class="d-flex w-md-80 align-items-baseline">
|
||
<div class="flex-grow-1 ms-sm-3 mt-3 mt-sm-0">
|
||
<input wire:model="ingredients.{{ $k }}.portion" class="form-control fs-4_5 py-3" placeholder="Порция" required="" type="number">
|
||
</div>
|
||
<div class="ms-4 me-2 mt-3 mt-sm-0">
|
||
<select name="unit" wire:model="ingredients.{{ $k }}.unit" class="form-select ps-4 pe-5 py-3 --f_bold">
|
||
<option value="gr">{{ __('recipe.gr') }}</option>
|
||
<option value="teespoon">{{ __('recipe.teespoon') }}</option>
|
||
<option value="tablespoon">{{ __('recipe.tablespoon') }}</option>
|
||
<option value="ml">{{ __('recipe.ml') }}</option>
|
||
<option value="pcs">{{ __('recipe.pcs') }}</option>
|
||
<option value="clove">{{ __('recipe.clove') }}</option>
|
||
<option value="to_taste">{{ __('recipe.to_taste') }}</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="flex-grow-1 ms-sm-3 mt-3 mt-sm-0">
|
||
<button wire:click="removeIngredient({{$k}})" type="button" class="btn btn-outline-danger">x</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
<div class="d-flex justify-content-end mt-2" data-row="0">
|
||
<button type="button" wire:click="addIngredient" class="btn btn-lg btn-primary btn-block py-4 fs-2 lh-0 --radius">+</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mb-4 fs-4_5" wire:ignore>
|
||
<label for="txtFormatter" class="mb-2">{{ __('recipe.content') }}</label>
|
||
<div
|
||
class="form-textarea w-full"
|
||
x-data="{}"
|
||
x-init="ClassicEditor.create($refs.myIdentifierHere,
|
||
{
|
||
toolbar: {
|
||
items: [
|
||
'heading', '|',
|
||
'bold', 'italic', '|',
|
||
'bulletedList', 'numberedList', '|',
|
||
'outdent', 'indent', '|',
|
||
'blockQuote', 'undo', 'redo'
|
||
],
|
||
shouldNotGroupWhenFull: true
|
||
}
|
||
})
|
||
.then( function(editor){
|
||
editor.model.document.on('change:data', () => {
|
||
$dispatch('input', editor.getData())
|
||
})
|
||
})
|
||
.catch( error => {
|
||
console.error( error );
|
||
});"
|
||
wire:ignore
|
||
wire:key="myIdentifierHere"
|
||
x-ref="myIdentifierHere"
|
||
wire:model.live.debounce.9999999ms="description">{!! $description !!}</div>
|
||
</div>
|
||
@php
|
||
$stepsCount = count($steps);
|
||
@endphp
|
||
@for($i = 0; $i < $stepsCount; $i++)
|
||
<div class="mb-4 fs-4_5 --reciept">
|
||
<div class="d-flex justify-content-between mb-2">
|
||
<div>{{ __('recipe.step') }} {{ $i + 1 }}</div>
|
||
@if($i == 0)
|
||
<div>{{ __('recipe.total_steps') }}: {{ $stepsCount }}</div>
|
||
@endif
|
||
</div>
|
||
<div class="row flex-md-nowrap">
|
||
<div class="col-12 col-sm-3 mb-3 mb-sm-0 pe-2 dnd_file">
|
||
<label class="form__item w-100 p-3 --radius --bordered text-center --f_grey --upload_image" style="background:url()">
|
||
@if (isset($steps[$i]['image']) && is_string($steps[$i]['image']))
|
||
<img src="{{ Storage::url($steps[$i]['image']) }}">
|
||
@endif
|
||
<input type="file" name="step[{{$i}}][image]" wire:model="steps.{{$i}}.image" id="step[{{$i}}][image]">
|
||
@error('steps.'. $i . '.image') <span class="error">{{ $message }}</span> @enderror
|
||
@if (!isset($steps[$i]['image']))
|
||
<div class="my-3">
|
||
<svg width="50" height="50">
|
||
<use xlink:href="#dndFileIcon"></use>
|
||
</svg>
|
||
</div>
|
||
@endif
|
||
</label>
|
||
</div>
|
||
<div class="col-sm-7 col-lg-8 mb-3 mb-sm-0 px-sm-2 flex-grow-1">
|
||
<div class="d-flex align-items-center form-control --textarea py-3 w-100 h-100" onclick="this.children[0].focus()">
|
||
<textarea name="step[{{$i}}][description]" wire:model.defer="steps.{{$i}}.description" autoresize="" placeholder="Введи описание шага" rows="5">{{ $steps[$i]['description'] ?? '' }}</textarea>
|
||
</div>
|
||
</div>
|
||
<div class="col d-flex flex-sm-column ps-sm-2 justify-content-between">
|
||
<button type="button" wire:click="removeStep({{$i}})" class="btn btn-lg {{ $i == 0 ? "btn-secondary" : "btn-primary" }} btn-block w-100 me-3 me-sm-0 py-4 fs-2 lh-0 --radius" @disabled($i == 0)>-</button>
|
||
<button type="button" wire:click="addStep" class="btn btn-lg btn-primary btn-block w-100 py-4 fs-2 lh-0 --radius" data-bs-toggle="tooltip" data-bs-placement="left" title="" data-bs-original-title="Добавить шаг">+</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
@endfor
|
||
<div class="mb-4 fs-4_5">
|
||
<div class="mb-2" data-tags="{{ json_encode($tags) }}">{{ __('recipe.tags') }}</div>
|
||
<livewire:tags-component :parentComponent="$recipe" />
|
||
</div>
|
||
<div class="mb-4 fs-4_5">
|
||
<div class="mb-2">{{ __('recipe.video_link') }}</div>
|
||
<input wire:model="video_url" type="text" class="form-control fs-4_5 py-3 w-100" placeholder="Прикрипите ссылку на YouTube видео" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="container mb-5 p-0 --mw-1000">
|
||
<div class="row gx-3 gx-lg-4 gy-3 gy-lg-4">
|
||
<div class="col">
|
||
<button wire:click="draft" class="btn btn-lg btn-secondary btn-block w-100 --f_bolder --no_wrap">{{ __('recipe.to_drafts') }}</button>
|
||
</div>
|
||
<div class="col">
|
||
<button wire:click="preview" class="btn btn-lg btn-secondary btn-block w-100 --f_bolder --no_wrap">{{ __('recipe.preview') }}</button>
|
||
</div>
|
||
<div class="col">
|
||
<button wire:click="publish" class="btn btn-lg btn-primary btn-block w-100 --f_bolder --no_wrap" type="submit">{{ __('recipe.publish') }}</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="container mb-5 p-0 --mw-1000">
|
||
@foreach ($errors->all() as $message)
|
||
<div class="alert alert-warning">{{ $message }}</div>
|
||
@endforeach
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|