Skip to content

Internal: Add course settings permission and improve table layout - refs #5644 #5723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions assets/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ form .field {
.permissions-table {
width: 100%;
border-collapse: collapse;
table-layout: auto;
th, td {
border: 1px solid #ccc;
padding: 8px;
Expand All @@ -713,8 +714,12 @@ form .field {
background-color: #e9e9e9;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
padding: 5px;
font-size: 0.9em;
white-space: normal;
word-wrap: break-word;
min-width: 100px;
vertical-align: top;
}
th {
padding-top: 12px;
Expand All @@ -741,6 +746,10 @@ form .field {
.save-button:hover {
background-color: #45a049;
}
input[type="checkbox"] {
transform: scale(1);
margin: 0 auto;
}
}

.files-info-page {
Expand Down
2 changes: 2 additions & 0 deletions src/CoreBundle/DataFixtures/PermissionFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public static function getPermissions(): array
['title' => 'Edit user', 'slug' => 'user:edit', 'description' => 'Edit users'],
['title' => 'Edit user Role', 'slug' => 'user:editrole', 'description' => 'Edit user roles'],
['title' => 'Login as user', 'slug' => 'user:loginas', 'description' => 'Login as another user'],
['title' => 'Edit Course Settings', 'slug' => 'course:editsettings', 'description' => 'Edit settings of a course'],
];
}

Expand Down Expand Up @@ -256,6 +257,7 @@ public static function getPermissionsMapping(): array
'user:edit' => ['ADM', 'SUA', 'GLO'],
'user:editrole' => ['ADM', 'SUA', 'GLO'],
'user:loginas' => ['SUA', 'GLO'],
'course:editsettings' => ['TEA', 'ADM', 'SUA', 'GLO'],
];
}
}
46 changes: 24 additions & 22 deletions src/CoreBundle/Resources/views/Permission/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@
<h1>{{ 'Permissions Management'|trans }}</h1>
<form method="post">
<button type="submit" class="save-button btn btn--primary hover:bg-blue-700 text-white font-bold py-2 px-4 rounded cursor-pointer mt-4 mb-4">{{ 'Save permissions'|trans }}</button>
<table class="permissions-table">
<thead>
<tr>
<th>{{ 'Permission '|trans }} <br> ({{ 'slug'|trans }})</th>
{% for role in roles %}
<th>
{{ role|trans }}<br>
<input type="checkbox" class="select-all" data-role="{{ role }}" style="margin-top: 5px;">
</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for permission in permissions %}
<div style="overflow-x: auto;">
<table class="permissions-table">
<thead>
<tr>
<td>{{ permission.title|trans }} <br> ({{ permission.slug }})</td>
<th>{{ 'Permission '|trans }} <br> ({{ 'slug'|trans }})</th>
{% for role in roles %}
<td>
<input type="checkbox" name="permissions[{{ permission.slug }}][{{ role }}]"
{% if forms[permission.slug].vars.value[role] %}checked="checked"{% endif %}>
</td>
<th>
{{ role|trans }}<br>
<input type="checkbox" class="select-all" data-role="{{ role }}" style="margin-top: 5px;">
</th>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for permission in permissions %}
<tr>
<td>{{ permission.title|trans }} <br> ({{ permission.slug }})</td>
{% for role in roles %}
<td>
<input type="checkbox" name="permissions[{{ permission.slug }}][{{ role }}]"
{% if forms[permission.slug].vars.value[role] %}checked="checked"{% endif %}>
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
<button type="submit" class="save-button btn btn--primary hover:bg-blue-700 text-white font-bold py-2 px-4 rounded cursor-pointer mt-4">{{ 'Save permissions'|trans }}</button>
</form>
<script>
Expand Down
Loading