diff --git a/src/app/pages/observations/observation-detail.component.html b/src/app/pages/observations/observation-detail.component.html index 59e49491..b5e58fff 100644 --- a/src/app/pages/observations/observation-detail.component.html +++ b/src/app/pages/observations/observation-detail.component.html @@ -27,7 +27,7 @@ -
+

{{'Observation details' | translate}}

{{'New observation' | translate}}

@@ -196,7 +196,7 @@

{{'Upload report' | translate}}

-
+
{{'Upload report' | translate}} name="operator_id" #operator_id="ngModel" [disabled]="isDisabled()" + required >
{{'Please select an operator' | translate}}
+
{{'You will not be able to submit this observation to review with unknown operator selected' | translate}}
diff --git a/src/app/pages/observations/observation-detail.component.ts b/src/app/pages/observations/observation-detail.component.ts index ba117eb2..1d278b35 100644 --- a/src/app/pages/observations/observation-detail.component.ts +++ b/src/app/pages/observations/observation-detail.component.ts @@ -67,6 +67,7 @@ export class ObservationDetailComponent implements OnDestroy { subcategories: Subcategory[] = []; severities: Severity[] = []; _operators: Operator[] = []; // Ordered by name, filtered by country + unknownOperator: Operator = null; // Special unknown operator governments: Government[] = []; observers: Observer[] = []; // Ordered by name fmus: Fmu[] = []; @@ -349,9 +350,13 @@ export class ObservationDetailComponent implements OnDestroy { get operators() { return this._operators; } set operators(collection) { - this._operators = collection; - this.operatorsOptions = collection.map((o) => ({ id: o.id, name: o.name })); - this.relevantOperatorsOptions = this.operators.map((operator) => ({ id: operator.id, name: operator.name })); + if (this.unknownOperator) { + this._operators = [this.unknownOperator, ...collection]; + } else { + this._operators = collection; + } + this.operatorsOptions = this._operators.map((o) => ({ id: o.id, name: o.name })); + this.relevantOperatorsOptions = collection.map((o) => ({ id: o.id, name: o.name })); } get operatorChoice() { return this.observation ? this.observation.operator : this._operatorChoice; } @@ -387,6 +392,9 @@ export class ObservationDetailComponent implements OnDestroy { this.operatorsSelection = []; } } + get unknownOperatorSelected() { + return this.operatorChoice && this.unknownOperator && +this.operatorChoice.id === +this.unknownOperator.id; + } get fmu() { return this.observation ? this.observation.fmu : this._fmu; } set fmu(fmu) { @@ -758,6 +766,12 @@ export class ObservationDetailComponent implements OnDestroy { this.updateTranslatedOptions(this.coordinatesFormats, 'coordinatesFormat'); }); + this.operatorsService.getAll({ filter: { slug: 'unknown' }}).then((operators) => { + if (operators.length > 0) { + this.unknownOperator = operators[0]; + } + }); + this.observersService.getAll({ sort: 'name' }) .then((observers) => { this.observers = observers; diff --git a/src/assets/locale/zu.json b/src/assets/locale/zu.json index 65a7fe7d..4c469cf4 100644 --- a/src/assets/locale/zu.json +++ b/src/assets/locale/zu.json @@ -396,5 +396,6 @@ "Please pick sub-category first.": "Please pick sub-category first.", "Add a new government entity to the list": "Add a new government entity to the list", "Add a new producer to the list": "Add a new producer to the list", - "Please select an existing report or upload a new one": "Please select an existing report or upload a new one" + "Please select an existing report or upload a new one": "Please select an existing report or upload a new one", + "You will not be able to submit this observation to review with unknown operator selected": "You will not be able to submit this observation to review with unknown operator selected" }