From f03934c7d90560b8f23509ab956958f609dc9ba2 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Mon, 14 Oct 2019 17:04:10 +0100 Subject: [PATCH] FEAT #11274 TIME 0:10 can not disable model if default model --- .../indexingModel/controllers/IndexingModelController.php | 5 ++++- .../indexing-models-administration.component.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/indexingModel/controllers/IndexingModelController.php b/src/app/indexingModel/controllers/IndexingModelController.php index b02573a3473..1e1fb8dacc0 100644 --- a/src/app/indexingModel/controllers/IndexingModelController.php +++ b/src/app/indexingModel/controllers/IndexingModelController.php @@ -404,10 +404,13 @@ class IndexingModelController return $response->withStatus(400)->withJson(['errors' => 'Route id is empty or not an integer']); } - $model = IndexingModelModel::getById(['select' => ['enabled'], 'id' => $args['id']]); + $model = IndexingModelModel::getById(['select' => ['enabled', '"default"'], 'id' => $args['id']]); if (empty($model)) { return $response->withStatus(400)->withJson(['errors' => 'Model not found']); } + if ($model['default']) { + return $response->withStatus(400)->withJson(['errors' => 'Can not disable this model because this is the default model']); + } IndexingModelModel::update([ 'set' => [ diff --git a/src/frontend/app/administration/indexingModel/indexing-models-administration.component.html b/src/frontend/app/administration/indexingModel/indexing-models-administration.component.html index f4bc2d67c5f..8502816a1f2 100644 --- a/src/frontend/app/administration/indexingModel/indexing-models-administration.component.html +++ b/src/frontend/app/administration/indexingModel/indexing-models-administration.component.html @@ -66,7 +66,7 @@ <mat-header-cell *matHeaderCellDef></mat-header-cell> <mat-cell *matCellDef="let element" style="justify-content: flex-end;"> <button mat-icon-button color="primary" *ngIf="element.enabled" matTooltip="{{lang.suspend}}" - (click)="$event.stopPropagation();disableIndexingModel(element)"> + (click)="$event.stopPropagation();disableIndexingModel(element)" [disabled]="element.default"> <mat-icon class="fa fa-pause fa-2x" aria-hidden="true"></mat-icon> </button> <button mat-icon-button color="accent" *ngIf="!element.enabled" matTooltip="{{lang.authorize}}" (click)="$event.stopPropagation();enableIndexingModel(element)"> -- GitLab