Commit d0065cbc authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'release/1.20.0' into 'master'

Release: merge 'release-1-20-0' into 'master' created by Enriko Käsper

See merge request teis/public-web-client!580
parents 6d8c2179 11996eb3
{
"name": "te-is",
"version": "1.20.0",
"version": "1.20.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "te-is",
"version": "1.20.0",
"version": "1.20.1",
"license": "MIT",
"scripts": {
"ng": "ng",
......
......@@ -7,6 +7,9 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
import { CompanyDetailsFacade } from '@official/features/company-details/company-details.facade.service';
import { catchError, skip } from 'rxjs/operators';
import { HttpErrorResponse } from '@angular/common/http';
import { RiskAssessmentPublicDto } from '@teis/services/risk-assessments/risk-assessments.models';
import { removeArrayItem } from '@teis/utils';
import { MessageContext } from '@ska-angular/core';
@Component({
selector: 'teis-risk-assessment-add-documents',
......@@ -28,6 +31,7 @@ export class RiskAssessmentAddDocumentsComponent implements OnInit, OnDestroy {
constructor(
private translate: TranslateService,
private facade: CompanyDetailsFacade,
private message: MessageContext,
) { }
ngOnInit(): void {
......@@ -76,7 +80,7 @@ export class RiskAssessmentAddDocumentsComponent implements OnInit, OnDestroy {
if (!uploading) {
this.saving = false;
this.facade.closeModal();
}
this.message.addToastSuccess('risk_assessment_saved', 3000);}
});
this.subscriptions$ = [createRiskAssessment$, filesUploading$];
......@@ -90,11 +94,7 @@ export class RiskAssessmentAddDocumentsComponent implements OnInit, OnDestroy {
}
fileRemoved(file: EntityFile) {
this.selectedFiles = this.selectedFiles.reduce((acc, currentFile) => {
if (currentFile.localId !== file.localId) acc.push(currentFile);
return acc;
}, []);
this.selectedFiles = removeArrayItem(file, 'localId', [...this.selectedFiles]);
}
handleLoading(isLoading: boolean) {
......
......@@ -1007,5 +1007,7 @@
"default_risk_assessment_header": "TI'le esitatud riskianalüüs",
"risk_assessments_title": "Dokumendid",
"archived": "Arhiveeritud",
"uploaded_in_TI_app": "TI-s üles laaditud"
}
\ No newline at end of file
"uploaded_in_TI_app": "TI-s üles laaditud",
"upload_files": "Lae üles faile",
"risk_assessment_saved": "Riskianalüüs on salvestatud"
}
......@@ -450,5 +450,6 @@
"megabyte": "MB",
"gigabyte": "GB",
"terabyte": "TB",
"petabyte": "PB"
"petabyte": "PB",
"risk_assessment_published": "Risk assessment is published"
}
......@@ -451,5 +451,6 @@
"megabyte": "MB",
"gigabyte": "GB",
"terabyte": "TB",
"petabyte": "PB"
"petabyte": "PB",
"risk_assessment_published": "Riskianalüüs on esitatud"
}
......@@ -450,5 +450,6 @@
"megabyte": "МБ",
"gigabyte": "ГБ",
"terabyte": "TБ",
"petabyte": "PБ"
"petabyte": "PБ",
"risk_assessment_published": "Risk assessment is published"
}
<teis-header
[title]="title">
<teis-icon
*ngIf="!currentRiskAssessment || currentRiskAssessment?.status?.code === riskAssessmentStatus.IN_PROGRESS"
*ngIf="currentRiskAssessment || currentRiskAssessment?.status?.code === riskAssessmentStatus.IN_PROGRESS"
subtitle
id="edit-riskassessment-title"
(click)="editTitle()"
......
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { RiskAssessmentsFacadeService } from '@teis/features/risk-assessments/risk-assessments-facade.service';
import { of, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';
import { triggerValidation } from '@teis/utils';
import { take } from 'rxjs/operators';
import { CreateRiskAssessmentService } from '@teis/features/risk-assessments/services/create-risk-assessment.service';
import { MessageContext } from '@ska-angular/core';
import { CreateRiskAssessmentDto } from '@teis/services/risk-assessments/risk-assessments.models';
@Component({
selector: 'app-edit-risk-assessment-title',
......@@ -53,18 +54,27 @@ export class EditRiskAssessmentTitleComponent implements OnInit {
private updateRiskAssessmentTitle(title: string) {
const riskAssessment = this.currentRiskAssessment;
const update$ = riskAssessment
? this.facade.updateTitle(riskAssessment.id, this.composeBody(riskAssessment, title))
: of(null);
update$.pipe(take(1)).subscribe(() => {
this.facade.setTitle(title);
this.message.addToastMessage('risk_assessment_title_updated', 'success', 3000);
this.facade.closeModal();
});
if (riskAssessment) {
this.facade.updateTitle(riskAssessment.id, this.composeBody(riskAssessment, title))
.pipe(take(1))
.subscribe(() => {
this.message.addToastMessage('risk_assessment_title_updated', 'success', 3000);
this.setTitle(title);
});
} else {
const body: CreateRiskAssessmentDto = { riskAssessment: { title, external: true } };
this.facade.saveRiskAssessmentToBackend(body);
this.setTitle(title);
}
}
private composeBody(riskAssessment, title) {
return { title, id: riskAssessment.id };
}
private setTitle(title: string) {
this.facade.setTitle(title);
this.facade.closeModal();
}
}
......@@ -23,7 +23,8 @@
[maxFiles]="20"
[fileManagerOptions]="{ showMaxFilesMessage: false, displayedExtensionsLimit: 10 }"
(loading)="handleLoading($event)"
(filesSelected)="filesSelectedHandler($event)">
(filesSelected)="filesSelectedHandler($event)"
(fileDeleted)="fileDeleted($event)">
</tehik-file-manager>
<ng-container footer>
......
......@@ -9,12 +9,12 @@ import { StepNavigationEvent } from '../../risk-assessment.models';
import { NEW_ASSESSMENT_SLUG, RiskAssessmentsFacadeService } from '../../risk-assessments-facade.service';
import { CreateRiskAssessmentService } from '../../services/create-risk-assessment.service';
import { EditRiskAssessmentTitleComponent } from '../edit-risk-assessment-title/edit-risk-assessment-title.component';
import { FileUploadService } from '@teis/modules/file-upload/file-upload.service';
import { Location } from '@angular/common';
import { FileService } from '@teis/services/file/file.service';
import { FileReferenceDto } from '@teis/services/file/file.model';
import { EntityFile } from '@teis/modules/files/entity-file';
import { MessageContext } from '@ska-angular/core';
import { removeArrayItem } from '@teis/utils';
@Component({
selector: 'app-upload-risk-assessment',
......@@ -103,18 +103,6 @@ export class UploadRiskAssessmentComponent implements OnInit, OnDestroy {
this.filesService.downloadFile(file.objectId, file.fileId, file.fileName, this.referencePath);
}
promptFileRemoval(userInputSubject: Subject<boolean>) {
this.modal.confirmDelete({
title: 'delete_files_confirm',
question: 'delete_files_question',
})
.pipe(take(1), tap(() => this.modal.close()))
.subscribe((answer: boolean) => {
userInputSubject.next(answer);
userInputSubject.complete();
});
}
filesSelectedHandler(files: EntityFile[]) {
this.uploadedFiles = files;
this.createExternalRiskAssessmentIfNotExist().pipe(take(1)).subscribe(() => {
......@@ -152,17 +140,17 @@ export class UploadRiskAssessmentComponent implements OnInit, OnDestroy {
tap(() => this.modal.close()),
filter((response: boolean) => response),
mergeMap(() => this.facade.updateRiskAssessmentStatus(this.currentRiskAssessment.id, params)))
.subscribe(() => {
this.message.addToastSuccess('risk_assessment_saved', 3000);
return this.router.navigate(['auth/risk-assessments']);
.subscribe(async () => {
await this.router.navigate(['auth/risk-assessments']);
this.message.addToastSuccess('risk_assessment_published', 3000);
});
}
private checkIfConditionsAreMetToCreateAssessment() {
const hasAtleastOneFile = this.uploadedFiles.length >= 1;
const hasAtLeastOneFile = this.uploadedFiles.length >= 1;
const noPendingUpload = !this.isSomeFileUploading;
this.canFinishRiskAssessment = hasAtleastOneFile && noPendingUpload;
this.canFinishRiskAssessment = hasAtLeastOneFile && noPendingUpload;
this.handleSubmitButton(this.canFinishRiskAssessment);
}
......@@ -172,4 +160,8 @@ export class UploadRiskAssessmentComponent implements OnInit, OnDestroy {
});
}
fileDeleted(file: EntityFile) {
this.uploadedFiles = removeArrayItem(file, 'localId', [...this.uploadedFiles]);
this.checkIfConditionsAreMetToCreateAssessment();
}
}
......@@ -32,3 +32,10 @@ export const sortTopicsData = (topics: ClassifierItemDto[]) => {
};
export const getFirstDuplicateAsString = (array: any[]) => array.find((elem, index) => array.lastIndexOf(elem) !== index);
export const removeArrayItem = (item: any, compareProperty: string, array: any[]) => {
return array.reduce((acc, currentItem) => {
if (currentItem[compareProperty] !== item[compareProperty]) acc.push(currentItem);
return acc;
}, []);
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment