From 3e90d8cbe15e1f82bc8a7d051177b33da6db31b8 Mon Sep 17 00:00:00 2001 From: Gogs Date: Thu, 3 Jun 2021 20:25:24 +0200 Subject: [PATCH] Aircraft Controller refactor and localization --- README.md | 4 ---- controllers/{Aircrafts.php => Aircraft.php} | 2 +- .../{aircrafts => aircraft}/_list_toolbar.htm | 2 +- controllers/aircraft/config_form.yaml | 10 ++++++++++ controllers/{aircrafts => aircraft}/config_list.yaml | 4 ++-- controllers/{aircrafts => aircraft}/create.htm | 4 ++-- controllers/{aircrafts => aircraft}/index.htm | 0 controllers/{aircrafts => aircraft}/preview.htm | 4 ++-- controllers/{aircrafts => aircraft}/update.htm | 6 +++--- controllers/aircrafts/config_form.yaml | 10 ---------- lang/en/lang.php | 12 +++++++++--- models/Aircraft.php | 7 ++++++- models/aircraft/fields.yaml | 8 ++++---- 13 files changed, 40 insertions(+), 33 deletions(-) rename controllers/{Aircrafts.php => Aircraft.php} (91%) rename controllers/{aircrafts => aircraft}/_list_toolbar.htm (86%) create mode 100644 controllers/aircraft/config_form.yaml rename controllers/{aircrafts => aircraft}/config_list.yaml (80%) rename controllers/{aircrafts => aircraft}/create.htm (90%) rename controllers/{aircrafts => aircraft}/index.htm (100%) rename controllers/{aircrafts => aircraft}/preview.htm (76%) rename controllers/{aircrafts => aircraft}/update.htm (90%) delete mode 100644 controllers/aircrafts/config_form.yaml diff --git a/README.md b/README.md index a69f732..5b6300c 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,6 @@ - Form Localization -## Aircrafts - -- Form Localization - ## Aircraft Type Groups - Form Localization diff --git a/controllers/Aircrafts.php b/controllers/Aircraft.php similarity index 91% rename from controllers/Aircrafts.php rename to controllers/Aircraft.php index 24e64f5..1d9946f 100644 --- a/controllers/Aircrafts.php +++ b/controllers/Aircraft.php @@ -3,7 +3,7 @@ use Backend\Classes\Controller; use BackendMenu; -class Aircrafts extends Controller +class Aircraft extends Controller { public $implement = ['Backend\Behaviors\ListController', 'Backend\Behaviors\FormController']; diff --git a/controllers/aircrafts/_list_toolbar.htm b/controllers/aircraft/_list_toolbar.htm similarity index 86% rename from controllers/aircrafts/_list_toolbar.htm rename to controllers/aircraft/_list_toolbar.htm index 57e55cb..f928dda 100644 --- a/controllers/aircrafts/_list_toolbar.htm +++ b/controllers/aircraft/_list_toolbar.htm @@ -1,5 +1,5 @@
-
@@ -45,7 +45,7 @@

fatalError)) ?>

-

diff --git a/controllers/aircrafts/index.htm b/controllers/aircraft/index.htm similarity index 100% rename from controllers/aircrafts/index.htm rename to controllers/aircraft/index.htm diff --git a/controllers/aircrafts/preview.htm b/controllers/aircraft/preview.htm similarity index 76% rename from controllers/aircrafts/preview.htm rename to controllers/aircraft/preview.htm index dcadc34..f1f8005 100644 --- a/controllers/aircrafts/preview.htm +++ b/controllers/aircraft/preview.htm @@ -1,6 +1,6 @@ @@ -14,7 +14,7 @@

- +

diff --git a/controllers/aircrafts/update.htm b/controllers/aircraft/update.htm similarity index 90% rename from controllers/aircrafts/update.htm rename to controllers/aircraft/update.htm index 5e51cca..e5094d0 100644 --- a/controllers/aircrafts/update.htm +++ b/controllers/aircraft/update.htm @@ -1,6 +1,6 @@ @@ -44,7 +44,7 @@ - + @@ -53,7 +53,7 @@

fatalError)) ?>

-

diff --git a/controllers/aircrafts/config_form.yaml b/controllers/aircrafts/config_form.yaml deleted file mode 100644 index 5d906f2..0000000 --- a/controllers/aircrafts/config_form.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: Aircrafts -form: $/germanairlinesva/fleet/models/aircraft/fields.yaml -modelClass: GermanAirlinesVa\Fleet\Models\Aircraft -defaultRedirect: germanairlinesva/fleet/aircrafts -create: - redirect: 'germanairlinesva/fleet/aircrafts/update/:id' - redirectClose: germanairlinesva/fleet/aircrafts -update: - redirect: germanairlinesva/fleet/aircrafts - redirectClose: germanairlinesva/fleet/aircrafts diff --git a/lang/en/lang.php b/lang/en/lang.php index ea25bbd..48dc683 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -4,9 +4,15 @@ 'description' => '', ], 'aircraft_manufacturers' => [ - 'name' => 'Name', - 'link' => 'Link', - 'history' => 'History', + 'name' => 'Manufacturer Name', + 'link' => 'Link to Homepage', + 'history' => 'History of Manufacturer', + ], + 'aircrafts' => [ + 'type' => 'Aircraft Type', + 'registration' => 'Aircraft Registration', + 'name' => 'Aircraft Name', + 'home_base' => 'Aircraft Home Base', ], 'menu' => [ 'main' => 'GA Fleet', diff --git a/models/Aircraft.php b/models/Aircraft.php index 948c728..4cf744a 100644 --- a/models/Aircraft.php +++ b/models/Aircraft.php @@ -24,7 +24,12 @@ class Aircraft extends Model /** * @var array Validation rules */ - public $rules = []; + public $rules = [ + 'aircraft_type' => 'required', + 'registration' => 'required', + 'name' => 'required', + 'home_airport_id' => 'required', + ]; public $belongsTo = [ 'aircraft_type' => 'GermanAirlinesVa\Fleet\Models\AircraftType', diff --git a/models/aircraft/fields.yaml b/models/aircraft/fields.yaml index 6867f6e..ae82fbe 100644 --- a/models/aircraft/fields.yaml +++ b/models/aircraft/fields.yaml @@ -1,23 +1,23 @@ fields: aircraft_type: - label: Type + label: 'germanairlinesva.fleet::lang.aircrafts.type' nameFrom: type descriptionFrom: description span: auto required: 1 type: relation registration: - label: Registration + label: 'germanairlinesva.fleet::lang.aircrafts.registration' span: auto required: 1 type: text name: - label: Name + label: 'germanairlinesva.fleet::lang.aircrafts.name' span: auto required: 1 type: text home_airport_id: - label: 'Home Base' + label: 'germanairlinesva.fleet::lang.aircrafts.home_base' span: auto required: 1 type: number