diff --git a/apps/maarch_entreprise/Views/status-administration.component.html b/apps/maarch_entreprise/Views/status-administration.component.html index a6e3ebf811a62d055ecf063fd3b15a578cedee09..49b19727b749344c957a128ea5789e7b06b60e2e 100644 --- a/apps/maarch_entreprise/Views/status-administration.component.html +++ b/apps/maarch_entreprise/Views/status-administration.component.html @@ -46,7 +46,7 @@ </span> <label class="form-control" for="can_be_searched">{{lang.can_be_searched}}</label> <span class="input-group-addon"> - <input [(ngModel)]="status.can_be_searched" [checked]="status.can_be_searched == 'Y'" name="can_be_searched" id="can_be_searched" type="checkbox"> + <input [(ngModel)]="status.can_be_searched" name="can_be_searched" id="can_be_searched" type="checkbox"> </span> </div> </div> @@ -57,7 +57,7 @@ </span> <label class="form-control" for="can_be_modified">{{lang.can_be_modified}}</label> <span class="input-group-addon"> - <input [(ngModel)]="status.can_be_modified" [checked]="status.can_be_modified == 'Y'" type="checkbox" name="can_be_modified" id="can_be_modified"> + <input [(ngModel)]="status.can_be_modified" type="checkbox" name="can_be_modified" id="can_be_modified"> </span> </div> </div> diff --git a/core/Controllers/StatusController.php b/core/Controllers/StatusController.php index 222f5991ce837a12fb6fdd292a9fd3370832d7d4..15b113bf93cc6dec265ce5130dfe5d1ec6e58a1f 100644 --- a/core/Controllers/StatusController.php +++ b/core/Controllers/StatusController.php @@ -70,7 +70,11 @@ class StatusController return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } - $this->control($request, 'create'); + $errors = $this->control($request, 'create'); + + if (!empty($errors)) { + return $response->withStatus(500)->withJson(['errors' => $errors]); + } $aArgs = $request->getParams(); @@ -94,7 +98,11 @@ class StatusController return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } - $this->control($request, 'update'); + $errors = $this->control($request, 'update'); + + if (!empty($errors)) { + return $response->withStatus(500)->withJson(['errors' => $errors]); + } $aArgs = $request->getParams(); @@ -166,59 +174,57 @@ class StatusController } if (!Validator::regex('/^[\w.-]*$/')->validate($request->getParam('id')) || - !Validator::length(null, 10)->validate($request->getParam('id'))) { - array_push($errors, _ID . ' ' . _NOT . ' ' . _VALID); + !Validator::length(1, 10)->validate($request->getParam('id'))) { + array_push($errors, 'id not valid'); } if (!Validator::notEmpty()->validate($request->getParam('label_status')) || - !Validator::length(null, 50)->validate($request->getParam('label_status'))) { - array_push($errors, _LABEL_STATUS . ' ' . _IS_EMPTY); + !Validator::length(1, 50)->validate($request->getParam('label_status'))) { + array_push($errors, 'label_status not valid'); } if ( Validator::notEmpty()->validate($request->getParam('is_system')) && !Validator::contains('Y')->validate($request->getParam('is_system')) && !Validator::contains('N')->validate($request->getParam('is_system')) ) { - array_push($errors, _IS_SYSTEM . ' ' . _NOT . ' ' . _VALID); + array_push($errors, 'is_system not valid'); } if ( Validator::notEmpty()->validate($request->getParam('is_folder_status')) && !Validator::contains('Y')->validate($request->getParam('is_folder_status')) && !Validator::contains('N')->validate($request->getParam('is_folder_status')) ) { - array_push($errors, _IS_FOLDER_STATUS . ' ' . _NOT . ' ' . _VALID); + array_push($errors, 'is_folder_status not valid'); } if ( Validator::notEmpty()->validate($request->getParam('img_filename')) && (!Validator::regex('/^[\w-.]+$/')->validate($request->getParam('img_filename')) || - !Validator::length(null, 255)->validate($request->getParam('img_filename'))) + !Validator::length(1, 255)->validate($request->getParam('img_filename'))) ) { - array_push($errors, _IMG_FILENAME . ' ' . _NOT . ' ' . _VALID); + array_push($errors, 'img_filename not valid'); } if ( Validator::notEmpty()->validate($request->getParam('maarch_module')) && !Validator::length(null, 255)->validate($request->getParam('maarch_module')) ) { - array_push($errors, _MAARCH_MODULE . ' ' . _NOT . ' ' . _VALID); + array_push($errors, 'maarch_module not valid'); } if ( Validator::notEmpty()->validate($request->getParam('can_be_searched')) && !Validator::contains('Y')->validate($request->getParam('can_be_searched')) && !Validator::contains('N')->validate($request->getParam('can_be_searched')) ) { - array_push($errors, _CAN_BE_SEARCHED . ' ' . _NOT . ' ' . _VALID); + array_push($errors, 'can_be_searched not valid'); } if ( Validator::notEmpty()->validate($request->getParam('can_be_modified')) && !Validator::contains('Y')->validate($request->getParam('can_be_modified')) && !Validator::contains('N')->validate($request->getParam('can_be_modified')) ) { - array_push($errors, _CAN_BE_MODIFIED . ' ' . _NOT . ' ' . _VALID); + array_push($errors, 'can_be_modified'); } - if (!empty($errors)) { - return $response->withStatus(500)->withJson(['errors' => $errors]); - } + return $errors; } } diff --git a/core/Models/StatusModelAbstract.php b/core/Models/StatusModelAbstract.php index 608453954ffb92c313ffd4bdf5b38435b01d4056..d7e81c83b904972f114984c7fa5a253178ec2a99 100644 --- a/core/Models/StatusModelAbstract.php +++ b/core/Models/StatusModelAbstract.php @@ -51,7 +51,7 @@ class StatusModelAbstract extends \Apps_Table_Service public static function create(array $aArgs = []) { - static::checkRequired($aArgs, ['id']); + static::checkRequired($aArgs, ['id', 'label_status']); static::checkString($aArgs, ['id']); $aReturn = static::insertInto($aArgs, 'status'); @@ -61,7 +61,7 @@ class StatusModelAbstract extends \Apps_Table_Service public static function update(array $aArgs = []) { - static::checkRequired($aArgs, ['id']); + static::checkRequired($aArgs, ['id', 'label_status']); static::checkString($aArgs, ['id']); $where['id'] = $aArgs['id'];