Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-mlc
kohinos
Commits
e90cbad5
Commit
e90cbad5
authored
Aug 19, 2020
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Choix du comptoir/groupe local à la création d'un utilisateur
parent
210f531c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
6 deletions
+75
-6
admin.js
assets/js/admin.js
+29
-0
admin.c440dffd.js
public/build/admin.c440dffd.js
+0
-0
entrypoints.json
public/build/entrypoints.json
+1
-1
manifest.json
public/build/manifest.json
+1
-1
UserAdmin.php
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
+44
-4
No files found.
assets/js/admin.js
View file @
e90cbad5
...
@@ -13,6 +13,35 @@ require('../js/geoloc.js');
...
@@ -13,6 +13,35 @@ require('../js/geoloc.js');
$
(
'#flash-messages'
).
flashNotification
(
'init'
);
$
(
'#flash-messages'
).
flashNotification
(
'init'
);
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
/*
* On user edit page, on the rolesgroup checkbox:
* - display 'group' select if "Gestionnaire de groupe" is checked
* - display 'comptoir' select if "Comptoir" is checked
*/
function
possiblegroups_display_selects
(
e
)
{
var
label
=
$
(
this
).
closest
(
'li'
).
find
(
'.control-label__text'
)[
0
].
textContent
.
trim
().
toLowerCase
()
var
isChecked
=
$
(
this
).
closest
(
'li'
).
find
(
'.checked'
).
length
>
0
if
(
label
.
includes
(
'comptoir'
))
{
if
(
isChecked
)
{
$
(
'.comptoirsgeres_select'
).
removeClass
(
'hide'
)
}
else
{
$
(
'.comptoirsgeres_select'
).
addClass
(
'hide'
)
}
}
else
if
(
label
.
includes
(
'groupe'
))
{
if
(
isChecked
)
{
$
(
'.groupesgeres_select'
).
removeClass
(
'hide'
)
}
else
{
$
(
'.groupesgeres_select'
).
addClass
(
'hide'
)
}
}
}
$
(
'.possible_group_cblist li .checkbox label'
).
on
(
'click'
,
possiblegroups_display_selects
);
$
(
'.possible_group_cblist li .checkbox label ins'
).
on
(
'click'
,
possiblegroups_display_selects
);
$
(
'.editableboolean'
).
on
(
'click'
,
function
(
e
)
{
$
(
'.editableboolean'
).
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
self
=
$
(
this
);
var
self
=
$
(
this
);
...
...
public/build/admin.
da628ab6
.js
→
public/build/admin.
c440dffd
.js
View file @
e90cbad5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
public/build/entrypoints.json
View file @
e90cbad5
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
"admin"
:
{
"admin"
:
{
"js"
:
[
"js"
:
[
"/build/runtime.420770e4.js"
,
"/build/runtime.420770e4.js"
,
"/build/admin.
da628ab6
.js"
"/build/admin.
c440dffd
.js"
],
],
"css"
:
[
"css"
:
[
"/build/admin.b8c3eca8.css"
"/build/admin.b8c3eca8.css"
...
...
public/build/manifest.json
View file @
e90cbad5
{
{
"build/admin.css"
:
"/build/admin.b8c3eca8.css"
,
"build/admin.css"
:
"/build/admin.b8c3eca8.css"
,
"build/admin.js"
:
"/build/admin.
da628ab6
.js"
,
"build/admin.js"
:
"/build/admin.
c440dffd
.js"
,
"build/app.css"
:
"/build/app.b1a10d11.css"
,
"build/app.css"
:
"/build/app.b1a10d11.css"
,
"build/app.js"
:
"/build/app.a6090119.js"
,
"build/app.js"
:
"/build/app.a6090119.js"
,
"build/runtime.js"
:
"/build/runtime.420770e4.js"
,
"build/runtime.js"
:
"/build/runtime.420770e4.js"
,
...
...
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
View file @
e90cbad5
...
@@ -31,6 +31,9 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
...
@@ -31,6 +31,9 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use
Symfony\Component\Form\Extension\Core\Type\TimezoneType
;
use
Symfony\Component\Form\Extension\Core\Type\TimezoneType
;
use
Symfony\Component\Form\Extension\Core\Type\UrlType
;
use
Symfony\Component\Form\Extension\Core\Type\UrlType
;
use
Symfony\Component\Form\FormTypeInterface
;
use
Symfony\Component\Form\FormTypeInterface
;
use
Symfony\Component\Form\FormEvent
;
use
Symfony\Component\Form\FormEvents
;
use
Doctrine\Common\Collections\ArrayCollection
;
class
UserAdmin
extends
BaseUserAdmin
class
UserAdmin
extends
BaseUserAdmin
{
{
...
@@ -208,13 +211,13 @@ class UserAdmin extends BaseUserAdmin
...
@@ -208,13 +211,13 @@ class UserAdmin extends BaseUserAdmin
->
add
(
'enabled'
,
null
,
[
'required'
=>
false
])
->
add
(
'enabled'
,
null
,
[
'required'
=>
false
])
->
end
()
->
end
()
;
;
$hideOrShowGroupe
=
[
'class'
=>
'hide'
];
$hideOrShowGroupe
=
[
'class'
=>
'
groupesgeres_select
hide'
];
$hideOrShowComptoir
=
[
'class'
=>
'hide'
];
$hideOrShowComptoir
=
[
'class'
=>
'
comptoirsgeres_select
hide'
];
if
((
$subject
->
isGranted
(
'ROLE_GESTION_GROUPE'
)
||
$subject
->
isGranted
(
'ROLE_CONTACT'
)
||
$subject
->
isGranted
(
'ROLE_TRESORIER'
)))
{
if
((
$subject
->
isGranted
(
'ROLE_GESTION_GROUPE'
)
||
$subject
->
isGranted
(
'ROLE_CONTACT'
)
||
$subject
->
isGranted
(
'ROLE_TRESORIER'
)))
{
$hideOrShowGroupe
=
[];
$hideOrShowGroupe
=
[
'class'
=>
'groupesgeres_select'
];
}
}
if
(
$subject
->
isGranted
(
'ROLE_COMPTOIR'
))
{
if
(
$subject
->
isGranted
(
'ROLE_COMPTOIR'
))
{
$hideOrShowComptoir
=
[];
$hideOrShowComptoir
=
[
'class'
=>
'comptoirsgeres_select'
];
}
}
$formMapper
$formMapper
->
with
(
'Groups'
)
->
with
(
'Groups'
)
...
@@ -223,6 +226,7 @@ class UserAdmin extends BaseUserAdmin
...
@@ -223,6 +226,7 @@ class UserAdmin extends BaseUserAdmin
'required'
=>
false
,
'required'
=>
false
,
'expanded'
=>
true
,
'expanded'
=>
true
,
'multiple'
=>
true
,
'multiple'
=>
true
,
'attr'
=>
[
'class'
=>
'possible_group_cblist'
]
])
])
// @TODO : Si on veut voir le groupe choisit par l'utilisateur
// @TODO : Si on veut voir le groupe choisit par l'utilisateur
// ->add('groups', null, [
// ->add('groups', null, [
...
@@ -292,4 +296,40 @@ class UserAdmin extends BaseUserAdmin
...
@@ -292,4 +296,40 @@ class UserAdmin extends BaseUserAdmin
}
}
}
}
}
}
public
function
postPersist
(
$user
)
:
void
{
// On empeche d'enregistrer des comptoirs/groupes gérés si la case correspondante n'est pas cochée dans le choix des possiblegroups
$em
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$possiblegroups
=
$user
->
getPossiblegroups
();
$groupesgeres
=
$user
->
getGroupesgeres
();
$comptoirsgeres
=
$user
->
getComptoirsgeres
();
$isComptoir
=
false
;
$isGroup
=
false
;
foreach
(
$possiblegroups
as
$possiblegroup
)
{
if
(
$possiblegroup
->
getName
()
==
"Comptoir"
)
{
$isComptoir
=
true
;
}
else
if
(
$possiblegroup
->
getName
()
==
"Gestionnaire de Groupe"
)
{
$isGroup
=
true
;
}
}
if
(
!
$isComptoir
&&
!
$comptoirsgeres
->
isEmpty
())
{
foreach
(
$comptoirsgeres
as
$comptoir
)
{
$user
->
removeComptoirsgere
(
$comptoir
);
}
}
if
(
!
$isGroup
&&
!
$groupesgeres
->
isEmpty
())
{
foreach
(
$groupesgeres
as
$group
)
{
$user
->
removeGroupesgere
(
$group
);
}
}
$em
->
persist
(
$user
);
$em
->
flush
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment