From 3fd624c29e3cbc4543178204567418f935de2d71 Mon Sep 17 00:00:00 2001
From: Damien <damien.burel@maarch.org>
Date: Fri, 29 Jan 2021 16:35:50 +0100
Subject: [PATCH] FEAT #16063 TIME 0:15 Can not update type + fix position

---
 src/app/home/controllers/TileController.php | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/app/home/controllers/TileController.php b/src/app/home/controllers/TileController.php
index 42133b7fe3f..af5ad66298e 100644
--- a/src/app/home/controllers/TileController.php
+++ b/src/app/home/controllers/TileController.php
@@ -50,8 +50,8 @@ class TileController
             return $response->withStatus(400)->withJson(['errors' => 'Body type is empty, not a string or not valid']);
         } elseif (!Validator::stringType()->notEmpty()->validate($body['view'] ?? null) || !in_array($body['view'], TileController::VIEWS)) {
             return $response->withStatus(400)->withJson(['errors' => 'Body view is empty, not a string or not valid']);
-        } elseif (!Validator::intVal()->notEmpty()->validate($body['position'] ?? null)) {
-            return $response->withStatus(400)->withJson(['errors' => 'Body position is empty or not an integer']);
+        } elseif (!Validator::intVal()->validate($body['position'] ?? null)) {
+            return $response->withStatus(400)->withJson(['errors' => 'Body position is not set or not an integer']);
         }
 
         $tiles = TileModel::get([
@@ -93,15 +93,12 @@ class TileController
 
         if (empty($body)) {
             return $response->withStatus(400)->withJson(['errors' => 'Body is empty']);
-        } elseif (!Validator::stringType()->notEmpty()->validate($body['type'] ?? null) || !in_array($body['type'], TileController::TYPES)) {
-            return $response->withStatus(400)->withJson(['errors' => 'Body type is empty, not a string or not valid']);
         } elseif (!Validator::stringType()->notEmpty()->validate($body['view'] ?? null) || !in_array($body['view'], TileController::VIEWS)) {
             return $response->withStatus(400)->withJson(['errors' => 'Body view is empty, not a string or not valid']);
         }
 
         TileModel::update([
             'set'   => [
-                'type'          => $body['type'],
                 'view'          => $body['view'],
                 'parameters'    => empty($body['parameters']) ? '{}' : json_encode($body['parameters'])
             ],
-- 
GitLab