wip Directory model
This commit is contained in:
parent
fad1e1b33b
commit
48e27c4b70
11 changed files with 269 additions and 2 deletions
20
app/Http/Controllers/Bo/DirectoriesController.php
Normal file
20
app/Http/Controllers/Bo/DirectoriesController.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Directory;
|
||||
|
||||
class DirectoriesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Index
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$directories = Directory::all();
|
||||
return \view('bo.pages.directories.index', \compact('directories'));
|
||||
}
|
||||
}
|
||||
11
app/Models/Directory.php
Normal file
11
app/Models/Directory.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Directory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ return [
|
|||
|
||||
'paths' => [
|
||||
resource_path('views'),
|
||||
resource_path('views/vendor'),
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
89
package-lock.json
generated
89
package-lock.json
generated
|
|
@ -49,7 +49,8 @@
|
|||
"typescript-eslint": "^0.0.1-alpha.0",
|
||||
"vue": "^3.2.38",
|
||||
"vue-eslint-parser": "^9.1.0",
|
||||
"vue-loader": "^16.8.3"
|
||||
"vue-loader": "^16.8.3",
|
||||
"vue3-nestable": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
|
|
@ -6415,6 +6416,12 @@
|
|||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/immutability-helper": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/immutability-helper/-/immutability-helper-3.1.1.tgz",
|
||||
"integrity": "sha512-Q0QaXjPjwIju/28TsugCHNEASwoCcJSyJV3uO1sOIQGI0jKgm9f41Lvz0DZj3n46cNCyAZTsEYoY4C2bVRUzyQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/immutable": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.2.4.tgz",
|
||||
|
|
@ -7889,6 +7896,16 @@
|
|||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/path": {
|
||||
"version": "0.12.7",
|
||||
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
|
||||
"integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"process": "^0.11.1",
|
||||
"util": "^0.10.3"
|
||||
}
|
||||
},
|
||||
"node_modules/path-browserify": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
|
||||
|
|
@ -7949,6 +7966,21 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/path/node_modules/inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/path/node_modules/util": {
|
||||
"version": "0.10.4",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
|
||||
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/pbkdf2": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz",
|
||||
|
|
@ -11113,6 +11145,17 @@
|
|||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vue3-nestable": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/vue3-nestable/-/vue3-nestable-3.0.3.tgz",
|
||||
"integrity": "sha512-1f2Y/eWZbH+QgGAwgnDKyU0Lp0O5+zRO1rmF9eJfB1rG6ZJb8KEcrEwzvpoOGkPC+Z3xDzUQeQCeFruDRBrrBA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"immutability-helper": "^3.1.1",
|
||||
"path": "^0.12.7",
|
||||
"vue": "^3.2.31"
|
||||
}
|
||||
},
|
||||
"node_modules/watchpack": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
|
||||
|
|
@ -16475,6 +16518,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"immutability-helper": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/immutability-helper/-/immutability-helper-3.1.1.tgz",
|
||||
"integrity": "sha512-Q0QaXjPjwIju/28TsugCHNEASwoCcJSyJV3uO1sOIQGI0jKgm9f41Lvz0DZj3n46cNCyAZTsEYoY4C2bVRUzyQ==",
|
||||
"dev": true
|
||||
},
|
||||
"immutable": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.2.4.tgz",
|
||||
|
|
@ -17600,6 +17649,33 @@
|
|||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"path": {
|
||||
"version": "0.12.7",
|
||||
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
|
||||
"integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"process": "^0.11.1",
|
||||
"util": "^0.10.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==",
|
||||
"dev": true
|
||||
},
|
||||
"util": {
|
||||
"version": "0.10.4",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
|
||||
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"path-browserify": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
|
||||
|
|
@ -19953,6 +20029,17 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"vue3-nestable": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/vue3-nestable/-/vue3-nestable-3.0.3.tgz",
|
||||
"integrity": "sha512-1f2Y/eWZbH+QgGAwgnDKyU0Lp0O5+zRO1rmF9eJfB1rG6ZJb8KEcrEwzvpoOGkPC+Z3xDzUQeQCeFruDRBrrBA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"immutability-helper": "^3.1.1",
|
||||
"path": "^0.12.7",
|
||||
"vue": "^3.2.31"
|
||||
}
|
||||
},
|
||||
"watchpack": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
"typescript-eslint": "^0.0.1-alpha.0",
|
||||
"vue": "^3.2.38",
|
||||
"vue-eslint-parser": "^9.1.0",
|
||||
"vue-loader": "^16.8.3"
|
||||
"vue-loader": "^16.8.3",
|
||||
"vue3-nestable": "^3.0.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ return [
|
|||
'orders' => 'Commandes',
|
||||
'contacts' => 'Messages de contact',
|
||||
'app_users' => 'Utilisateurs de l\'application', // FIXME : Gérer le singulier
|
||||
'directories' => 'Dossiers',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
103
resources/ts/bo/components/DirectoriesComponent.vue
Normal file
103
resources/ts/bo/components/DirectoriesComponent.vue
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<template>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<!-- CARD HEADER -->
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>
|
||||
Arborescence : cliquer/glisser pour réorganiser l'arborescence
|
||||
</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="row float-end">
|
||||
<div class="col">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control mr-1"
|
||||
placeholder="Nouveau dossier"
|
||||
v-model="newFolderFR"
|
||||
>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input
|
||||
type="submit"
|
||||
value="Ajouter"
|
||||
class="btn btn-primary"
|
||||
@click="addFolder"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- CARD BODY -->
|
||||
<div class="card-body" />
|
||||
<!-- FIXME : alertVisible -->
|
||||
<!-- FIXME : alertErrorVisible -->
|
||||
<vue-nestable :value="inTdirectories">
|
||||
<template #default="slot">
|
||||
<vue-nestable-handle>
|
||||
{{ slot.item.name.fr }}
|
||||
</vue-nestable-handle>
|
||||
</template>
|
||||
</vue-nestable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import trans from "../../modules/trans";
|
||||
import { VueNestable, VueNestableHandle } from "vue3-nestable";
|
||||
|
||||
type DirectoryObject = {
|
||||
id: number;
|
||||
name: string;
|
||||
parent: number | null;
|
||||
order: number;
|
||||
needAuthorization: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
children: Array<DirectoryObject> | undefined;
|
||||
};
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [trans],
|
||||
components: { VueNestable, VueNestableHandle },
|
||||
mounted() {
|
||||
const json = String(this.$attrs.json ?? "{}");
|
||||
const data = JSON.parse(json);
|
||||
if (data.directories) {
|
||||
this.inTdirectories = this.recursiveDir(data.directories);
|
||||
}
|
||||
},
|
||||
data(): {
|
||||
inTdirectories: Object;
|
||||
} {
|
||||
return {
|
||||
inTdirectories: {},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
recursiveDir(list: Array<DirectoryObject>, parent: number | null = null) {
|
||||
let root = list.filter((e: DirectoryObject) => e.parent == parent);
|
||||
for (let i = 0; i < root.length; i++) {
|
||||
let childs = this.recursiveDir(list, root[i].id);
|
||||
root[i].children = [];
|
||||
for (let j = 0; j < childs.length; j++) {
|
||||
root[i].children?.push(childs[j]);
|
||||
}
|
||||
if (!root[i].children?.length) {
|
||||
delete root[i].children;
|
||||
}
|
||||
}
|
||||
return root;
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss"></style>
|
||||
6
resources/ts/types/ vue3-nestable/index.d.ts
vendored
Normal file
6
resources/ts/types/ vue3-nestable/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
declare module "vue3-nestable" {
|
||||
export class VueNestable {}
|
||||
export class VueNestableHandle {}
|
||||
|
||||
export default VueNestable;
|
||||
}
|
||||
|
|
@ -16,5 +16,13 @@
|
|||
{{ __('Utilisateurs') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if(request()->routeIs('bo.directories')) active @endif"
|
||||
href="{{ route('bo.directories.index') }}"
|
||||
title="{{ __('Dossiers') }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Dossiers') }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@endauth
|
||||
|
|
|
|||
27
resources/views/bo/pages/directories/index.blade.php
Normal file
27
resources/views/bo/pages/directories/index.blade.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title', sprintf('%s - %s', __('models.classes.directories'), Str::ucfirst(__('liste'))))
|
||||
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1 class="h3">{{ __('models.classes.directories') }} {{ Str::ucfirst(__('liste')) }}</h1>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="input-group justify-content-end">
|
||||
<a href="{{ route('bo.directories.create') }}" class="btn btn-primary" title="{{ __('Ajouter un :model', [
|
||||
'model' => Str::singular(__('models.classes.directories')),
|
||||
]) }}" data-bs-toggle="tooltip"><i class="fa-solid fa-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="directories" data-json='@json(['directories' => $directories])'></div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use App\Http\Controllers\Bo\AppUserController;
|
||||
use App\Http\Controllers\Bo\DashboardController;
|
||||
use App\Http\Controllers\Bo\DirectoriesController;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
|
@ -20,5 +21,6 @@ Route::prefix('bo')->name('bo.')->middleware(['admin-secure', 'throttle:credenti
|
|||
Route::middleware('auth:backend')->group(function () {
|
||||
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
|
||||
Route::resource('app-users', AppUserController::class);
|
||||
Route::resource('directories', DirectoriesController::class);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue