comparison core/misc/entity-form.es6.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 /**
2 * @file
3 * Defines Javascript behaviors for the block_content module.
4 */
5
6 (function ($, Drupal) {
7 /**
8 * Sets summaries about revision and translation of entities.
9 *
10 * @type {Drupal~behavior}
11 *
12 * @prop {Drupal~behaviorAttach} attach
13 * Attaches summary behaviour entity form tabs.
14 *
15 * Specifically, it updates summaries to the revision information and the
16 * translation options.
17 */
18 Drupal.behaviors.entityContentDetailsSummaries = {
19 attach(context) {
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');
24
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');
31 }
32
33 return Drupal.t('No revision');
34 });
35
36 $context.find('details.entity-translation-options').drupalSetSummary((context) => {
37 const $translationContext = $(context);
38 let translate;
39 let $checkbox = $translationContext.find('.js-form-item-translation-translate input');
40
41 if ($checkbox.length) {
42 translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
43 }
44 else {
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');
47 }
48
49 return translate;
50 });
51 },
52 };
53 }(jQuery, Drupal));