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