diff --git a/core/modules/media_entity/js/media_form.js b/core/modules/media_entity/js/media_form.js new file mode 100644 index 0000000..e8c9547 --- /dev/null +++ b/core/modules/media_entity/js/media_form.js @@ -0,0 +1,55 @@ +/** + * @file + * Defines Javascript behaviors for the media entity form. + */ + +(function ($, Drupal, drupalSettings) { + + 'use strict'; + + /** + * Behaviors for tabs in the media edit form. + * + * @type {Drupal~behavior} + * + * @prop {Drupal~behaviorAttach} attach + * Attaches summary behavior for tabs in the media edit form. + */ + Drupal.behaviors.mediaDetailsSummaries = { + attach: function (context) { + var $context = $(context); + $context.find('.media-form-revision-information').drupalSetSummary(function (context) { + var $revisionContext = $(context); + var revisionCheckbox = $revisionContext.find('.js-form-item-revision input'); + + // Return 'New revision' if the 'Create new revision' checkbox is + // checked, or if the checkbox doesn't exist, but the revision log does. + // For users without the "Administer content" permission the checkbox + // won't appear, but the revision log will if the content type is set to + // auto-revision. + if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) { + return Drupal.t('New revision'); + } + + return Drupal.t('No revision'); + }); + + $context.find('.media-form-author').drupalSetSummary(function (context) { + var $authorContext = $(context); + var name = $authorContext.find('.field--name-uid input').val(); + var date = $authorContext.find('.field--name-created input').val(); + + if (name && date) { + return Drupal.t('By @name on @date', {'@name': name, '@date': date}); + } + else if (name) { + return Drupal.t('By @name', {'@name': name}); + } + else if (date) { + return Drupal.t('Authored on @date', {'@date': date}); + } + }); + } + }; + +})(jQuery, Drupal, drupalSettings); diff --git a/core/modules/media_entity/src/Entity/Media.php b/core/modules/media_entity/src/Entity/Media.php index 2543318..833e3f2 100644 --- a/core/modules/media_entity/src/Entity/Media.php +++ b/core/modules/media_entity/src/Entity/Media.php @@ -452,7 +452,7 @@ public function getRevisionLogMessage() { * {@inheritdoc} */ public function setRevisionLogMessage($revision_log_message) { - $this->revision_log-> value = $revision_log_message; + $this->revision_log->value = $revision_log_message; return $this; } diff --git a/core/modules/media_entity/tests/src/Kernel/TokensTest.php b/core/modules/media_entity/tests/src/Kernel/TokensTest.php index 7fb843e..3f50d8e 100644 --- a/core/modules/media_entity/tests/src/Kernel/TokensTest.php +++ b/core/modules/media_entity/tests/src/Kernel/TokensTest.php @@ -11,7 +11,6 @@ * Tests token handling. * * @requires module token - * @requires module entity * * @group media_entity */