diff --git a/frontend/cypress/e2e/checkIn.cy.ts b/frontend/cypress/e2e/checkIn.cy.ts
index 70c2c17a38..f6281c9f06 100644
--- a/frontend/cypress/e2e/checkIn.cy.ts
+++ b/frontend/cypress/e2e/checkIn.cy.ts
@@ -193,15 +193,16 @@ describe('OKR Check-in e2e tests', () => {
cy.getByTestId('add-check-in').first().click();
cy.fillOutCheckInMetric(30, 5, 'Here we are', 'A cat would be great');
- cy.contains('Aktuell: CHF 30.-');
+ cy.contains('Aktuell: 30 CHF');
cy.getByTestId('show-all-checkins').click();
cy.wait(500);
cy.contains('Check-in History');
+ cy.contains('Wert: 30 CHF');
cy.getByTestId('edit-check-in').first().click();
cy.contains('Here we edit a metric checkin');
- cy.contains('CHF 30.-');
- cy.contains('Confidence um Target Zone (CHF 213.-) zu erreichen');
+ cy.contains('30 CHF');
+ cy.contains('Confidence um Target Zone (213 CHF) zu erreichen');
cy.contains('5/10');
cy.getByTestId('check-in-metric-value').click().clear().type('200');
cy.getByTestId('confidence-slider').realMouseDown();
@@ -211,10 +212,70 @@ describe('OKR Check-in e2e tests', () => {
cy.getByTestId('submit-check-in').click();
cy.wait(200);
- cy.contains('CHF 200.-');
+ cy.contains('200 CHF');
cy.contains('We bought a new sheep');
});
+ it('Should generate right labels in checkin history list', () => {
+ cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
+ cy.getByTestId('submit').should('be.disabled');
+ cy.fillOutKeyResult(
+ 'A new KeyResult for checking checkin list',
+ 'EUR',
+ '10',
+ '300',
+ null,
+ null,
+ null,
+ null,
+ 'This is my description',
+ );
+
+ cy.getByTestId('submit').click();
+
+ cy.getByTestId('keyresult').contains('A new KeyResult for checking checkin list').click();
+
+ cy.getByTestId('add-check-in').first().click();
+ cy.fillOutCheckInMetric(30, 5, 'Here we are', 'A cat would be great');
+ cy.contains('Aktuell: 30 EUR');
+ cy.getByTestId('show-all-checkins').click();
+
+ cy.wait(500);
+ cy.contains('Check-in History');
+ cy.contains('Wert: 30 EUR');
+
+ cy.getByTestId('closeButton').click();
+ // Wait this time because of the toaster message
+ cy.wait(2000);
+ cy.getByTestId('close-drawer').click();
+
+ cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
+ cy.fillOutKeyResult(
+ 'There is another kr with fte',
+ 'FTE',
+ '10',
+ '300',
+ null,
+ null,
+ null,
+ null,
+ 'This is my description',
+ );
+
+ cy.getByTestId('submit').click();
+
+ cy.getByTestId('keyresult').contains('There is another kr with fte').click();
+
+ cy.getByTestId('add-check-in').first().click();
+ cy.fillOutCheckInMetric(30, 5, 'Here we are', 'A cat would be great');
+ cy.contains('Aktuell: 30 FTE');
+ cy.getByTestId('show-all-checkins').click();
+
+ cy.wait(500);
+ cy.contains('Check-in History');
+ cy.contains('Wert: 30 FTE');
+ });
+
it('Edit ordinal checkin', () => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');
@@ -312,7 +373,7 @@ describe('OKR Check-in e2e tests', () => {
cy.wait('@getKeyResultsAfterSave');
cy.getByTestId('add-check-in').first().click();
- cy.contains('Letzter Wert').siblings('div').contains('10 %');
+ cy.contains('Letzter Wert').siblings('div').contains('10%');
});
});
});
diff --git a/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.html b/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.html
index 56a6727b9b..7204f756a4 100644
--- a/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.html
+++ b/frontend/src/app/components/check-in-history-dialog/check-in-history-dialog.component.html
@@ -22,8 +22,7 @@
Wert:
- {{ getMetricKeyResult().unit | unitLabelTransformation }}
- {{ +checkIn.value! | unitValueTransformation: getMetricKeyResult().unit }}
+ {{ +checkIn.value! | unitValueTransformation }}{{ getMetricKeyResult().unit | unitLabelTransformation }}
{{ checkIn.value }}
@@ -49,7 +48,7 @@ Massnahmen:
-
+
diff --git a/frontend/src/app/components/checkin/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/components/checkin/check-in-form-metric/check-in-form-metric.component.html
index 3c796f384f..f66dfb6ea5 100644
--- a/frontend/src/app/components/checkin/check-in-form-metric/check-in-form-metric.component.html
+++ b/frontend/src/app/components/checkin/check-in-form-metric/check-in-form-metric.component.html
@@ -27,7 +27,7 @@
diff --git a/frontend/src/app/components/checkin/check-in-form/check-in-form.component.html b/frontend/src/app/components/checkin/check-in-form/check-in-form.component.html
index 5a2ee63747..29b2f62070 100644
--- a/frontend/src/app/components/checkin/check-in-form/check-in-form.component.html
+++ b/frontend/src/app/components/checkin/check-in-form/check-in-form.component.html
@@ -75,7 +75,7 @@
Confidence um Target Zone
- ({{ calculateTarget(kr) | unitValueTransformation: kr.unit }})
+ ({{ calculateTarget(kr) | unitValueTransformation }}{{ kr.unit | unitLabelTransformation }})
zu erreichen:
diff --git a/frontend/src/app/components/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/components/keyresult-detail/keyresult-detail.component.html
index d020898f33..48515f68a6 100644
--- a/frontend/src/app/components/keyresult-detail/keyresult-detail.component.html
+++ b/frontend/src/app/components/keyresult-detail/keyresult-detail.component.html
@@ -35,7 +35,8 @@ {{ keyResult.title }}
- Baseline: {{ keyResultMetric.baseline | unitValueTransformation: keyResultMetric.unit.toString() }}
+ Baseline: {{ keyResultMetric.baseline | unitValueTransformation
+ }}{{ keyResultMetric.unit | unitLabelTransformation }}
{{ keyResult.title }}
!
Aktuell:
- {{ +lastCheckIn.value | unitValueTransformation: keyResultMetric.unit.toString() }}
+ {{ +lastCheckIn.value | unitValueTransformation }}{{ keyResultMetric.unit | unitLabelTransformation }}
Stretch Goal:
- {{ keyResultMetric.stretchGoal | unitValueTransformation: keyResultMetric.unit.toString() }}
+ {{ keyResultMetric.stretchGoal | unitValueTransformation
+ }}{{ keyResultMetric.unit | unitLabelTransformation }}
diff --git a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts
index 7f3fab87b5..0b3ec67928 100644
--- a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts
+++ b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts
@@ -9,22 +9,22 @@ describe('UnitLabelTransformationPipe', () => {
it('Format Percent label', () => {
const pipe = new UnitLabelTransformationPipe();
- expect(pipe.transform(Unit.PERCENT)).toBe('');
+ expect(pipe.transform(Unit.PERCENT)).toBe('%');
});
it('Format FTE label', () => {
const pipe = new UnitLabelTransformationPipe();
- expect(pipe.transform(Unit.FTE)).toBe(Unit.FTE);
+ expect(pipe.transform(Unit.FTE)).toBe(' ' + Unit.FTE);
});
it('Format CHF label', () => {
const pipe = new UnitLabelTransformationPipe();
- expect(pipe.transform(Unit.CHF)).toBe(Unit.CHF);
+ expect(pipe.transform(Unit.CHF)).toBe(' ' + Unit.CHF);
});
it('Format EUR label', () => {
const pipe = new UnitLabelTransformationPipe();
- expect(pipe.transform(Unit.EUR)).toBe(Unit.EUR);
+ expect(pipe.transform(Unit.EUR)).toBe(' ' + Unit.EUR);
});
it('Format Number label', () => {
diff --git a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts
index 5e9328089c..c39c1c8de8 100644
--- a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts
+++ b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts
@@ -1,5 +1,5 @@
-import { Pipe, PipeTransform } from '@angular/core';
import { Unit } from '../../types/enums/Unit';
+import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'unitLabelTransformation',
@@ -8,13 +8,13 @@ export class UnitLabelTransformationPipe implements PipeTransform {
transform(unitLabel: string): string {
switch (unitLabel) {
case Unit.PERCENT:
- return '';
+ return '%';
case Unit.FTE:
- return Unit.FTE;
+ return ' ' + Unit.FTE;
case Unit.CHF:
- return Unit.CHF;
+ return ' ' + Unit.CHF;
case Unit.EUR:
- return Unit.EUR;
+ return ' ' + Unit.EUR;
case Unit.NUMBER:
return '';
default:
diff --git a/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts
index 54f23d7fc2..043843bf5e 100644
--- a/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts
+++ b/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts
@@ -1,5 +1,4 @@
import { UnitValueTransformationPipe } from './unit-value-transformation.pipe';
-import { Unit } from '../../types/enums/Unit';
describe('UnitTransformationPipe', () => {
it('create an instance', () => {
@@ -9,41 +8,21 @@ describe('UnitTransformationPipe', () => {
it('should format as Percent', () => {
const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380, Unit.PERCENT)).toBe('380%');
+ expect(pipe.transform(380)).toBe('380');
});
it('should format as Number', () => {
const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380, Unit.NUMBER)).toBe('380');
- });
-
- it('should format as FTE', () => {
- const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380, Unit.FTE)).toBe('380 FTE');
- });
-
- it('should format as CHF without double value', () => {
- const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380, Unit.CHF)).toBe('CHF 380.-');
- });
-
- it('should format as EUR without double value', () => {
- const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380, Unit.EUR)).toBe('380 €');
+ expect(pipe.transform(38000)).toBe("38'000");
});
it('should format as CHF as double value', () => {
const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380.987, Unit.CHF)).toBe('CHF 380.99');
- });
-
- it('should format as EUR as double value', () => {
- const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(380.987, Unit.EUR)).toBe('380.99 €');
+ expect(pipe.transform(380.987)).toBe('380.99');
});
it('should return with no format if unit is not preset one', () => {
const pipe = new UnitValueTransformationPipe();
- expect(pipe.transform(140, 'MEMBERS')).toBe('140');
+ expect(pipe.transform(140)).toBe('140');
});
});
diff --git a/frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts
index 30c26c36ed..ca8d95c7f9 100644
--- a/frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts
+++ b/frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts
@@ -5,29 +5,9 @@ import { Unit } from '../../types/enums/Unit';
name: 'unitValueTransformation',
})
export class UnitValueTransformationPipe implements PipeTransform {
- transform(value: number, unit: string): string {
+ transform(value: number): string {
/* If user tries to input String, set value to 0 */
- if (Number.isNaN(value)) {
- value = 0;
- }
- switch (unit) {
- case Unit.CHF:
- return 'CHF ' + this.addCHFSign(this.roundAndAddThousandSplitSign(value));
- case Unit.EUR:
- return this.roundAndAddThousandSplitSign(value) + ' €';
- case Unit.PERCENT:
- return value + '%';
- case Unit.FTE:
- return this.roundAndAddThousandSplitSign(value) + ' FTE';
- case Unit.NUMBER:
- return this.roundAndAddThousandSplitSign(value);
- default:
- return value.toString();
- }
- }
-
- addCHFSign(value: string): string {
- return !+value.split('.')[1] ? value.split('.')[0] + '.-' : value;
+ return Number.isNaN(value) ? '0' : this.roundAndAddThousandSplitSign(value);
}
roundAndAddThousandSplitSign(value: number): string {
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index 94941adb44..783ed85b71 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -4,7 +4,6 @@ import { ExampleDialogComponent } from './dialog/example-dialog/example-dialog.c
import { ObjectiveFormComponent } from './dialog/objective-dialog/objective-form.component';
import { UnitValueTransformationPipe } from './pipes/unit-value-transformation/unit-value-transformation.pipe';
import { ConfirmDialogComponent } from './dialog/confirm-dialog/confirm-dialog.component';
-import { UnitLabelTransformationPipe } from './pipes/unit-label-transformation/unit-label-transformation.pipe';
import { ParseUnitValuePipe } from './pipes/parse-unit-value/parse-unit-value.pipe';
import { ScoringComponent } from './custom/scoring/scoring.component';
import { CompleteDialogComponent } from './dialog/complete-dialog/complete-dialog.component';
@@ -26,6 +25,7 @@ import { SpinnerComponent } from './custom/spinner/spinner.component';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { DialogTemplateCoreComponent } from './custom/dialog-template-core/dialog-template-core.component';
import { MatDividerModule } from '@angular/material/divider';
+import { UnitLabelTransformationPipe } from './pipes/unit-label-transformation/unit-label-transformation.pipe';
@NgModule({
declarations: [
@@ -33,8 +33,8 @@ import { MatDividerModule } from '@angular/material/divider';
ObjectiveFormComponent,
UnitValueTransformationPipe,
ConfirmDialogComponent,
- UnitLabelTransformationPipe,
ParseUnitValuePipe,
+ UnitLabelTransformationPipe,
ScoringComponent,
CompleteDialogComponent,
OkrTangramComponent,
@@ -68,8 +68,8 @@ import { MatDividerModule } from '@angular/material/divider';
ObjectiveFormComponent,
UnitValueTransformationPipe,
ConfirmDialogComponent,
- UnitLabelTransformationPipe,
ParseUnitValuePipe,
+ UnitLabelTransformationPipe,
ScoringComponent,
CompleteDialogComponent,
OkrTangramComponent,