Skip to content

Commit 252ea82

Browse files
authored
Merge pull request #433 from openITCOCKPIT/ITC-3653
ITC-3653 MapModule: Index list shows Delete even if not allowed.
2 parents bc002bc + 8d817f8 commit 252ea82

File tree

2 files changed

+156
-127
lines changed

2 files changed

+156
-127
lines changed

src/app/modules/map_module/pages/maps/maps-index/maps-index.component.html

Lines changed: 152 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h6 class="pb-2 mb-3 border-bottom">
7070
</c-row>
7171
<form cForm>
7272

73-
<c-row class="mb-2">
73+
<c-row>
7474
<c-col md="6">
7575
<c-input-group>
7676
<span cInputGroupText>
@@ -104,7 +104,7 @@ <h6 class="pb-2 mb-3 border-bottom">
104104
</c-input-group>
105105
</c-col>
106106
</c-row>
107-
<c-row class="mb-2">
107+
<c-row class="my-2">
108108
<c-col [xs]="12" lg="2">
109109
<fieldset>
110110
<h5>
@@ -123,7 +123,7 @@ <h5>
123123
[(ngModel)]="mapsFilter.is_auto_generated"/>
124124

125125
<label cFormCheckLabel class="ms-1 mt-1"
126-
for="maps.is_auto_generated">{{ t('Auto Generated') }}</label>
126+
for="maps.is_auto_generated">{{ t('Auto generated') }}</label>
127127
</c-form-check>
128128
<c-form-check>
129129
<input
@@ -153,133 +153,164 @@ <h5>
153153
</c-container>
154154
<!-- End Filter -->
155155

156-
<oitc-table-loader *ngIf="!maps"></oitc-table-loader>
157-
<table *ngIf="maps" bordered cTable class="mt-2 mb-0" hover striped matSort
158-
(matSortChange)="onSortChange($event)"
159-
[matSortActive]="params.sort" [matSortDirection]="params.direction">
160-
<thead>
161-
<tr>
162-
<th class="text-center col-1" scope="col" style="width: 5px;">
163-
<fa-icon [icon]="['fas', 'square-check']"></fa-icon>
164-
</th>
165-
<th scope="col" mat-sort-header="Maps.name">
166-
{{ t('Map name') }}
167-
</th>
168-
<th scope="col" mat-sort-header="Maps.title">
169-
{{ t('Map title') }}
170-
</th>
171-
<th class="text-center col-1 width-50" scope="col">
172-
<fa-icon [icon]="['fas', 'gear']"></fa-icon>
173-
</th>
174-
</tr>
175-
</thead>
176-
<tbody>
177-
<tr *ngFor="let map of maps.all_maps">
178-
<td class="text-center">
179-
@if (( PermissionsService.hasPermissionObservable(['MapModule', 'maps', 'delete'])|async ) || ( PermissionsService.hasPermissionObservable(['MapModule', 'maps', 'copy'])|async )) {
180-
<oitc-item-select
181-
[disabled]="!map.allowEdit"
182-
[item]="map"></oitc-item-select>
183-
}
184-
</td>
185-
<td class="word-break"><a
186-
[routerLink]="['/', 'map_module', 'mapeditors', 'view', map.id, false]">{{ map.name }}</a>
187-
@if (map.auto_generated) {
188-
<oitc-badge-outline class="ms-2"
189-
[title]="'Auto generated' | transloco"
190-
color="info"> {{ t('Auto generated') }}
191-
</oitc-badge-outline>
192-
}
193-
</td>
194-
<td class="word-break">{{ map.title }}</td>
156+
@if (!maps) {
157+
<oitc-table-loader></oitc-table-loader>
158+
}
159+
@if (maps) {
160+
<table bordered cTable class="mt-2 mb-0" hover striped matSort
161+
(matSortChange)="onSortChange($event)"
162+
[matSortActive]="params.sort" [matSortDirection]="params.direction">
163+
<thead>
164+
<tr>
165+
<th class="text-center col-1" scope="col" style="width: 5px;">
166+
<fa-icon [icon]="['fas', 'square-check']"></fa-icon>
167+
</th>
168+
<th scope="col" mat-sort-header="Maps.name">
169+
{{ t('Map name') }}
170+
</th>
171+
<th scope="col" mat-sort-header="Maps.title">
172+
{{ t('Map title') }}
173+
</th>
174+
<th class="text-center col-1 width-50" scope="col">
175+
<fa-icon [icon]="['fas', 'gear']"></fa-icon>
176+
</th>
177+
</tr>
178+
</thead>
179+
<tbody>
195180

196-
<td class="width-50">
197-
<oitc-actions-button [allowEdit]="map.allowEdit"
198-
[permission]="'mapmodule.maps.edit'"
199-
[url]="'/map_module/mapeditors/edit/' + map.id">
181+
@for (map of maps.all_maps; track $index) {
182+
<tr>
183+
<td class="text-center">
184+
@if (( PermissionsService.hasPermissionObservable(['MapModule', 'maps', 'delete'])|async ) || ( PermissionsService.hasPermissionObservable(['MapModule', 'maps', 'copy'])|async )) {
185+
<oitc-item-select
186+
[disabled]="!map.allowEdit"
187+
[item]="map"></oitc-item-select>
188+
}
189+
</td>
190+
<td class="word-break">
191+
<a *oitcPermission="['MapModule', 'mapeditors', 'view']"
192+
[routerLink]="['/', 'map_module', 'mapeditors', 'view', map.id, false]">
193+
{{ map.name }}
194+
</a>
195+
<span
196+
*oitcPermission="['MapModule', 'mapeditors', 'view']; negate: true">
197+
{{ map.name }}
198+
</span>
199+
@if (map.auto_generated) {
200+
<oitc-badge-outline class="ms-2"
201+
[title]="'Auto generated' | transloco"
202+
color="info"> {{ t('Auto generated') }}
203+
</oitc-badge-outline>
204+
}
205+
</td>
206+
<td class="word-break">{{ map.title }}</td>
200207

201-
<oitc-actions-button-element [permission]="'mapmodule.maps.edit'"
202-
[allow]="map.allowEdit"
208+
<td class="width-50">
209+
<oitc-actions-button [allowEdit]="map.allowEdit"
210+
[permission]="'mapmodule.maps.edit'"
203211
[url]="'/map_module/mapeditors/edit/' + map.id">
204-
<fa-icon [icon]="['fas', 'cog']"></fa-icon>
205-
{{ t('Edit in Map editor') }}
206-
</oitc-actions-button-element>
207-
<oitc-actions-button-element [permission]="'mapmodule.maps.edit'"
208-
[allow]="map.allowEdit"
209-
[url]="'/map_module/maps/edit/' + map.id">
210-
<fa-icon [icon]="['fas', 'edit']"></fa-icon>
211-
{{ t('Edit settings') }}
212-
</oitc-actions-button-element>
213-
<li cDropdownDivider *oitcPermission="['MapModule', 'maps', 'copy']"></li>
214-
<oitc-actions-button-element [permission]="'mapmodule.maps.copy'"
215-
[allow]="map.allowCopy"
216-
[url]="'/map_module/maps/copy/' + map.id">
217-
<fa-icon [icon]="['fas', 'copy']"></fa-icon>
218-
{{ t('Copy') }}
219-
</oitc-actions-button-element>
220-
<li cDropdownDivider></li>
221-
<oitc-actions-button-element [permission]="'mapmodule.mapeditors.view'"
222-
[url]="'/map_module/mapeditors/view/' + map.id + '/' + false">
223-
<fa-icon [icon]="['fas', 'eye']"></fa-icon>
224-
{{ t('View') }}
225-
</oitc-actions-button-element>
226-
<oitc-actions-button-element [permission]="'mapmodule.mapeditors.view'"
227-
[url]="'/map_module/mapeditors/view/' + map.id + '/' + true">
228-
<fa-icon [icon]="['fas', 'expand']"></fa-icon>
229-
{{ t('View in fullscreen') }}
230-
</oitc-actions-button-element>
231-
<li cDropdownDivider *oitcPermission="['MapModule', 'maps', 'delete']"></li>
232-
<oitc-actions-button-element (click)="toggleDeleteAllModal(map)"
233-
[permission]="'mapmodule.maps.delete'">
234-
<span class="text-danger">
235-
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
236-
{{ t('Delete') }}
237-
</span>
238-
</oitc-actions-button-element>
239-
</oitc-actions-button>
240-
</td>
241-
</tr>
242-
</tbody>
243-
</table>
244212

245-
<oitc-no-records *ngIf="maps && maps.all_maps.length === 0"></oitc-no-records>
246-
<ng-container *ngIf="maps && maps.all_maps">
247-
<c-container class="bg-secondary bg-opacity-10 mb-3 py-2 rounded-bottom border border-top-0"
248-
[fluid]="true">
249-
<c-row>
250-
<c-col>
251-
<oitc-select-all
252-
[itemsCount]="maps.all_maps.length"></oitc-select-all>
253-
</c-col>
254-
<c-col [sm]="8" [md]="5" [lg]="4" [xs]="3">
255-
<div class="btn-group d-flex flex-row" role="group">
256-
<button class="btn btn-outline-primary col-3 border-0" type="button"
257-
*oitcPermission="['MapModule', 'maps', 'copy']"
258-
(click)="navigateCopy()">
259-
<fa-icon [icon]="['fas', 'copy']"></fa-icon>
260-
{{ t('Copy') }}
261-
</button>
262-
<button (click)="toggleDeleteAllModal()"
263-
*oitcPermission="['MapModule', 'maps', 'delete']"
264-
class="btn btn-outline-danger col-3 border-0"
265-
type="button">
266-
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
267-
{{ t('Delete selected') }}
268-
</button>
269-
</div>
270-
</c-col>
271-
</c-row>
272-
</c-container>
273-
</ng-container>
213+
<oitc-actions-button-element [permission]="'mapmodule.maps.edit'"
214+
[allow]="map.allowEdit"
215+
[url]="'/map_module/mapeditors/edit/' + map.id">
216+
<fa-icon [icon]="['fas', 'cog']"></fa-icon>
217+
{{ t('Edit in Map editor') }}
218+
</oitc-actions-button-element>
219+
<oitc-actions-button-element [permission]="'mapmodule.maps.edit'"
220+
[allow]="map.allowEdit"
221+
[url]="'/map_module/maps/edit/' + map.id">
222+
<fa-icon [icon]="['fas', 'edit']"></fa-icon>
223+
{{ t('Edit settings') }}
224+
</oitc-actions-button-element>
225+
<li cDropdownDivider *oitcPermission="['MapModule', 'maps', 'copy']"></li>
226+
<oitc-actions-button-element [permission]="'mapmodule.maps.copy'"
227+
[allow]="map.allowCopy"
228+
[url]="'/map_module/maps/copy/' + map.id">
229+
<fa-icon [icon]="['fas', 'copy']"></fa-icon>
230+
{{ t('Copy') }}
231+
</oitc-actions-button-element>
232+
233+
@if (this.PermissionsService.hasPermissionObservable(['mapmodule', 'mapeditors', 'view'])|async) {
234+
@if (( this.PermissionsService.hasPermissionObservable(['mapmodule', 'mapeditors', 'edit'])|async ) ||
235+
( this.PermissionsService.hasPermissionObservable(['mapmodule', 'mapeditors', 'copy'])|async )) {
236+
<li cDropdownDivider></li>
237+
}
238+
<oitc-actions-button-element [permission]="'mapmodule.mapeditors.view'"
239+
[url]="'/map_module/mapeditors/view/' + map.id + '/' + false">
240+
<fa-icon [icon]="['fas', 'eye']"></fa-icon>
241+
{{ t('View') }}
242+
</oitc-actions-button-element>
243+
<oitc-actions-button-element [permission]="'mapmodule.mapeditors.view'"
244+
[url]="'/map_module/mapeditors/view/' + map.id + '/' + true">
245+
<fa-icon [icon]="['fas', 'expand']"></fa-icon>
246+
{{ t('View in fullscreen') }}
247+
</oitc-actions-button-element>
248+
}
249+
250+
@if (map.allowEdit && ( this.PermissionsService.hasPermissionObservable(['mapmodule', 'maps', 'delete'])|async )) {
251+
<li cDropdownDivider *oitcPermission="['MapModule', 'maps', 'delete']"></li>
252+
<oitc-actions-button-element (click)="toggleDeleteAllModal(map)"
253+
[permission]="'mapmodule.maps.delete'">
254+
<span class="text-danger">
255+
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
256+
{{ t('Delete') }}
257+
</span>
258+
</oitc-actions-button-element>
259+
}
260+
</oitc-actions-button>
261+
</td>
262+
</tr>
263+
}
264+
</tbody>
265+
</table>
266+
}
267+
@if (maps && maps.all_maps.length === 0) {
268+
<oitc-no-records></oitc-no-records>
269+
}
270+
271+
@if (maps && maps.all_maps) {
272+
<ng-container>
273+
<c-container class="bg-secondary bg-opacity-10 mb-3 py-2 rounded-bottom border border-top-0"
274+
[fluid]="true">
275+
<c-row>
276+
<c-col>
277+
<oitc-select-all
278+
[itemsCount]="maps.all_maps.length"></oitc-select-all>
279+
</c-col>
280+
<c-col [sm]="8" [md]="5" [lg]="4" [xs]="3">
281+
<div class="btn-group d-flex flex-row" role="group">
282+
<button class="btn btn-outline-primary col-3 border-0" type="button"
283+
*oitcPermission="['MapModule', 'maps', 'copy']"
284+
(click)="navigateCopy()">
285+
<fa-icon [icon]="['fas', 'copy']"></fa-icon>
286+
{{ t('Copy') }}
287+
</button>
288+
<button (click)="toggleDeleteAllModal()"
289+
*oitcPermission="['MapModule', 'maps', 'delete']"
290+
class="btn btn-outline-danger col-3 border-0"
291+
type="button">
292+
<fa-icon [icon]="['fas', 'trash']"></fa-icon>
293+
{{ t('Delete selected') }}
294+
</button>
295+
</div>
296+
</c-col>
297+
</c-row>
298+
</c-container>
299+
</ng-container>
300+
}
301+
302+
274303

275304
<c-container
276305
[fluid]="true">
277306
<c-row>
278307
<c-col>
279-
<oitc-paginate-or-scroll
280-
(paginatorChange)="onPaginatorChange($event)"
281-
*ngIf="maps"
282-
[paginateOrScroll]="maps"></oitc-paginate-or-scroll>
308+
@if (maps) {
309+
<oitc-paginate-or-scroll
310+
(paginatorChange)="onPaginatorChange($event)"
311+
[paginateOrScroll]="maps"></oitc-paginate-or-scroll>
312+
}
313+
283314
</c-col>
284315
</c-row>
285316
</c-container>

0 commit comments

Comments
 (0)