change user project assignment system
This commit is contained in:
parent
35074bd0c9
commit
62a159fa9b
4 changed files with 27 additions and 18 deletions
|
|
@ -36,11 +36,6 @@ tabs:
|
|||
query: page.logo.toFile
|
||||
layout: cardlets
|
||||
required: true
|
||||
managers:
|
||||
label: Chefs de projet
|
||||
type: users
|
||||
help: Utilisateurs autorisés à intervenir sur ce projet et notifiés lorsque quelqu'un intervient dessus.
|
||||
required: true
|
||||
|
||||
- width: 2/3
|
||||
sections:
|
||||
|
|
|
|||
|
|
@ -8,5 +8,9 @@ fields:
|
|||
type: pages
|
||||
max: 1
|
||||
query: page('clients').children
|
||||
projects:
|
||||
label: Projets
|
||||
type: pages
|
||||
query: page('projects').children
|
||||
notifications:
|
||||
type: hidden
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
title:
|
||||
fr: Chef·fe de projet
|
||||
en: Project Manager
|
||||
permissions:
|
||||
access:
|
||||
users: false
|
||||
|
||||
fields:
|
||||
projects:
|
||||
label: Projets
|
||||
type: pages
|
||||
query: page('projects').children
|
||||
notifications:
|
||||
type: hidden
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
<?php
|
||||
$children = $page->children()->filter(function ($child) {
|
||||
return kirby()->user()->role() === 'admin' || $child->managers()->toUsers()->has(kirby()->user());
|
||||
})->map(function ($child) {
|
||||
return [
|
||||
'title' => $child->title()->value(),
|
||||
'url' => $child->url(),
|
||||
'uri' => '/' . $child->uri(),
|
||||
'modified' => $child->modified('Y-MM-d'),
|
||||
'currentStep' => $child->currentStep()->value(),
|
||||
'status' => $child->status(),
|
||||
'logo' => $child->client()->toPage()->logo()->toFile()->url(),
|
||||
'steps' => $child->getSteps()
|
||||
function getProjectData($project) {
|
||||
return [
|
||||
'title' => $project->title()->value(),
|
||||
'url' => $project->url(),
|
||||
'uri' => '/' . $project->uri(),
|
||||
'modified' => $project->modified('Y-MM-d'),
|
||||
'currentStep' => $project->currentStep()->value(),
|
||||
'status' => $project->status(),
|
||||
'logo' => $project->client()->toPage()->logo()->toFile()->url(),
|
||||
'steps' => $project->getSteps()
|
||||
];
|
||||
})->values();
|
||||
}
|
||||
|
||||
try {
|
||||
$children = $kirby->user()->role() == 'admin' ? $page->children()->map(fn($project) => getProjectData($project))->values() : $kirby->user()->projects()->toPages()->map(fn($project) => getProjectData($project))->values();
|
||||
} catch (\Throwable $th) {
|
||||
$children = [];
|
||||
}
|
||||
|
||||
$specificData = [
|
||||
"children" => $children,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue