Skip to content

Commit

Permalink
gh-439: Choose data specification
Browse files Browse the repository at this point in the history
  • Loading branch information
NigelPalmer committed Nov 21, 2024
1 parent 46e4f3f commit a99bf14
Show file tree
Hide file tree
Showing 53 changed files with 1,503 additions and 246 deletions.
9 changes: 7 additions & 2 deletions src/app/core/broadcast.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export type BroadcastEvent =
| 'data-bookmarks-refreshed'
| 'loading';

export enum StepRunnerIntent {
Submitting = 'Submitting',
Attaching = 'Attaching',
}

/**
* Represents a message to broadcast with an optional data payload.
*/
Expand Down Expand Up @@ -113,10 +118,10 @@ export class BroadcastService {
*
* @param message The message to show
*/
submittingDataSpecification(message: string) {
submittingDataSpecification(message: string, stepRunnerIntent: StepRunnerIntent) {
this.loading({
isLoading: true,
caption: `Submitting your data specification - ${message}`,
caption: `${stepRunnerIntent} 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
76 changes: 76 additions & 0 deletions src/app/core/sde-mauro-core.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
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[]> {
// return [{ mauroId: '1', name: 'My Name' } as MauroDataSpecificationDTO];

console.log('NIGE - getFinalisedDataSpecifications');
const user = this.security.getSignedInUser();
if (user) {
console.log('NIGE - getFinalisedDataSpecifications - has 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 {
console.log('NIGE - getFinalisedDataSpecifications - no user');
return of([]);
}
}

attachMauroDataSpecificationToRequest(
specificationId: Uuid,
requestId: Uuid
): Observable<boolean> {
console.log('NIGE - attachDataSpecificationToRequest');
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',
};
}
}
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,9 @@ 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> {
console.log('NIGE - AttachmentsService - attachmentsAreRequired');
return this.requestEndpoints.listAttachments(requestId).pipe(
map((attachmentsList) => {
const isRequired = !attachmentsList.some(
(attachment) => attachment.attachmentType === attachmentType
Expand All @@ -56,7 +54,7 @@ export class AttachmentsService {
}

attachFile(
dataRequestId: Uuid,
requestId: Uuid,
fileProperties: FileProperties,
attachmentType: AttachmentType,
dataSpecificationId: Uuid
Expand All @@ -80,7 +78,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 a99bf14

Please sign in to comment.