Skip to content

Commit

Permalink
Merge pull request #485 from MauroDataMapper/feature/gh-439_choose_da…
Browse files Browse the repository at this point in the history
…ta_spec

Feature/gh 439 choose data spec
  • Loading branch information
NigelPalmer authored Dec 10, 2024
2 parents 46e4f3f + 361ac5b commit 1b0e816
Show file tree
Hide file tree
Showing 54 changed files with 1,619 additions and 291 deletions.
2 changes: 1 addition & 1 deletion src/app/core/broadcast.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class BroadcastService {
submittingDataSpecification(message: string) {
this.loading({
isLoading: true,
caption: `Submitting your data specification - ${message}`,
caption: `Attaching your data specification - ${message}`,
fillviewport: false,
});
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ import { MatAutocompleteModule } from '@angular/material/autocomplete';
import {
SDE_RESOURCES_CONFIG,
SDE_REST_HANDLER_CONFIG,
MAURO_CORE_SERVICE,
SdeResourcesModule,
} from '@maurodatamapper/sde-resources';
import { ResearcherSdeResourcesConfig } from '../secure-data-environment/configuration/researcher-sde-resources.config';
import { environment } from 'src/environments/environment';
import { SdeMauroCoreService } from './sde-mauro-core.service';

const angularModules = [CommonModule, FormsModule, ReactiveFormsModule, RouterModule];
const primeNgModules = [CarouselModule];
Expand Down Expand Up @@ -99,6 +101,10 @@ const materialModules = [
baseUrl: environment.sdeResearcherEndpoint,
},
},
{
provide: MAURO_CORE_SERVICE,
useClass: SdeMauroCoreService,
},
],
})
export class CoreModule {
Expand Down
70 changes: 70 additions & 0 deletions src/app/core/sde-mauro-core.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2022-2023 University of Oxford
and Health and Social Care Information Centre, also known as NHS Digital
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
*/
import { Injectable } from '@angular/core';
import { IMauroCoreService, MauroDataSpecificationDTO } from '@maurodatamapper/sde-resources';
import { SecurityService } from '../security/security.service';
import { DataSpecificationService } from '../data-explorer/data-specification.service';
import { DataSpecification } from '../data-explorer/data-explorer.types';
import { map, Observable, of } from 'rxjs';
import { Uuid } from '@maurodatamapper/mdm-resources';
import { SpecificationSubmissionService } from '../data-explorer/specification-submission/services/specification-submission.service';
import { SubmissionType } from '../data-explorer/specification-submission/type-declarations/submission.resource';

@Injectable({
providedIn: 'root',
})
export class SdeMauroCoreService implements IMauroCoreService {
constructor(
private security: SecurityService,
private dataSpecification: DataSpecificationService,
private specificationSubmissionService: SpecificationSubmissionService
) {}

getFinalisedDataSpecifications(): Observable<MauroDataSpecificationDTO[]> {
const user = this.security.getSignedInUser();
if (user) {
return this.dataSpecification.list().pipe(
map((dataSpecifications: DataSpecification[]) => {
return dataSpecifications
.filter(
(dataSpecification) =>
dataSpecification.status === 'finalised' && !!dataSpecification.id
)
.map((dataSpecification: DataSpecification) => ({
mauroId: dataSpecification.id as Uuid,
name: `${dataSpecification.label} (${dataSpecification.modelVersion})`,
}));
})
);
} else {
return of([]);
}
}

attachMauroDataSpecificationToRequest(
specificationId: Uuid,
requestId: Uuid
): Observable<boolean> {
return this.specificationSubmissionService.submit(
specificationId,
SubmissionType.AttachPdfToRequest,
requestId
);
}
}
3 changes: 3 additions & 0 deletions src/app/data-explorer/data-explorer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ import { ArrowFormatPipe } from './query-builder/pipes/arrow-format-pipe';
import { SelectProjectDialogComponent } from './specification-submission/select-project-dialog/select-project-dialog.component';
import { ReadOnlyMeqlPipe } from './pipes/readonly-meql.pipe';
import { SimpleDialogComponent } from './simple-dialog/simple-dialog.component';
import { SpecificationSubmissionService } from './specification-submission/services/specification-submission.service';
import { SpecificationSubmissionWizardComponent } from './specification-submission/specification-submission-wizard/specification-submission-wizard.component';

const queryBuilderModules = [
QueryBuilderComponent,
Expand Down Expand Up @@ -120,6 +122,7 @@ const queryBuilderModules = [
VersionSelectorComponent,
SelectProjectDialogComponent,
LetDirective,
SpecificationSubmissionWizardComponent,
...queryBuilderModules,
],
imports: [CoreModule, SharedModule],
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-explorer/data-explorer.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export const mapProfileSearchResult = (item: ProfileSearchResult): DataElementSe
};
};

export type DataSpecificationStatus = 'draft' | 'finalised' | 'submitted';
export type DataSpecificationStatus = 'draft' | 'finalised' | 'attached to request' | 'submitted';

/**
* Define a data specification, which is an extension of a {@link DataModel}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ <h3 header-title class="header-title">
aria-label="Submit data specification"
(click)="onSubmitClick()"
>
<span class="fa-solid fa-paper-plane"></span>
Submit
<span class="fa-solid fa-paperclip"></span>
Attach to Request
</button>
<button
*ngIf="showViewRequestButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ export class DataSpecificationRowComponent implements OnChanges {
// Can only submit/share if finalised and user owns the data spec.
this.showSubmitButton = this.currentUserOwnsDataSpec && status === 'finalised';
this.showShareButton =
this.currentUserOwnsDataSpec && (status === 'finalised' || status === 'submitted');
this.showViewRequestButton = this.currentUserOwnsDataSpec && status === 'submitted';
this.currentUserOwnsDataSpec &&
(status === 'finalised' || status === 'attached to request' || status === 'submitted');
this.showViewRequestButton =
this.currentUserOwnsDataSpec && (status === 'attached to request' || status === 'submitted');
}

onSubmitClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ SPDX-License-Identifier: Apache-2.0
color: $color-submittedDataSpecification-contrast;
background-color: $color-submittedDataSpecification;
}

&--attached {
color: $color-attachedDataSpecification-contrast;
background-color: $color-attachedDataSpecification;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class DataSpecificationStatusChipComponent {
'mdm-data-specification-status-chip--draft': this.status === 'draft',
'mdm-data-specification-status-chip--finalised': this.status === 'finalised',
'mdm-data-specification-status-chip--submitted': this.status === 'submitted',
'mdm-data-specification-status-chip--attached': this.status === 'attached to request',
};
}
}
3 changes: 3 additions & 0 deletions src/app/data-explorer/data-specification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ export class DataSpecificationService {
return EMPTY;
}),
switchMap(([dataSpecification, dataElements]) => {
this.broadcast.loading({
isLoading: false,
});
this.broadcast.dispatch('data-specification-added');

return this.dialogs
Expand Down
13 changes: 13 additions & 0 deletions src/app/data-explorer/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import {
SelectProjectDialogData,
} from './specification-submission/select-project-dialog/select-project-dialog.component';
import { SimpleDialogComponent, SimpleDialogData } from './simple-dialog/simple-dialog.component';
import {
SpecificationSubmissionWizardComponent,
SubmissionWizardDialogData,
} from './specification-submission/specification-submission-wizard/specification-submission-wizard.component';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -163,4 +167,13 @@ export class DialogService {
}
);
}

openSubmissionWizard(data: SubmissionWizardDialogData) {
return this.matDialog.open<SpecificationSubmissionWizardComponent, SubmissionWizardDialogData>(
SpecificationSubmissionWizardComponent,
{
data,
}
);
}
}
8 changes: 7 additions & 1 deletion src/app/data-explorer/pipes/readonly-meql.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'readOnlyMeql', pure: false })
export class ReadOnlyMeqlPipe implements PipeTransform {
transform(status: string, isEmpty: boolean, currentUserOwnsDataSpec: boolean): boolean {
return status === 'finalised' || status === 'submitted' || isEmpty || !currentUserOwnsDataSpec;
return (
status === 'finalised' ||
status === 'attached to request' ||
status === 'submitted' ||
isEmpty ||
!currentUserOwnsDataSpec
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ export class AttachmentsService {
private fileEndpoints: FileEndpoints
) {}

attachmentsAreRequired(
dataRequestId: Uuid,
attachmentType: AttachmentType
): Observable<StepResult> {
return this.requestEndpoints.listAttachments(dataRequestId).pipe(
attachmentsAreRequired(requestId: Uuid, attachmentType: AttachmentType): Observable<StepResult> {
return this.requestEndpoints.listAttachments(requestId).pipe(
map((attachmentsList) => {
const isRequired = !attachmentsList.some(
(attachment) => attachment.attachmentType === attachmentType
Expand All @@ -56,7 +53,7 @@ export class AttachmentsService {
}

attachFile(
dataRequestId: Uuid,
requestId: Uuid,
fileProperties: FileProperties,
attachmentType: AttachmentType,
dataSpecificationId: Uuid
Expand All @@ -80,7 +77,7 @@ export class AttachmentsService {
return EMPTY; // Emit nothing for progress events
} else {
return this.requestEndpoints
.attachFile(dataRequestId, uploadEvent.fileId, attachmentType, dataSpecificationId)
.attachFile(requestId, uploadEvent.fileId, attachmentType, dataSpecificationId)
.pipe(
map(() => {
// Process the final result here
Expand Down
Loading

0 comments on commit 1b0e816

Please sign in to comment.