Documents ready

This commit is contained in:
Александр Бабкин
2022-07-04 14:53:54 +03:00
parent 62482b624d
commit 621b1fd677
12 changed files with 254 additions and 139 deletions

View File

@@ -0,0 +1,16 @@
{{-- <a href="{{ route('documents.show',$document->id) }}">
<i class="fa fa-eye text-green-500 hover:text-green-700 px-2 text-lg"></i>
</a> --}}
<a href="{{ route('documents.edit', $document->id) }}">
<i class="fa fa-edit text-blue-500 hover:text-blue-700 px-2 text-lg"></i>
</a>
@if (!count($document->childs))
<form class="inline-block" action="{{ route('documents.destroy', $document->id) }}" method="POST"
onsubmit="return confirm('{{ __('Are you sure remove document ') . $document->name . '?' }}');">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit">
<i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i>
</button>
</form>
@endif

View File

@@ -11,13 +11,13 @@
<div class="p-6 bg-white border-b border-gray-200">
<div class="w-96 mx-auto">
@if ($errors->any())
<div class="alert alert-danger text-red-500 p-2">
<ul class="list-unstyled alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
<div class="alert alert-danger text-red-500 p-2">
<ul class="list-unstyled alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="POST" action="{{ route('documents.store') }}">
@csrf
@@ -25,7 +25,8 @@
<div>
<x-label for="name" :value="__('Title')" />
<x-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required autofocus />
<x-input id="name" class="block mt-1 w-full" type="text" name="name"
:value="old('name')" required autofocus />
</div>
<div>
@@ -33,20 +34,28 @@
<x-select id="parent_id" class="block mt-1 w-full" name="parent_id" required>
<option value="0">---</option>
@foreach($documents as $document)
<option value="{{ $document->id }}">{{ $document->name}}</option>
@foreach ($top_documents as $document)
<option value="{{ $document->id }}">{{ $document->name }}</option>
@if (count($document->childs))
@include('documents.optionChild', [
'childs' => $document->childs,
'level' => 1,
])
@endif
@endforeach
</x-select>
</div>
<div class="flex items-center justify-end mt-4">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
<button
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-add pr-2"></i>{{ __('Create document') }}
</button>
<div class="pl-2">
<a href="{{ route('documents.index') }}" class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-cancel pr-2"></i>{{__('Cancel')}}
<a href="{{ route('documents.index') }}"
class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-cancel pr-2"></i>{{ __('Cancel') }}
</a>
</div>
</div>
@@ -56,4 +65,4 @@
</div>
</div>
</div>
</x-app-layout>
</x-app-layout>

View File

@@ -1,7 +1,7 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Edit project') }}
{{ $project->name }}: {{ __('Create document') }}
</h2>
</x-slot>
@@ -11,40 +11,58 @@
<div class="p-6 bg-white border-b border-gray-200">
<div class="w-96 mx-auto">
@if ($errors->any())
<div class="alert alert-danger text-red-500 p-2">
<ul class="list-unstyled alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
<div class="alert alert-danger text-red-500 p-2">
<ul class="list-unstyled alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="POST" action="{{ route('projects.update',$project->id) }}">
<form method="POST" action="{{ route('documents.update',$document->id) }}">
@csrf
@method('PUT')
<!-- Document name -->
<input type="hidden" id="id" name="id" value="{{ $document->id }}">
<div>
<x-label for="name" :value="__('Title')" />
<x-label for="name" value="{{ __('Title') }}" />
<x-input id="name" class="block mt-1 w-full" type="text" name="name" value="{{ $project->name }}" required autofocus />
<x-input id="name" class="block mt-1 w-full" type="text" name="name"
value="{{ $document->name }}" required autofocus />
</div>
<div class="mt-4">
<x-label for="description" :value="__('Description')" />
<x-input id="description" class="block mt-1 w-full" type="text" name="description" value="{{ $project->description }}" required />
</div>
<div class="mt-4">
<x-label for="mmc_path" :value="__('MMC Path')" />
<div>
<x-label for="parent_id" :value="__('Parent document')" />
<x-input id="mmc_path" class="block mt-1 w-full" type="text" name="mmc_path" value="{{ $project->mmc_path }}" required />
<x-select id="parent_id" class="block mt-1 w-full" name="parent_id" required>
<option value="0">---</option>
@foreach ($top_documents as $top_document)
@if ($document->parent_id == $top_document->id)
<option value="{{ $top_document->id }}" selected>{{ $top_document->name }}</option>
@else
<option value="{{ $top_document->id }}">{{ $top_document->name }}</option>
@endif
@if (count($top_document->childs))
@include('documents.optionChildSelected', [
'childs' => $top_document->childs,
'parent_id' => $document->parent_id,
'level' => 1,
])
@endif
@endforeach
</x-select>
</div>
<div class="flex items-center justify-end mt-4">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-add pr-2"></i>{{ __('Save') }}
<button
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-add pr-2"></i>{{ __('Save document') }}
</button>
<div class="pl-2">
<a href="{{ route('projects.index') }}" class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-cancel pr-2"></i>{{__('Cancel')}}
<a href="{{ route('documents.index') }}"
class="btn bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-cancel pr-2"></i>{{ __('Cancel') }}
</a>
</div>
</div>
@@ -54,4 +72,4 @@
</div>
</div>
</div>
</x-app-layout>
</x-app-layout>

View File

@@ -9,9 +9,9 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<a href="{{ route('documents.create')}}">
<a href="{{ route('documents.create') }}">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
<i class="fa fa-add pr-2"></i>{{__('Create doucment')}}
<i class="fa fa-add pr-2"></i>{{ __('Create doucment') }}
</button>
</a>
@@ -19,37 +19,37 @@
<table class="table table-sm border-b border-gray-200">
<tr class="border border-gray-200">
<th class="p-2 border border-gray-200">
{{ __('Title')}}
{{ __('Title') }}
</th>
<th class="p-2 border border-gray-200">
{{ __('Actions')}}
{{ __('Actions') }}
</th>
</tr>
@forelse ( $documents as $document)
<tr class="border border-gray-200">
<td class="p-2 border border-gray-200">{{ $document->name }}</td>
<td class="p-2 border border-gray-200">
<div class="text-center">
{{-- <a href="{{ route('projects.show',$project->id) }}">
<i class="fa fa-eye text-green-500 hover:text-green-700 px-2 text-lg"></i>
</a>
<a href="{{ route('projects.edit',$project->id) }}">
<i class="fa fa-edit text-blue-500 hover:text-blue-700 px-2 text-lg"></i>
</a>
<form class="inline-block" action="{{ route('projects.destroy', $project->id) }}" method="POST" onsubmit="return confirm('{{ __('Are you sure remove project ').$project->name.'?' }}');">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit">
<i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i>
</button>
</form> --}}
</div>
</td>
</tr>
@forelse ($top_documents as $document)
<tr class="border border-gray-200">
<td class="p-2 border border-gray-200">{{ $document->name }}</td>
<td class="p-2 border border-gray-200">
<div class="text-center">
@include('documents.actions', ['document' => $document])
</div>
</td>
</tr>
@if (count($document->childs))
@php
$level = 1;
@endphp
@include('documents.tableChild', [
'childs' => $document->childs,
'level' => $level,
])
@endif
@empty
<tr>
<td colspan="2" class="p-2 border border-gray-200 text-center">No Documents!</td>
</tr>
<tr>
<td colspan="2" class="p-2 border border-gray-200 text-center">No Documents!</td>
</tr>
@endforelse
</table>
</div>
@@ -57,4 +57,4 @@
</div>
</div>
</div>
</x-app-layout>
</x-app-layout>

View File

@@ -0,0 +1,9 @@
@foreach ($childs as $child)
<option value="{{ $child->id }}">{{ str_pad('', $level, '-') . ' ' . $child->name }}</option>
@if (count($child->childs))
@include('documents.optionChild', [
'childs' => $child->childs,
'level' => $level + 1,
])
@endif
@endforeach

View File

@@ -0,0 +1,14 @@
@foreach ($childs as $child)
@if ($parent_id == $child->id)
<option value="{{ $child->id }}" selected>{{ str_pad('', $level, '-') . ' ' . $child->name }}</option>
@else
<option value="{{ $child->id }}">{{ str_pad('', $level, '-') . ' ' . $child->name }}</option>
@endif
@if (count($child->childs))
@include('documents.optionChildSelected', [
'childs' => $child->childs,
'parent_id' => $document->parent_id,
'level' => $level + 1,
])
@endif
@endforeach

View File

@@ -0,0 +1,16 @@
@foreach ($childs as $child)
<tr>
<td class="p-2 border border-gray-200">
{{ str_pad('', $level, '-') . ' ' . $child->name }}
</td>
<td class="p-2 border border-gray-200">
@include('documents.actions', ['document' => $child])
</td>
</tr>
@if (count($child->childs))
@include('documents.tableChild', [
'childs' => $child->childs,
'level' => $level + 1,
])
@endif
@endforeach