Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_patterns
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ui_patterns
Commits
a39cf3e4
Commit
a39cf3e4
authored
8 months ago
by
Mikael Meulle
Browse files
Options
Downloads
Patches
Plain Diff
fix label in details element
parent
0e3d171c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Element/ComponentFormBase.php
+28
-21
28 additions, 21 deletions
src/Element/ComponentFormBase.php
src/Element/ComponentSlotForm.php
+2
-0
2 additions, 0 deletions
src/Element/ComponentSlotForm.php
with
30 additions
and
21 deletions
src/Element/ComponentFormBase.php
+
28
−
21
View file @
a39cf3e4
...
@@ -22,6 +22,32 @@ abstract class ComponentFormBase extends FormElementBase implements TrustedCallb
...
@@ -22,6 +22,32 @@ abstract class ComponentFormBase extends FormElementBase implements TrustedCallb
return
[
'preRenderPropOrSlot'
,
'processPropOrSlot'
];
return
[
'preRenderPropOrSlot'
,
'processPropOrSlot'
];
}
}
/**
* Check if the form element needs a details.
*
* @param array $element
* The form element.
*
* @return string|null
* Prop or slot id if the form element needs a details.
*/
protected
static
function
checkDetailsElement
(
array
&
$element
)
:
?string
{
if
(
!
isset
(
$element
[
"#wrap"
])
||
!
$element
[
"#wrap"
])
{
return
NULL
;
}
$prop_or_slot_id
=
$element
[
"#prop_id"
]
??
$element
[
"#slot_id"
];
$title_in_component
=
$element
[
"#title_in_component"
]
??
$prop_or_slot_id
;
$title
=
!
empty
(
$element
[
'#title'
])
?
$element
[
'#title'
]
:
$title_in_component
;
if
(
!
array_key_exists
(
$prop_or_slot_id
,
$element
))
{
$element
[
$prop_or_slot_id
]
=
[
"#type"
=>
"details"
,
"#title"
=>
$title
,
"#open"
=>
FALSE
,
];
}
return
$prop_or_slot_id
;
}
/**
/**
* Customize slot or prop form elements (pre-render).
* Customize slot or prop form elements (pre-render).
*
*
...
@@ -32,17 +58,8 @@ abstract class ComponentFormBase extends FormElementBase implements TrustedCallb
...
@@ -32,17 +58,8 @@ abstract class ComponentFormBase extends FormElementBase implements TrustedCallb
* Processed element
* Processed element
*/
*/
public
static
function
preRenderPropOrSlot
(
array
$element
)
:
array
{
public
static
function
preRenderPropOrSlot
(
array
$element
)
:
array
{
if
(
isset
(
$element
[
"#wrap"
])
&&
$element
[
"#wrap"
])
{
if
(
$prop_or_slot_id
=
static
::
checkDetailsElement
(
$element
))
{
$prop_or_slot_id
=
$element
[
"#prop_id"
]
??
$element
[
"#slot_id"
];
$title
=
!
empty
(
$element
[
'#title'
])
?
$element
[
'#title'
]
:
$prop_or_slot_id
;
$children_keys
=
Element
::
children
(
$element
);
$children_keys
=
Element
::
children
(
$element
);
if
(
!
array_key_exists
(
$prop_or_slot_id
,
$element
))
{
$element
[
$prop_or_slot_id
]
=
[
"#type"
=>
"details"
,
"#title"
=>
$title
,
"#open"
=>
FALSE
,
];
}
foreach
(
$children_keys
as
$child_key
)
{
foreach
(
$children_keys
as
$child_key
)
{
if
(
$child_key
===
$prop_or_slot_id
)
{
if
(
$child_key
===
$prop_or_slot_id
)
{
continue
;
continue
;
...
@@ -67,17 +84,7 @@ abstract class ComponentFormBase extends FormElementBase implements TrustedCallb
...
@@ -67,17 +84,7 @@ abstract class ComponentFormBase extends FormElementBase implements TrustedCallb
*/
*/
public
static
function
processPropOrSlot
(
array
&
$element
,
FormStateInterface
$form_state
)
{
public
static
function
processPropOrSlot
(
array
&
$element
,
FormStateInterface
$form_state
)
{
$triggering_element
=
$form_state
->
getTriggeringElement
();
$triggering_element
=
$form_state
->
getTriggeringElement
();
if
(
isset
(
$element
[
"#wrap"
])
&&
$element
[
"#wrap"
])
{
if
(
$prop_or_slot_id
=
static
::
checkDetailsElement
(
$element
))
{
$prop_or_slot_id
=
$element
[
"#prop_id"
]
??
$element
[
"#slot_id"
];
$title
=
!
empty
(
$element
[
'#title'
])
?
$element
[
'#title'
]
:
$prop_or_slot_id
;
if
(
!
array_key_exists
(
$prop_or_slot_id
,
$element
))
{
$element
[
$prop_or_slot_id
]
=
[
"#type"
=>
"details"
,
"#title"
=>
$title
,
"#open"
=>
FALSE
,
];
}
if
(
is_array
(
$triggering_element
)
&&
isset
(
$triggering_element
[
"#array_parents"
])
&&
is_array
(
$triggering_element
[
"#array_parents"
]))
{
if
(
is_array
(
$triggering_element
)
&&
isset
(
$triggering_element
[
"#array_parents"
])
&&
is_array
(
$triggering_element
[
"#array_parents"
]))
{
$element_array_parents
=
$element
[
"#array_parents"
];
$element_array_parents
=
$element
[
"#array_parents"
];
$trigger_array_parents
=
$triggering_element
[
"#array_parents"
];
$trigger_array_parents
=
$triggering_element
[
"#array_parents"
];
...
...
This diff is collapsed.
Click to expand it.
src/Element/ComponentSlotForm.php
+
2
−
0
View file @
a39cf3e4
...
@@ -78,6 +78,7 @@ class ComponentSlotForm extends ComponentFormBase {
...
@@ -78,6 +78,7 @@ class ComponentSlotForm extends ComponentFormBase {
[
$class
,
'preRenderPropOrSlot'
],
[
$class
,
'preRenderPropOrSlot'
],
],
],
"#wrap"
=>
TRUE
,
"#wrap"
=>
TRUE
,
"#title_in_component"
=>
NULL
,
];
];
}
}
...
@@ -109,6 +110,7 @@ class ComponentSlotForm extends ComponentFormBase {
...
@@ -109,6 +110,7 @@ class ComponentSlotForm extends ComponentFormBase {
$wrapper_id
=
static
::
getElementId
(
$element
,
'ui-patterns-slot-'
.
$slot_id
);
$wrapper_id
=
static
::
getElementId
(
$element
,
'ui-patterns-slot-'
.
$slot_id
);
$element
[
'#tree'
]
=
TRUE
;
$element
[
'#tree'
]
=
TRUE
;
$element
[
'#table_title'
]
=
$element
[
'#title'
];
$element
[
'#table_title'
]
=
$element
[
'#title'
];
$element
[
'#title_in_component'
]
=
$element
[
'#title'
];
$element
[
'#title'
]
=
''
;
$element
[
'#title'
]
=
''
;
$element
[
'sources'
]
=
static
::
buildSourcesForm
(
$element
,
$form_state
,
$definition
,
$wrapper_id
);
$element
[
'sources'
]
=
static
::
buildSourcesForm
(
$element
,
$form_state
,
$definition
,
$wrapper_id
);
if
(
$element
[
'#cardinality_multiple'
]
===
TRUE
||
if
(
$element
[
'#cardinality_multiple'
]
===
TRUE
||
...
...
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