Commit ad36f57a authored by Navneet Singh's avatar Navneet Singh Committed by Navneet Singh
Browse files

Merge pull request #3216 from goalgorilla/issue/3321091-Images_disappear_in_an_album

Issue #3321091  by kashandarash: Update Post form to keep album relation on edit
parent 20c4f4dc
Loading
Loading
Loading
Loading
+26 −64
Changes for modules/social_features/social_album/config/install/views.view.albums.yml: 26 added lines, 64 removed lines.
Original line number Diff line number Diff line
@@ -790,99 +790,61 @@ display:
      tags:
        - 'config:field.storage.post.field_post_image'
  entity_reference:
    display_plugin: entity_reference
    id: entity_reference
    display_title: 'Entity Reference'
    display_plugin: entity_reference
    position: 1
    display_options:
      display_extenders: {  }
      display_description: ''
      sorts:
        title:
          id: title
          table: node_field_data
          field: title
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: node
          entity_field: title
          plugin_id: standard
          order: ASC
          expose:
            label: ''
            field_identifier: title
          exposed: false
      filters:
        type:
          id: type
          table: node_field_data
          field: type
          value:
            album: album
          entity_type: node
          entity_field: type
          plugin_id: bundle
          value:
            album: album
          expose:
            operator_limit_selection: false
            operator_list: {  }
      defaults:
        filters: false
        filter_groups: false
        arguments: false
        sorts: false
      filter_groups:
        operator: AND
        groups:
          1: AND
      arguments:
        uid:
          id: uid
          table: node_field_data
          field: uid
          relationship: none
          group_type: group
          admin_label: ''
          default_action: default
          exception:
            value: all
            title_enable: false
            title: All
          title_enable: false
          title: ''
          default_argument_type: current_user
          default_argument_options: {  }
          default_argument_skip_url: false
          summary_options:
            base_path: ''
            count: true
            items_per_page: 25
            override: false
          summary:
            sort_order: asc
            number_of_records: 0
            format: default_summary
          specify_validation: false
          validate:
            type: none
            fail: 'not found'
          validate_options: {  }
          break_phrase: false
          not: false
          entity_type: node
          entity_field: uid
          plugin_id: numeric
      sorts:
        title:
          id: title
          table: node_field_data
          field: title
          relationship: none
          group_type: group
          admin_label: ''
          order: ASC
          exposed: false
          expose:
            label: ''
          entity_type: node
          entity_field: title
          plugin_id: standard
      style:
        type: entity_reference
        options:
          search_fields:
            title: title
      defaults:
        sorts: false
        arguments: false
        filters: false
        filter_groups: false
      display_description: ''
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - user
        - 'user.node_grants:view'
      tags: {  }
  page_albums_overview:
+16 −0
Changes for modules/social_features/social_album/config/update/social_album_update_11470.yml: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
views.view.albums:
  expected_config: {  }
  update_actions:
    delete:
      display:
        entity_reference:
          display_options:
            arguments: { }
    change:
      display:
        entity_reference:
          cache_metadata:
            contexts:
              - 'languages:language_content'
              - 'languages:language_interface'
              - 'user.node_grants:view'
+14 −0
Changes for modules/social_features/social_album/social_album.install: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -347,3 +347,17 @@ function social_album_update_11402(): void {
function social_album_update_11403(): void {
  _social_album_set_group_permissions();
}

/**
 * Update entity_reference display, remove contextual filter.
 */
function social_album_update_11470(): string {
  /** @var \Drupal\update_helper\Updater $updateHelper */
  $updateHelper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updateHelper->executeUpdate('social_album', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $updateHelper->logger()->output();
}
+16 −2
Changes for modules/social_features/social_album/social_album.module: 16 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -188,9 +188,9 @@ function social_album_post_presave(EntityInterface $entity) {
}

/**
 * Implements hook_ENTITY_TYPE_insert().
 * Helper function to invalidate tags.
 */
function social_album_post_insert(EntityInterface $entity) {
function _social_album_invalidate_tags(EntityInterface $entity): void {
  /** @var \Drupal\social_post\Entity\PostInterface $entity */
  if ($entity->bundle() === 'photo' && !$entity->field_album->isEmpty()) {
    \Drupal::service('cache_tags.invalidator')->invalidateTags([
@@ -200,6 +200,20 @@ function social_album_post_insert(EntityInterface $entity) {
  }
}

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function social_album_post_insert(EntityInterface $entity) {
  _social_album_invalidate_tags($entity);
}

/**
 * Implements hook_ENTITY_TYPE_update().
 */
function social_album_post_update(EntityInterface $entity) {
  _social_album_invalidate_tags($entity);
}

/**
 * Implements hook_ENTITY_TYPE_create_access().
 */
+4 −1
Changes for modules/social_features/social_album/src/Controller/SocialAlbumController.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -232,7 +232,10 @@ class SocialAlbumController extends ControllerBase {
    if ($this->checkAlbumAccess($node)) {
      $account = $this->currentUser();

      if ($node->getOwnerId() === $account->id()) {
      // Access allowed for the owner or for the user who can edit any posts.
      // The 'edit any post entities' is used because there is no separate
      // permission for managers to add to any albums.
      if ($node->getOwnerId() === $account->id() || $account->hasPermission('edit any post entities')) {
        return AccessResult::allowed();
      }
      elseif (
Loading