Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Base lexicale BaLex
Manage
Activity
Members
Labels
Plan
Issues
18
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lex gaMe
Base lexicale BaLex
Commits
a5e1e9a3
Commit
a5e1e9a3
authored
2 years ago
by
Pierre Fleutot
Browse files
Options
Downloads
Patches
Plain Diff
Réordonnement des blocs d'une entrée: ajout d'un log
parent
b76dd2cf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Controller/EntryController.php
+13
-28
13 additions, 28 deletions
src/Controller/EntryController.php
src/Entity/Log.php
+1
-1
1 addition, 1 deletion
src/Entity/Log.php
templates/log/_formattedLog.html.twig
+6
-2
6 additions, 2 deletions
templates/log/_formattedLog.html.twig
with
20 additions
and
31 deletions
src/Controller/EntryController.php
+
13
−
28
View file @
a5e1e9a3
...
@@ -308,14 +308,14 @@ class EntryController extends AppBaseController
...
@@ -308,14 +308,14 @@ class EntryController extends AppBaseController
return
$this
->
redirectToRoute
(
'app_entry_show'
,
[
'id'
=>
$entry
->
getId
()]);
return
$this
->
redirectToRoute
(
'app_entry_show'
,
[
'id'
=>
$entry
->
getId
()]);
}
}
public
function
addBlockLog
(
Entry
$entry
,
$type
,
$blockCategory
)
public
function
addBlockLog
(
Entry
$entry
,
$type
,
$blockCategory
=
null
)
{
{
if
(
in_array
(
$blockCategory
,
[
//
if (in_array($blockCategory, [
Entry
::
ATTR_DEFINITION
,
//
Entry::ATTR_DEFINITION,
Entry
::
ATTR_EXAMPLE
,
//
Entry::ATTR_EXAMPLE,
Entry
::
ATTR_PRONUNCIATION
,
//
Entry::ATTR_PRONUNCIATION,
Entry
::
ATTR_PART_OF_SPEECH
,
//
Entry::ATTR_PART_OF_SPEECH,
]))
{
//
])) {
$log
=
new
Log
();
$log
=
new
Log
();
$log
->
setCreatedBy
(
$this
->
getUser
());
$log
->
setCreatedBy
(
$this
->
getUser
());
...
@@ -324,7 +324,7 @@ class EntryController extends AppBaseController
...
@@ -324,7 +324,7 @@ class EntryController extends AppBaseController
$log
->
setBlockCategory
(
$blockCategory
);
$log
->
setBlockCategory
(
$blockCategory
);
$entry
->
addLog
(
$log
);
$entry
->
addLog
(
$log
);
}
//
}
}
}
/**
/**
...
@@ -334,36 +334,21 @@ class EntryController extends AppBaseController
...
@@ -334,36 +334,21 @@ class EntryController extends AppBaseController
{
{
$movedId
=
$request
->
get
(
'movedId'
);
$movedId
=
$request
->
get
(
'movedId'
);
$position
=
$request
->
get
(
'position'
);
$position
=
$request
->
get
(
'position'
);
// dump($movedId, $position);die();
// dump($movedId, $position);die();
$oldAttributes
=
$entry
->
getAttributes
();
$attributes
=
$entry
->
getAttributes
();
$attributes
=
$entry
->
getAttributes
();
$result
=
$this
->
moveBlock
(
$attributes
,
$movedId
,
$position
);
$result
=
$this
->
moveBlock
(
$attributes
,
$movedId
,
$position
);
if
(
$oldAttributes
!=
$attributes
)
{
$this
->
addBlockLog
(
$entry
,
'order'
);
}
$entry
->
setAttributes
(
$attributes
);
$entry
->
setAttributes
(
$attributes
);
$this
->
em
->
flush
();
$this
->
em
->
flush
();
return
$this
->
render
(
'entry/show.html.twig'
,
[
'entry'
=>
$entry
]);
return
$this
->
render
(
'entry/show.html.twig'
,
[
'entry'
=>
$entry
]);
}
}
// public function getBlockByIdAndParent($attrArray, $id)
// {
// foreach ($attrArray as $item) {
// if (isset($item['id']) && $item['id'] == $id) {
// return [
// 'block' => $item,
// 'parent' => $attrArray,
// ];
// } elseif (is_array($item)) {
// $result = $this->getBlockByIdAndParent($item, $id);
// if ($result) {
// return $result;
// }
// }
// }
// return false;
// }
public
function
moveBlock
(
&
$attrArray
,
$id
,
$newKey
)
public
function
moveBlock
(
&
$attrArray
,
$id
,
$newKey
)
{
{
foreach
(
$attrArray
as
$key
=>
&
$item
)
{
foreach
(
$attrArray
as
$key
=>
&
$item
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Entity/Log.php
+
1
−
1
View file @
a5e1e9a3
...
@@ -168,7 +168,7 @@ class Log
...
@@ -168,7 +168,7 @@ class Log
return
$this
->
blockCategory
;
return
$this
->
blockCategory
;
}
}
public
function
setBlockCategory
(
string
$blockCategory
):
self
public
function
setBlockCategory
(
?
string
$blockCategory
):
self
{
{
$this
->
blockCategory
=
$blockCategory
;
$this
->
blockCategory
=
$blockCategory
;
...
...
This diff is collapsed.
Click to expand it.
templates/log/_formattedLog.html.twig
+
6
−
2
View file @
a5e1e9a3
...
@@ -5,8 +5,12 @@
...
@@ -5,8 +5,12 @@
{%
if
log.content
==
'add'
%}{{
'a ajouté'
|
trans
}}{%
endif
%}
{%
if
log.content
==
'add'
%}{{
'a ajouté'
|
trans
}}{%
endif
%}
{%
if
log.content
==
'edit'
%}{{
'a modifié'
|
trans
}}{%
endif
%}
{%
if
log.content
==
'edit'
%}{{
'a modifié'
|
trans
}}{%
endif
%}
{%
if
log.content
==
'delete'
%}{{
'a supprimé'
|
trans
}}{%
endif
%}
{%
if
log.content
==
'delete'
%}{{
'a supprimé'
|
trans
}}{%
endif
%}
{{
'un bloc de type'
|
trans
}}
{%
if
log.content
==
'order'
%}
{{
log.blockCategory
}}
{{
'a réordonné les blocs'
|
trans
}}
{%
else
%}
{{
'un bloc de type'
|
trans
}}
{{
log.blockCategory
}}
{%
endif
%}
{%
elseif
log.category
in
[
constant
(
'App\\Entity\\Log::CATEGORY_ADD_ENTRY'
),
constant
(
'App\\Entity\\Log::CATEGORY_DELETE_ENTRY'
)]
%}
{%
elseif
log.category
in
[
constant
(
'App\\Entity\\Log::CATEGORY_ADD_ENTRY'
),
constant
(
'App\\Entity\\Log::CATEGORY_DELETE_ENTRY'
)]
%}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment