Jelajahi Sumber

added note templates to tree

Josh 4 tahun lalu
induk
melakukan
9e5ccd1e33

+ 30 - 0
app/Http/Controllers/note_templates_Controller.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Auth;
+
+class note_templates_Controller extends Controller
+{
+    public $selfName = 'note_templates_Controller';
+    public $dashboardName = 'dashboard';
+
+	// GET /note_templates
+	public function index(Request $request) {
+		$records = DB::table('note_template')->get();
+		return response()->view('admin/note_templates/index', compact('records'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+
+	// GET /note_templates/add_new
+	public function add_new(Request $request) {
+		$records = DB::table('note_template')->get();
+		return response()->view('admin/note_templates/add_new', compact('records'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+
+	// GET /note_templates/view/{uid}
+	public function view(Request $request, $uid) {
+		return redirect("/note_templates/view/$uid/SUB_dashboard");
+	}
+}

+ 55 - 0
app/Http/Controllers/note_templates_SINGLE_Controller.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Auth;
+
+class note_templates_SINGLE_Controller extends Controller
+{
+    public $selfName = 'note_templates_SINGLE_Controller';
+    public $dashboardName = 'dashboard';
+
+	// GET /note_templates/view/{uid}/ACTION_updateTitle
+	public function ACTION_updateTitle(Request $request, $uid) {
+		$record = DB::table('note_template')->where('uid', $uid)->first();
+		if(!$record) {
+			$record = DB::table('note_template')->where('id', $uid)->first();
+			if($record) return redirect('/note_templates/view/' . $record->uid . '/ACTION_updateTitle');
+		}
+		return response()->view('admin/note_templates_SINGLE/ACTION_updateTitle', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+
+	// GET /note_templates/view/{uid}/SUB_dashboard
+	public function SUB_dashboard(Request $request, $uid) {
+		$record = DB::table('note_template')->where('uid', $uid)->first();
+		if(!$record) {
+			$record = DB::table('note_template')->where('id', $uid)->first();
+			if($record) return redirect('/note_templates/view/' . $record->uid . '/SUB_dashboard');
+		}
+		return response()->view('admin/note_templates_SINGLE/SUB_dashboard', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+
+	// GET /note_templates/view/{uid}/SUB_note_template_section_templates
+	public function SUB_note_template_section_templates(Request $request, $uid) {
+		$record = DB::table('note_template')->where('uid', $uid)->first();
+		if(!$record) {
+			$record = DB::table('note_template')->where('id', $uid)->first();
+			if($record) return redirect('/note_templates/view/' . $record->uid . '/SUB_note_template_section_templates');
+		}
+		$subRecords = DB::table('note_template_section_template')->where('note_template_id', $record->id)->get();
+		$result_section_templates = DB::select("SELECT id, title FROM section_template");
+		return response()->view('admin/note_templates_SINGLE/SUB_note_template_section_templates', compact('record', 'subRecords', 'result_section_templates'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+
+	// GET /note_templates/view/{uid}/ACTION_add_new_note_template_section_template
+	public function ACTION_add_new_note_template_section_template(Request $request, $uid) {
+		$record = DB::table('note_template')->where('uid', $uid)->first();
+		if(!$record) {
+			$record = DB::table('note_template')->where('id', $uid)->first();
+			if($record) return redirect('/note_templates/view/' . $record->uid . '/ACTION_add_new_note_template_section_template');
+		}
+		return response()->view('admin/note_templates_SINGLE/ACTION_add_new_note_template_section_template', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+	}
+}

+ 18 - 0
generatecv/tree.txt

@@ -1117,3 +1117,21 @@ ADMIN
     section_templates/add_new:create
         title
         internalName
+    note_templates|note_template|add|view|icon:user-md
+        !inc:@title
+    note_templates/add_new:create
+        title
+    note_templates/view/{uid}
+        ACTIONS
+            updateTitle
+                title=title
+        SUB
+            dashboard
+            note_template_section_templates|note_template_section_template|add
+                id=note_template_section_template.note_template_id=>/note_template_section_templates/view/UID
+                !inc:@uid,section_template_id
+                !qry:section_templates:SELECT id, title FROM section_template
+                #!col:section_template_id:Section Template:~section_templates:title:id,=,$section_template_id:all
+                add_new:note_template_section_template:create
+                    noteTemplateUID:hidden=uid
+                    sectionTemplateUID:record:section_template:uid,title

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

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

+ 40 - 0
resources/views/admin/note_templates/add_new.blade.php

@@ -0,0 +1,40 @@
+@extends('layouts.pro-logged-in')
+@section('content')
+
+    <div class="form-contents"><div class="failed-form-contents">
+
+    <h4 class="d-flex m-0 p-3 stag-heading stag-heading-modal">
+        <div>Note Templates: Add New</div>
+        <div class="ml-auto">
+            <a class="text-secondary" href="{{route('note_templates-index')}}" 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="_api" value="/api/noteTemplate/create">
+        <input type="hidden" name="_success" value="{{route('note_templates-index')}}">
+        <input type="hidden" name="_return" value="{{route('note_templates-add_new')}}">
+        <div class='form-group mb-3'>
+<label class='control-label'>Title </label>
+<input class='form-control' type='text' name='title' value='{{ old('title') ? old('title') : '' }}' >
+</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('note_templates-index')}}" class="btn btn-sm btn-default px-5" up-close>Cancel</a>
+        </div>
+    </form>
+
+    </div></div>
+
+@endsection

+ 30 - 0
resources/views/admin/note_templates/index.blade.php

@@ -0,0 +1,30 @@
+@extends('layouts.pro-logged-in')
+@section('content')
+
+    <h3 class="d-flex my-3 px-3 stag-heading stag-heading-index">
+        <div>Note Templates: List</div>
+        <div class="ml-auto">
+            <a class='btn btn-primary btn-sm ml-2' up-modal=".form-contents" up-preload up-delay="25" up-width="800" up-history="false" href='/note_templates/add_new?optimised=1'><i class='fa fa-plus-circle' aria-hidden='true'></i> Add New</a>
+        </div>
+    </h3>
+
+    <div class="table-responsive p-0 bg-white border stag-table stag-table-index">
+        <table class="table table-hover text-nowrap table-striped">
+            <thead>
+            <tr>
+<th>&nbsp;</th>
+<th>Title</th>
+            </tr>
+            </thead>
+            <tbody>
+            @foreach($records as $record)
+                <tr>
+<td><a href="/note_templates/view/<?= $record->uid ?>"><i class="fas fa-share-square"></i></a></td>
+<td><a href="/note_templates/view/<?= $record->uid ?>"><?= $record->title ?></a></td>
+                </tr>
+            @endforeach
+            </tbody>
+        </table>
+    </div>
+
+@endsection

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

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

+ 2 - 0
resources/views/admin/note_templates/subs.blade.php

@@ -0,0 +1,2 @@
+<a href='/note_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>
+<a href='/note_templates/view/<?= $record->uid ?>/SUB_note_template_section_templates' class='d-block px-3 py-2 border-bottom stag-sublink {{ request()->route()->getActionMethod() === 'SUB_note_template_section_templates' ? 'bg-secondary text-white font-weight-bold' : '' }}'>Note Template Section Templates</a>

+ 20 - 0
resources/views/admin/note_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/note_templates/info')</div>
+        <div class="d-flex align-items-stretch">
+            <div class="inner-side-nav">
+                <div class="border-right h-100">
+                    @include('admin/note_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

+ 48 - 0
resources/views/admin/note_templates_SINGLE/ACTION_add_new_note_template_section_template.blade.php

@@ -0,0 +1,48 @@
+@extends('admin.note_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>Add New Note Template Section Template</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/noteTemplateSectionTemplate/create">
+        <input type="hidden" name="_success" value="{{route('note_templates_SINGLE-SUB_note_template_section_templates', ['uid' => $record->uid])}}">
+        <input type="hidden" name="_return" value="{{route('note_templates_SINGLE-ACTION_add_new_note_template_section_template', ['uid' => $record->uid])}}">
+        <input class='form-control' type='hidden' name='noteTemplateUID' value='{{ old('noteTemplateUID') ? old('noteTemplateUID') : $record->uid }}' >
+<div class='form-group mb-3'>
+<label class='control-label'>Section Template </label>
+<select class='form-control' name='sectionTemplateUID' value='{{ old('sectionTemplateUID') ? old('sectionTemplateUID') : '' }}' >
+<option value=''>-- Select --</option>
+<?php $dbOptions = \Illuminate\Support\Facades\DB::table('section_template')->get(); ?>
+<?php foreach($dbOptions as $o): ?>
+<option <?= $o->uid === (old('sectionTemplateUID') ? old('sectionTemplateUID') : '') ? 'selected' : '' ?> value='<?= $o->uid ?>'><?= $o->title ?> (<?= $o->uid ?>)</option>
+<?php endforeach; ?>
+</select>
+</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('note_templates_SINGLE-SUB_note_template_section_templates', ['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/note_templates_SINGLE/ACTION_updateTitle.blade.php

@@ -0,0 +1,41 @@
+@extends('admin.note_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>Update Title</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/noteTemplate/updateTitle">
+        <input type="hidden" name="_success" value="{{route('note_templates-view', ['uid' => $record->uid])}}">
+        <input type="hidden" name="_return" value="{{route('note_templates_SINGLE-ACTION_updateTitle', ['uid' => $record->uid])}}">
+        <div class='form-group mb-3'>
+<label class='control-label'>Title </label>
+<input class='form-control' type='text' name='title' value='{{ old('title') ? old('title') : $record->title }}' >
+</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('note_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/note_templates_SINGLE/SUB_dashboard.blade.php

@@ -0,0 +1,41 @@
+@extends('admin.note_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/note_templates/actions')
+        </div>
+    </div>
+</div>
+
+
+@endsection

+ 34 - 0
resources/views/admin/note_templates_SINGLE/SUB_note_Template_section_templates.blade.php

@@ -0,0 +1,34 @@
+@extends('admin.note_templates.view')
+@section('content-inner')
+
+    <div class="pb-3">
+
+        <h5 class='my-3 d-flex stag-heading stag-heading-sub'>
+            <div>Note Template Section Templates</div>
+            <div class="ml-auto">
+                <a class="btn btn-primary btn-sm ml-2" up-modal=".form-contents" up-preload up-delay="25" up-width="800" up-history="false" href="{{route('note_templates_SINGLE-ACTION_add_new_note_template_section_template', ['uid' => $record->uid])}}?optimised=1"><i class='fa fa-plus-circle' aria-hidden='true'></i> Add New</a>
+            </div>
+        </h5>
+
+        <div class="table-responsive p-0 bg-white border stag-table stag-table-sub">
+            <table class="table table-hover text-nowrap">
+                <thead>
+                <tr>
+                    <th>&nbsp;</th>
+<th>Section Template</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($subRecords as $subRecord)
+                    <tr>
+                        <td><a href="/note_template_section_templates/view/{{ $subRecord->uid }}"><i class="fas fa-share-square"></i></a></td>
+<td><?= value_from_rs($result_section_templates, 'title', [['id', '=', $record->section_template_id], ], 'all'); ?></td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+
+    </div>
+
+@endsection

+ 34 - 0
resources/views/admin/note_templates_SINGLE/SUB_note_template_section_templates.blade.php

@@ -0,0 +1,34 @@
+@extends('admin.note_templates.view')
+@section('content-inner')
+
+    <div class="pb-3">
+
+        <h5 class='my-3 d-flex stag-heading stag-heading-sub'>
+            <div>Note Template Section Templates</div>
+            <div class="ml-auto">
+                <a class="btn btn-primary btn-sm ml-2" up-modal=".form-contents" up-preload up-delay="25" up-width="800" up-history="false" href="{{route('note_templates_SINGLE-ACTION_add_new_note_template_section_template', ['uid' => $record->uid])}}?optimised=1"><i class='fa fa-plus-circle' aria-hidden='true'></i> Add New</a>
+            </div>
+        </h5>
+
+        <div class="table-responsive p-0 bg-white border stag-table stag-table-sub">
+            <table class="table table-hover text-nowrap">
+                <thead>
+                <tr>
+                    <th>&nbsp;</th>
+<th>Section Template Id</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($subRecords as $subRecord)
+                    <tr>
+                        <td><a href="/note_template_section_templates/view/{{ $subRecord->uid }}"><i class="fas fa-share-square"></i></a></td>
+<td><?= $subRecord->section_template_id ?></td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+
+    </div>
+
+@endsection

+ 7 - 0
resources/views/layouts/generated-links.blade.php

@@ -130,3 +130,10 @@
 		<p>Section Templates</p>
 	</a>
 </li>
+
+<li class='nav-item'>
+	<a href='/note_templates' class='nav-link {{ (isset(request()->route()->getController()->selfName) && strpos(request()->route()->getController()->selfName, 'note_templates') === 0 ? 'active' : '') }} '>
+		<i class='nav-icon fa fa-user-md'></i>
+		<p>Note Templates</p>
+	</a>
+</li>

+ 15 - 0
routes/generated.php

@@ -425,3 +425,18 @@ 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');
 });
+
+// --- admin: note_templates_SINGLE --- //
+Route::prefix('/note_templates/view/{uid}')->group(function () {
+	Route::get('ACTION_updateTitle', 'note_templates_SINGLE_Controller@ACTION_updateTitle')->name('note_templates_SINGLE-ACTION_updateTitle');
+	Route::get('SUB_dashboard', 'note_templates_SINGLE_Controller@SUB_dashboard')->name('note_templates_SINGLE-SUB_dashboard');
+	Route::get('SUB_note_template_section_templates', 'note_templates_SINGLE_Controller@SUB_note_template_section_templates')->name('note_templates_SINGLE-SUB_note_template_section_templates');
+	Route::get('ACTION_add_new_note_template_section_template', 'note_templates_SINGLE_Controller@ACTION_add_new_note_template_section_template')->name('note_templates_SINGLE-ACTION_add_new_note_template_section_template');
+});
+
+// --- admin: note_templates --- //
+Route::prefix('/note_templates')->group(function () {
+	Route::get('', 'note_templates_Controller@index')->name('note_templates-index');
+	Route::get('add_new', 'note_templates_Controller@add_new')->name('note_templates-add_new');
+	Route::get('view/{uid}', 'note_templates_Controller@view')->name('note_templates-view');
+});