Type Groups

This commit is contained in:
Gogs 2021-06-03 18:34:22 +02:00
parent 9fdfe9dfb1
commit 27410bf5c2
23 changed files with 437 additions and 145 deletions

View File

@ -0,0 +1,17 @@
<?php namespace GermanAirlinesVa\Fleet\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class AircraftTypeGroups extends Controller
{
public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController' ];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public function __construct()
{
parent::__construct();
}
}

View File

@ -0,0 +1,18 @@
<div data-control="toolbar">
<a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', true)"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
</div>

View File

@ -0,0 +1,10 @@
name: AircraftTypeGroups
form: $/germanairlinesva/fleet/models/aircrafttypegroup/fields.yaml
modelClass: GermanAirlinesVa\Fleet\Models\AircraftTypeGroup
defaultRedirect: germanairlinesva/fleet/aircrafttypegroups
create:
redirect: 'germanairlinesva/fleet/aircrafttypegroups/update/:id'
redirectClose: germanairlinesva/fleet/aircrafttypegroups
update:
redirect: germanairlinesva/fleet/aircrafttypegroups
redirectClose: germanairlinesva/fleet/aircrafttypegroups

View File

@ -0,0 +1,12 @@
list: $/germanairlinesva/fleet/models/aircrafttypegroup/columns.yaml
modelClass: GermanAirlinesVa\Fleet\Models\AircraftTypeGroup
title: AircraftTypeGroups
noRecordsMessage: 'backend::lang.list.no_records'
showSetup: true
showCheckboxes: true
recordsPerPage: 20
toolbar:
buttons: list_toolbar
search:
prompt: 'backend::lang.list.search_prompt'
recordUrl: 'germanairlinesva/fleet/aircrafttypegroups/update/:id'

View File

@ -0,0 +1,46 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>">AircraftTypeGroups</a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>
<?php if (!$this->fatalError): ?>
<?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
<?= $this->formRender() ?>
</div>
<div class="form-buttons">
<div class="loading-indicator-container">
<button
type="submit"
data-request="onSave"
data-hotkey="ctrl+s, cmd+s"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-primary">
<?= e(trans('backend::lang.form.create')) ?>
</button>
<button
type="button"
data-request="onSave"
data-request-data="close:1"
data-hotkey="ctrl+enter, cmd+enter"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-default">
<?= e(trans('backend::lang.form.create_and_close')) ?>
</button>
<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
</span>
</div>
</div>
<?= Form::close() ?>
<?php else: ?>
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
<p><a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
<?php endif ?>

View File

@ -0,0 +1 @@
<?= $this->listRender() ?>

View File

@ -0,0 +1,22 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>">AircraftTypeGroups</a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>
<?php if (!$this->fatalError): ?>
<div class="form-preview">
<?= $this->formRenderPreview() ?>
</div>
<?php else: ?>
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
<?php endif ?>
<p>
<a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>" class="btn btn-default oc-icon-chevron-left">
<?= e(trans('backend::lang.form.return_to_list')) ?>
</a>
</p>

View File

@ -0,0 +1,54 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>">AircraftTypeGroups</a></li>
<li><?= e($this->pageTitle) ?></li>
</ul>
<?php Block::endPut() ?>
<?php if (!$this->fatalError): ?>
<?= Form::open(['class' => 'layout']) ?>
<div class="layout-row">
<?= $this->formRender() ?>
</div>
<div class="form-buttons">
<div class="loading-indicator-container">
<button
type="submit"
data-request="onSave"
data-request-data="redirect:0"
data-hotkey="ctrl+s, cmd+s"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-primary">
<?= e(trans('backend::lang.form.save')) ?>
</button>
<button
type="button"
data-request="onSave"
data-request-data="close:1"
data-hotkey="ctrl+enter, cmd+enter"
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
class="btn btn-default">
<?= e(trans('backend::lang.form.save_and_close')) ?>
</button>
<button
type="button"
class="oc-icon-trash-o btn-icon danger pull-right"
data-request="onDelete"
data-load-indicator="<?= e(trans('backend::lang.form.deleting')) ?>"
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')) ?>">
</button>
<span class="btn-text">
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
</span>
</div>
</div>
<?= Form::close() ?>
<?php else: ?>
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
<p><a href="<?= Backend::url('germanairlinesva/fleet/aircrafttypegroups') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
<?php endif ?>

View File

@ -15,5 +15,6 @@
'manufacturers' => 'Aircraft Manufacturers',
'types' => 'Aircraft Types',
'aircrafts' => 'Aircrafts',
'groups' => 'Aircraft Type Groups',
],
];

View File

@ -18,7 +18,6 @@ class Aircraft extends Model
/**
* @var string The database table used by the model.
*/
//public $table = 'germanairlinesva_fleet_aircrafts';
public $table = 'aircrafts';
protected $connection = 'germanairlinesva_fleet';

View File

@ -18,7 +18,6 @@ class AircraftManufacturer extends Model
/**
* @var string The database table used by the model.
*/
// public $table = 'germanairlinesva_fleet_aircraft_manufacturers';
public $table = 'aircraft_manufacturers';
protected $connection = 'germanairlinesva_fleet';

View File

@ -18,7 +18,6 @@ class AircraftType extends Model
/**
* @var string The database table used by the model.
*/
// public $table = 'germanairlinesva_fleet_aircraft_types';
public $table = 'aircraft_types';
protected $connection = 'germanairlinesva_fleet';
@ -31,6 +30,10 @@ class AircraftType extends Model
'aircraft_manufacturer' => 'GermanAirlinesVa\Fleet\Models\AircraftManufacturer',
];
public $belongsToMany = [
'aircraft_type_groups' => 'GermanAirlinesVa\Fleet\Models\AircraftTypeGroup',
];
public $hasMany = [
'aircrafts' => 'GermanAirlinesVa\Fleet\Models\Aircraft',
];

View File

@ -0,0 +1,32 @@
<?php namespace GermanAirlinesVa\Fleet\Models;
use Model;
/**
* Model
*/
class AircraftTypeGroup extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
public $table = 'aircraft_type_groups';
protected $connection = 'germanairlinesva_fleet';
/**
* @var array Validation rules
*/
public $rules = [];
public $belongsToMany = [
'aircraft_types' => 'GermanAirlinesVa\Fleet\Models\AircraftType',
];
}

View File

@ -32,6 +32,14 @@ tabs:
required: 1
type: text
tab: Operational
aircraft_type_groups:
label: 'Aircraft Type Groups'
nameFrom: comment
descriptionFrom: description
span: auto
required: 1
type: relation
tab: Operational
dom:
label: DOM
span: auto

View File

@ -0,0 +1,7 @@
columns:
id:
label: id
type: number
comment:
label: comment
type: text

View File

@ -0,0 +1,5 @@
fields:
comment:
label: Comment
span: auto
type: text

View File

@ -22,3 +22,7 @@ navigation:
label: 'germanairlinesva.fleet::lang.menu.aircrafts'
url: germanairlinesva/fleet/aircrafts
icon: icon-plane
side-menu-item4:
label: 'germanairlinesva.fleet::lang.menu.groups'
url: germanairlinesva/fleet/aircrafttypegroups
icon: icon-group

View File

@ -9,7 +9,6 @@ class BuilderTableCreateGermanAirlinesVaAircraftManufacturers extends Migration
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircraft_manufacturers', function ($table) {
//Schema::create('germanairlinesva_fleet_aircraft_manufacturers', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('name');
@ -21,6 +20,5 @@ class BuilderTableCreateGermanAirlinesVaAircraftManufacturers extends Migration
public function down()
{
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircraft_manufacturers');
//Schema::dropIfExists('germanairlinesva_fleet_aircraft_manufacturers');
}
}

View File

@ -0,0 +1,31 @@
<?php namespace GermanAirlinesVa\Fleet\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaFleetAircraftTypesAircraftTypeGroups extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircraft_type_aircraft_type_group', function ($table) {
$table->engine = 'InnoDB';
$table->bigInteger('aircraft_type_id')->unsigned();
$table
->foreign('aircraft_type_id')
->references('id')
->on('aircraft_types');
$table->bigInteger('aircraft_type_group_id')->unsigned();
$table
->foreign('aircraft_type_group_id')
->references('id')
->on('aircraft_type_groups');
});
}
public function down()
{
Schema::connection('germanairlinesva_fleet')->disableForeignKeyConstraints();
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircraft_type_aircraft_type_group');
Schema::connection('germanairlinesva_fleet')->enableForeignKeyConstraints();
}
}

View File

@ -0,0 +1,21 @@
<?php namespace GermanAirlinesVa\Fleet\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaFleetAircraftTypeGroups extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircraft_type_groups', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('comment');
});
}
public function down()
{
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircraft_type_groups');
}
}

View File

@ -9,7 +9,6 @@ class BuilderTableCreateGermanAirlinesVaAircraftTypes extends Migration
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircraft_types', function ($table) {
//Schema::create('germanairlinesva_fleet_aircraft_types', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('aircraft_manufacturer_id')->unsigned();
@ -47,7 +46,8 @@ class BuilderTableCreateGermanAirlinesVaAircraftTypes extends Migration
public function down()
{
Schema::connection('germanairlinesva_fleet')->disableForeignKeyConstraints();
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircraft_types');
//Schema::dropIfExists('germanairlinesva_fleet_aircraft_types');
Schema::connection('germanairlinesva_fleet')->enableForeignKeyConstraints();
}
}

View File

@ -8,7 +8,6 @@ class BuilderTableCreateGermanAirlinesVaFleetAircrafts extends Migration
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircrafts', function ($table) {
//Schema::create('germanairlinesva_fleet_aircrafts', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('aircraft_type_id')->unsigned();
@ -58,7 +57,8 @@ class BuilderTableCreateGermanAirlinesVaFleetAircrafts extends Migration
public function down()
{
Schema::connection('germanairlinesva_fleet')->disableForeignKeyConstraints();
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircrafts');
//Schema::dropIfExists('germanairlinesva_fleet_aircrafts');
Schema::connection('germanairlinesva_fleet')->enableForeignKeyConstraints();
}
}

View File

@ -7,3 +7,7 @@
- builder_table_create_aircraft_types.php
- 'Created table aircrafts'
- builder_table_create_aircrafts.php
- 'Created table aircraft_type_groups'
- builder_table_create_aircraft_type_groups.php
- 'Created table aircraft_type_aircraft_type_group'
- builder_table_create_aircraft_type_aircraft_type_group.php