Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
madis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Soluris
madis
Commits
b9b4976b
Commit
b9b4976b
authored
4 months ago
by
Jonathan Foucher
Browse files
Options
Downloads
Patches
Plain Diff
linked items selector labels. Fixes
#953
parent
3cf8e7df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Pipeline
#84768
passed
4 months ago
Stage: cache
Stage: tests
Stage: quality-assurance
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Application/Form/Type/LinkableType.php
+53
-6
53 additions, 6 deletions
src/Application/Form/Type/LinkableType.php
with
53 additions
and
6 deletions
src/Application/Form/Type/LinkableType.php
+
53
−
6
View file @
b9b4976b
...
...
@@ -4,6 +4,8 @@ namespace App\Application\Form\Type;
use
App\Application\Interfaces\CollectivityRelated
;
use
App\Domain\Registry\Dictionary\MesurementStatusDictionary
;
use
App\Domain\Registry\Dictionary\ProofTypeDictionary
;
use
App\Domain\Registry\Dictionary\ViolationNatureDictionary
;
use
App\Domain\Registry\Model\Mesurement
;
use
App\Domain\Registry\Model\Proof
;
use
App\Domain\Registry\Model\Request
;
...
...
@@ -65,8 +67,14 @@ class LinkableType extends AbstractType
'aria-label'
=>
$ariaLabel
,
],
'choice_label'
=>
function
(
$object
)
{
if
(
$object
instanceof
Violation
||
$object
instanceof
Request
||
$object
instanceof
Proof
)
{
return
$this
->
formatArchivedObjectLabel
(
$object
);
if
(
$object
instanceof
Request
)
{
return
$this
->
formatRequestLabel
(
$object
);
}
if
(
$object
instanceof
Violation
)
{
return
$this
->
formatViolationLabel
(
$object
);
}
if
(
$object
instanceof
Proof
)
{
return
$this
->
formatProofLabel
(
$object
);
}
if
(
$object
instanceof
Treatment
)
{
return
$this
->
formatInactiveObjectLabel
(
$object
);
...
...
@@ -80,6 +88,19 @@ class LinkableType extends AbstractType
];
}
protected
function
formatRequestLabel
(
Request
$object
)
{
if
(
!
\method_exists
(
$object
,
'__toString'
))
{
throw
new
\RuntimeException
(
'The object '
.
\get_class
(
$object
)
.
' must implement __toString() method'
);
}
if
(
\method_exists
(
$object
,
'getDeletedAt'
)
&&
null
!==
$object
->
getDeletedAt
())
{
return
'(Archivé) '
.
$object
->
getDate
()
->
format
(
'd/m/Y'
)
.
' - '
.
$object
->
__toString
();
}
return
$object
->
getDate
()
->
format
(
'd/m/Y'
)
.
' - '
.
$object
->
__toString
();
}
/**
* Prefix every inactive object with "Inactif".
*/
...
...
@@ -113,18 +134,44 @@ class LinkableType extends AbstractType
}
/**
* Prefix every
archived object with "Archivé"
.
* Prefix every
proof
.
*/
protected
function
format
ArchivedObjectLabel
(
$object
):
string
protected
function
format
ProofLabel
(
Proof
$object
):
string
{
if
(
!
\method_exists
(
$object
,
'__toString'
))
{
throw
new
\RuntimeException
(
'The object '
.
\get_class
(
$object
)
.
' must implement __toString() method'
);
}
if
(
\method_exists
(
$object
,
'getDeletedAt'
)
&&
null
!==
$object
->
getDeletedAt
())
{
return
'(Archivé) '
.
$object
->
__toString
();
return
'(Archivé) '
.
$object
->
__toString
()
.
' ('
.
ProofTypeDictionary
::
getTypes
()[
$object
->
getType
()]
.
')'
;
}
return
$object
->
__toString
();
return
$object
->
__toString
()
.
' ('
.
ProofTypeDictionary
::
getTypes
()[
$object
->
getType
()]
.
')'
;
}
/**
* Prefix violations.
*/
protected
function
formatViolationLabel
(
Violation
$object
):
string
{
if
(
!
\method_exists
(
$object
,
'__toString'
))
{
throw
new
\RuntimeException
(
'The object '
.
\get_class
(
$object
)
.
' must implement __toString() method'
);
}
$natures
=
[];
if
(
$object
->
getViolationNatures
())
{
$raw
=
$object
->
getViolationNatures
();
if
(
is_string
(
$raw
))
{
$raw
=
explode
(
','
,
$raw
);
}
$natures
=
array_map
(
function
(
$n
)
{
return
ViolationNatureDictionary
::
getNatures
()[
trim
(
$n
)];
},
(
array
)
$raw
);
}
if
(
\method_exists
(
$object
,
'getDeletedAt'
)
&&
null
!==
$object
->
getDeletedAt
())
{
return
'(Archivé) '
.
$object
->
getDate
()
->
format
(
'd/m/Y'
)
.
' - '
.
join
(
', '
,
$natures
);
}
return
$object
->
getDate
()
->
format
(
'd/m/Y'
)
.
' - '
.
join
(
', '
,
$natures
);
}
}
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