Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_dashboard
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor 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
WCMS
uw_dashboard
Commits
794a34ec
Commit
794a34ec
authored
1 year ago
by
Lily Yan
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-6737 Add default moderation state filter
parent
1d9a4600
No related branches found
No related tags found
1 merge request
!33
ISTWCMS-6737 Add default moderation state filter
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Block/ContentListBlock.php
+34
-0
34 additions, 0 deletions
src/Plugin/Block/ContentListBlock.php
with
34 additions
and
0 deletions
src/Plugin/Block/ContentListBlock.php
+
34
−
0
View file @
794a34ec
...
@@ -103,6 +103,23 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
...
@@ -103,6 +103,23 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
$view
->
removeHandler
(
$view
->
current_display
,
'filter'
,
'type'
);
$view
->
removeHandler
(
$view
->
current_display
,
'filter'
,
'type'
);
}
}
// Process Default moderation state filter field.
if
(
isset
(
$this
->
configuration
[
'moderation_state'
]))
{
// Get moderation state.
$state
=
$this
->
configuration
[
'moderation_state'
];
// Get current handler with old value.
$moderation_state
=
$view
->
getHandler
(
$display_id
,
'filter'
,
'current_state_views_filter'
);
// Set moderation_state configuration value.
$moderation_state
[
'value'
]
=
[
$state
=>
$state
];
// Set handler with new value.
$view
->
setHandler
(
$display_id
,
'filter'
,
'current_state_views_filter'
,
$moderation_state
);
}
// Check if we have an author restriction, if so add to arguments and
// Check if we have an author restriction, if so add to arguments and
// remove from exposed filters.
// remove from exposed filters.
if
(
isset
(
$this
->
configuration
[
'display_my_content'
])
&&
$this
->
configuration
[
'display_my_content'
])
{
if
(
isset
(
$this
->
configuration
[
'display_my_content'
])
&&
$this
->
configuration
[
'display_my_content'
])
{
...
@@ -209,6 +226,20 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
...
@@ -209,6 +226,20 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
'#default_value'
=>
isset
(
$this
->
configuration
[
'content_type'
])
?
$this
->
configuration
[
'content_type'
]
:
'all'
,
'#default_value'
=>
isset
(
$this
->
configuration
[
'content_type'
])
?
$this
->
configuration
[
'content_type'
]
:
'all'
,
];
];
// Set the content type form element.
$form
[
'filters'
][
'moderation_state'
]
=
[
'#type'
=>
'select'
,
'#title'
=>
$this
->
t
(
'Default moderation state filter'
),
'#options'
=>
[
'All'
=>
$this
->
t
(
'- Any -'
),
'uw_workflow-uw_wf_archived'
=>
$this
->
t
(
'Archived'
),
'uw_workflow-draft'
=>
$this
->
t
(
'Draft'
),
'uw_workflow-uw_wf_needs_review'
=>
$this
->
t
(
'Needs Review'
),
'uw_workflow-published'
=>
$this
->
t
(
'Published'
),
],
'#default_value'
=>
isset
(
$this
->
configuration
[
'moderation_state'
])
?
$this
->
configuration
[
'moderation_state'
]
:
'All'
,
];
// Set the display only my content form element.
// Set the display only my content form element.
$form
[
'filters'
][
'display_my_content'
]
=
[
$form
[
'filters'
][
'display_my_content'
]
=
[
'#type'
=>
'select'
,
'#type'
=>
'select'
,
...
@@ -260,6 +291,9 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
...
@@ -260,6 +291,9 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
// Set the config for content type.
// Set the config for content type.
$this
->
configuration
[
'content_type'
]
=
$values
[
'filters'
][
'content_type'
];
$this
->
configuration
[
'content_type'
]
=
$values
[
'filters'
][
'content_type'
];
// Set the config for moderation state.
$this
->
configuration
[
'moderation_state'
]
=
$values
[
'filters'
][
'moderation_state'
];
// Set the config for displaying only my content.
// Set the config for displaying only my content.
$this
->
configuration
[
'display_my_content'
]
=
$values
[
'filters'
][
'display_my_content'
];
$this
->
configuration
[
'display_my_content'
]
=
$values
[
'filters'
][
'display_my_content'
];
...
...
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