Skip to content

Commit

Permalink
refs# 25701 Access on IACM meeting & permissions refactoring (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuga-paula authored Jul 9, 2024
1 parent 69e9917 commit 2fc8097
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 4 deletions.
6 changes: 4 additions & 2 deletions modules/edw_event/src/Services/MeetingDocumentsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ public function addDocumentModal(TermInterface $agenda, string $phase) {
*
* @param \Drupal\Core\Url $url
* The agenda selected for the document.
* @param string $title
* The links title
*
* @return array
* Modal dialog.
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
public function addButtonModal(Url $url) {
public function addButtonModal(Url $url, string $title) {
return [
'#type' => 'link',
'#title' => $this->t('Add new document'),
'#title' => $this->t($title),
'#url' => $url,
'#attributes' => [
'class' => ['button button--action', 'button--primary', 'use-ajax'],
Expand Down
17 changes: 17 additions & 0 deletions modules/edw_themes/modules/edwt_backend/css/manage-groups.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.view-meeting-groups .gin-layer-wrapper {
background: none;
border: none;
box-shadow: none;
}

.main-group-section__container {
padding:16px;
}

.main-content__container {
background: var(--gin-bg-layer);
border: 1px solid var(--gin-border-color-layer);
box-shadow: var(--gin-shadow-l1);
border-radius: var(--gin-border-l);
margin-bottom: 32px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ manage-documents:
- core/jquery
- core/once

manage-groups:
css:
component:
css/manage-groups.css: {}

bootstrap:
css:
theme:
Expand Down
33 changes: 31 additions & 2 deletions modules/edw_themes/modules/edwt_backend/edwt_backend.theme
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Drupal\Component\Serialization\Json;
use Drupal\Core\Url;
use Drupal\views\ViewExecutable;

Expand Down Expand Up @@ -85,8 +84,38 @@ function edwt_backend_preprocess_views_view_table(&$variables) {
'field_document_types' => $firstResult->_relationship_entities['field_document_types']->id(),
'field_document_phase' => 'in_session',
]);
$variables['add_document'] = $meetingDocumentsService->addButtonModal($url);
$variables['add_document'] = $meetingDocumentsService->addButtonModal($url, 'Add new document');
$variables['group_id'] = $firstResult->_relationship_entities['field_document_types']->id();
}

if ($view->id() == 'meeting_groups' && $view->current_display == 'access_groups'
&& isset($variables['result'])) {
$firstResult = reset($variables['result']);
$sectionId = $firstResult->_relationship_entities['reverse__node__field_groups']->id();
if ($firstResult->_entity == NULL) {
$firstRowKey = array_key_first($variables['rows']);
$variables['rows'][$firstRowKey]['empty_message'] = t('There are no groups for this section');
foreach ($variables['rows'][$firstRowKey]['columns'] as &$value) {
$value['content'] = [];
}
}

$currentPath = \Drupal::request()->getRequestUri();
$uuid = \Drupal::service('uuid')->generate();

$addUrl = Url::fromRoute('entity.group.add_form', [
'group_type' => 'event',
'nid' => $sectionId,
'destination' => $currentPath,
]);

$assignUrl = Url::fromRoute('entity_browser.access_groups', [
'uuid' => $uuid,
'original_path' => $currentPath,
'nid' => $sectionId,
]);
$variables['add_group'] = $meetingDocumentsService->addButtonModal($addUrl, 'Add new group');
$variables['assign_group'] = $meetingDocumentsService->addButtonModal($assignUrl, 'Assign group');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{#
/**
* @file
* Theme override for displaying a view as a table.
*
* Available variables:
* - attributes: Remaining HTML attributes for the element.
* - class: HTML classes that can be used to style contextually through CSS.
* - title : The title of this group of rows.
* - header: The table header columns.
* - attributes: Remaining HTML attributes for the element.
* - content: HTML classes to apply to each header cell, indexed by
* the header's key.
* - default_classes: A flag indicating whether default classes should be
* used.
* - caption_needed: Is the caption tag needed.
* - caption: The caption for this table.
* - accessibility_description: Extended description for the table details.
* - accessibility_summary: Summary for the table details.
* - rows: Table row items. Rows are keyed by row number.
* - attributes: HTML classes to apply to each row.
* - columns: Row column items. Columns are keyed by column number.
* - attributes: HTML classes to apply to each column.
* - content: The column content.
* - default_classes: A flag indicating whether default classes should be
* used.
* - responsive: A flag indicating whether table is responsive.
* - sticky: A flag indicating whether table header is sticky.
* - summary_element: A render array with table summary information (if any).
*
* @see template_preprocess_views_view_table()
*/
#}

{{ attach_library('edwt_backend/manage-groups') }}

{% set classes = [
'views-table',
'views-view-table',
'cols-' ~ header|length,
responsive ? 'responsive-enabled',
sticky ? 'sticky-enabled',
] %}
<div class="main-content__container">
<div class="main-group-section__container">
<h3> {{ title }} </h3>
{% if assign_group %}
{{ assign_group }}
{% endif %}
{% if add_group %}
{{ add_group }}
{% endif %}
</div>
<table{{ attributes.addClass(classes) }}>
{% if header %}
<thead>
<tr>
{% for key, column in header %}
{% if column.default_classes %}
{% set column_classes = [
'views-field',
'views-field-' ~ fields[key],
] %}
{% endif %}
<th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
{%- if column.wrapper_element -%}
<{{ column.wrapper_element }}>
{%- if column.url -%}
<a href="{{ column.url }}" title="{{ column.title }}"
rel="nofollow">{{ column.content }}{{ column.sort_indicator }}</a>
{%- else -%}
{{ column.content }}{{ column.sort_indicator }}
{%- endif -%}
</{{ column.wrapper_element }}>
{%- else -%}
{%- if column.url -%}
<a href="{{ column.url }}" title="{{ column.title }}"
rel="nofollow">{{ column.content }}{{ column.sort_indicator }}</a>
{%- else -%}
{{- column.content }}{{ column.sort_indicator }}
{%- endif -%}
{%- endif -%}
</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tbody>
{% for row in rows %}
<tr{{ row.attributes }}>
{% if row.empty_message %}
<td>
{{ row.empty_message }}
</td>
{% endif %}
{% for key, column in row.columns %}
{% if column.default_classes %}
{% set column_classes = [
'views-field'
] %}
{% for field in column.fields %}
{% set column_classes = column_classes|merge(['views-field-' ~ field]) %}
{% endfor %}
{% endif %}
<td{{ column.attributes.addClass(column_classes) }}>
{%- if column.wrapper_element -%}
<{{ column.wrapper_element }}>
{% for content in column.content %}
{{ content.separator }}{{ content.field_output }}
{% endfor %}
</{{ column.wrapper_element }}>
{%- else -%}
{% for content in column.content %}
{{- content.separator }}{{ content.field_output -}}
{% endfor %}
{%- endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>

0 comments on commit 2fc8097

Please sign in to comment.