Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
technobel.sf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
technobel.sf
Commits
60f49fd8
Commit
60f49fd8
authored
May 19, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implémente l'action ajax sur les boutons supprimer
parent
93da61ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
0 deletions
+50
-0
src/APIBundle/Controller/ImageAPIController.php
src/APIBundle/Controller/ImageAPIController.php
+17
-0
src/APIBundle/Resources/config/routing.yml
src/APIBundle/Resources/config/routing.yml
+7
-0
src/TechnoBundle/Repository/ImageRepository.php
src/TechnoBundle/Repository/ImageRepository.php
+16
-0
src/TechnoBundle/Resources/views/Ajax/Image/mainDisplay.html.twig
...noBundle/Resources/views/Ajax/Image/mainDisplay.html.twig
+10
-0
No files found.
src/APIBundle/Controller/ImageAPIController.php
View file @
60f49fd8
...
...
@@ -94,6 +94,23 @@ class ImageAPIController extends MasterAPIController
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public
function
deleteOneAction
(
$id
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$image
=
$em
->
getRepository
(
'TechnoBundle:Image'
)
->
findOneForAPIdelete
(
$id
);
if
(
$image
!==
null
)
{
$em
->
remove
(
$image
);
$em
->
flush
();
}
return
$this
->
api
([]);
}
/*
...
...
src/APIBundle/Resources/config/routing.yml
View file @
60f49fd8
...
...
@@ -70,6 +70,13 @@ api_image_update:
_controller
:
APIBundle:ImageAPI:update
methods
:
[
POST
]
api_image_delete_one
:
path
:
/image/{id}
defaults
:
_controller
:
APIBundle:ImageAPI:deleteOne
requirements
:
id
:
\d+
methods
:
[
DELETE
]
##
## Note:
##
...
...
src/TechnoBundle/Repository/ImageRepository.php
View file @
60f49fd8
...
...
@@ -115,7 +115,23 @@ class ImageRepository extends \Doctrine\ORM\EntityRepository
return
$qb
->
getQuery
()
->
getOneOrNullResult
();
}
/**
* @param $id
* @return Image
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public
function
findOneForAPIdelete
(
$id
)
{
$qb
=
$this
->
createQueryBuilder
(
'i'
)
->
join
(
'i.owner'
,
'o'
)
->
addSelect
(
'o'
)
->
where
(
'i.id = :id'
)
->
setParameter
(
':id'
,
$id
);
return
$qb
->
getQuery
()
->
getOneOrNullResult
();
}
/**
* @param $id
* @return Image
...
...
src/TechnoBundle/Resources/views/Ajax/Image/mainDisplay.html.twig
View file @
60f49fd8
...
...
@@ -137,7 +137,17 @@
deleteBtn
.
addEventListener
(
'
click
'
,
function
(
e
)
{
let
imageId
=
this
.
dataset
.
imageId
;
let
r
=
confirm
(
'
Are you sure ?
'
);
if
(
r
===
true
)
{
submitURL
=
Routing
.
generate
(
'
api_image_delete_one
'
,
{
'
id
'
:
imageId
});
AJAX
(
'
DELETE
'
,
submitURL
,
function
()
{
reloadGridImage
();
});
}
});
modify
.
appendChild
(
deleteBtn
);
...
...
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