3 * Defines Javascript behaviors for the block_content module.
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);
22 .find('.entity-content-form-revision-information')
23 .drupalSetSummary(context => {
24 const $revisionContext = $(context);
25 const revisionCheckbox = $revisionContext.find(
26 '.js-form-item-revision input',
29 // Return 'New revision' if the 'Create new revision' checkbox is checked,
30 // or if the checkbox doesn't exist, but the revision log does. For users
31 // without the "Administer content" permission the checkbox won't appear,
32 // but the revision log will if the content type is set to auto-revision.
34 revisionCheckbox.is(':checked') ||
35 (!revisionCheckbox.length &&
36 $revisionContext.find('.js-form-item-revision-log textarea')
39 return Drupal.t('New revision');
42 return Drupal.t('No revision');
46 .find('details.entity-translation-options')
47 .drupalSetSummary(context => {
48 const $translationContext = $(context);
50 let $checkbox = $translationContext.find(
51 '.js-form-item-translation-translate input',
54 if ($checkbox.length) {
55 translate = $checkbox.is(':checked')
56 ? Drupal.t('Needs to be updated')
57 : Drupal.t('Does not need to be updated');
59 $checkbox = $translationContext.find(
60 '.js-form-item-translation-retranslate input',
62 translate = $checkbox.is(':checked')
63 ? Drupal.t('Flag other translations as outdated')
64 : Drupal.t('Do not flag other translations as outdated');