Skip to content

Commit

Permalink
Merge branch 'develop' into feature/gh-682
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrwelch authored Dec 7, 2022
2 parents ddac2ca + fef2ee4 commit 4292b47
Show file tree
Hide file tree
Showing 21 changed files with 320 additions and 186 deletions.
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

<main ui-view></main>

<mdm-footer
class="app-footer"
[version]="appVersion"
[copyright]="copyright"
[links]="footerLinks"
></mdm-footer>

<mdm-loading-indicator></mdm-loading-indicator>
</div>

<mdm-footer
class="app-footer"
[version]="appVersion"
[copyright]="copyright"
[links]="footerLinks"
></mdm-footer>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h4 mat-dialog-title>Edit Profile - {{ data.profileName }}</h4>
enctype="multipart/form-data"
method="POST"
>
<mdm-alert *ngIf="data.finalised" alertStyle="info" showIcon="true">
<mdm-alert *ngIf="data.finalised && showCanEditPropertyAlert" alertStyle="info" showIcon="true">
Only certain fields can be edited on this profile as the catalogue item is
finalised.
</mdm-alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
MAT_DIALOG_DATA
} from '@angular/material/dialog';
import {
ApiProperty,
ApiPropertyIndexResponse,
Profile,
ProfileField,
ProfileValidationError,
Expand All @@ -35,6 +37,7 @@ import { ModalDialogStatus } from '@mdm/constants/modal-dialog-status';
import { MdmResourcesService } from '@mdm/modules/resources';
import { ElementSelectorComponent } from '@mdm/utility/element-selector.component';
import { MarkdownParserService } from '@mdm/utility/markdown/markdown-parser/markdown-parser.service';
import { MessageHandlerService } from '@mdm/services';
import { EMPTY, Observable, of } from 'rxjs';
import { catchError, finalize, map, switchMap } from 'rxjs/operators';
import {
Expand All @@ -51,12 +54,14 @@ export class EditProfileModalComponent implements OnInit {
profileData: Profile;
description?: string;
okBtnText: string;
showCanEditPropertyAlert = true;
validationErrors: ProfileValidationErrorList = {
total: 0,
fieldTotal: 0,
errors: []
};
isValidated = false;
private readonly showCanEditPropertyAlertKey = 'ui.show_can_edit_property_alert';

formOptionsMap = {
integer: 'number',
Expand All @@ -78,6 +83,7 @@ export class EditProfileModalComponent implements OnInit {
private markdownParser: MarkdownParserService,
protected resources: MdmResourcesService,
private dialog: MatDialog,
private messageHandler: MessageHandlerService,
protected editing: EditingService
) {
data.profile.sections.forEach((section) => {
Expand Down Expand Up @@ -107,7 +113,19 @@ export class EditProfileModalComponent implements OnInit {
this.okBtnText = data.okBtn ?? 'Save';
}

ngOnInit(): void {}
ngOnInit(): void {
this.resources.apiProperties
.listPublic()
.pipe(
catchError(errors => {
this.messageHandler.showError('There was a problem getting the configuration properties.', errors);
return [];
})
)
.subscribe((response: ApiPropertyIndexResponse) => {
this.loadDefaultCustomProfile(response.body.items);
});
}

save() {
this.validateData()
Expand Down Expand Up @@ -237,4 +255,12 @@ export class EditProfileModalComponent implements OnInit {
finalize(() => (this.isValidated = true))
);
}

private loadDefaultCustomProfile(properties: ApiProperty[]) {
this.showCanEditPropertyAlert = JSON.parse(this.getContentProperty(properties, this.showCanEditPropertyAlertKey));
}

private getContentProperty(properties: ApiProperty[], key: string): string {
return properties?.find(p => p.key === key)?.value;
}
}
8 changes: 8 additions & 0 deletions src/app/model/api-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,13 @@ export const propertyMetadata: ApiPropertyMetadata[] = [
isSystem: true,
publiclyVisible: true,
requiresReload: true
},
{
key: 'ui.show_can_edit_property_alert',
category: 'UI',
editType: ApiPropertyEditType.Boolean,
isSystem: true,
publiclyVisible: true,
requiresReload: true
}
];
19 changes: 18 additions & 1 deletion src/app/services/element-types.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,24 @@ export class ElementTypesService {
markdown: 'dt',
classifiable: true
},

PrimitiveType: {
id: 'PrimitiveType',
link: 'dataType',
title: 'PrimitiveType',
resourceName: 'dataType',
domainName: 'dataTypes',
markdown: 'dt',
classifiable: true
},
EnumerationType: {
id: 'EnumerationType',
link: 'dataType',
title: 'EnumerationType',
resourceName: 'dataType',
domainName: 'dataTypes',
markdown: 'dt',
classifiable: true
},
Classifier: {
id: 'Classifier',
link: 'classifier',
Expand Down
12 changes: 11 additions & 1 deletion src/app/services/handlers/security-handler.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { MdmResourcesService } from '@mdm/modules/resources';
import { UserDetails } from './security-handler.model';
import { cold } from 'jest-marbles';
import { HttpErrorResponse } from '@angular/common/http';
import { LoginPayload } from '@maurodatamapper/mdm-resources';
import { LoginPayload, Securable } from '@maurodatamapper/mdm-resources';

interface MdmSecurityResourceStub {
login: jest.Mock;
Expand Down Expand Up @@ -119,4 +119,14 @@ describe('SecurityHandlerService', () => {
const actual$ = service.signIn({ username: 'fail', password: 'fail' });
expect(actual$).toBeObservable(expected$);
});

it('should return showPermission when element is editable after finalization', () => {
const dataModel: Securable = {
availableActions: ['finalisedEditActions']
};
const actual$ = service.elementAccess(
dataModel
);
expect(actual$.showPermission).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion src/app/services/handlers/security-handler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class SecurityHandlerService {
showEdit: element.availableActions?.includes('update'),
canEditDescription: element.availableActions?.includes('editDescription'),
showFinalise: element.availableActions?.includes('finalise'),
showPermission: element.availableActions?.includes('update'),
showPermission: element.availableActions?.includes('update') || element.availableActions?.includes('finalisedEditActions'),
showSoftDelete: element.availableActions?.includes('softDelete'),
showPermanentDelete: element.availableActions?.includes('delete'),
canAddAnnotation: element.availableActions?.includes('comment'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,43 @@ <h4 class="marginless">Classified Elements</h4>
</div>
</td>
</ng-container>
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef mat-sort-header="domainType" [disabled]="!hideFilters" style="cursor:pointer;max-width: 15%;width: 15%; text-align: center;" columnName="type" scope="col">
<ng-container matColumnDef="domainType">
<th mat-header-cell
*matHeaderCellDef
mat-sort-header
[disabled]="!hideFilters"
style="cursor:pointer;max-width: 15%;width: 15%; text-align: center;"
columnName="domainType"
sortable="true"
filterable="true"
scope="col">
<span [hidden]="!hideFilters">Type</span>
<!-- <div [hidden]="hideFilters">
<mat-label>Type</mat-label>
<mat-select [(value)]="domainType"
name="domainType"
[(ngModel)]="domainType"
(ngModelChange)="applyMatSelectFilter($event, 'domainType')">
<mat-option></mat-option>
<mat-option [value]="baseType.id" *ngFor="let baseType of classifiableBaseTypes">{{baseType.title}}</mat-option>
</mat-select>
</div> -->
<div [hidden]="hideFilters">
<mat-label>Type</mat-label>
<mat-select
[(value)]="domainType"
name="domainType"
[(ngModel)]="domainType"
(ngModelChange)="applyMatSelectFilter()"
>
<mat-option [value]="dt" *ngFor="let dt of allDataTypes">{{
dt.title
}}</mat-option>
</mat-select>
</div>
</th>
<td mat-cell *matCellDef="let record" style="max-width: 15%;width: 15%;text-align: left;word-wrap: break-word;" >
<mdm-element-link [element]="record" [showLink]="false" [showTypeTitle]="true"></mdm-element-link>
<td mat-cell *matCellDef="let record">
<div *ngIf="allDataTypesMap[record?.domainType]?.title">
{{ allDataTypesMap[record?.domainType]['title'] }}
</div>
<div class="full-width">
<mdm-element-data-type
[elementDataType]="record"
[hideName]="true"
[onlyShowRefDataClass]="true"
[hideEnumList]="false"
></mdm-element-data-type>
</div>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class ClassifiedElementsListComponent implements OnInit, AfterViewInit {
@ViewChild(MatSort, { static: false }) sort: MatSort;
@ViewChild(MdmPaginatorComponent, { static: true }) paginator: MdmPaginatorComponent;

allDataTypes: any;
allDataTypesMap: any;
checkAllCheckbox = false;
processing: boolean;
failCount: number;
Expand All @@ -62,8 +64,8 @@ export class ClassifiedElementsListComponent implements OnInit, AfterViewInit {
loading: boolean;
totalItemCount = 0;
isLoadingResults = true;
filterEvent = new EventEmitter<string>();
filter: string;
filterEvent = new EventEmitter<any>();
filter: {};
deleteInProgress: boolean;
domainType;

Expand All @@ -79,7 +81,7 @@ export class ClassifiedElementsListComponent implements OnInit, AfterViewInit {
private gridService: GridService
) { }
ngOnInit(): void {
this.displayedColumns = ['label', 'description', 'type'];
this.displayedColumns = ['label', 'description', 'domainType'];
this.isLoadingResults = false;
}

Expand All @@ -92,6 +94,9 @@ export class ClassifiedElementsListComponent implements OnInit, AfterViewInit {
this.classifiableBaseTypes = this.baseTypes.filter(f => f.classifiable === true);
this.classifiableBaseTypes = [{ id: '', title: '' }].concat(this.classifiableBaseTypes);

this.allDataTypes = this.classifiableBaseTypes;
this.allDataTypesMap = this.getClassifiableBaseTypesMap();

merge(this.sort.sortChange, this.paginator.page, this.filterEvent).pipe(startWith({}), switchMap(() => {
this.isLoadingResults = true;

Expand Down Expand Up @@ -130,30 +135,39 @@ export class ClassifiedElementsListComponent implements OnInit, AfterViewInit {
}

applyFilter = () => {
let filter: any = '';
const filter = {};
this.filters.forEach((x: any) => {
const name = x.nativeElement.name;
const value = x.nativeElement.value;

if (value !== '') {
filter += `${name}=${value}&`;
filter[name] = value;
}
});

if (this.filterValue !== null && this.filterValue !== undefined && this.filterName !== null && this.filterName !== undefined) {
filter += `${this.filterName}=${this.filterValue}&`;
if (this.domainType) {
if (this.domainType.id !== 'DataType') {
filter['domainType'] = this.domainType.id;
}
}
this.filter = filter.substring(0, filter.length - 1);

this.filter = filter;
this.filterEvent.emit(filter);
};

applyMatSelectFilter(filterValue: any, filterName) {
this.filterValue = filterValue;
if (this.filterValue !== '') { this.filterName = filterName; } else { this.filterName = ''; }
applyMatSelectFilter() {
this.applyFilter();
}

filterClick = () => {
this.hideFilters = !this.hideFilters;
};

getClassifiableBaseTypesMap() {
const dataTypes = this.allDataTypes;
const dtMap = {};
dataTypes.forEach((dt) => {
dtMap[dt.id] = dt;
});
return dtMap;
}
}
9 changes: 1 addition & 8 deletions src/app/shared/models/models.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,7 @@
</div>
</div>
</div>
<div
style="
width: 100%;
clear: left;
height: calc(100vh - 168px);
overflow-y: auto;
"
>
<div style="width: 100%; clear: left; overflow-y: auto">
<div
style="margin: 3px 0px 0px 0px"
*ngIf="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
</div>

<mdm-alert
*ngIf="catalogueItem.finalised && canEditCustomProfile"
*ngIf="catalogueItem.finalised && canEditCustomProfile && showCanEditPropertyAlert"
alertStyle="info"
showIcon="true"
>
Expand Down
Loading

0 comments on commit 4292b47

Please sign in to comment.