Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Layout\Generic to Layout #1335

Merged
merged 3 commits into from Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions demos/layout/layouts_manual.php
Expand Up @@ -7,12 +7,12 @@
/** @var \atk4\ui\App $app */
require_once __DIR__ . '/../init-app.php';

$layout = new \atk4\ui\Layout\Generic(['defaultTemplate' => __DIR__ . '/templates/layout1.html']);
$layout = new \atk4\ui\Layout(['defaultTemplate' => __DIR__ . '/templates/layout1.html']);

\atk4\ui\Lister::addTo($layout, [], ['Report'])
->setModel(new SomeData());

$app->html = null;
$app->initLayout([\atk4\ui\Layout\Generic::class]);
$app->initLayout([\atk4\ui\Layout::class]);

\atk4\ui\Text::addTo($app->layout)->addHTML($layout->render());
2 changes: 1 addition & 1 deletion demos/layout/layouts_nolayout.php
Expand Up @@ -12,6 +12,6 @@
$text = $a->generateLorem(150);

$app->html = null;
$app->initLayout([\atk4\ui\Layout\Generic::class]);
$app->initLayout([\atk4\ui\Layout::class]);

\atk4\ui\Text::addTo($app->layout)->addParagraph($text);
10 changes: 4 additions & 6 deletions src/App.php
Expand Up @@ -12,8 +12,6 @@
use atk4\core\InitializerTrait;
use atk4\data\Persistence;
use atk4\ui\Exception\ExitApplicationException;
use atk4\ui\Layout\Centered;
use atk4\ui\Layout\Generic;
use atk4\ui\Persistence\UI;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -52,7 +50,7 @@ class App
/** @var string Name of application */
public $title = 'Agile UI - Untitled Application';

/** @var Generic */
/** @var Layout */
public $layout; // the top-most view object

/**
Expand Down Expand Up @@ -255,7 +253,7 @@ public function caughtException(\Throwable $exception)
// just replace layout to avoid any extended App->_construct problems
// it will maintain everything as in the original app StickyGet, logger, Events
$this->html = null;
$this->initLayout([Centered::class]);
$this->initLayout([Layout\Centered::class]);

$this->layout->template->setHTML('Content', $this->renderExceptionHTML($exception));

Expand Down Expand Up @@ -417,7 +415,7 @@ public function terminateJSON($output, array $headers = []): void
/**
* Initializes layout.
*
* @param string|Layout\Generic|array $seed
* @param string|Layout|array $seed
*
* @return $this
*/
Expand Down Expand Up @@ -607,7 +605,7 @@ protected function getRequestURI()
}

/**
* @var null
* @var string|null
*/
public $page;

Expand Down
2 changes: 1 addition & 1 deletion src/Card.php
Expand Up @@ -47,7 +47,7 @@ class Card extends View
/** @var string The CardSection default class name. */
public $cardSection = CardSection::class;

/** @var null | View The extra content view container for the card. */
/** @var View|null The extra content view container for the card. */
public $extraContainer;

/** @var string|View|null A description inside the Card content. */
Expand Down
9 changes: 4 additions & 5 deletions src/Component/InlineEdit.php
Expand Up @@ -10,7 +10,6 @@
use atk4\data\ValidationException;
use atk4\ui\Exception;
use atk4\ui\jsToast;
use atk4\ui\jsVueService;
use atk4\ui\View;

class InlineEdit extends View
Expand All @@ -20,14 +19,14 @@ class InlineEdit extends View
/**
* jsCallback for saving data.
*
* @var null
* @var \atk4\ui\jsCallback
*/
public $cb;

/**
* Input initial value.
*
* @var null
* @var mixed
*/
public $initValue;

Expand Down Expand Up @@ -77,7 +76,7 @@ class InlineEdit extends View
* A default one is supply if this is null.
* It receive the error ($e) as parameter.
*
* @var null | callable
* @var callable|null
*/
public $formatErrorMsg;

Expand All @@ -94,7 +93,7 @@ public function init(): void
$this->formatErrorMsg = function ($e, $value) {
$caption = $this->model->getField($this->field)->getCaption();

return "{$caption} - {$e->getMessage()}. <br>Trying to set this value: '{$value}'";
return $caption . ' - ' . $e->getMessage() . '. <br>Trying to set this value: "' . $value . '"';
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Component/ItemSearch.php
Expand Up @@ -38,7 +38,7 @@ class ItemSearch extends View
* The jquery selector where you need to add the semantic-ui 'loading' class.
* Default to reload selector.
*
* @var null
* @var View
*/
public $context;

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Control/Dropdown.php
Expand Up @@ -54,7 +54,7 @@ class Dropdown extends Input
* Note: dropdown icon is show on the right side of the menu
* while other icon are usually display on the left side.
*
* @var null
* @var string|null
*/
public $dropIcon;

Expand Down
4 changes: 2 additions & 2 deletions src/Form/Control/DropdownCascade.php
Expand Up @@ -27,10 +27,10 @@ class DropdownCascade extends Dropdown
/** @var string|Model|null the hasMany reference model that will generated value for this dropdown list. */
public $reference;

/** @var null The form input create by cascadeFrom field */
/** @var Field The form input create by cascadeFrom field */
protected $cascadeInput;

/** @var null The casacade input value. */
/** @var string The casacade input value. */
protected $cascadeInputValue;

public function init(): void
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Control/Multiline.php
Expand Up @@ -199,7 +199,7 @@ class Multiline extends Form\Control
public $caption;

/**
* @var null | jsFunction
* @var jsFunction|null
*
* A jsFunction to execute when Multiline add(+) button is clicked.
* The function is execute after mulitline component finish adding a row of fields.
Expand All @@ -209,7 +209,7 @@ class Multiline extends Form\Control
public $jsAfterAdd;

/**
* @var null | jsFunction
* @var jsFunction|null
*
* A jsFunction to execute when Multiline delete button is clicked.
* The function is execute after mulitline component finish deleting rows.
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Control/TreeItemSelector.php
Expand Up @@ -25,7 +25,7 @@ class TreeItemSelector extends Form\Control
/**
* Template for the item selector view.
*
* @var null
* @var Template
*/
public $itemSelectorTemplate;

Expand Down
9 changes: 4 additions & 5 deletions src/Form/Control/Upload.php
Expand Up @@ -15,7 +15,7 @@ class Upload extends Input
/**
* The action button to open file browser dialog.
*
* @var null
* @var View
*/
public $action;

Expand All @@ -25,7 +25,7 @@ class Upload extends Input
* If not set, will default to file name.
* file id is also sent with onDelete Callback.
*
* @var null
* @var string
*/
public $fileId;

Expand All @@ -48,10 +48,9 @@ class Upload extends Input
public $defaultTemplate = 'formfield/upload.html';

/**
* The jsCallback.
* Same callback is use for onUpload or onDelete.
* Callback is use for onUpload or onDelete.
*
* @var null
* @var \atk4\ui\jsCallback
*/
public $cb;

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Control/UploadImage.php
Expand Up @@ -26,7 +26,7 @@ class UploadImage extends Upload
/**
* The default thumbnail source.
*
* @var null
* @var string
*/
public $defaultSrc;

Expand Down
2 changes: 1 addition & 1 deletion src/Grid.php
Expand Up @@ -63,7 +63,7 @@ class Grid extends View
* Calling addAction will add a new column inside $table with dropdown menu,
* and will be re-used for next addActionMenuItem().
*
* @var null
* @var Table\Column
*/
public $actionMenu;

Expand Down
16 changes: 16 additions & 0 deletions src/Layout.php
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace atk4\ui;

class Layout extends View
{
/**
* Add a loadable View.
*/
public function addRightPanel(Panel\Loadable $panel): Panel\Loadable
{
return $this->owner->add($panel, 'RightPanel');
}
}
6 changes: 1 addition & 5 deletions src/Layout/Admin.php
Expand Up @@ -32,7 +32,7 @@
*
* - Content
*/
class Admin extends Generic implements Navigable
class Admin extends \atk4\ui\Layout implements NavigableInterface
{
public $menuLeft; // vertical menu
public $menu; // horizontal menu
Expand Down Expand Up @@ -89,10 +89,6 @@ public function addMenuGroup($seed): Menu

/**
* Add items to left menu.
*
* @param $name
* @param null $action
* @param null $group
*/
public function addMenuItem($name, $action = null, $group = null): Item
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layout/Centered.php
Expand Up @@ -11,7 +11,7 @@
* Bevel will use some padding and will contain your Content.
* This layout is handy for a simple and single-purpose applications.
*/
class Centered extends Generic
class Centered extends \atk4\ui\Layout
{
use \atk4\core\DebugTrait;

Expand Down
2 changes: 1 addition & 1 deletion src/Layout/Column.php
Expand Up @@ -13,7 +13,7 @@
*
* Sticky top-bar for simple navigation and three flexible areas for flexible use.
*/
class Column extends Generic
class Column extends \atk4\ui\Layout
{
public $defaultTemplate = 'layout/column.html';

Expand Down
14 changes: 4 additions & 10 deletions src/Layout/Generic.php
Expand Up @@ -4,16 +4,10 @@

namespace atk4\ui\Layout;

use atk4\ui\Panel\Loadable;
use atk4\ui\View;
if (!class_exists(\SebastianBergmann\CodeCoverage\CodeCoverage::class, false)) {
'trigger_error'('Class atk4\ui\Layout\Generic is deprecated. Use atk4\ui\Layout instead', E_USER_DEPRECATED);
}

class Generic extends View
class Generic extends \atk4\ui\Layout
{
/**
* Add a loadable View.
*/
public function addRightPanel(Loadable $panel): Loadable
{
return $this->owner->add($panel, 'RightPanel');
}
}
23 changes: 4 additions & 19 deletions src/Layout/Navigable.php
Expand Up @@ -7,25 +7,10 @@

namespace atk4\ui\Layout;

use atk4\ui\Item;
use atk4\ui\Menu;
if (!class_exists(\SebastianBergmann\CodeCoverage\CodeCoverage::class, false)) {
'trigger_error'('Interface atk4\ui\Layout\Navigable is deprecated. Use atk4\ui\NavigableInterface instead', E_USER_DEPRECATED);
}

interface Navigable
interface Navigable extends NavigableInterface
{
/**
* Add a group to left menu.
*
* @param $seed
*/
public function addMenuGroup($seed): Menu;

/**
* Add items to left menu.
* Will place item in a group if supply.
*
* @param $name
* @param null $action
* @param null $group
*/
public function addMenuItem($name, $action = null, $group = null): Item;
}
27 changes: 27 additions & 0 deletions src/Layout/NavigableInterface.php
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);
/**
* Interface for a Layout using a navigable side menu.
*/

namespace atk4\ui\Layout;

use atk4\ui\Item;
use atk4\ui\Menu;

interface NavigableInterface
{
/**
* Add a group to left menu.
*
* @param $seed
*/
public function addMenuGroup($seed): Menu;

/**
* Add items to left menu.
* Will place item in a group if supply.
*/
public function addMenuItem($name, $action = null, $group = null): Item;
}
2 changes: 1 addition & 1 deletion src/Layout/Product.php
Expand Up @@ -8,7 +8,7 @@
* Ideally suited for your product page, this layout is a single-column
* layout designed specifically product description.
*/
class Product extends Generic
class Product extends \atk4\ui\Layout
{
public $defaultTemplate = 'layout/product.html';
}
6 changes: 1 addition & 5 deletions src/Panel/Right.php
Expand Up @@ -22,7 +22,7 @@ class Right extends View implements Loadable
{
public $defaultTemplate = 'panel/right.html';

/** @var null */
/** @var Modal */
public $closeModal;
/** @var array Confirmation Modal default */
public $defaultModal = [Modal::class, 'class' => ['mini']];
Expand Down Expand Up @@ -128,10 +128,6 @@ public function jsClose(): jsExpression
* Attach confirmation modal view to display.
* js flyoutService will prevent closing of Flyout if a confirmation modal
* is attached to it and flyoutService detect that the current open flyoutContent has warning on.
*
* @param $msg
* @param null $okBtn
* @param null $cancelBtn
*/
public function addConfirmation(string $msg, string $title = 'Closing panel!', string $okBtn = null, string $cancelBtn = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Table/Column.php
Expand Up @@ -59,7 +59,7 @@ class Column
/**
* The data-column attribute value for Table th tag.
*
* @var null
* @var string|null
*/
public $columnData;

Expand Down