Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
agplv3
kohinos-tav
Commits
7f1c5e1b
Commit
7f1c5e1b
authored
Jan 10, 2025
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display informative modale to user, customable by admin, only 1 active at a time
parent
560f9676
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
5 deletions
+40
-5
sonata_admin.yaml
config/packages/sonata_admin.yaml
+1
-1
services.yaml
config/services.yaml
+2
-2
InformationPopupAdmin.php
src/Admin/InformationPopupAdmin.php
+32
-2
InformationPopup.php
src/Entity/InformationPopup.php
+5
-0
No files found.
config/packages/sonata_admin.yaml
View file @
7f1c5e1b
...
@@ -342,7 +342,7 @@ sonata_admin:
...
@@ -342,7 +342,7 @@ sonata_admin:
sonata.admin.informationPopup
:
sonata.admin.informationPopup
:
keep_open
:
false
keep_open
:
false
on_top
:
true
on_top
:
true
label
:
"
Popup
d'information"
label
:
"
Popup
s
d'information"
label_catalogue
:
SonataAdminBundle
label_catalogue
:
SonataAdminBundle
icon
:
'
<i
class="fa
fa-exclamation-circle"></i>'
icon
:
'
<i
class="fa
fa-exclamation-circle"></i>'
items
:
items
:
...
...
config/services.yaml
View file @
7f1c5e1b
...
@@ -686,8 +686,8 @@ services:
...
@@ -686,8 +686,8 @@ services:
tags
:
tags
:
-
name
:
sonata.admin
-
name
:
sonata.admin
manager_type
:
orm
manager_type
:
orm
group
:
"
Popup
d'information"
group
:
"
Popup
s
d'information"
label
:
"
Popup
d'information"
label
:
"
Popup
s
d'information"
public
:
true
public
:
true
sonata.media.provider.csv
:
sonata.media.provider.csv
:
...
...
src/Admin/InformationPopupAdmin.php
View file @
7f1c5e1b
...
@@ -16,8 +16,6 @@ use FOS\CKEditorBundle\Form\Type\CKEditorType;
...
@@ -16,8 +16,6 @@ use FOS\CKEditorBundle\Form\Type\CKEditorType;
* et s'ouvrent automatiquement au lancement de l'application,
* et s'ouvrent automatiquement au lancement de l'application,
* tant que l'utilisateur n'a pas cliqué sur le bouton de confirmation
* tant que l'utilisateur n'a pas cliqué sur le bouton de confirmation
*
*
* TODO: make sure only one popup is active at a given time (use post save hook)
*
* KOHINOS : Outil de gestion de Monnaie Locale Complémentaire
* KOHINOS : Outil de gestion de Monnaie Locale Complémentaire
*/
*/
class
InformationPopupAdmin
extends
AbstractAdmin
class
InformationPopupAdmin
extends
AbstractAdmin
...
@@ -53,6 +51,38 @@ class InformationPopupAdmin extends AbstractAdmin
...
@@ -53,6 +51,38 @@ class InformationPopupAdmin extends AbstractAdmin
]);
]);
}
}
public
function
postPersist
(
$informationPopup
)
{
$this
->
disableOtherPopups
(
$informationPopup
);
}
public
function
preUpdate
(
$informationPopup
)
{
$this
->
disableOtherPopups
(
$informationPopup
);
}
/**
* Only one popup should be enabled at a time.
* If enableling a popup in the admin, disable the rest.
*/
private
function
disableOtherPopups
(
$informationPopup
)
{
if
(
true
==
$informationPopup
->
getEnabled
())
{
$em
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$qb
=
$em
->
createQueryBuilder
();
$qb
->
update
(
'App\Entity\InformationPopup'
,
'e'
)
->
set
(
'e.enabled'
,
':newValue'
)
->
where
(
'e.id != :id'
)
->
setParameter
(
'newValue'
,
0
)
->
setParameter
(
'id'
,
$informationPopup
->
getId
());
$query
=
$qb
->
getQuery
();
$query
->
execute
();
}
}
protected
function
configureDatagridFilters
(
DatagridMapper
$datagrid
)
:
void
protected
function
configureDatagridFilters
(
DatagridMapper
$datagrid
)
:
void
{
{
$datagrid
$datagrid
...
...
src/Entity/InformationPopup.php
View file @
7f1c5e1b
...
@@ -61,6 +61,11 @@ class InformationPopup
...
@@ -61,6 +61,11 @@ class InformationPopup
$this
->
informationPopupUsers
=
new
ArrayCollection
();
$this
->
informationPopupUsers
=
new
ArrayCollection
();
}
}
public
function
__toString
()
:
string
{
return
$this
->
getTitle
();
}
public
function
getId
()
public
function
getId
()
{
{
return
$this
->
id
;
return
$this
->
id
;
...
...
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