Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mathieu
potage
Commits
d4a753e6
Commit
d4a753e6
authored
Jun 30, 2018
by
Mat
Browse files
le formulaire updateSorted est opérationnel
parent
cda2a756
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/APIBundle/Controller/LettreAPIController.php
View file @
d4a753e6
...
...
@@ -3,6 +3,7 @@
namespace
APIBundle\Controller
;
use
APIBundle\Form\LettreAPIType
;
use
APIBundle\Form\LettreSortedAPIType
;
use
APIBundle\Form\LettreStatusAPIType
;
use
PotageBundle\Entity\Lettre
;
use
Symfony\Component\HttpFoundation\Request
;
...
...
@@ -145,6 +146,36 @@ class LettreAPIController extends MasterAPIController
}
/**
* Form update (post) pour modifier la colonne 'sorted'
*
* @param Request $request
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public
function
updateSortedAction
(
Request
$request
,
$id
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$lettre
=
$em
->
getRepository
(
'PotageBundle:Lettre'
)
->
findOneForSorted
(
$id
);
if
(
$lettre
===
null
)
{
return
$this
->
api
(
'Not found'
,
Response
::
HTTP_NOT_FOUND
);
}
$form
=
$this
->
createForm
(
LettreSortedAPIType
::
class
,
$lettre
);
$form
->
handleRequest
(
$request
);
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
$em
->
flush
();
return
$this
->
api
([]);
}
return
$this
->
api
(
$form
,
Response
::
HTTP_BAD_REQUEST
);
}
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
...
...
src/APIBundle/Resources/config/routing.yml
View file @
d4a753e6
...
...
@@ -204,6 +204,14 @@ api_lettre_update_status:
_controller
:
APIBundle:LettreAPI:updateStatus
methods
:
[
POST
]
api_lettre_update_sorted
:
path
:
/lettre/{id}/sort
requirements
:
id
:
\d+
defaults
:
_controller
:
APIBundle:LettreAPI:updateSorted
methods
:
[
POST
]
api_lettre_delete
:
path
:
/lettre/{id}
requirements
:
...
...
src/PotageBundle/Repository/LettreRepository.php
View file @
d4a753e6
...
...
@@ -108,4 +108,23 @@ class LettreRepository extends \Doctrine\ORM\EntityRepository
->
setParameter
(
':id'
,
$id
);
return
$qb
->
getQuery
()
->
getOneOrNullResult
();
}
/**
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public
function
findOneForSorted
(
$id
)
{
$qb
=
$this
->
createQueryBuilder
(
'l'
)
->
where
(
'l.id = :id'
)
->
andWhere
(
'l.status = :draft '
)
->
setParameters
(
array
(
':id'
=>
$id
,
':draft'
=>
'draft'
));
return
$qb
->
getQuery
()
->
getOneOrNullResult
();
}
}
src/PotageBundle/Resources/views/LettreInfos/ajaxDisplay.js
View file @
d4a753e6
...
...
@@ -62,9 +62,10 @@ sortForm.addEventListener('submit', function(e)
let
items
=
document
.
querySelectorAll
(
'
.ui-state-default
'
);
for
(
let
i
=
0
;
i
<
items
.
length
;
i
++
)
{
list
[
i
]
=
items
[
i
].
dataset
.
lettreI
nfo
s
Id
;
list
[
i
]
=
items
[
i
].
dataset
.
i
nfoId
;
}
console
.
log
(
list
);
input
.
value
=
list
;
let
form
=
this
;
...
...
@@ -91,6 +92,9 @@ $( function() {
}
);
/*
*
* Modifier le bloc Lettre (aside droite)
...
...
src/PotageBundle/Resources/views/OffreLegumes/ajaxDisplay.js
View file @
d4a753e6
...
...
@@ -135,8 +135,6 @@ $( function() {
/*
*
* Modifier le bloc Offre (aside droite)
...
...
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