From 385ca7219e18b6cca6b2561a64b558084d3d2504 Mon Sep 17 00:00:00 2001 From: Zohar Stolar Date: Tue, 22 Sep 2020 14:35:42 +0200 Subject: [PATCH] Sync current repo with istolar/openideal_distribution --- composer.json | 4 +- config/install/block.block.node_tags.yml | 1 - .../install/block.block.workflow_status.yml | 1 + ...tity_form_display.node.article.default.yml | 17 +- ...ty_form_display.node.challenge.default.yml | 39 ++-- ....entity_form_display.node.idea.default.yml | 14 +- ....entity_view_display.node.article.full.yml | 2 +- config/install/user.role.authenticated.yml | 1 + config/install/views.view.challenges.yml | 14 ++ config/install/views.view.frontpage.yml | 14 +- config/install/views.view.ideas.yml | 14 ++ config/install/views.view.news.yml | 18 +- .../install/views.view.user_admin_people.yml | 9 +- .../OpenidealStatisticsWorkflowBlock.php | 169 +++++++++++++++++- 14 files changed, 272 insertions(+), 45 deletions(-) diff --git a/composer.json b/composer.json index 300b0279a..8d2880336 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "linnovate/openideal", - "description": "OpenideaL - open source ideas and innovation management system", + "name": "istolar/openideal_distribution", + "description": "The OpenideaL distribution profile", "type": "drupal-profile", "license": "GPL-2.0-or-later", "minimum-stability": "dev", diff --git a/config/install/block.block.node_tags.yml b/config/install/block.block.node_tags.yml index e5ce0e54d..9dd9f39d9 100644 --- a/config/install/block.block.node_tags.yml +++ b/config/install/block.block.node_tags.yml @@ -24,7 +24,6 @@ visibility: node_type: id: node_type bundles: - article: article idea: idea negate: false context_mapping: diff --git a/config/install/block.block.workflow_status.yml b/config/install/block.block.workflow_status.yml index 1a4084f29..7a6bcf5c6 100644 --- a/config/install/block.block.workflow_status.yml +++ b/config/install/block.block.workflow_status.yml @@ -18,6 +18,7 @@ settings: label: Status provider: openideal_statistics label_display: visible + show_all_states: true context_mapping: node: '@node.node_route_context:node' visibility: diff --git a/config/install/core.entity_form_display.node.article.default.yml b/config/install/core.entity_form_display.node.article.default.yml index 56d2f8fc2..551ebc8cf 100644 --- a/config/install/core.entity_form_display.node.article.default.yml +++ b/config/install/core.entity_form_display.node.article.default.yml @@ -10,6 +10,7 @@ dependencies: - field.field.node.article.field_tags - node.type.article module: + - content_moderation - entity_browser - metatag - path @@ -64,7 +65,7 @@ content: type: entity_browser_file region: content field_meta_tags: - weight: 101 + weight: 12 settings: sidebar: true third_party_settings: { } @@ -82,7 +83,7 @@ content: third_party_settings: { } moderation_state: type: moderation_state_default - weight: 100 + weight: 11 settings: { } region: content third_party_settings: { } @@ -99,6 +100,13 @@ content: weight: 4 region: content third_party_settings: { } + sticky: + type: boolean_checkbox + weight: 9 + region: content + settings: + display_label: true + third_party_settings: { } title: type: string_textfield weight: 0 @@ -123,10 +131,9 @@ content: placeholder: '' third_party_settings: { } url_redirects: - weight: 50 + weight: 10 + region: content settings: { } third_party_settings: { } - region: content hidden: promote: true - sticky: true diff --git a/config/install/core.entity_form_display.node.challenge.default.yml b/config/install/core.entity_form_display.node.challenge.default.yml index 6f1cee9ae..ee98b4493 100644 --- a/config/install/core.entity_form_display.node.challenge.default.yml +++ b/config/install/core.entity_form_display.node.challenge.default.yml @@ -17,6 +17,7 @@ dependencies: - node.type.challenge module: - allowed_formats + - content_moderation - entity_browser - metatag - openideal_challenge @@ -29,7 +30,7 @@ mode: default content: body: type: text_textarea_with_summary - weight: 6 + weight: 5 settings: rows: 9 placeholder: '' @@ -42,18 +43,18 @@ content: region: content created: type: datetime_timestamp - weight: 3 + weight: 2 region: content settings: { } third_party_settings: { } field_category: - weight: 10 + weight: 9 settings: { } third_party_settings: { } type: options_buttons region: content field_images: - weight: 8 + weight: 7 settings: entity_browser: openideal_images_browser field_widget_remove: true @@ -67,14 +68,14 @@ content: type: entity_browser_file region: content field_is_open: - weight: 11 + weight: 10 settings: display_label: true third_party_settings: { } type: boolean_checkbox region: content field_main_image: - weight: 7 + weight: 6 settings: entity_browser: openideal_image_browser field_widget_remove: true @@ -88,26 +89,26 @@ content: type: entity_browser_file region: content field_meta_tags: - weight: 16 + weight: 14 settings: sidebar: true third_party_settings: { } type: metatag_firehose region: content field_schedule_close: - weight: 15 + weight: 13 settings: { } third_party_settings: { } type: openideal_datetime_timestamp region: content field_schedule_open: - weight: 14 + weight: 12 settings: { } third_party_settings: { } type: openideal_datetime_timestamp region: content field_supporting_data: - weight: 9 + weight: 8 settings: entity_browser: openideal_file_browser field_widget_remove: true @@ -122,13 +123,13 @@ content: region: content moderation_state: type: moderation_state_default - weight: 13 + weight: 11 settings: { } region: content third_party_settings: { } path: type: path - weight: 4 + weight: 3 region: content settings: { } third_party_settings: { } @@ -136,9 +137,16 @@ content: type: boolean_checkbox settings: display_label: true - weight: 5 + weight: 4 region: content third_party_settings: { } + sticky: + type: boolean_checkbox + weight: 16 + region: content + settings: + display_label: true + third_party_settings: { } title: type: string_textfield weight: 0 @@ -163,12 +171,11 @@ content: placeholder: '' third_party_settings: { } url_redirects: - weight: 50 + weight: 15 + region: content settings: { } third_party_settings: { } - region: content hidden: field_comments: true field_like: true promote: true - sticky: true diff --git a/config/install/core.entity_form_display.node.idea.default.yml b/config/install/core.entity_form_display.node.idea.default.yml index f51f855e1..cbb416e32 100644 --- a/config/install/core.entity_form_display.node.idea.default.yml +++ b/config/install/core.entity_form_display.node.idea.default.yml @@ -15,10 +15,12 @@ dependencies: - field.field.node.idea.field_meta_tags - field.field.node.idea.field_overall_score - node.type.idea + - workflows.workflow.life_cycle_phases module: - allowed_formats - entity_browser - metatag + - moderation_state_buttons_widget - path - text - votingapi_reaction @@ -139,6 +141,13 @@ content: weight: 4 region: content third_party_settings: { } + sticky: + type: boolean_checkbox + weight: 16 + region: content + settings: + display_label: true + third_party_settings: { } title: type: string_textfield weight: 0 @@ -163,12 +172,11 @@ content: region: content third_party_settings: { } url_redirects: - weight: 50 + weight: 15 + region: content settings: { } third_party_settings: { } - region: content hidden: field_comments: true field_overall_score: true promote: true - sticky: true diff --git a/config/install/core.entity_view_display.node.article.full.yml b/config/install/core.entity_view_display.node.article.full.yml index 6d1335eb8..68dafa23c 100644 --- a/config/install/core.entity_view_display.node.article.full.yml +++ b/config/install/core.entity_view_display.node.article.full.yml @@ -102,7 +102,7 @@ third_party_settings: label: hidden type: string settings: - link_to_entity: false + link_to_entity: true third_party_settings: { } context_mapping: entity: layout_builder.entity diff --git a/config/install/user.role.authenticated.yml b/config/install/user.role.authenticated.yml index 49fd2a6da..64ca656c8 100644 --- a/config/install/user.role.authenticated.yml +++ b/config/install/user.role.authenticated.yml @@ -43,6 +43,7 @@ permissions: - 'modify reaction on node:challenge:field_like' - 'modify reaction on node:idea:field_like' - 'post comments' + - 'rabbit hole bypass user' - 'search content' - 'skip comment approval' - 'translate idea node' diff --git a/config/install/views.view.challenges.yml b/config/install/views.view.challenges.yml index ab781c053..612dc1bac 100644 --- a/config/install/views.view.challenges.yml +++ b/config/install/views.view.challenges.yml @@ -989,6 +989,20 @@ display: groups: 1: AND sorts: + sticky: + id: sticky + table: node_field_data + field: sticky + relationship: none + group_type: group + admin_label: '' + order: DESC + exposed: false + expose: + label: '' + entity_type: node + entity_field: sticky + plugin_id: standard random: id: random table: views diff --git a/config/install/views.view.frontpage.yml b/config/install/views.view.frontpage.yml index 564c2e506..cc6329b3b 100644 --- a/config/install/views.view.frontpage.yml +++ b/config/install/views.view.frontpage.yml @@ -819,16 +819,16 @@ display: 1: AND sorts: sticky: - admin_label: '' - expose: - label: '' - exposed: false + id: sticky + table: node_field_data field: sticky + relationship: none group_type: group - id: sticky + admin_label: '' order: DESC - relationship: none - table: node_field_data + exposed: false + expose: + label: '' plugin_id: boolean entity_type: node entity_field: sticky diff --git a/config/install/views.view.ideas.yml b/config/install/views.view.ideas.yml index 83e3c89d9..3f1e36c19 100644 --- a/config/install/views.view.ideas.yml +++ b/config/install/views.view.ideas.yml @@ -1387,6 +1387,20 @@ display: entity_field: uid plugin_id: standard sorts: + sticky: + id: sticky + table: node_field_data + field: sticky + relationship: none + group_type: group + admin_label: '' + order: DESC + exposed: false + expose: + label: '' + entity_type: node + entity_field: sticky + plugin_id: standard created: id: created table: node_field_data diff --git a/config/install/views.view.news.yml b/config/install/views.view.news.yml index 610b9e562..c34897d23 100644 --- a/config/install/views.view.news.yml +++ b/config/install/views.view.news.yml @@ -2,7 +2,7 @@ langcode: en status: true dependencies: config: - - core.entity_view_mode.node.teaser + - core.entity_view_mode.node.full - node.type.article - system.menu.main module: @@ -71,7 +71,7 @@ display: type: 'entity:node' options: relationship: none - view_mode: teaser + view_mode: full fields: title: id: title @@ -147,6 +147,20 @@ display: operator_limit_selection: false operator_list: { } sorts: + sticky: + id: sticky + table: node_field_data + field: sticky + relationship: none + group_type: group + admin_label: '' + order: DESC + exposed: false + expose: + label: '' + entity_type: node + entity_field: sticky + plugin_id: standard created: id: created table: node_field_data diff --git a/config/install/views.view.user_admin_people.yml b/config/install/views.view.user_admin_people.yml index 358e8e7a0..c62ee5a08 100644 --- a/config/install/views.view.user_admin_people.yml +++ b/config/install/views.view.user_admin_people.yml @@ -8,6 +8,7 @@ dependencies: - field.storage.user.user_picture - image.style.thumbnail - system.menu.main + - user.role.authenticated module: - better_exposed_filters - image @@ -1548,6 +1549,7 @@ display: exposed_form: false css_class: false empty: false + access: false display_description: '' path: community menu: @@ -1780,6 +1782,11 @@ display: tokenize: false content: '
No people available.
' plugin_id: text_custom + access: + type: role + options: + role: + authenticated: authenticated cache_metadata: max-age: -1 contexts: @@ -1789,7 +1796,7 @@ display: - url.query_args - 'url.query_args:sort_by' - 'url.query_args:sort_order' - - user.permissions + - user.roles tags: - 'config:core.entity_view_display.user.user.author' - 'config:core.entity_view_display.user.user.compact' diff --git a/modules/openideal_statistics/src/Plugin/Block/OpenidealStatisticsWorkflowBlock.php b/modules/openideal_statistics/src/Plugin/Block/OpenidealStatisticsWorkflowBlock.php index b4bdb7a76..e5b6c1a6a 100644 --- a/modules/openideal_statistics/src/Plugin/Block/OpenidealStatisticsWorkflowBlock.php +++ b/modules/openideal_statistics/src/Plugin/Block/OpenidealStatisticsWorkflowBlock.php @@ -5,6 +5,7 @@ use Drupal\content_moderation\ModerationInformation; use Drupal\Core\Block\BlockBase; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\openideal_challenge\OpenidealContextEntityTrait; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -86,23 +87,177 @@ public static function create(ContainerInterface $container, array $configuratio */ public function build() { $build = []; - if ($node = $this->getEntity($this->getContexts())) { - $state = $this->moderationInformation->getOriginalState($node); + if (!($node = $this->getEntity($this->getContexts()))) { + return $build; + } + $state = $this->moderationInformation->getOriginalState($node); + if (!$this->configuration['show_all_states']) { $build = [ - 'status' => [ - '#type' => 'html_tag', - '#tag' => 'div', - '#attributes' => ['class' => ['idea-statistics-and-status-block--status']], - '#value' => $state->label(), + 'container' => [ + '#type' => 'container', + '#attributes' => ['class' => ['idea-statistics-and-status-block--status', $state->id()]], + 'status' => [ + '#type' => 'html_tag', + '#attributes' => ['class' => ['idea-statistics-and-status-block--status__container']], + '#tag' => 'div', + '#value' => $state->label(), + ], ], '#cache' => [ 'tags' => $node->getCacheTags(), ], ]; } + else { + /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration $contentModerationPlugin */ + $contentModerationPlugin = $this->entityManager->getStorage('workflow')->load('life_cycle_phases')->getTypePlugin(); + // Hardcoded states groups FE configuration. + $configurations = [ + [ + 'states' => ['draft', 'draft_approval'], + 'label' => $this->t('Prepare'), + 'id' => 'prepare', + ], + [ + 'states' => ['published'], + 'label' => $this->t('Discuss'), + 'id' => 'discuss', + ], + [ + 'states' => ['ex', 'needs_work'], + 'label' => $this->t('Refine'), + 'id' => 'refine', + ], + [ + 'states' => ['postponed'], + 'label' => $this->t('Postponed'), + 'id' => 'postponed', + ], + [ + 'states' => ['rejected'], + 'label' => $this->t('Rejected'), + 'id' => 'rejected', + ], + [ + 'states' => ['approved', 'launched'], + 'label' => $this->t('Innovate'), + 'id' => 'innovate', + ], + ]; + + $list = []; + // Indicate if it's a last finished group where is state in. + $last_finished_group = FALSE; + foreach ($configurations as $id => $configuration) { + if (in_array($state->id(), $configuration['states'])) { + $list[$id] = [ + '#type' => 'container', + '#attributes' => [ + 'class' => [ + 'current_group', + 'idea-workflow-full--group-' . $configuration['id'], + ], + ], + 'group' => [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => ['class' => ['idea-workflow-full--group-title']], + '#value' => $configuration['label'], + ], + 'list' => [ + '#theme' => 'item_list', + ], + ]; + $build['#wrapper_attributes']['class'][] = 'idea-workflow-full--' . $configuration['id']; + + if ($state->id() == 'postponed' || $state->id() == 'rejected') { + break; + } + $items = []; + foreach ($configuration['states'] as $available_state) { + $items[$available_state] = [ + '#type' => 'html_tag', + '#tag' => 'div', + '#attributes' => ['class' => ['idea-workflow-full--group-states']], + '#value' => $contentModerationPlugin->getState($available_state)->label(), + ]; + if ($available_state == $state->id()) { + $items[$available_state]['#attributes']['class'][] = 'idea-workflow-full--active-state'; + } + } + + $list[$id]['list']['#items'] = $items; + $last_finished_group = TRUE; + } + else { + // Do not need to add rejected and postponed if they are not active. + if (($state->id() != 'rejected' && in_array('rejected', $configuration['states'])) + || ($state->id() != 'postponed' && in_array('postponed', $configuration['states'])) + ) { + continue; + } + + $list[$id] = [ + '#type' => 'container', + '#attributes' => ['class' => ['idea-workflow-full--group-wrapper']], + 'indicator' => [ + '#type' => 'container', + '#attributes' => [ + 'class' => [ + $last_finished_group ?: 'idea-workflow-full--checked', + 'idea-workflow-full--group-' . $configuration['id'], + 'idea-workflow-full--indicator', + ], + ], + ], + 'label' => [ + '#type' => 'html_tag', + '#tag' => 'div', + '#value' => $configuration['label'], + '#attributes' => ['class' => ['idea-workflow-full--value']], + ], + ]; + } + } + + $build['#wrapper_attributes']['class'][] = 'idea-workflow-full'; + + $build += [ + '#theme' => 'item_list', + '#items' => $list, + ]; + } return $build; } + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $form['show_all_states'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Show all workflow states'), + '#default_value' => $this->configuration['show_all_states'], + ]; + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + $this->configuration['show_all_states'] = (bool) $form_state->getValue('show_all_states'); + } + + /** + * {@inheritDoc} + */ + public function defaultConfiguration() { + return [ + 'show_all_states' => FALSE, + ]; + } + }