-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow partial export #522
Open
ClFeSc
wants to merge
15
commits into
dev
Choose a base branch
from
feature/392-partial-exports
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Allow partial export #522
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cf17cc3
Allow partial export
ClFeSc f7c99b3
Allow importing partial exports
ClFeSc a4fbbbb
WIP: Migrate partial export
ClFeSc d881d74
Remove `alarmGroups` when overwriting `vehicleTemplates`
ClFeSc 548ba0f
Apply suggestions from code review
ClFeSc a1e0789
Merge remote-tracking branch 'origin/dev' into feature/392-partial-ex…
ClFeSc f294749
Fix validation decorators on new parts
ClFeSc 2375b6b
Perform migration of partial export in frontend & remove redundant va…
ClFeSc 99dc5a6
Only remove `alarmGroupVehicles` and not all `alarmGroups`
ClFeSc 4c29288
Rename `PartialExportSelectionComponent` to `PartialExportComponent`
ClFeSc 5df1efa
Rename `PartialImportOverwriteComponent` to `PartialImportModalCompon…
ClFeSc 91b950f
Rename some variables for clarity
ClFeSc 0859757
Review: Refactorings
ClFeSc 265574c
Merge remote-tracking branch 'origin/dev' into feature/392-partial-ex…
ClFeSc 09649a3
Fix prettier
ClFeSc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...app/pages/exercises/exercise/shared/partial-export/open-partial-export-selection-modal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { PartialExportComponent } from './partial-export-modal/partial-export-modal.component'; | ||
|
||
export function openPartialExportSelectionModal(ngbModalService: NgbModal) { | ||
ngbModalService.open(PartialExportComponent, { | ||
size: 'm', | ||
}); | ||
} |
47 changes: 47 additions & 0 deletions
47
...s/exercise/shared/partial-export/partial-export-modal/partial-export-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<div class="modal-header"> | ||
<h4 class="modal-title">Partieller Export</h4> | ||
<button type="button" class="btn-close" (click)="close()"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<p>Wählen Sie aus, welche Vorlagen exportiert werden sollen.</p> | ||
<ul class="list-group list-group-flush"> | ||
<li class="list-group-item"> | ||
<input | ||
[(ngModel)]="configuration.patientCategories" | ||
class="form-check-input" | ||
type="checkbox" | ||
/> | ||
Patientenvorlagen | ||
</li> | ||
<li class="list-group-item"> | ||
<input | ||
[(ngModel)]="configuration.vehicleTemplates" | ||
class="form-check-input" | ||
type="checkbox" | ||
/> | ||
Fahrzeugvorlagen | ||
</li> | ||
<li class="list-group-item"> | ||
<input | ||
[(ngModel)]="configuration.mapImageTemplates" | ||
class="form-check-input" | ||
type="checkbox" | ||
/> | ||
Bildvorlagen | ||
</li> | ||
</ul> | ||
<br /> | ||
<button | ||
(click)="partialExport()" | ||
[disabled]=" | ||
!( | ||
configuration.mapImageTemplates || | ||
configuration.patientCategories || | ||
configuration.vehicleTemplates | ||
) | ||
" | ||
class="btn btn-primary" | ||
> | ||
Exportieren | ||
</button> | ||
</div> |
Empty file.
62 changes: 62 additions & 0 deletions
62
...ses/exercise/shared/partial-export/partial-export-modal/partial-export-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,62 @@ | ||||||
import { Component } from '@angular/core'; | ||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||||||
import { Store } from '@ngrx/store'; | ||||||
import { cloneDeepMutable, PartialExport } from 'digital-fuesim-manv-shared'; | ||||||
import { saveBlob } from 'src/app/shared/functions/save-blob'; | ||||||
import type { AppState } from 'src/app/state/app.state'; | ||||||
import { selectExerciseState } from 'src/app/state/application/selectors/exercise.selectors'; | ||||||
import { selectStateSnapshot } from 'src/app/state/get-state-snapshot'; | ||||||
|
||||||
interface PartialExportConfiguration { | ||||||
patientCategories: boolean; | ||||||
vehicleTemplates: boolean; | ||||||
mapImageTemplates: boolean; | ||||||
} | ||||||
|
||||||
@Component({ | ||||||
selector: 'app-partial-export-modal', | ||||||
templateUrl: './partial-export-modal.component.html', | ||||||
styleUrls: ['./partial-export-modal.component.scss'], | ||||||
}) | ||||||
export class PartialExportComponent { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
constructor( | ||||||
private readonly store: Store<AppState>, | ||||||
private readonly activeModal: NgbActiveModal | ||||||
) {} | ||||||
|
||||||
public configuration: PartialExportConfiguration = { | ||||||
mapImageTemplates: false, | ||||||
patientCategories: false, | ||||||
vehicleTemplates: false, | ||||||
}; | ||||||
|
||||||
public close() { | ||||||
this.activeModal.close(); | ||||||
} | ||||||
|
||||||
public partialExport() { | ||||||
const currentState = selectStateSnapshot( | ||||||
selectExerciseState, | ||||||
this.store | ||||||
); | ||||||
const patientCategories = this.configuration.patientCategories | ||||||
? currentState.patientCategories | ||||||
: undefined; | ||||||
const vehicleTemplates = this.configuration.vehicleTemplates | ||||||
? currentState.vehicleTemplates | ||||||
: undefined; | ||||||
const mapImageTemplates = this.configuration.mapImageTemplates | ||||||
? currentState.mapImageTemplates | ||||||
: undefined; | ||||||
const blob = new Blob([ | ||||||
JSON.stringify( | ||||||
new PartialExport( | ||||||
cloneDeepMutable(patientCategories), | ||||||
cloneDeepMutable(vehicleTemplates), | ||||||
cloneDeepMutable(mapImageTemplates) | ||||||
) | ||||||
), | ||||||
]); | ||||||
saveBlob(blob, `exercise-partial-${currentState.participantId}.json`); | ||||||
} | ||||||
} |
19 changes: 19 additions & 0 deletions
19
...app/pages/exercises/exercise/shared/partial-import/open-partial-import-overwrite-modal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import type { PartialExport } from 'digital-fuesim-manv-shared'; | ||
import { PartialImportModalComponent } from './partial-import-modal/partial-import-modal.component'; | ||
|
||
/** | ||
* | ||
* @param partialExport The migrated {@link PartialExport} to import. | ||
*/ | ||
export function openPartialImportOverwriteModal( | ||
ngbModalService: NgbModal, | ||
partialExport: PartialExport | ||
) { | ||
const modelRef = ngbModalService.open(PartialImportModalComponent, { | ||
size: 'm', | ||
}); | ||
const componentInstance = | ||
modelRef.componentInstance as PartialImportModalComponent; | ||
componentInstance.partialExport = partialExport; | ||
} |
41 changes: 41 additions & 0 deletions
41
...s/exercise/shared/partial-import/partial-import-modal/partial-import-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<div class="modal-header"> | ||
<h4 class="modal-title">Vorlagenimport</h4> | ||
<button type="button" class="btn-close" (click)="close()"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<p> | ||
Wollen Sie die vorhandenen Vorlagen mit den importierten Vorlagen | ||
ergänzen oder überschreiben? | ||
</p> | ||
<button | ||
type="button" | ||
class="btn btn-primary me-5" | ||
[disabled]="importingPartialExport" | ||
(click)="partialImportOverwrite('append')" | ||
> | ||
Ergänzen | ||
</button> | ||
<button | ||
type="button" | ||
class="btn btn-danger" | ||
[disabled]="importingPartialExport" | ||
(click)="partialImportOverwrite('overwrite')" | ||
> | ||
Überschreiben | ||
</button> | ||
<div *ngIf="importingPartialExport"> | ||
<span class="spinner-border spinner-border-sm"></span> | ||
Import läuft | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button | ||
type="button" | ||
class="btn btn-outline-secondary m-0" | ||
[appAutofocus]="true" | ||
[disabled]="importingPartialExport" | ||
(click)="close()" | ||
> | ||
Abbrechen | ||
</button> | ||
</div> |
Empty file.
59 changes: 59 additions & 0 deletions
59
...ses/exercise/shared/partial-import/partial-import-modal/partial-import-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||||||
import { Component } from '@angular/core'; | ||||||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||||||||||
import { plainToInstance } from 'class-transformer'; | ||||||||||
import { | ||||||||||
PartialExport, | ||||||||||
preparePartialExportForImport, | ||||||||||
} from 'digital-fuesim-manv-shared'; | ||||||||||
import { ExerciseService } from 'src/app/core/exercise.service'; | ||||||||||
import { MessageService } from 'src/app/core/messages/message.service'; | ||||||||||
|
||||||||||
@Component({ | ||||||||||
selector: 'app-partial-import-modal', | ||||||||||
templateUrl: './partial-import-modal.component.html', | ||||||||||
styleUrls: ['./partial-import-modal.component.scss'], | ||||||||||
}) | ||||||||||
export class PartialImportModalComponent { | ||||||||||
public importingPartialExport = false; | ||||||||||
constructor( | ||||||||||
public activeModal: NgbActiveModal, | ||||||||||
private readonly messageService: MessageService, | ||||||||||
private readonly exerciseService: ExerciseService | ||||||||||
) {} | ||||||||||
|
||||||||||
public partialExport!: PartialExport; | ||||||||||
|
||||||||||
public close() { | ||||||||||
this.activeModal.close(); | ||||||||||
} | ||||||||||
|
||||||||||
public async partialImportOverwrite(mode: 'append' | 'overwrite') { | ||||||||||
this.importingPartialExport = true; | ||||||||||
try { | ||||||||||
const importInstance = plainToInstance( | ||||||||||
PartialExport, | ||||||||||
this.partialExport | ||||||||||
); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You should be able to use |
||||||||||
const result = await this.exerciseService.proposeAction({ | ||||||||||
type: '[Exercise] Import Templates', | ||||||||||
mode, | ||||||||||
partialExport: preparePartialExportForImport(importInstance), | ||||||||||
}); | ||||||||||
if (!result.success) { | ||||||||||
throw new Error((result as { message?: string }).message); | ||||||||||
} | ||||||||||
this.messageService.postMessage({ | ||||||||||
title: 'Vorlagen erfolgreich importiert', | ||||||||||
color: 'success', | ||||||||||
}); | ||||||||||
this.close(); | ||||||||||
} catch (error: unknown) { | ||||||||||
this.messageService.postError({ | ||||||||||
title: 'Fehler beim Importieren von Vorlagen', | ||||||||||
error, | ||||||||||
}); | ||||||||||
} finally { | ||||||||||
this.importingPartialExport = false; | ||||||||||
} | ||||||||||
} | ||||||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.