Explorar el Código

fixed section ordering

Josh hace 4 años
padre
commit
d4bd4efee6

+ 7 - 1
app/Http/Controllers/section_templates_Controller.php

@@ -1,3 +1,4 @@
+<?php /* DO NOT GENERATE */ ?>
 <?php
 
 namespace App\Http\Controllers;
@@ -13,7 +14,7 @@ class section_templates_Controller extends Controller
 
 	// GET /section_templates
 	public function index(Request $request) {
-		$records = DB::table('section_template')->get();
+		$records = DB::table('section_template')->orderBy('position_index', 'asc')->get();
 		return response()->view('admin/section_templates/index', compact('records'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
 	}
 
@@ -22,4 +23,9 @@ class section_templates_Controller extends Controller
 		$records = DB::table('section_template')->get();
 		return response()->view('admin/section_templates/add_new', compact('records'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
 	}
+
+	// GET /section_templates/view/{uid}
+	public function view(Request $request, $uid) {
+		return redirect("/section_templates/view/$uid/SUB_dashboard");
+	}
 }

+ 33 - 0
app/Http/Controllers/section_templates_SINGLE_Controller.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Auth;
+
+class section_templates_SINGLE_Controller extends Controller
+{
+    public $selfName = 'section_templates_SINGLE_Controller';
+    public $dashboardName = 'dashboard';
+
+	// GET /section_templates/view/{uid}/ACTION_changePositionIndex
+	public function ACTION_changePositionIndex(Request $request, $uid) {
+		$record = DB::table('section_template')->where('uid', $uid)->first();
+		if(!$record) {
+			$record = DB::table('section_template')->where('id', $uid)->first();
+			if($record) return redirect('/section_templates/view/' . $record->uid . '/ACTION_changePositionIndex');
+		}
+		return response()->view('admin/section_templates_SINGLE/ACTION_changePositionIndex', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+
+	// GET /section_templates/view/{uid}/SUB_dashboard
+	public function SUB_dashboard(Request $request, $uid) {
+		$record = DB::table('section_template')->where('uid', $uid)->first();
+		if(!$record) {
+			$record = DB::table('section_template')->where('id', $uid)->first();
+			if($record) return redirect('/section_templates/view/' . $record->uid . '/SUB_dashboard');
+		}
+		return response()->view('admin/section_templates_SINGLE/SUB_dashboard', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+}

+ 8 - 2
generatecv/tree.txt

@@ -1130,11 +1130,17 @@ ADMIN
                 memo=reactivation_memo
         SUB
             dashboard
-    section_templates|section_template|add|icon:user-md
-        !inc:@title,internal_name
+    section_templates|section_template|add|view|icon:user-md
+        !inc:@title,internal_name,position_index
     section_templates/add_new:create
         title
         internalName
+    section_templates/view/{uid}
+        ACTIONS
+            changePositionIndex
+                newPositionIndex:number=position_index
+        SUB
+            dashboard
     note_templates|note_template|add|view|icon:user-md
         !inc:@title
     note_templates/add_new:create

+ 1 - 0
resources/views/admin/section_templates/actions.blade.php

@@ -0,0 +1 @@
+<a up-modal=".form-contents" up-preload up-delay="25" up-width="800" up-history="false" href='/section_templates/view/<?= $record->uid ?>/ACTION_changePositionIndex?optimised=1' class='d-block btn btn-sm btn-default mb-3'>Change Position Index</a>

+ 3 - 1
resources/views/admin/section_templates/index.blade.php

@@ -15,14 +15,16 @@
 <th>&nbsp;</th>
 <th>Title</th>
 <th>Internal Name</th>
+<th>Position Index</th>
             </tr>
             </thead>
             <tbody>
             @foreach($records as $record)
                 <tr>
 <td><a href="/section_templates/view/<?= $record->uid ?>"><i class="fas fa-share-square"></i></a></td>
-<td><?= $record->title ?></td>
+<td><a href="/section_templates/view/<?= $record->uid ?>"><?= $record->title ?></a></td>
 <td><?= $record->internal_name ?></td>
+<td><?= $record->position_index ?></td>
                 </tr>
             @endforeach
             </tbody>

+ 3 - 0
resources/views/admin/section_templates/info.blade.php

@@ -0,0 +1,3 @@
+<h4 class="d-flex my-3 px-3 stag-heading stag-heading-info">
+    <div>Section Templates: Single [<?= $record->uid ?>]</div>
+</h4>

+ 1 - 0
resources/views/admin/section_templates/subs.blade.php

@@ -0,0 +1 @@
+<a href='/section_templates/view/<?= $record->uid ?>/SUB_dashboard' class='d-block px-3 py-2 border-bottom stag-sublink {{ request()->route()->getActionMethod() === 'SUB_dashboard' ? 'bg-secondary text-white font-weight-bold' : '' }}{{ strpos(request()->route()->getActionMethod(), 'ACTION_') === 0 ? 'bg-secondary text-white font-weight-bold' : '' }}'>Dashboard</a>

+ 20 - 0
resources/views/admin/section_templates/view.blade.php

@@ -0,0 +1,20 @@
+@extends('layouts.pro-logged-in')
+@section('content')
+
+    <div class="card rounded-0">
+        <div class="border-bottom bg-light">@include('admin/section_templates/info')</div>
+        <div class="d-flex align-items-stretch">
+            <div class="inner-side-nav">
+                <div class="border-right h-100">
+                    @include('admin/section_templates/subs')
+                </div>
+            </div>
+            <div class="flex-grow-1 px-3 pb-3 mb-3 inner-content">
+                <div>
+                    @yield('content-inner')
+                </div>
+            </div>
+        </div>
+    </div>
+
+@endsection

+ 41 - 0
resources/views/admin/section_templates_SINGLE/ACTION_changePositionIndex.blade.php

@@ -0,0 +1,41 @@
+@extends('admin.section_templates.view')
+@section('content-inner')
+
+    <div class="form-contents"><div class="failed-form-contents">
+
+    <h4 class="d-flex m-0 p-3 stag-heading stag-heading-modal">
+        <div>Change Position Index</div>
+        <div class="ml-auto">
+            <a class="text-secondary" href="#" up-close>
+                <i class="fa fa-times"></i>
+            </a>
+        </div>
+    </h4>
+
+    <form action="/post-to-api"
+          up-target="#main-content" up-history="false" up-fail-target=".failed-form-contents" up-reveal="false"
+          method="post" enctype="multipart/form-data"
+          class="border-top px-3 pt-3 pb-1 custom-submit">
+        @csrf
+
+        @if (session('message'))
+            <div class="alert alert-danger">{{ session('message') }}</div>
+        @endif
+
+        <input type="hidden" name="_uid" value="{{ $record->uid }}">
+        <input type="hidden" name="_api" value="/api/sectionTemplate/changePositionIndex">
+        <input type="hidden" name="_success" value="{{route('section_templates-view', ['uid' => $record->uid])}}">
+        <input type="hidden" name="_return" value="{{route('section_templates_SINGLE-ACTION_changePositionIndex', ['uid' => $record->uid])}}">
+        <div class='form-group mb-3'>
+<label class='control-label'>New Position Index </label>
+<input class='form-control' type='number' name='newPositionIndex' value='{{ old('newPositionIndex') ? old('newPositionIndex') : $record->position_index }}' >
+</div>
+        <div class="form-group mb-3 d-flex justify-content-center">
+            <button class="btn btn-sm btn-primary mr-3 px-5">Submit</button>
+            <a href="{{route('section_templates-view', ['uid' => $record->uid])}}" class="btn btn-sm btn-default px-5" up-close>Cancel</a>
+        </div>
+    </form>
+
+    </div></div>
+
+@endsection

+ 41 - 0
resources/views/admin/section_templates_SINGLE/SUB_dashboard.blade.php

@@ -0,0 +1,41 @@
+@extends('admin.section_templates.view')
+@section('content-inner')
+
+    <div class="row mt-3">
+    <div class="col-8">
+
+        <div class="table-responsive p-0 bg-white table-sm stag-table border-top">
+            <table class="table table-hover text-nowrap table-striped border-left border-right border-bottom">
+                <thead>
+                <tr>
+                    <th colspan="2" class="px-2">Record Details</th>
+                </tr>
+                </thead>
+                <tbody>
+                <?php foreach($record as $k => $v): ?>
+                    <?php
+                    if($k === 'id' || $k === 'uid') continue;
+                    $displayValue = $record->$k;
+                    if(substr($k, -3) === '_at') {
+                        $displayValue = friendly_date_time($record->$k);
+                    }
+                    ?>
+                    <tr>
+                        <td class="px-2 text-secondary border-right w-50">{{ ucwords(str_replace("_", " ", $k)) }}</td>
+                        <td class="px-2 font-weight-bold w-50">{{ $displayValue }}</td>
+                    </tr>
+                <?php endforeach; ?>
+                </tbody>
+            </table>
+        </div>
+
+    </div>
+    <div class="col-4">
+        <div class="border-left h-100 pl-3">
+            @include('admin/section_templates/actions')
+        </div>
+    </div>
+</div>
+
+
+@endsection

+ 7 - 0
routes/generated.php

@@ -428,6 +428,13 @@ Route::prefix('/client_pro_access/view/{uid}')->group(function () {
 Route::prefix('/section_templates')->group(function () {
 	Route::get('', 'section_templates_Controller@index')->name('section_templates-index');
 	Route::get('add_new', 'section_templates_Controller@add_new')->name('section_templates-add_new');
+	Route::get('view/{uid}', 'section_templates_Controller@view')->name('section_templates-view');
+});
+
+// --- admin: section_templates_SINGLE --- //
+Route::prefix('/section_templates/view/{uid}')->group(function () {
+	Route::get('ACTION_changePositionIndex', 'section_templates_SINGLE_Controller@ACTION_changePositionIndex')->name('section_templates_SINGLE-ACTION_changePositionIndex');
+	Route::get('SUB_dashboard', 'section_templates_SINGLE_Controller@SUB_dashboard')->name('section_templates_SINGLE-SUB_dashboard');
 });
 
 // --- admin: note_templates --- //