Skip to content
Snippets Groups Projects
Verified Commit f03934c7 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #11274 TIME 0:10 can not disable model if default model

parent 9d88fbd5
No related branches found
No related tags found
No related merge requests found
...@@ -404,10 +404,13 @@ class IndexingModelController ...@@ -404,10 +404,13 @@ class IndexingModelController
return $response->withStatus(400)->withJson(['errors' => 'Route id is empty or not an integer']); 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)) { if (empty($model)) {
return $response->withStatus(400)->withJson(['errors' => 'Model not found']); 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([ IndexingModelModel::update([
'set' => [ 'set' => [
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<mat-header-cell *matHeaderCellDef></mat-header-cell> <mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let element" style="justify-content: flex-end;"> <mat-cell *matCellDef="let element" style="justify-content: flex-end;">
<button mat-icon-button color="primary" *ngIf="element.enabled" matTooltip="{{lang.suspend}}" <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> <mat-icon class="fa fa-pause fa-2x" aria-hidden="true"></mat-icon>
</button> </button>
<button mat-icon-button color="accent" *ngIf="!element.enabled" matTooltip="{{lang.authorize}}" (click)="$event.stopPropagation();enableIndexingModel(element)"> <button mat-icon-button color="accent" *ngIf="!element.enabled" matTooltip="{{lang.authorize}}" (click)="$event.stopPropagation();enableIndexingModel(element)">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment