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
15bcea00
Commit
15bcea00
authored
7 months ago
by
Pierre Dureau
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3475962
by pdureau: Cleaner meta:enum conversion
parent
56348467
No related branches found
No related tags found
1 merge request
!222
Issue #3475962 by pdureau: Cleaner meta:enum conversion
Pipeline
#301047
passed with warnings
6 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ui_patterns_legacy/src/PropConverter.php
+37
-17
37 additions, 17 deletions
modules/ui_patterns_legacy/src/PropConverter.php
with
37 additions
and
17 deletions
modules/ui_patterns_legacy/src/PropConverter.php
+
37
−
17
View file @
15bcea00
...
@@ -20,13 +20,7 @@ class PropConverter {
...
@@ -20,13 +20,7 @@ class PropConverter {
'boolean'
=>
[
'boolean'
=>
[
'$ref'
=>
'ui-patterns://boolean'
,
'$ref'
=>
'ui-patterns://boolean'
,
],
],
'checkboxes'
=>
[
'checkboxes'
=>
$this
->
convertCheckboxes
(
$setting
),
'$ref'
=>
'ui-patterns://enum_list'
,
'items'
=>
[
'enum'
=>
\array_keys
(
$setting
[
'options'
]),
'meta:enum'
=>
$setting
[
'options'
],
],
],
'links'
=>
[
'links'
=>
[
'$ref'
=>
'ui-patterns://links'
,
'$ref'
=>
'ui-patterns://links'
,
],
],
...
@@ -34,16 +28,8 @@ class PropConverter {
...
@@ -34,16 +28,8 @@ class PropConverter {
'$ref'
=>
'ui-patterns://machine_name'
,
'$ref'
=>
'ui-patterns://machine_name'
,
],
],
'number'
=>
$this
->
convertNumber
(
$setting
),
'number'
=>
$this
->
convertNumber
(
$setting
),
'radios'
=>
[
'radios'
=>
$this
->
convertEnum
(
$setting
),
'$ref'
=>
'ui-patterns://enum'
,
'select'
=>
$this
->
convertEnum
(
$setting
),
'enum'
=>
\array_keys
(
$setting
[
'options'
]),
'meta:enum'
=>
$setting
[
'options'
],
],
'select'
=>
[
'$ref'
=>
'ui-patterns://enum'
,
'enum'
=>
\array_keys
(
$setting
[
'options'
]),
'meta:enum'
=>
$setting
[
'options'
],
],
'textfield'
=>
[
'textfield'
=>
[
'$ref'
=>
'ui-patterns://string'
,
'$ref'
=>
'ui-patterns://string'
,
],
],
...
@@ -57,6 +43,40 @@ class PropConverter {
...
@@ -57,6 +43,40 @@ class PropConverter {
};
};
}
}
/**
* Convert checkboxes.
*/
private
function
convertCheckboxes
(
array
$setting
):
array
{
$values
=
\array_keys
(
$setting
[
'options'
]);
$labels
=
\array_values
(
$setting
[
'options'
]);
$prop
=
[
'$ref'
=>
'ui-patterns://enum_list'
,
'items'
=>
[
'enum'
=>
$values
,
],
];
if
(
!
empty
(
array_diff
(
$values
,
$labels
)))
{
$prop
[
'items'
][
'meta:enum'
]
=
$setting
[
'options'
];
}
return
$prop
;
}
/**
* Convert select and radios.
*/
private
function
convertEnum
(
array
$setting
):
array
{
$values
=
\array_keys
(
$setting
[
'options'
]);
$labels
=
\array_values
(
$setting
[
'options'
]);
$prop
=
[
'$ref'
=>
'ui-patterns://enum'
,
'enum'
=>
$values
,
];
if
(
!
empty
(
array_diff
(
$values
,
$labels
)))
{
$prop
[
'meta:enum'
]
=
$setting
[
'options'
];
}
return
$prop
;
}
/**
/**
* Convert number.
* Convert number.
*/
*/
...
...
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