Nov block za (od)objavo revizije iz diff pogleda

pull/60/head
Jurij Podgoršek 2024-04-21 20:25:38 +02:00
parent f87710cecf
commit 1f5aaede91
5 changed files with 294 additions and 163 deletions

View File

@ -1,28 +0,0 @@
uuid: 882a1fb8-dba5-4370-b1c4-fb8b5d46db4c
langcode: en
status: true
dependencies:
module:
- content_moderation_info_block
theme:
- olivero
id: olivero_moderationinfocontent
theme: olivero
region: content
weight: 0
provider: null
plugin: 'content_moderation_info_block:node'
settings:
id: 'content_moderation_info_block:node'
label: 'Moderation info (Content)'
label_display: visible
provider: content_moderation_info_block
context_mapping:
entity: '@node.node_route_context:node'
changed_date_display: true
author_display: true
latest_revision_display: true
current_state_display: true
change_state_display: true
revision_log_message_input_display: false
visibility: { }

View File

@ -0,0 +1,28 @@
uuid: 2f782113-6263-4112-8cb9-f4de096fabda
langcode: en
status: true
dependencies:
module:
- yufu_concept
theme:
- olivero
id: olivero_moderationinfocontent_2
theme: olivero
region: sidebar
weight: 0
provider: null
plugin: 'yufu_concept_moderate_from_diff:node'
settings:
id: 'yufu_concept_moderate_from_diff:node'
label: 'YUFU Moderation info from diff (Content)'
label_display: visible
provider: yufu_concept
context_mapping:
entity: '@node.node_route_context:node'
changed_date_display: 1
author_display: 1
latest_revision_display: 1
current_state_display: 1
change_state_display: 1
revision_log_message_input_display: 0
visibility: { }

View File

@ -24,6 +24,204 @@ display:
display_options:
title: 'Zadnje spremembe'
fields:
nid:
id: nid
table: node_field_revision
field: nid
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: nid
plugin_id: field
label: nID
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
vid_1:
id: vid_1
table: node_field_revision
field: vid
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: vid
plugin_id: field
label: rID
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
vid:
id: vid
table: node_field_revision
field: vid
relationship: nid
group_type: group
admin_label: ''
entity_type: node
entity_field: vid
plugin_id: field
label: 'Latest Revision ID'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
title:
id: title
table: node_field_revision
@ -39,8 +237,8 @@ display:
alter:
alter_text: false
text: ''
make_link: false
path: ''
make_link: true
path: '/node/{{nid}}/revisions/view/{{vid}}/{{vid_1}}/visual_inline'
absolute: false
external: false
replace_spaces: false
@ -78,7 +276,7 @@ display:
click_sort_column: value
type: string
settings:
link_to_entity: true
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
@ -294,138 +492,6 @@ display:
multi_type: separator
separator: ', '
field_api_classes: false
vid_1:
id: vid_1
table: node_field_revision
field: vid
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: vid
plugin_id: field
label: rID
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
nid:
id: nid
table: node_field_revision
field: nid
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: nid
plugin_id: field
label: nID
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
pager:
type: mini
options:

View File

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace Drupal\yufu_concept\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\content_moderation_info_block\Plugin\Block\ContentModerationInfoBlock;
use Drupal\content_moderation_info_block\Form\ContentModerationInfoBlockModerationForm;
use Drupal\content_moderation_info_block\Form\ContentModerationInfoBlockPublishForm;
/**
* Provides a yufu concept moderate from diff block.
*
* @Block(
* id = "yufu_concept_moderate_from_diff",
* admin_label = @Translation("YUFU concept moderate from diff"),
* category = @Translation("Content moderation"),
* deriver = "\Drupal\content_moderation_info_block\Plugin\Derivative\ContentModerationInfoBlockDeriver",
* )
*/
final class ModerateFromDiffBlock extends ContentModerationInfoBlock {
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$configuration = $this->getConfiguration();
$entity = $this->getContextValue('entity');
$routeMatcher = \Drupal::service('current_route_match');
if ($routeMatcher->getRouteName() !== 'diff.revisions_diff') {
return [];
}
$revisionId = $routeMatcher->getParameter('right_revision');
$revision = $this->entityTypeManager->getStorage('node')->loadRevision($revisionId);
if (!$revision) {
return [];
}
if ($configuration['change_state_display']) {
$class = NULL;
if ($this->moderationInfo->isModeratedEntity($revision)) {
$class = ContentModerationInfoBlockModerationForm::class;
}
elseif ($revision instanceof EntityPublishedInterface) {
$class = ContentModerationInfoBlockPublishForm::class;
}
if ($class) {
$build['change_state'] = $this
->formBuilder
->getForm($class, $revision, $configuration['revision_log_message_input_display']);
}
}
$build['#markup'] = 'Revision ID: ' . $revision->getRevisionId()
. 'Title: ' . $revision->getTitle();
return $build;
}
}

View File

@ -5,3 +5,4 @@ package: Yufu
core_version_requirement: ^9 || ^10
dependencies:
- drupal:rest
- content_moderation_info_block:content_moderation_info_block