diff --git a/css/theme/moderation-state.theme.css b/css/theme/moderation-state.theme.css index 73b485759efc99db5c94c8cc82b5e851467e94e6..799b41736625aaffc3fb28d90831bd7ff00b42cc 100644 --- a/css/theme/moderation-state.theme.css +++ b/css/theme/moderation-state.theme.css @@ -1,12 +1,12 @@ -#edit-gin-sticky-actions #edit-moderation-state-0 .form-element--type-select { +#edit-gin-sticky-actions #edit-moderation-state-0--2 .form-element--type-select { width: 8rem; } -#edit-gin-sticky-actions #edit-moderation-state-0 .form-item--moderation-state-0-current { +#edit-gin-sticky-actions #edit-moderation-state-0--2 .form-item--moderation-state-0-current { display: none; } -#edit-gin-sticky-actions #edit-moderation-state-0 .form-item--moderation-state-0-state label { +#edit-gin-sticky-actions #edit-moderation-state-0--2 .form-item--moderation-state-0-state label { display: none; } @@ -17,3 +17,8 @@ #edit-gin-sticky-actions [data-gin-sticky-form-selector=edit-submit] { order: -4; } + +#edit-gin-sidebar #edit-moderation-state-wrapper { + display: none; +} + diff --git a/js/moderation-state.js b/js/moderation-state.js new file mode 100644 index 0000000000000000000000000000000000000000..4a1ccab5f41b579208a1879f49fae17242c3f972 --- /dev/null +++ b/js/moderation-state.js @@ -0,0 +1,25 @@ +/** + * @file + * Behaviors of Varbase Moderation State for state dropdown change. + */ + +(function ($, _, Drupal) { + Drupal.behaviors.varbaseModerationStateSync = { + attach: function (context, settings) { + const dropdown1 = $('[id="edit-moderation-state-0-state"]', context); + const dropdown2 = $('[id="edit-moderation-state-0-state--2"]', context); + + if (dropdown1.length && dropdown2.length) { + // Sync dropdown2 when dropdown1 changes. + dropdown1.on('change', function () { + dropdown2.val($(this).val()).trigger('change'); + }); + + // Sync dropdown1 when dropdown2 changes. + dropdown2.on('change', function () { + dropdown1.val($(this).val()).trigger('change'); + }); + } + } + }; +})(window.jQuery, window._, window.Drupal); diff --git a/scss/theme/moderation-state.theme.scss b/scss/theme/moderation-state.theme.scss index 4927946c4af479aaab2376e9eac8c172501faa22..6feaac16403554ebb0bb9e513c1d116bbac274dc 100644 --- a/scss/theme/moderation-state.theme.scss +++ b/scss/theme/moderation-state.theme.scss @@ -1,6 +1,6 @@ #edit-gin-sticky-actions { - #edit-moderation-state-0 { + #edit-moderation-state-0--2 { .form-element--type-select { width: 8rem; } @@ -24,3 +24,9 @@ order: -4; } } + +#edit-gin-sidebar { + #edit-moderation-state-wrapper { + display: none; + } +} diff --git a/varbase_workflow.libraries.yml b/varbase_workflow.libraries.yml index 5e55714fb4a71b771ed6e0021ffd49a1fad13d79..4bd28d290a89fcb28df6ba5c5f860c58c42236dc 100644 --- a/varbase_workflow.libraries.yml +++ b/varbase_workflow.libraries.yml @@ -2,3 +2,5 @@ moderation-state: css: theme: css/theme/moderation-state.theme.css: { } + js: + js/moderation-state.js: { } diff --git a/varbase_workflow.module b/varbase_workflow.module index 1784fac7f45edb2178c7e0137adbc23fbddd73cc..7b5b64b3e74a90130aad79851cb9cc45b2e1dba1 100644 --- a/varbase_workflow.module +++ b/varbase_workflow.module @@ -86,8 +86,9 @@ function varbase_workflow_form_alter(array &$form, FormStateInterface $form_stat $base_themes = (array) $active_theme->getBaseThemeExtensions(); if ($active_theme->getName() === 'gin' || array_key_exists('gin', $base_themes)) { - // Set the group for moderation status to be in Gin Actions sticky status. - $form['moderation_state']['#group'] = 'status'; + // Copy the moderation status form. + $form['moderation_state_sticky_form'] = $form['moderation_state']; + $form['moderation_state_sticky_form']['#group'] = 'status'; // Change the title of the submit button. $form['actions']['submit']['#value'] = t('Save as');