Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
content_model_documentation
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
content_model_documentation
Commits
f04f0f8b
Commit
f04f0f8b
authored
1 year ago
by
Steve Wirt
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3406751
by swirt: Include an edit link in the table that lists sibling fields
parent
eeec48a6
No related branches found
Branches containing commit
Tags
1.0.24
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/CMDocumentConnectorTrait.php
+24
-9
24 additions, 9 deletions
src/CMDocumentConnectorTrait.php
src/CmDocumentViewBuilder.php
+14
-15
14 additions, 15 deletions
src/CmDocumentViewBuilder.php
with
38 additions
and
24 deletions
src/CMDocumentConnectorTrait.php
+
24
−
9
View file @
f04f0f8b
...
@@ -334,36 +334,43 @@ trait CMDocumentConnectorTrait {
...
@@ -334,36 +334,43 @@ trait CMDocumentConnectorTrait {
}
}
/**
/**
* Get
the
link to
the field
edit page using
the
entity.field_config.node_field_edit_form route.
* Get link to edit page using entity.field_config.node_field_edit_form route.
*
*
* @todo
u
pdate
this
to account for other entity types supported by CM Document.
* @todo
U
pdate to account for other entity types supported by CM Document.
*
*
* @param string $type
* @param string $type
* The entity type that the field is on.
* @param string $bundle
* @param string $bundle
* The bundle that the field is on.
* @param string $machine
* @param string $machine
* The machine name of the field.
*
*
* @return \Drupal\Core\Link
* @return \Drupal\Core\Link|string
* The link to the field instance edit page, or empty string if type not
* supported, or user has no access.
*/
*/
public
function
getFieldEditLink
(
string
$type
,
string
$bundle
,
string
$machine
)
:
Link
{
public
function
getFieldEditLink
(
string
$type
,
string
$bundle
,
string
$machine
)
{
// Set the $type_parameter_key based on the type.
// Set the $type_parameter_key based on the type.
switch
(
$type
)
{
switch
(
$type
)
{
case
'node'
:
case
'node'
:
$type_parameter_key
=
'node_type'
;
$type_parameter_key
=
'node_type'
;
break
;
break
;
case
'paragraph'
:
case
'paragraph'
:
$type_parameter_key
=
'paragraphs_type'
;
$type_parameter_key
=
'paragraphs_type'
;
break
;
break
;
}
}
// Get the current path.
// Get the current path.
$current_path
=
\Drupal
::
service
(
'path.current'
)
->
getPath
();
$current_path
=
\Drupal
::
service
(
'path.current'
)
->
getPath
();
if
(
!
empty
(
$type_parameter_key
))
{
return
Link
::
createFromRoute
(
$link
=
Link
::
createFromRoute
(
$this
->
t
(
'Edit'
),
$this
->
t
(
'Edit'
),
"entity.field_config.
{
$type
}
_field_edit_form"
,
"entity.field_config.
{
$type
}
_field_edit_form"
,
[
[
"
{
$type_parameter_key
}
"
=>
$bundle
,
$type_parameter_key
=>
$bundle
,
'field_config'
=>
"
{
$type
}
.
{
$bundle
}
.
{
$machine
}
"
,
'field_config'
=>
"
{
$type
}
.
{
$bundle
}
.
{
$machine
}
"
,
],
],
[
[
...
@@ -371,8 +378,16 @@ trait CMDocumentConnectorTrait {
...
@@ -371,8 +378,16 @@ trait CMDocumentConnectorTrait {
'destination'
=>
$current_path
,
'destination'
=>
$current_path
,
],
],
]
]
);
);
if
(
!
$link
->
getUrl
()
->
access
())
{
// User has no access to edit field, so output no link.
$link
=
''
;
}
}
else
{
$link
=
''
;
}
return
$link
;
}
}
}
}
This diff is collapsed.
Click to expand it.
src/CmDocumentViewBuilder.php
+
14
−
15
View file @
f04f0f8b
...
@@ -158,12 +158,12 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
...
@@ -158,12 +158,12 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
$add_on
[
'table'
]
=
[
$add_on
[
'table'
]
=
[
'#type'
=>
'table'
,
'#type'
=>
'table'
,
'#header'
=>
[
'#header'
=>
[
$this
->
t
(
"
Field Name
"
),
$this
->
t
(
'
Field Name
'
),
$this
->
t
(
"
Entity Type
"
),
$this
->
t
(
'
Entity Type
'
),
$this
->
t
(
"
Bundle
"
),
$this
->
t
(
'
Bundle
'
),
$this
->
t
(
"
Field Type
"
),
$this
->
t
(
'
Field Type
'
),
$this
->
t
(
"
Documentation
"
),
$this
->
t
(
'
Documentation
'
),
$this
->
t
(
"
Edit
"
),
$this
->
t
(
'
Edit
'
),
],
],
'#rows'
=>
$rows
,
'#rows'
=>
$rows
,
'#footer'
=>
[[
"Total instances:
$count
"
,
''
,
''
,
''
,
''
,
''
]],
'#footer'
=>
[[
"Total instances:
$count
"
,
''
,
''
,
''
,
''
,
''
]],
...
@@ -207,6 +207,7 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
...
@@ -207,6 +207,7 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
'Bundle'
=>
$bundle
,
'Bundle'
=>
$bundle
,
'Field Type'
=>
$fields
[
$field
][
'type'
],
'Field Type'
=>
$fields
[
$field
][
'type'
],
'Document'
=>
$this
->
getCmDocumentLink
(
$entity_type
,
$bundle
,
$field
),
'Document'
=>
$this
->
getCmDocumentLink
(
$entity_type
,
$bundle
,
$field
),
'Edit'
=>
$edit_link
=
$this
->
getFieldEditLink
(
$entity_type
,
$bundle
,
$field
),
];
];
}
}
}
}
...
@@ -216,7 +217,6 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
...
@@ -216,7 +217,6 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
return
$sibling_rows
;
return
$sibling_rows
;
}
}
/**
/**
* Gets a a table of field data for fields on a fieldable entity.
* Gets a a table of field data for fields on a fieldable entity.
*
*
...
@@ -236,12 +236,12 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
...
@@ -236,12 +236,12 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
$add_on
[
'table'
]
=
[
$add_on
[
'table'
]
=
[
'#type'
=>
'table'
,
'#type'
=>
'table'
,
'#header'
=>
[
'#header'
=>
[
$this
->
t
(
"
Field Name
"
),
$this
->
t
(
'
Field Name
'
),
$this
->
t
(
"
Field Machine Name
"
),
$this
->
t
(
'
Field Machine Name
'
),
$this
->
t
(
"
Field Type
"
),
$this
->
t
(
'
Field Type
'
),
$this
->
t
(
"
Description
"
),
$this
->
t
(
'
Description
'
),
$this
->
t
(
"
Documentation
"
),
$this
->
t
(
'
Documentation
'
),
$this
->
t
(
"
Edit
"
),
$this
->
t
(
'
Edit
'
),
],
],
'#rows'
=>
$rows
,
'#rows'
=>
$rows
,
'#footer'
=>
[[
"Total fields:
$count
"
,
''
,
''
,
''
,
''
,
''
]],
'#footer'
=>
[[
"Total fields:
$count
"
,
''
,
''
,
''
,
''
,
''
]],
...
@@ -278,14 +278,13 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
...
@@ -278,14 +278,13 @@ class CmDocumentViewBuilder extends EntityViewBuilder {
// It is not a field element, so bail out.
// It is not a field element, so bail out.
continue
;
continue
;
}
}
$edit_link
=
$this
->
getFieldEditLink
(
$type
,
$bundle
,
$machine
);
$field_rows
[]
=
[
$field_rows
[]
=
[
'field _name'
=>
$value
->
getLabel
(),
'field _name'
=>
$value
->
getLabel
(),
'machine name'
=>
$machine
,
'machine name'
=>
$machine
,
'field_type'
=>
$value
->
getType
(),
'field_type'
=>
$value
->
getType
(),
'description'
=>
$value
->
getDescription
(),
'description'
=>
$value
->
getDescription
(),
'documentation'
=>
$this
->
getCmDocumentLink
(
$type
,
$bundle
,
$machine
),
'documentation'
=>
$this
->
getCmDocumentLink
(
$type
,
$bundle
,
$machine
),
'edit'
=>
$
edit_link
->
getUrl
()
->
access
()
?
$edit_link
:
''
,
'edit'
=>
$
this
->
getFieldEditLink
(
$type
,
$bundle
,
$machine
)
,
];
];
}
}
...
...
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