Skip to content

Commit

Permalink
Merge branch 'develop' into release-versions/v3.4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
berliner committed Dec 7, 2023
2 parents 9fa076b + 79e7219 commit e64fc98
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- entity_browser.browser.articles
- field.field.paragraph.document_chapter.field_articles
- field.field.paragraph.document_chapter.field_hide_from_navigation
- field.field.paragraph.document_chapter.field_short_title
- field.field.paragraph.document_chapter.field_summary
- field.field.paragraph.document_chapter.field_tags
Expand Down Expand Up @@ -51,6 +52,7 @@ third_party_settings:
- field_summary
- field_tags
- status
- field_hide_from_navigation
label: 'Chapter properties'
region: content
parent_name: group_tabs
Expand Down Expand Up @@ -88,18 +90,25 @@ content:
weight: 2
region: content
settings:
open: true
entity_browser: articles
field_widget_display: label
field_widget_edit: '1'
field_widget_remove: '1'
open: '1'
selection_mode: selection_append
additional_fields:
options:
status: status
field_widget_replace: 0
field_widget_display_settings: { }
third_party_settings: { }
field_hide_from_navigation:
type: boolean_checkbox
weight: 8
region: content
settings:
display_label: true
third_party_settings: { }
field_short_title:
type: string_textfield
weight: 22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ status: true
dependencies:
config:
- field.field.paragraph.document_chapter.field_articles
- field.field.paragraph.document_chapter.field_hide_from_navigation
- field.field.paragraph.document_chapter.field_short_title
- field.field.paragraph.document_chapter.field_summary
- field.field.paragraph.document_chapter.field_tags
Expand All @@ -23,6 +24,16 @@ content:
third_party_settings: { }
weight: 2
region: content
field_hide_from_navigation:
type: boolean
label: above
settings:
format: default
format_custom_false: ''
format_custom_true: ''
third_party_settings: { }
weight: 3
region: content
field_summary:
type: basic_string
label: hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- core.entity_view_mode.paragraph.preview
- field.field.paragraph.document_chapter.field_articles
- field.field.paragraph.document_chapter.field_hide_from_navigation
- field.field.paragraph.document_chapter.field_short_title
- field.field.paragraph.document_chapter.field_summary
- field.field.paragraph.document_chapter.field_tags
Expand Down Expand Up @@ -42,6 +43,7 @@ content:
weight: 0
region: content
hidden:
field_hide_from_navigation: true
field_short_title: true
field_summary: true
field_tags: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uuid: eb6f7af0-4f35-4cd0-a789-82f1e6ad8513
langcode: en
status: true
dependencies:
config:
- field.storage.paragraph.field_hide_from_navigation
- paragraphs.paragraphs_type.document_chapter
id: paragraph.document_chapter.field_hide_from_navigation
field_name: field_hide_from_navigation
entity_type: paragraph
bundle: document_chapter
label: 'Hide in document navigation'
description: 'If checked, the chapter is marked as part of the document but should not be automatically included in the documents navigation. Useful for example for articles that are mostly shown as sub-articles in other article pages.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean
18 changes: 18 additions & 0 deletions config/field.storage.paragraph.field_hide_from_navigation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
uuid: 0472638f-b863-4754-a06c-89b9ba148312
langcode: en
status: true
dependencies:
module:
- paragraphs
id: paragraph.field_hide_from_navigation
field_name: field_hide_from_navigation
entity_type: paragraph
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
6 changes: 3 additions & 3 deletions html/modules/custom/gho_fields/gho_fields.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function gho_fields_deploy_post_rename_datawrapper_fields(&$sandbox) {
$paragraph->get('field_show_interactive_content')->setValue([
'value' => $paragraph->get('field_show_datawrapper')->value,
]);
$paragraph->isSyncing();
$paragraph->setSyncing(TRUE);
$paragraph->save();
}
}
Expand Down Expand Up @@ -53,7 +53,7 @@ function gho_fields_deploy_migrate_bottom_figure_rows() {
'value' => $figure->second,
]);
}
$paragraph->isSyncing();
$paragraph->setSyncing(TRUE);
$paragraph->save();

foreach ($paragraph->getTranslationLanguages() as $language) {
Expand All @@ -74,7 +74,7 @@ function gho_fields_deploy_migrate_bottom_figure_rows() {
'value' => $figure->second,
]);
}
$translated_paragraph->isSyncing();
$translated_paragraph->setSyncing(TRUE);
$translated_paragraph->save();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type DocumentChapter {
title: String
title_short: String
summary: String
hidden: Boolean
articles: [Article]
}

Expand Down
2 changes: 1 addition & 1 deletion html/modules/custom/ncms_graphql/ncms_graphql.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ncms_graphql_deploy_set_auto_visible_flag(&$sandbox) {
$node->get('field_automatically_visible')->setValue([
'value' => 1,
]);
$node->isSyncing();
$node->setSyncing(TRUE);
$node->save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ private function addFieldResolverDocumentChapter(ResolverRegistryInterface $regi
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_summary.value')),
);
$registry->addFieldResolver('DocumentChapter', 'hidden',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:node'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_hide_from_navigation.value')),
);
$registry->addFieldResolver('DocumentChapter', 'articles',
$builder->produce('entity_reference')
->map('entity', $builder->fromParent())
Expand Down
57 changes: 54 additions & 3 deletions html/modules/custom/ncms_ui/ncms_ui.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function ncms_ui_deploy_set_content_space_nodes(&$sandbox) {
$node->get('field_content_space')->setValue([
'target_id' => $term->id(),
]);
$node->isSyncing();
$node->setSyncing(TRUE);
$node->save();
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ function ncms_ui_deploy_set_content_space_nodes_orphaned(&$sandbox) {
$node->get('field_content_space')->setValue([
'target_id' => $term->id(),
]);
$node->isSyncing();
$node->setSyncing(TRUE);
$node->save();
}
}
Expand All @@ -225,7 +225,7 @@ function ncms_ui_deploy_set_content_space_media(&$sandbox) {
$entity->get('field_content_space')->setValue([
'target_id' => $term->id(),
]);
$entity->isSyncing();
$entity->setSyncing(TRUE);
$entity->save();
}
}
Expand All @@ -243,3 +243,54 @@ function ncms_ui_deploy_remove_obsolete_admin_menu_links() {
$menu_link->delete();
}
}

/**
* Correct the changed date for content.
*
* The changed date got corrupted by
* ncms_graphql_deploy_set_auto_visible_flag().
*/
function ncms_ui_deploy_correct_changed_date(&$sandbox) {
/** @var \Drupal\Node\NodeStorageInterface $node_storage */
$node_storage = \Drupal::entityTypeManager()->getStorage('node');

/** @var \Drupal\node\NodeInterface[] $nodes */
$nodes = $node_storage->loadByProperties([
'type' => ['article', 'document'],
]);

foreach ($nodes as $node) {
if (!$node instanceof ContentBase) {
continue;
}

// Get all revision ids.
$revision_ids = $node_storage->revisionIds($node);
if (count($revision_ids) < 2) {
continue;
}
$revision_ids = array_values(array_reverse($revision_ids));

/** @var \Drupal\ncms_ui\Entity\Content\ContentBase $revision */
$revision = $node_storage->loadRevision($revision_ids[0]);
if (!$revision) {
continue;
}

if ($revision->getChangedTime() != 1698930576) {
continue;
}

// Update the changed date of the current revision.
$revision->setChangedTime($revision->getRevisionCreationTime());
$revision->setNewRevision(FALSE);
$revision->setSyncing(TRUE);
$revision->save();

// Update the changed date of the node.
$node->setChangedTime($revision->getRevisionCreationTime());
$node->setNewRevision(FALSE);
$node->setSyncing(TRUE);
$node->save();
}
}
17 changes: 17 additions & 0 deletions html/modules/custom/ncms_ui/ncms_ui.module
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\media\MediaInterface;
Expand Down Expand Up @@ -305,6 +306,22 @@ function ncms_ui_preprocess_layout_paragraphs_builder_component_menu(&$variables
$variables['types']['layout'] = [];
}

/**
* Implements hook_preprocess_hook().
*/
function ncms_ui_preprocess_field__paragraph__field_title__document_chapter(&$variables) {
if ($variables['element']['#view_mode'] != 'preview') {
return;
}
/** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
$paragraph = $variables['element']['#object'];
// If the chapter is marked as hidden, add a note to the title.
if ($paragraph->hasField('field_hide_from_navigation') && $paragraph->get('field_hide_from_navigation')->value) {
$variables['items'][0]['content']['#template'] .= Markup::create('<span style="font-style: italic; font-weight: normal;"> ({{ note }})</span>');
$variables['items'][0]['content']['#context']['note'] = t('Hidden from navigation');
}
}

/**
* Implements hook_form_FORM_ID_alter().
*/
Expand Down
2 changes: 1 addition & 1 deletion html/modules/custom/ncms_ui/ncms_ui.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ncms_ui_post_update_set_content_space_nodes(&$sandbox) {
$node->get('field_content_space')->setValue([
'target_id' => $term->id(),
]);
$node->isSyncing();
$node->setSyncing(TRUE);
$node->save();
}
}
Expand Down

0 comments on commit e64fc98

Please sign in to comment.