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
|
query: page.logo.toFile
|
||||||
layout: cardlets
|
layout: cardlets
|
||||||
required: true
|
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
|
- width: 2/3
|
||||||
sections:
|
sections:
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,9 @@ fields:
|
||||||
type: pages
|
type: pages
|
||||||
max: 1
|
max: 1
|
||||||
query: page('clients').children
|
query: page('clients').children
|
||||||
|
projects:
|
||||||
|
label: Projets
|
||||||
|
type: pages
|
||||||
|
query: page('projects').children
|
||||||
notifications:
|
notifications:
|
||||||
type: hidden
|
type: hidden
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,14 @@
|
||||||
title:
|
title:
|
||||||
fr: Chef·fe de projet
|
fr: Chef·fe de projet
|
||||||
en: Project Manager
|
en: Project Manager
|
||||||
|
permissions:
|
||||||
|
access:
|
||||||
|
users: false
|
||||||
|
|
||||||
fields:
|
fields:
|
||||||
|
projects:
|
||||||
|
label: Projets
|
||||||
|
type: pages
|
||||||
|
query: page('projects').children
|
||||||
notifications:
|
notifications:
|
||||||
type: hidden
|
type: hidden
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
$children = $page->children()->filter(function ($child) {
|
function getProjectData($project) {
|
||||||
return kirby()->user()->role() === 'admin' || $child->managers()->toUsers()->has(kirby()->user());
|
return [
|
||||||
})->map(function ($child) {
|
'title' => $project->title()->value(),
|
||||||
return [
|
'url' => $project->url(),
|
||||||
'title' => $child->title()->value(),
|
'uri' => '/' . $project->uri(),
|
||||||
'url' => $child->url(),
|
'modified' => $project->modified('Y-MM-d'),
|
||||||
'uri' => '/' . $child->uri(),
|
'currentStep' => $project->currentStep()->value(),
|
||||||
'modified' => $child->modified('Y-MM-d'),
|
'status' => $project->status(),
|
||||||
'currentStep' => $child->currentStep()->value(),
|
'logo' => $project->client()->toPage()->logo()->toFile()->url(),
|
||||||
'status' => $child->status(),
|
'steps' => $project->getSteps()
|
||||||
'logo' => $child->client()->toPage()->logo()->toFile()->url(),
|
|
||||||
'steps' => $child->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 = [
|
$specificData = [
|
||||||
"children" => $children,
|
"children" => $children,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue