3 * Defines Javascript behaviors for the block_content module.
6 (function ($, Drupal) {
8 * Sets summaries about revision and translation of entities.
10 * @type {Drupal~behavior}
12 * @prop {Drupal~behaviorAttach} attach
13 * Attaches summary behaviour entity form tabs.
15 * Specifically, it updates summaries to the revision information and the
16 * translation options.
18 Drupal.behaviors.entityContentDetailsSummaries = {
20 const $context = $(context);
21 $context.find('.entity-content-form-revision-information').drupalSetSummary((context) => {
22 const $revisionContext = $(context);
23 const revisionCheckbox = $revisionContext.find('.js-form-item-revision input');
25 // Return 'New revision' if the 'Create new revision' checkbox is checked,
26 // or if the checkbox doesn't exist, but the revision log does. For users
27 // without the "Administer content" permission the checkbox won't appear,
28 // but the revision log will if the content type is set to auto-revision.
29 if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) {
30 return Drupal.t('New revision');
33 return Drupal.t('No revision');
36 $context.find('details.entity-translation-options').drupalSetSummary((context) => {
37 const $translationContext = $(context);
39 let $checkbox = $translationContext.find('.js-form-item-translation-translate input');
41 if ($checkbox.length) {
42 translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
45 $checkbox = $translationContext.find('.js-form-item-translation-retranslate input');
46 translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');