Commit 5e890b40 authored by Hando Lukats's avatar Hando Lukats
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Hando Lukats

See merge request teis/public-web-client!628
parents b0994e85 5dd19a79
{
"name": "te-is",
"version": "1.22.0",
"version": "1.23.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "te-is",
"version": "1.22.0",
"version": "1.23.0",
"license": "MIT",
"scripts": {
"ng": "ng",
......
......@@ -12,6 +12,7 @@
rows="5"
minlength="3"
type="textarea"
maxlength="255"
[preventErrorsWhileFocused]="true"></ska-input>
</form-row>
<teis-flex>
......
......@@ -39,6 +39,12 @@
id="upperLimit"
formControlName="upperLimit">
</ska-input>
<div *ngIf="showUpperLimitError"
class="form-errors has-danger">
<div class="form-control-feedback" role="alert">
{{'upper_limit_too_low' | translate}}
</div>
</div>
</form-row>
<form-row label="{{ 'indicator_recommendation' | translate }}">
......
import { Component, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { RiskFactorDto, RiskIndicatorBody, RiskIndicatorLightDto, RiskStatementDto } from '@official/api-services/risk-assessments-settings/risk-assessments-settings.models';
import {
RiskFactorDto,
RiskIndicatorBody,
RiskIndicatorLightDto,
RiskStatementDto
} from '@official/api-services/risk-assessments-settings/risk-assessments-settings.models';
import { Subscription } from 'rxjs';
import { triggerValidation } from '@teis/utils';
import { RiskFactorsFacadeService } from '@official/features/settings/features/risk-assessment-settings/features/risk-factors/risk-factors-facade.service';
......@@ -20,6 +25,7 @@ export class RiskIndicatorAddOrEditComponent implements OnInit {
options: any[];
displayFunc;
subscription$: Subscription;
showUpperLimitError: boolean;
constructor(
private facade: RiskFactorsFacadeService,
......@@ -37,12 +43,15 @@ export class RiskIndicatorAddOrEditComponent implements OnInit {
}
private replaceComma(value) {
return value.toString().replace(',', ('.'));
if (value) {
return value.toString().replace(',', ('.'));
}
}
submit(form: FormGroup) {
triggerValidation(form);
if (form.valid) {
this.showUpperLimitError = parseFloat(form.value.upperLimit) < parseFloat(form.value.lowerLimit);
if (form.valid && !this.showUpperLimitError) {
const formValues = form.value;
const body: RiskIndicatorBody = {
riskStatementId: this.riskStatement.id,
......
......@@ -1063,5 +1063,6 @@
"file_upload_failure": "Faili üleslaadimisel tekkis tõrge",
"no_published_risk_assessment": "Ettevõttel ei ole esitatud riskianalüüsi",
"upload_risk_assessment": "Iseteeninduse väliselt esitatud riskianalüüsi saab üles laadida ettevõtte konto lehel",
"deleting_last_file_risk_assessment_removed": "Riskianalüüsi viimase faili kustutamisega kustatatakse ka riskianalüüs."
"deleting_last_file_risk_assessment_removed": "Riskianalüüsi viimase faili kustutamisega kustatatakse ka riskianalüüs.",
"upper_limit_too_low": "Mõõdetava näitaja ülempiir peab olema suurem alampiirist"
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ import { AuthenticationService } from '@teis/services/authentication/authenticat
import { TeisFeatureFlagsService } from '@teis/services/feature-flags/feature-flags.service';
import { FeatureFlag } from '@teis/services/feature-flags/feature-flags.model';
import { Subscription } from 'rxjs';
import { take } from 'rxjs/operators';
import { distinctUntilChanged, filter, take } from 'rxjs/operators';
@Component({
selector: 'app-root',
......@@ -114,10 +114,11 @@ export class AppComponent implements OnInit, OnDestroy {
});
this.subscription$ = this.authentication.isAuthenticated
.pipe(take(1))
.subscribe((authenticated) => {
if (authenticated) this.getFeatureFlags();
});
.pipe(
filter(isAuthenticated => isAuthenticated),
distinctUntilChanged(),
)
.subscribe(() => this.getFeatureFlags());
}
ngOnDestroy() {
......
......@@ -5,6 +5,7 @@ import { Observable } from 'rxjs';
import { FormControl, FormGroup } from '@angular/forms';
import { addTimeToDate } from '@teis/utils';
import { AlertVariants } from '@teis/modules/alert/alert/alert.component';
import { SortInstance, SortType } from '@ska-angular/common';
@Component({
selector: 'app-audit-logs',
......@@ -26,9 +27,14 @@ export class AuditLogsComponent implements OnInit {
activityFrom: new FormControl(''),
activityTo: new FormControl(''),
});
this.setDefaultSort();
this.facade.fetchAuditLogs();
}
private setDefaultSort() {
this.auditLogsListManager.sort = new SortInstance('activityTime', SortType.DESC);
}
pageChange() {
this.facade.fetchAuditLogs();
}
......@@ -41,6 +47,7 @@ export class AuditLogsComponent implements OnInit {
this.filterForm.controls.activityFrom.reset('');
this.filterForm.controls.activityTo.reset('');
this.auditLogsListManager.reset();
this.setDefaultSort();
this.facade.fetchAuditLogs();
}
......
......@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { AvailableTabs } from '@teis/modules/tabs/components/tehik-tabs/tehik-tabs.component';
import { TabContainer } from '@teis/modules/tabs/tab-container';
import { ActivatedRoute, Router } from '@angular/router';
import { EPublicUserPrivilege } from '@teis/services/privileges/privilege.models';
@Component({
selector: 'app-company-settings',
......@@ -12,7 +13,7 @@ export class CompanySettingsComponent extends TabContainer {
availableTabs: AvailableTabs[] = [
{ title: 'locations', name: 'locations' },
{ title: 'use_of_data', name: 'audit-logs' },
{ title: 'use_of_data', name: 'audit-logs', privileges: [EPublicUserPrivilege.EX_VIEW_AUTHORITIES] },
];
constructor(
......
......@@ -508,6 +508,8 @@
"describe": "Kirjelda",
"action_plan_no_risk_statements_not_applied": "Riskianalüüsis pole ühtegi rakendamata abinõud.",
"action_plan_evaluation_intro": "Consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"action_plan_intro": "Sissejuhatus. Consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"action_plan_intro_title": "Sissejuhatus",
"action_plan_no_risk_statements_evaluation_intro": "Siin sammus võiks kasutajale kirjeldada, et II etapis pole temal ohtusi.",
"action_plan_delete_task_title": "Tegevuse kustutamine",
"action_plan_delete_task_question": "Kas oled kindel, et soovid tegevuse kustutada?",
......
<p>action-plan-introduction works!</p>
<teis-header [title]="'action_plan_intro_title' | translate" variant="block"></teis-header>
<p [innerHtml]="'action_plan_intro' | translate"></p>
......@@ -4,7 +4,7 @@ import { Subscription } from 'rxjs';
import { CreateRiskAssessmentService } from '../../../services/create-risk-assessment.service';
import { RiskAssessmentsFacadeService } from '../../../risk-assessments-facade.service';
import { ConfirmationOptions } from '@teis/modules/modal/confirmation/confirmation.component';
import { RiskAssessmentPath } from '../../../risk-assessment.models';
import { ERiskAssessmentStatusCodes, RiskAssessmentPath } from '../../../risk-assessment.models';
import { RiskAssessMentStep } from '../../../services/risk-assessment-step';
import { AuthorizationService } from '@teis/services/authorization/authorization.service';
import { RiskAssessmentStatus } from '@teis/services/risk-assessments/risk-assessments.models';
......@@ -65,7 +65,11 @@ export class RiskAssessmentMenuComponent implements OnInit {
mergeMap(() => this.createRiskAssessmentService.riskFactorList$)
)
.subscribe((riskFactorList) => {
this.createMenu(riskFactorList.stepperMenu);
if (this.currentRiskAssessment.status.code === ERiskAssessmentStatusCodes.CONFIRMED) {
this.createMenu(riskFactorList.riskAssessmentMenuForActionPlan().stepperMenu);
} else {
this.createMenu(riskFactorList.stepperMenu);
}
this.menu?.forEach(step => step.enable());
});
......
<teis-header [title]="'dangers_assessment' | translate" variant="block"></teis-header>
<p [innerHtml]="'risk_assessment_riskfactor_content' | translate"></p>
<button teis-button variant="no-style" type="button">
<teis-icon icon="icon-download"></teis-icon>
<span> {{ 'risk_assessment_riskfactor_download_list' | translate }}</span>
</button>
\ No newline at end of file
......@@ -21,7 +21,6 @@ export class RiskFactorList {
constructor(input: RiskFactorAssessmentPublicDto[] = [], riskFactorsAreDeletable = false) {
this.riskFactorAssessments = input;
this.riskFactorsAreDeletable = riskFactorsAreDeletable;
// this.isCreateMenu = isCreateMenu;
this.composeRiskFactorStepperMenu();
......@@ -29,7 +28,12 @@ export class RiskFactorList {
}
forViewing() {
this.composeRiskFactorStepperMenu(false);
this.composeRiskFactorStepperMenu(false, false);
return this;
}
riskAssessmentMenuForActionPlan() {
this.composeRiskFactorStepperMenu(false, true);
return this;
}
......@@ -67,9 +71,9 @@ export class RiskFactorList {
this.flatMenu = this.stepperMenu.reduce((arr, current) => [...arr, ...current.items], []);
}
private composeRiskFactorStepperMenu(additional = true, forViewing = false): void {
private composeRiskFactorStepperMenu(additional = true, forViewing = true): void {
this.stepperMenu = [
...this.composeRegularRiskFactorCategories(this.riskFactorAssessments, this.riskFactorsAreDeletable, additional),
...this.composeRegularRiskFactorCategories(this.riskFactorAssessments, this.riskFactorsAreDeletable, forViewing),
this.composeAdditionalRiskFactorCategory(this.riskFactorAssessments, this.riskFactorsAreDeletable, additional, forViewing),
];
......@@ -111,7 +115,7 @@ export class RiskFactorList {
private composeRegularRiskFactorCategories(
riskFactorAssessments: RiskFactorAssessmentPublicDto[],
riskFactorsAreDeletable: boolean, viewsingMenu: boolean): RiskAssessmentMenuItemChild[] {
riskFactorsAreDeletable: boolean, viewingMenu: boolean): RiskAssessmentMenuItemChild[] {
const riskFactorsStringMap: { [key: string]: RiskFactorAssessmentPublicDto[] } = {};
const regularRiskFactors = riskFactorAssessments.filter(riskFactorAssessment => !riskFactorAssessment.additional);
......@@ -128,7 +132,7 @@ export class RiskFactorList {
const progressCounter = (assessment: RiskFactorAssessmentPublicDto[]) => assessment
.filter(item => item.riskFactorAssessmentStatus === RiskFactorAssessmentStatus.DONE).length;
let statusForMenuIcon;
if (!viewsingMenu) {
if (!viewingMenu) {
statusForMenuIcon = RiskFactorAssessmentStatus.ACTION;
} else {
statusForMenuIcon = RiskFactorAssessmentStatus.DONE;
......
......@@ -7,7 +7,7 @@
<ng-container card-middle>
<div class="px-2">
<h5 *ngIf="!actionPlanTasksExists && riskAssessmentExists">
<h5 *ngIf="isNoNotificationsVisible">
{{'no_notifications' | translate}}
</h5>
......
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { combineLatest, forkJoin, Observable, of, Subscription } from 'rxjs';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { forkJoin, Observable, of, Subscription } from 'rxjs';
import { TaskApiService } from '@teis/services/tasks/task-api.service';
import {
ETaskDefinitionCode,
......@@ -24,13 +24,14 @@ export class NotificationsCardContainerComponent implements OnInit, OnDestroy {
privileges = EPublicUserPrivilege;
tasksCount: TasksCountDto;
riskAssessmentExists = true;
riskAssessmentExists: boolean;
actionPlanTasksExists = false;
hasManageRiskAssessmentsPrivilege = this.authorizationService
.hasSomePermission([this.privileges.EX_MANAGE_RISK_ASSESSMENTS]);
hasViewActionPlanPrivilege = this.authorizationService
.hasSomePermission([this.privileges.EX_VIEW_ACTION_PLAN]);
areNotificationsVisible = this.hasManageRiskAssessmentsPrivilege || this.hasViewActionPlanPrivilege;
isNoNotificationsVisible: boolean;
private subscriptions$: Subscription[];
......@@ -48,12 +49,14 @@ export class NotificationsCardContainerComponent implements OnInit, OnDestroy {
switchMap((employer: Employer) => {
return forkJoin([
this.taskCountRequest(employer),
this.riskAssessmentExistsRequest(),
this.checkIfPrivilegedUserHasRiskAssessment(),
]);
})
).subscribe(([tasksCount, riskAssessmentExists]: [TasksCountDto, boolean]) => {
this.actionPlanTasksExists = NotificationsCardContainerComponent.checkIfTasksExists(tasksCount);
this.tasksCount = tasksCount;
this.isNoNotificationsVisible = this.validateNoNotificationsVisibility(this.actionPlanTasksExists, riskAssessmentExists);
if (riskAssessmentExists) {
this.riskAssessmentExists = riskAssessmentExists;
}
......@@ -66,11 +69,15 @@ export class NotificationsCardContainerComponent implements OnInit, OnDestroy {
this.subscriptions$.forEach(subscription => subscription.unsubscribe());
}
validateNoNotificationsVisibility(actionPlanTasksExists: boolean, riskAssessmentExists: boolean): boolean {
return !actionPlanTasksExists && (riskAssessmentExists || riskAssessmentExists === null);
}
private static checkIfTasksExists(tasksCount): boolean {
return Object.values(tasksCount).some(count => count > 0);
}
private riskAssessmentExistsRequest(): Observable<boolean> {
private checkIfPrivilegedUserHasRiskAssessment(): Observable<boolean> {
if (this.hasManageRiskAssessmentsPrivilege) {
return this.riskAssessmentApiService.fetchEmployerRiskAssessmentExists()
.pipe(map(existsRiskAssessment => existsRiskAssessment?.riskAssessmentExists));
......
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