Closes #21
This commit is contained in:
parent
316b56b0c4
commit
62dfba632d
20 changed files with 270 additions and 202 deletions
|
|
@ -103,7 +103,7 @@ class AppUserController extends Controller
|
|||
*/
|
||||
public function edit(AppUser $app_user)
|
||||
{
|
||||
$directories = Directory::renderDirectories(Directory::where('needAuthorization', 1)
|
||||
$directories = Directory::renderDirectories(Directory::query()->where('needAuthorization', 1)
|
||||
->orderBy('name', 'ASC')->get());
|
||||
$app_user->directories = Directory::renderDirectories($app_user->directories);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ use App\Http\Controllers\Controller;
|
|||
use App\Http\Requests\Bo\Directories\StoreDirectoryRequest;
|
||||
use App\Http\Requests\Bo\Directories\UpdateDirectoryRequest;
|
||||
use App\Models\Directory;
|
||||
use App\Models\Document;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DirectoriesController extends Controller
|
||||
|
|
@ -20,7 +22,7 @@ class DirectoriesController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$directories = Directory::orderBy('order', 'ASC')->get();
|
||||
$directories = $this->getDirectoriesForComponent();
|
||||
|
||||
return \view('bo.pages.directories.index', \compact('directories'));
|
||||
}
|
||||
|
|
@ -61,6 +63,7 @@ class DirectoriesController extends Controller
|
|||
*/
|
||||
public function edit(Directory $directory)
|
||||
{
|
||||
$this->authorize('edit', $directory);
|
||||
return view('bo.pages.directories.edit', ['directoryModel' => $directory]);
|
||||
}
|
||||
|
||||
|
|
@ -73,6 +76,7 @@ class DirectoriesController extends Controller
|
|||
*/
|
||||
public function update(UpdateDirectoryRequest $request, Directory $directory)
|
||||
{
|
||||
$this->authorize('edit', $directory);
|
||||
return DB::transaction(function () use ($request, $directory) {
|
||||
$directory->fill($request->validated());
|
||||
|
||||
|
|
@ -101,28 +105,39 @@ class DirectoriesController extends Controller
|
|||
*/
|
||||
public function destroy(Directory $directory)
|
||||
{
|
||||
foreach ($directory->children as $directoryChild) {
|
||||
$directoryChild->directory_id = null;
|
||||
$directoryChild->saveOrFail();
|
||||
}
|
||||
$buttons = Setting::where('key', 'Button1')->orWhere('key', 'Button2')->orWhere('key', 'Button3')->get();
|
||||
foreach ($buttons as $button) {
|
||||
if (isset($button->value) && intval($button->value) === $directory->id) {
|
||||
return [
|
||||
$button->id => trans(
|
||||
':model :name n\'a pas été supprimé,
|
||||
un bouton est encore associé à ce dernier dans les paramètres :',
|
||||
[
|
||||
'model' => Str::singular(trans('models.classes.directories')),
|
||||
'name' => $directory->name['fr']
|
||||
]
|
||||
)
|
||||
];
|
||||
$this->authorize('delete', $directory);
|
||||
return DB::transaction(function () use ($directory) {
|
||||
foreach ($directory->children as $directoryChild) {
|
||||
$directoryChild->directory_id = null;
|
||||
$directoryChild->saveOrFail();
|
||||
}
|
||||
}
|
||||
if ($directory->deleteOrFail()) {
|
||||
return Directory::orderBy('order', 'ASC')->get();
|
||||
}
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Document> */
|
||||
$documents = $directory->documents()->get()->sortBy('lang', \SORT_REGULAR, true);
|
||||
if ($documents->count()) {
|
||||
$documents->each(function (Document $document) {
|
||||
$document->deleteOrFail();
|
||||
});
|
||||
}
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Setting> */
|
||||
$buttons = Setting::query()->whereIn('key', ['Button1', 'Button2', 'Button3'])->get();
|
||||
foreach ($buttons as $button) {
|
||||
if (isset($button->value) && intval($button->value) === $directory->id) {
|
||||
return [
|
||||
$button->id => trans(
|
||||
':model :name n\'a pas été supprimé,
|
||||
un bouton est encore associé à ce dernier dans les paramètres :',
|
||||
[
|
||||
'model' => Str::singular(trans('models.classes.directories')),
|
||||
'name' => $directory->name['fr']
|
||||
]
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($directory->deleteOrFail()) {
|
||||
return $this->getDirectoriesForComponent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -171,4 +186,16 @@ class DirectoriesController extends Controller
|
|||
return $directory;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get directories for component
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\Directory>
|
||||
*/
|
||||
private function getDirectoriesForComponent()
|
||||
{
|
||||
return Directory::query()
|
||||
->withCount('documents')
|
||||
->orderBy('order', 'ASC')->get();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Requests\Bo\Directories;
|
||||
|
||||
use App\Enums\Documents\LangEnum;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreDirectoryRequest extends FormRequest
|
||||
|
|
@ -49,9 +50,16 @@ class StoreDirectoryRequest extends FormRequest
|
|||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
$rules = [
|
||||
'name' => \trans('nom du dossier'),
|
||||
'needAuthorization' => \trans('autorisation du dossier')
|
||||
];
|
||||
foreach (LangEnum::toArray() as $langEnum) {
|
||||
$def = $langEnum->getDefinition();
|
||||
$rules["name.{$def}"] = \trans('nom du dossier :lang', [
|
||||
'lang' => $langEnum->label
|
||||
]);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class Directory extends Model
|
|||
*/
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Directory', 'directory_id');
|
||||
return $this->belongsTo(Directory::class, 'directory_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -150,7 +150,7 @@ class Directory extends Model
|
|||
*/
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany('App\Models\Directory', 'directory_id');
|
||||
return $this->hasMany(Directory::class, 'directory_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,6 +170,6 @@ class Directory extends Model
|
|||
*/
|
||||
public function documents()
|
||||
{
|
||||
return $this->hasMany('App\Models\Document', 'directory_id');
|
||||
return $this->hasMany(Document::class, 'directory_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class Document extends Model
|
|||
*/
|
||||
public static function removeDocument(Model $model): void
|
||||
{
|
||||
$path = \ltrim(\urldecode("storage/docs/" . $model->uuid . $model->type), '/');
|
||||
$path = \ltrim(\urldecode("storage/docs/{$model->uuid}.{$model->type}"), '/');
|
||||
if (\strpos($path, 'storage') !== 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ class Document extends Model
|
|||
*/
|
||||
public function directory()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Directory', 'directory_id');
|
||||
return $this->belongsTo(Directory::class, 'directory_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -148,7 +148,7 @@ class Document extends Model
|
|||
*/
|
||||
public function parentDocument()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Document', 'document_id');
|
||||
return $this->belongsTo(Document::class, 'document_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -158,7 +158,7 @@ class Document extends Model
|
|||
*/
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany('App\Models\Document', 'document_id');
|
||||
return $this->hasMany(Document::class, 'document_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
// * HTTPS FIX
|
||||
//URL::forceScheme('http');
|
||||
URL::forceScheme('https');
|
||||
// * HA PROXY FIX
|
||||
App::singleton('clientIp', function () {
|
||||
if (config('app.env') === 'local') {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Directory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -14,5 +17,14 @@ class AuthServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
Gate::define('edit', function (User $user, Directory $directory) {
|
||||
return !$directory->is_system;
|
||||
});
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
Gate::define('delete', function (User $user, Directory $directory) {
|
||||
return !$directory->is_system;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@charset "UTF-8";
|
||||
@import "~toastify-js/src/toastify.css";
|
||||
|
||||
// * UTILITIES
|
||||
@import "./utilities/variables";
|
||||
|
|
|
|||
|
|
@ -63,15 +63,16 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import type VueTagsInput from "@sipec/vue3-tags-input";
|
||||
import { VueTagsInput as VueTagsInputCls } from "@sipec/vue3-tags-input";
|
||||
import slugify from "slugify";
|
||||
import { defineComponent } from "vue";
|
||||
import parseLaravelErrorMessages from "../../modules/parseLaravelErrorMessages";
|
||||
import route from "../../modules/route";
|
||||
import trans from "../../modules/trans";
|
||||
import parseLaravelErrorMessages from "../../modules/parseLaravelErrorMessages";
|
||||
|
||||
export default defineComponent({
|
||||
name: "BelongsToManyDropdownComponent",
|
||||
mixins: [route, trans, parseLaravelErrorMessages],
|
||||
components: {
|
||||
VueTagsInputCls,
|
||||
|
|
|
|||
|
|
@ -15,11 +15,12 @@
|
|||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import trans from "../../modules/trans";
|
||||
import "../../../js/vendor/ckeditor/build/ckeditor";
|
||||
import trans from "../../modules/trans";
|
||||
// import { CKUploadAdaptater } from "../../bo/CkUploadAdaptater";
|
||||
|
||||
export default defineComponent({
|
||||
name: "CkEditorComponent",
|
||||
emits: ["input"],
|
||||
mixins: [trans],
|
||||
beforeMount() {
|
||||
|
|
|
|||
|
|
@ -80,10 +80,11 @@
|
|||
import { defineComponent, PropType } from "vue";
|
||||
// @ts-ignore
|
||||
import { Chrome } from "@ckpack/vue-color";
|
||||
import trans from "./../../modules/trans";
|
||||
import Tooltip from "bootstrap/js/dist/tooltip";
|
||||
import trans from "./../../modules/trans";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ColorPickerComponent",
|
||||
inheritAttrs: false,
|
||||
mixins: [trans],
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
id: number,
|
||||
name: string[],
|
||||
needAuthorization: boolean,
|
||||
documents_count: number,
|
||||
children: number[],
|
||||
is_system: boolean,
|
||||
},
|
||||
|
|
@ -66,6 +67,16 @@
|
|||
<button class="btn btn-sm border-0 disabled opacity-100">
|
||||
<FontAwesomeIcon icon="fa-solid fa-grip-vertical" />
|
||||
</button>
|
||||
<p class="m-0">
|
||||
<span class="badge d-flex align-items-center p-1 pe-2 text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-pill">
|
||||
<FontAwesomeIcon
|
||||
icon="fa-solid fa-file"
|
||||
class="rounded-circle me-1"
|
||||
/>
|
||||
{{ item.documents_count }}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p class="m-0">
|
||||
{{ item.name["fr" as keyof typeof item.name] }}
|
||||
</p>
|
||||
|
|
@ -102,7 +113,7 @@
|
|||
<FontAwesomeIcon icon="fa-solid fa-pencil" />
|
||||
</a>
|
||||
<button
|
||||
@click="deleteDirectory($event, item)"
|
||||
@click="deleteDirectory($event, item as never as DirectoryObject)"
|
||||
class="btn btn-sm btn-danger confirmDelete"
|
||||
:title="__('Supprimer le Dossier')"
|
||||
data-bs="tooltip"
|
||||
|
|
@ -132,13 +143,15 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { VueNestable, VueNestableHandle } from "vue3-nestable";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import { Tooltip } from "bootstrap";
|
||||
import { defineComponent } from "vue";
|
||||
import { VueNestable, VueNestableHandle } from "vue3-nestable";
|
||||
import parseLaravelErrorMessages from "../../modules/parseLaravelErrorMessages";
|
||||
import route from "../../modules/route";
|
||||
import trans from "../../modules/trans";
|
||||
import sweetalertConfirm from "../../modules/sweetalertConfirm";
|
||||
import toast from "../../modules/toast";
|
||||
import trans from "../../modules/trans";
|
||||
|
||||
type DirectoryObject = {
|
||||
id: number;
|
||||
|
|
@ -147,6 +160,7 @@ type DirectoryObject = {
|
|||
text: string | null;
|
||||
order: number;
|
||||
needAuthorization: number;
|
||||
documents_count: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
children: Array<DirectoryObject> | undefined;
|
||||
|
|
@ -154,12 +168,13 @@ type DirectoryObject = {
|
|||
};
|
||||
|
||||
export default defineComponent({
|
||||
name: "DirectoriesComponent",
|
||||
components: {
|
||||
VueNestable,
|
||||
VueNestableHandle,
|
||||
FontAwesomeIcon,
|
||||
},
|
||||
mixins: [route, trans, sweetalertConfirm],
|
||||
mixins: [route, trans, sweetalertConfirm, toast, parseLaravelErrorMessages],
|
||||
data(): {
|
||||
intCsrf: string | null | undefined;
|
||||
intId: String;
|
||||
|
|
@ -193,11 +208,7 @@ export default defineComponent({
|
|||
});
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* Prepare the list of items.
|
||||
* @param list
|
||||
* @param parent
|
||||
*/
|
||||
/** Prepare the list of items. */
|
||||
recursiveDir(list: DirectoryObject[], parent: number | null = null) {
|
||||
let root = list.filter((e: DirectoryObject) => e.directory_id == parent);
|
||||
for (let i = 0; i < root.length; i++) {
|
||||
|
|
@ -212,10 +223,7 @@ export default defineComponent({
|
|||
}
|
||||
return root;
|
||||
},
|
||||
/**
|
||||
* Check if item is a system item before the move.
|
||||
* @param object
|
||||
*/
|
||||
/** Check if item is a system item before the move. */
|
||||
beforeMove({
|
||||
dragItem,
|
||||
pathTo,
|
||||
|
|
@ -232,34 +240,19 @@ export default defineComponent({
|
|||
}
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
* Update data's directories.
|
||||
*/
|
||||
/** Update data's directories. */
|
||||
updateOrderDirectories() {
|
||||
let newOrder = this.assignOrder(this.intDirectories, null);
|
||||
const route = this.route("bo.directories.save-order");
|
||||
if (!route) {
|
||||
throw new Error("Undefined route bo.directories.save-order");
|
||||
}
|
||||
window.axios.post(route, { directories: newOrder }).catch((error) => {
|
||||
if (error.response) {
|
||||
console.error(error.response.data);
|
||||
} else if (error.request) {
|
||||
console.error(error.request);
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error.
|
||||
console.error("Error", error.message);
|
||||
}
|
||||
});
|
||||
window.axios.post(route, { directories: newOrder }).catch(this.ajaxErrorHandler);
|
||||
this.$nextTick(() => {
|
||||
this.updateBootstrapTooltip();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Assign the new order and parent id to each directory.
|
||||
* @param children
|
||||
* @param parentId
|
||||
*/
|
||||
/** Assign the new order and parent id to each directory. */
|
||||
assignOrder(children: DirectoryObject[], parentId: number | null) {
|
||||
children.forEach((element, index) => {
|
||||
element.order = index;
|
||||
|
|
@ -272,11 +265,7 @@ export default defineComponent({
|
|||
});
|
||||
return children;
|
||||
},
|
||||
/**
|
||||
* Return edit route for a directory.
|
||||
* @param id
|
||||
* @return string
|
||||
*/
|
||||
/** Return edit route for a directory. */
|
||||
getEditDirectoryRoute(id: number): string {
|
||||
const route = this.route("bo.directories.edit", {
|
||||
ID: id,
|
||||
|
|
@ -286,11 +275,7 @@ export default defineComponent({
|
|||
}
|
||||
return route;
|
||||
},
|
||||
/**
|
||||
* Return edit route for a directory.
|
||||
* @param id
|
||||
* @return string
|
||||
*/
|
||||
/** Return edit route for a directory. */
|
||||
getEditButtonRoute(id: number): string {
|
||||
const route = this.route("bo.settings.edit", {
|
||||
ID: id,
|
||||
|
|
@ -300,10 +285,7 @@ export default defineComponent({
|
|||
}
|
||||
return route;
|
||||
},
|
||||
/**
|
||||
* Show/Hide children.
|
||||
* @param id
|
||||
*/
|
||||
/** Show/Hide children. */
|
||||
displayList(e: Event, id: number) {
|
||||
this.intDisplay[id] = this.intDisplay[id] ? false : true;
|
||||
document
|
||||
|
|
@ -313,10 +295,7 @@ export default defineComponent({
|
|||
this.updateBootstrapTooltip();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Update authorization for a specific directory.
|
||||
* @param LaravelModel model
|
||||
*/
|
||||
/** Update authorization for a specific directory. */
|
||||
updateAuthorization(model: LaravelModel) {
|
||||
this.intLoading = true;
|
||||
const route = this.route("bo.directories.need-authorization", {
|
||||
|
|
@ -328,35 +307,54 @@ export default defineComponent({
|
|||
window.axios
|
||||
.post(route, { id: model.id })
|
||||
.then((reponse) => {
|
||||
this.intDirectories.forEach((directory, directoryindex) => {
|
||||
if (directory.id === reponse.data.id) {
|
||||
this.intDirectories[directoryindex] = reponse.data;
|
||||
}
|
||||
});
|
||||
model.needAuthorization = reponse.data.needAuthorization;
|
||||
this.intLoading = false;
|
||||
this.$nextTick(() => {
|
||||
this.updateBootstrapTooltip();
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.response) {
|
||||
console.error(error.response.data);
|
||||
} else if (error.request) {
|
||||
console.error(error.request);
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error.
|
||||
console.error("Error", error.message);
|
||||
}
|
||||
});
|
||||
.catch(this.ajaxErrorHandler);
|
||||
},
|
||||
/**
|
||||
* Update authorization for a specific directory.
|
||||
* @param LaravelModel model
|
||||
*/
|
||||
deleteDirectory(e: Event, model: LaravelModel) {
|
||||
/** Update authorization for a specific directory. */
|
||||
deleteDirectory(e: Event, model: DirectoryObject) {
|
||||
const btnConfirmDelete = this.$refs.confirmDelete as HTMLButtonElement;
|
||||
let promise:Promise<boolean>|null = null;
|
||||
(async () => {
|
||||
const promise = new Promise((resolve: (value: boolean) => void) => {
|
||||
if (model.children?.length) {
|
||||
promise = new Promise((resolve: (value: boolean) => void) => {
|
||||
sweetalertConfirm.methods.confirm(
|
||||
"Les dossiers enfants seront déplacés plus haut",
|
||||
"Êtes vous sure ?",
|
||||
btnConfirmDelete,
|
||||
function (response) {
|
||||
resolve(response.isConfirmed);
|
||||
},
|
||||
{ icon: "warning" }
|
||||
);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (promise !== null && await promise === false) {
|
||||
return;
|
||||
}
|
||||
if (model.documents_count > 0) {
|
||||
promise = new Promise((resolve: (value: boolean) => void) => {
|
||||
sweetalertConfirm.methods.confirm(
|
||||
"Les document enfants seront SUPPRIMÉS",
|
||||
"Êtes vous sure ?",
|
||||
btnConfirmDelete,
|
||||
function (response) {
|
||||
resolve(response.isConfirmed);
|
||||
},
|
||||
{ icon: "warning" }
|
||||
);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (promise !== null && await promise === false) {
|
||||
return;
|
||||
}
|
||||
promise = new Promise((resolve: (value: boolean) => void) => {
|
||||
sweetalertConfirm.methods.confirm(
|
||||
"Confirmez",
|
||||
"Êtes vous sure ?",
|
||||
|
|
@ -395,22 +393,11 @@ export default defineComponent({
|
|||
this.updateBootstrapTooltip();
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.response) {
|
||||
console.error(error.response.data);
|
||||
} else if (error.request) {
|
||||
console.error(error.request);
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error.
|
||||
console.error("Error", error.message);
|
||||
}
|
||||
});
|
||||
.catch(this.ajaxErrorHandler);
|
||||
}
|
||||
})();
|
||||
},
|
||||
/**
|
||||
* Update Bootstrap tooltips.
|
||||
*/
|
||||
/** Update Bootstrap tooltips. */
|
||||
updateBootstrapTooltip() {
|
||||
let newTooltipList = [].slice.call(
|
||||
document.querySelectorAll(
|
||||
|
|
@ -424,15 +411,39 @@ export default defineComponent({
|
|||
this.closeBootstrapTooltip();
|
||||
this.intTooltipList = newTooltipList;
|
||||
},
|
||||
/**
|
||||
* Close all Bootstrap tooltips.
|
||||
*/
|
||||
/** Close all Bootstrap tooltips. */
|
||||
closeBootstrapTooltip() {
|
||||
this.intTooltipList.forEach((tooltip) => {
|
||||
tooltip.blur();
|
||||
Tooltip.getInstance(tooltip)?.hide();
|
||||
});
|
||||
},
|
||||
ajaxErrorHandler(e: any) {
|
||||
this.intLoading = false;
|
||||
let message = this.__("Une erreur est survenue");
|
||||
if (e.response.status === 422) {
|
||||
message =
|
||||
this.parseValidationErrors(
|
||||
e.response?.data?.errors ?? {}
|
||||
) || message;
|
||||
if (window.vueDebug) {
|
||||
console.warn(e.response.data.errors);
|
||||
}
|
||||
} else if (e.response.status === 419) {
|
||||
// * CSRF TOKEN MISMATCH (On ne pourrais plus faire d'appels AJAX sans recharger la page)
|
||||
this.errorNotify(this.__("Votre session a expiré, la page va être rechargée"));
|
||||
setTimeout(() => window.location.reload(), 2000);
|
||||
} else if (e.response.status === 403) {
|
||||
// * Access denied
|
||||
this.errorNotify(this.__("Vous n'êtes pas autorisé a effectuer cette action"));
|
||||
setTimeout(() => window.location.reload(), 2000);
|
||||
} else {
|
||||
if (window.vueDebug) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
this.errorNotify(message);
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ import ListItemComponent from "./ListItemComponent.vue";
|
|||
import WordCounter from "./WordCounterComponent.vue";
|
||||
|
||||
export default defineComponent({
|
||||
name: "FormulariesSelectInputComponent",
|
||||
mixins: [trans, parseLaravelErrorMessages],
|
||||
components: {
|
||||
FormulariesSwitchComponent,
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ import { defineComponent, PropType } from "vue";
|
|||
import trans from "../../modules/trans";
|
||||
|
||||
export default defineComponent({
|
||||
name: "FormulariesSwitchComponent",
|
||||
mixins: [trans],
|
||||
props: {
|
||||
id: {
|
||||
|
|
|
|||
|
|
@ -398,10 +398,10 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import Cropper from "cropperjs";
|
||||
import { Tooltip } from "bootstrap";
|
||||
import Cropper from "cropperjs";
|
||||
import { defineComponent } from "vue";
|
||||
import trans from "./../../modules/trans";
|
||||
|
||||
const UNITS = [
|
||||
|
|
@ -415,6 +415,7 @@ const UNITS = [
|
|||
const BYTES_PER_KB = 1024;
|
||||
|
||||
export default defineComponent({
|
||||
name: "ImageInputComponent",
|
||||
mixins: [trans],
|
||||
emits: ["browseFile"],
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import WordCounter from "./WordCounterComponent.vue";
|
|||
const textarea = ref<HTMLTextAreaElement | null>(null);
|
||||
|
||||
export default defineComponent({
|
||||
name: "InputTextAutoComponent",
|
||||
inheritAttrs: false,
|
||||
mixins: [trans],
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import { defineComponent } from "vue";
|
|||
import trans from "../../modules/trans";
|
||||
|
||||
export default defineComponent({
|
||||
name: "WordCounterComponent",
|
||||
mixins: [trans],
|
||||
mounted() {
|
||||
const json = String(this.$attrs.json ?? "{}");
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
import { dom, library, config } from "@fortawesome/fontawesome-svg-core";
|
||||
import { config, dom, library } from "@fortawesome/fontawesome-svg-core";
|
||||
import {
|
||||
faEraser,
|
||||
faArrowLeftLong,
|
||||
faPlus,
|
||||
faMinus,
|
||||
faTrash,
|
||||
faEye,
|
||||
faFolderOpen,
|
||||
faCrop,
|
||||
faQuestionCircle,
|
||||
faCheck,
|
||||
faUndoAlt,
|
||||
faRedoAlt,
|
||||
faSyncAlt,
|
||||
faSearchPlus,
|
||||
faSearchMinus,
|
||||
faArrowLeft,
|
||||
faArrowRight,
|
||||
faArrowUp,
|
||||
faArrowDown,
|
||||
faArrowsAltH,
|
||||
faArrowsAltV,
|
||||
faWandMagic,
|
||||
faPencil,
|
||||
faTimes,
|
||||
faBackspace,
|
||||
faSearch,
|
||||
faArrowRightFromBracket,
|
||||
faAnglesRight,
|
||||
faArrowAltCircleDown,
|
||||
faArrowAltCircleUp,
|
||||
faArrowDown,
|
||||
faArrowLeft,
|
||||
faArrowLeftLong,
|
||||
faArrowRight,
|
||||
faArrowRightFromBracket,
|
||||
faArrowUp,
|
||||
faArrowsAltH,
|
||||
faArrowsAltV,
|
||||
faBackspace,
|
||||
faCheck,
|
||||
faChevronLeft,
|
||||
faChevronRight,
|
||||
faCircleCheck,
|
||||
faCircleNotch,
|
||||
faSliders,
|
||||
faCircleXmark,
|
||||
faCrop,
|
||||
faEraser,
|
||||
faEye,
|
||||
faEyeSlash,
|
||||
faFile,
|
||||
faFloppyDisk,
|
||||
faFolderOpen,
|
||||
faGripVertical,
|
||||
faHeading,
|
||||
faListUl,
|
||||
faLock,
|
||||
faLockOpen,
|
||||
faCircleCheck,
|
||||
faCircleXmark,
|
||||
faFloppyDisk,
|
||||
faMinus,
|
||||
faPencil,
|
||||
faPlus,
|
||||
faQuestionCircle,
|
||||
faRedoAlt,
|
||||
faSearch,
|
||||
faSearchMinus,
|
||||
faSearchPlus,
|
||||
faSliders,
|
||||
faSyncAlt,
|
||||
faTimes,
|
||||
faTrash,
|
||||
faUndoAlt,
|
||||
faVideo,
|
||||
faFile,
|
||||
faListUl,
|
||||
faHeading,
|
||||
faAnglesRight,
|
||||
faWandMagic,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
config.autoReplaceSvg = false;
|
||||
|
|
@ -89,6 +89,7 @@ library.add(faVideo);
|
|||
library.add(faListUl);
|
||||
library.add(faHeading);
|
||||
library.add(faAnglesRight);
|
||||
library.add(faFile);
|
||||
|
||||
// Front
|
||||
library.add(faChevronLeft);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="row">
|
||||
{{-- LASTNAME --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Nom') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Doit posséder 3 caractères minimum, 255 maximum.'),
|
||||
'placeholder' => "Un beau nom"
|
||||
'placeholder' => 'Un beau nom',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
</div>
|
||||
{{-- FIRSTNAME --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Prénom') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Doit posséder 3 caractères minimum, 255 maximum.'),
|
||||
'placeholder' => "Un beau prénom"
|
||||
'placeholder' => 'Un beau prénom',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
</div>
|
||||
{{-- EMAIL --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Email') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
|
|
@ -52,8 +52,9 @@
|
|||
'hasWordCounter' => true,
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Tapez votre e-mail en respectant la convention d\'appellation des e-mails (ex: firstname.lastname@yourdomain.com).'),
|
||||
'placeholder' => "firstname.lastname@yourdomain.com"
|
||||
'helper' => __(
|
||||
'Tapez votre e-mail en respectant la convention d\'appellation des e-mails (ex: firstname.lastname@yourdomain.com).'),
|
||||
'placeholder' => 'firstname.lastname@yourdomain.com',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -61,7 +62,7 @@
|
|||
</div>
|
||||
{{-- PASSWORD --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Mot de passe') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
|
|
@ -78,7 +79,9 @@
|
|||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar-password', [
|
||||
'id' => 'app_userPassword_confirmation',
|
||||
'label' => __('Confirmation du mot de passe de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'label' => __('Confirmation du mot de passe de l\':model', [
|
||||
'model' => Str::singular(__('models.classes.users')),
|
||||
]),
|
||||
'name' => 'password_confirmation',
|
||||
'hasWordCounter' => true,
|
||||
'required' => false,
|
||||
|
|
@ -91,7 +94,7 @@
|
|||
</div>
|
||||
{{-- AUTHORIZED FOLDERS --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Dossiers') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
|
|
@ -110,7 +113,7 @@
|
|||
</div>
|
||||
{{-- ROLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Rôle') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
|
|
@ -129,7 +132,7 @@
|
|||
</div>
|
||||
{{-- STATUS --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<legend>{{ __('Visibility') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
|
@ -138,7 +141,7 @@
|
|||
'name' => 'status',
|
||||
'label' => __('L\'utilisateur est-il activé ?'),
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Activation de l\'utilisateur de l\'application.')
|
||||
'helper' => __('Activation de l\'utilisateur de l\'application.'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -147,15 +150,15 @@
|
|||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
submitClone = document.getElementById('formSubmitClone');
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
|
|||
|
|
@ -1,29 +1,26 @@
|
|||
@if(!empty($label))
|
||||
<label for="{{ $id }}" class="col-form-label">
|
||||
<b>{{ $label }} {{ $required ? '*' : '' }}</b>
|
||||
</label>
|
||||
@if (!empty($label))
|
||||
<label class="col-form-label" for="{{ $id }}">
|
||||
<b>{{ $label }} {{ $required ? '*' : '' }}</b>
|
||||
</label>
|
||||
@endif
|
||||
@if(!empty($hasWordCounter ?? false))
|
||||
<div class="word-counter" data-json='@json(['id'=> "$id"])'></div>
|
||||
@if (!empty($hasWordCounter ?? false))
|
||||
<div class="word-counter" data-json='@json(['id' => "$id"])'></div>
|
||||
@endif
|
||||
<div class="col-12 input-group d-flex w-100 justify-content-center">
|
||||
<input id="{{ $id }}"
|
||||
name="{{ $name }}"
|
||||
type="password"
|
||||
value="{{ old($name, $model->{$name} ?? '') }}"
|
||||
class="form-control @if($errors->has($name)) is-invalid @endif @if(!empty($hasWordCounter ?? false)) need-word-counter-password @endif"
|
||||
id="{{ $id }}"
|
||||
aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ $placeholder ?? __('Un beau mot de passe') }}"
|
||||
autocomplete="current-password"
|
||||
@if(!empty($required))required @endif>
|
||||
<input
|
||||
class="form-control @if ($errors->has($name)) is-invalid @endif @if (!empty($hasWordCounter ?? false)) need-word-counter-password @endif"
|
||||
id="{{ $id }}" id="{{ $id }}" name="{{ $name }}" type="password"
|
||||
value="{{ old($name, $model->{$name} ?? '') }}" aria-describedby="{{ $id }}Help"
|
||||
placeholder="{{ $placeholder ?? __('Un beau mot de passe') }}" autocomplete="current-password"
|
||||
@if (!empty($required)) required @endif>
|
||||
@php $dataPassword = ['inputId' => $id]; @endphp
|
||||
<span class="btn btn-primary password-visibility w-fit d-flex justify-content-center align-items-center p-0 @if(!empty($hasWordCounter ?? false)) need-word-counter-password-btn @endif"
|
||||
<span
|
||||
class="btn btn-primary password-visibility d-flex justify-content-center align-items-center @if (!empty($hasWordCounter ?? false)) need-word-counter-password-btn @endif w-fit p-0"
|
||||
data-json='@json($dataPassword)'>
|
||||
</span>
|
||||
</div>
|
||||
@include('modules.input-error', [
|
||||
'inputName' => $name,
|
||||
'helperId' => $id . 'Help',
|
||||
'helper' => $helper
|
||||
'helper' => $helper,
|
||||
])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue