Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 87e20c86 authored by Sebastian-Ion TINCU's avatar Sebastian-Ion TINCU
Browse files

EDELIVERY-4014 "+" icon for Service metadata on search/edit page is

Extract logic to controllers to allow them to step in when deciding if
the row expander should be disabled or not even when the rows are not
disabled themselves (e.g. when they were previously deleted).
parent 790101fc
No related branches found
No related tags found
No related merge requests found
......@@ -10,4 +10,11 @@ export interface SearchTableController {
newRow(): SearchTableEntity;
newDialog(config?: MatDialogConfig): MatDialogRef<any>;
dataSaved();
/**
* Returns whether the row expander should be shown as disabled even when the actual row is not fully disabled.
*
* @param row the row for which the row expander should be disabled or not
*/
isRowExpanderDisabled(row: SearchTableEntity): boolean;
}
......@@ -85,8 +85,8 @@
</ng-template>
<ng-template #rowExpand let-row="row" let-expanded="expanded" let-disabled="disabled" ngx-datatable-cell-template >
<span *ngIf="disabled || row.serviceMetadata?.length === 0">()</span>
<a *ngIf="!disabled && row.serviceMetadata?.length" class="table-button-expand"
<span *ngIf="isRowExpanderDisabled(row, disabled)">()</span>
<a *ngIf="!isRowExpanderDisabled(row, disabled)" class="table-button-expand"
href="javascript:void(0)"
title="Expand/Collapse Row"
(click)="toggleExpandRow(row)">{{expanded?'(-)':'(+)'}}
......
......@@ -332,6 +332,10 @@ export class SearchTableComponent implements OnInit {
return !(!this.submitButtonsEnabled || this.forceRefresh);
}
isRowExpanderDisabled(row: any, rowDisabled: boolean): boolean {
return rowDisabled || this.searchTableController.isRowExpanderDisabled(row);
}
private editSearchTableEntity(rowNumber: number) {
const row = this.rows[rowNumber];
const formRef: MatDialogRef<any> = this.searchTableController.newDialog({
......
......@@ -61,4 +61,8 @@ export class DomainController implements SearchTableController {
stringMessage: '',
}
}
isRowExpanderDisabled(row: SearchTableEntity): boolean {
return false;
}
}
......@@ -8,6 +8,7 @@ import {ServiceGroupMetadataDialogComponent} from "./service-group-metadata-dial
import {of} from "rxjs/internal/observable/of";
import {SearchTableValidationResult} from "../common/search-table/search-table-validation-result.model";
import {SearchTableEntity} from "../common/search-table/search-table-entity.model";
import {ServiceGroupSearchRo} from "../service-group-search/service-group-search-ro.model";
export class ServiceGroupEditController implements SearchTableController {
......@@ -84,4 +85,8 @@ export class ServiceGroupEditController implements SearchTableController {
}
}
isRowExpanderDisabled(row: ServiceGroupEditRo): boolean {
const serviceGroup = <ServiceGroupEditRo>row;
return !(serviceGroup.serviceMetadata && serviceGroup.serviceMetadata.length);
}
}
......@@ -4,6 +4,7 @@ import {ServiceGroupSearchRo} from './service-group-search-ro.model';
import {of} from "rxjs/internal/observable/of";
import {SearchTableValidationResult} from "../common/search-table/search-table-validation-result.model";
import {SearchTableEntity} from "../common/search-table/search-table-entity.model";
import {ServiceGroupEditRo} from "../service-group-edit/service-group-edit-ro.model";
export class ServiceGroupSearchController implements SearchTableController {
......@@ -39,4 +40,9 @@ export class ServiceGroupSearchController implements SearchTableController {
stringMessage: message,
}
}
isRowExpanderDisabled(row: SearchTableEntity): boolean {
const serviceGroup = <ServiceGroupSearchRo>row;
return !(serviceGroup.serviceMetadata && serviceGroup.serviceMetadata.length);
}
}
......@@ -4,11 +4,8 @@ import {UserDetailsDialogComponent} from './user-details-dialog/user-details-dia
import {UserRo} from './user-ro.model';
import {SearchTableEntityStatus} from '../common/search-table/search-table-entity-status.model';
import {GlobalLookups} from "../common/global-lookups";
import {CertificateRo} from "./certificate-ro.model";
import {SearchTableEntity} from "../common/search-table/search-table-entity.model";
import {of} from "rxjs/internal/observable/of";
import {SearchTableValidationResult} from "../common/search-table/search-table-validation-result.model";
import {ServiceMetadataValidationEditRo} from "../service-group-edit/service-group-metadata-dialog/service-metadata-validation-edit-ro.model";
import {SmpConstants} from "../smp.constants";
import {HttpClient} from "@angular/common/http";
......@@ -64,7 +61,8 @@ export class UserController implements SearchTableController {
}
}
isRowExpanderDisabled(row: SearchTableEntity): boolean {
return false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment