Procházet zdrojové kódy

edit order from card

Alexander Musikhin před 2 měsíci
rodič
revize
f906491441

+ 84 - 50
resources/views/orders/show.blade.php

@@ -49,33 +49,21 @@
         <div class="row">
             <div class="col-xl-3 border-end">
                 <h4>Общая информация об объекте</h4>
-                <div>Название: {{ $order->name }}</div>
                 <div>ID площадки: {{ $order->id }}</div>
-                <div>
-                    Адрес: {{ $order->common_name }}
-                </div>
 
-                <div>Тип объекта: {{ $order->objectType->name }}</div>
-                <div class="text-{{ Order::STATUS_COLOR[$order->order_status_id] }}">Статус
-                    объекта: {{ $order->orderStatus->name }}</div>
-                <div>Комментарий: {{ $order->comment }}</div>
-                <div class="row">
-                    <div class="col-md-8">Дата выхода на монтаж:</div>
-                    <div class="col-md-4">
-                        <input type="date" name="installation_date" id="installation_date" @disabled(!hasRole('admin')) value="{{ $order->installation_date }}" class="form-control form-control-sm">
-                    </div>
-                </div>
-                <div class="row">
-                    <div class="col-md-8">Дней на монтаж:</div>
-                    <div class="col-md-4">
-                        <input type="number" min="1" name="install_days" id="install_days" @disabled(!hasRole('admin')) value="{{ $order->install_days }}"  class="form-control form-control-sm">
-                    </div>
-                </div>
-                <div>Дата готовности площадки: {{ $order->ready_date }}</div>
-                <div>Бригадир: {{ $order?->brigadier?->name }}, тел. {{ $order?->brigadier?->phone }}</div>
-                <div>Менеджер: {{ $order->user->name }}, тел. {{ $order->user->phone }}</div>
-                <div>Название группы в ТГ: {{ $order->tg_group_name }}</div>
-                <div>Ссылка на группу в ТГ: {{ $order->tg_group_link }}</div>
+                @include('partials.input',  ['name' => 'name', 'title' => 'Название', 'value' => $order->name ?? old('name'), 'required' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.input',  ['name' => 'object_address', 'title' => 'Адрес объекта', 'value' => $order->object_address ?? old('object_address'), 'required' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.select', ['name' => 'object_type_id', 'title' => 'Тип объекта', 'options' => $objectTypes, 'value' => $order->object_type_id ?? old('object_type_id'), 'required' => true, 'first_empty' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.select', ['name' => 'order_status_id', 'title' => 'Статус', 'options' => $orderStatuses, 'value' => $order->order_status_id ?? old('order_status_id'), 'required' => true, 'classes' => ['update-once']])
+                @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'value' => $order->comment ?? old('comment'), 'classes' => ['update-once']])
+                @include('partials.input', ['name' => 'installation_date', 'title' => 'Дата выхода на монтаж', 'type' => 'date', 'value' => $order->installation_date ?? old('installation_date'), 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.input', ['name' => 'install_days', 'title' => 'Дней на монтаж', 'type' => 'number', 'min' => 1, 'value' => $order->install_days ?? old('install_days'), 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.input', ['name' => 'ready_date', 'title' => 'Дата готовности площадки', 'type' => 'date', 'value' => $order->ready_date ?? old('ready_date'), 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $order->brigadier_id ?? old('brigadier_id'), 'first_empty' => true, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $order->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin'), 'classes' => ['update-once']])
+                @include('partials.input', ['name' => 'tg_group_name', 'title' => 'Название группы в ТГ', 'value' => $order->tg_group_name ?? old('tg_group_name'), 'classes' => ['update-once']])
+                @include('partials.input', ['name' => 'tg_group_link', 'title' => 'Ссылка на группу в ТГ', 'value' => $order->tg_group_link ?? old('tg_group_link'), 'classes' => ['update-once']])
+
                 <hr>
                 <div class="reclamations">
                     Рекламации
@@ -483,18 +471,19 @@
             }
         });
 
-        $('#installation_date').on('change', function () {
-            let installationDate = $(this).val();
+        $('.update-once').on('change', function () {
+            let v = $(this).val();
+            let n = $(this).attr('name');
             $.post(
                 '{{ route('order.update', $order->id) }}',
                 {
                     '_token': '{{ csrf_token() }}',
                     id: '{{ $order->id }}',
-                    installation_date: installationDate
+                    [n]: v
                 },
                 function () {
                     $('.alerts').append(
-                        '<div class="main-alert alert alert-success" role="alert">Обновлена дата выхода на монтаж!</div>'
+                        '<div class="main-alert alert alert-success" role="alert">Площадка обновлена!</div>'
                     );
                     setTimeout(function () {
                         $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {
@@ -505,27 +494,72 @@
             );
         });
 
-        $('#install_days').on('change', function () {
-            let installDays = $(this).val();
-            $.post(
-                '{{ route('order.update', $order->id) }}',
-                {
-                    '_token' : '{{ csrf_token() }}',
-                    id: '{{ $order->id }}',
-                    install_days: installDays
-                },
-                function () {
-                    $('.alerts').append(
-                        '<div class="main-alert alert alert-success" role="alert">Обновлено количество дней на монтаж!</div>'
-                    );
-                    setTimeout(function () {
-                        $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {
-                            $(".main-alert").slideUp(500);
-                        })
-                    }, 3000);
-                }
-            );
-        });
+
+        {{--$('#installation_date').on('change', function () {--}}
+        {{--    let installationDate = $(this).val();--}}
+        {{--    $.post(--}}
+        {{--        '{{ route('order.update', $order->id) }}',--}}
+        {{--        {--}}
+        {{--            '_token': '{{ csrf_token() }}',--}}
+        {{--            id: '{{ $order->id }}',--}}
+        {{--            installation_date: installationDate--}}
+        {{--        },--}}
+        {{--        function () {--}}
+        {{--            $('.alerts').append(--}}
+        {{--                '<div class="main-alert alert alert-success" role="alert">Обновлена дата выхода на монтаж!</div>'--}}
+        {{--            );--}}
+        {{--            setTimeout(function () {--}}
+        {{--                $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {--}}
+        {{--                    $(".main-alert").slideUp(500);--}}
+        {{--                })--}}
+        {{--            }, 3000);--}}
+        {{--        }--}}
+        {{--    );--}}
+        {{--});--}}
+
+        {{--$('#install_days').on('change', function () {--}}
+        {{--    let installDays = $(this).val();--}}
+        {{--    $.post(--}}
+        {{--        '{{ route('order.update', $order->id) }}',--}}
+        {{--        {--}}
+        {{--            '_token' : '{{ csrf_token() }}',--}}
+        {{--            id: '{{ $order->id }}',--}}
+        {{--            install_days: installDays--}}
+        {{--        },--}}
+        {{--        function () {--}}
+        {{--            $('.alerts').append(--}}
+        {{--                '<div class="main-alert alert alert-success" role="alert">Обновлено количество дней на монтаж!</div>'--}}
+        {{--            );--}}
+        {{--            setTimeout(function () {--}}
+        {{--                $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {--}}
+        {{--                    $(".main-alert").slideUp(500);--}}
+        {{--                })--}}
+        {{--            }, 3000);--}}
+        {{--        }--}}
+        {{--    );--}}
+        {{--});--}}
+
+        {{--$('#name').on('change', function () {--}}
+        {{--    let name = $(this).val();--}}
+        {{--    $.post(--}}
+        {{--        '{{ route('order.update', $order->id) }}',--}}
+        {{--        {--}}
+        {{--            '_token' : '{{ csrf_token() }}',--}}
+        {{--            id: '{{ $order->id }}',--}}
+        {{--            name: name--}}
+        {{--        },--}}
+        {{--        function () {--}}
+        {{--            $('.alerts').append(--}}
+        {{--                '<div class="main-alert alert alert-success" role="alert">Обновлено название!</div>'--}}
+        {{--            );--}}
+        {{--            setTimeout(function () {--}}
+        {{--                $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {--}}
+        {{--                    $(".main-alert").slideUp(500);--}}
+        {{--                })--}}
+        {{--            }, 3000);--}}
+        {{--        }--}}
+        {{--    );--}}
+        {{--});--}}
 
     </script>
 @endpush

+ 2 - 2
resources/views/partials/input.blade.php

@@ -1,5 +1,5 @@
 <div class="row mb-2">
-    <label for="{{ $name }}" class="col-form-label @if(!($right ?? null)) col-md-4 text-md-end @endif">
+    <label for="{{ $name }}" class="col-form-label small @if(!($right ?? null)) col-md-4 text-md-end @endif">
         {{ $title ?? '' }}
         @isset($required)
             <sup>*</sup>
@@ -8,7 +8,7 @@
     <div class="@if(!($right ?? null)) col-md-8 @endif">
         <div class="input-group">
             <input type="{{ $type ?? 'text' }}" name="{{ $name }}" id="{{ $name }}"
-                   class="@if(($type ?? 'text') === 'range') form-range @else form-control @endif  @error($name) is-invalid @enderror "
+                   class="@if(($type ?? 'text') === 'range') form-range @else form-control form-control-sm @endif @error($name) is-invalid @enderror @isset($classes) {{ implode(' ', $classes) }} @endisset }}"
                    @disabled($disabled ?? null) @required($required ?? null)
                    @isset($min) min="{{ $min }}" @endisset
                    @isset($max) max="{{ $max }}" @endisset

+ 2 - 2
resources/views/partials/select.blade.php

@@ -1,6 +1,6 @@
 <div class="row mb-{{ ($mb ?? 2) }}">
     @if(!empty($title))
-        <label for="{{ $name }}" class="col-form-label @if(!($right ?? null)) col-md-4 text-md-end @endif mt-1">
+        <label for="{{ $name }}" class="col-form-label small @if(!($right ?? null)) col-md-4 text-md-end @endif">
             {{ $title }}
             @isset($required)
                 <sup>*</sup>
@@ -11,7 +11,7 @@
         <select name="{{ $name }}"
                 id="{{ $name }}"
                 @isset($multiple) multiple @endisset
-                class="form-select @error($name) is-invalid @enderror class-{{ $name }}"
+                class="form-select form-select-sm @error($name) is-invalid @enderror class-{{ $name }} @isset($classes) {{ implode(' ', $classes) }} @endisset"
                 @required($required ?? null)
                 @disabled($disabled ?? null)>
             @if(isset($first_empty))

+ 1 - 1
resources/views/partials/textarea.blade.php

@@ -5,7 +5,7 @@
     </label>
     <div class="col-md-8">
         <textarea type="{{ $type ?? 'text' }}" name="{{ $name }}" id="{{ $name }}" @isset($size) rows="{{ $size }}" @endisset
-               class="form-control @error($name) is-invalid @enderror" @disabled($disabled ?? null) @required($required ?? null)
+               class="form-control @error($name) is-invalid @enderror  @isset($classes) {{ implode(' ', $classes) }} @endisset" @disabled($disabled ?? null) @required($required ?? null)
         >{{ old($name, $value ?? '') }}</textarea>
         @error($name)
         <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>