Skip to content

Feature/Panel Action Executor #1650

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

Merged
merged 62 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e6bddb5
init
ibelar Jul 6, 2021
b8f7372
move url method to View class
ibelar Jul 6, 2021
932a566
cs fix
ibelar Jul 6, 2021
5cb1f63
cs fix
ibelar Jul 6, 2021
b303602
remove report error
ibelar Jul 6, 2021
df2e538
make sure callback never reach is caught
ibelar Jul 7, 2021
5a45235
cs fix
ibelar Jul 7, 2021
0e6c9bb
Remove callback from Wizard
ibelar Jul 7, 2021
a9f6e70
fix
ibelar Jul 7, 2021
d996585
cs fix
ibelar Jul 7, 2021
e70f9b7
phpstan fix
ibelar Jul 7, 2021
ab62f41
Merge branch 'develop' into feature/callback-url
ibelar Jul 13, 2021
6bed38f
update factory
ibelar Jul 14, 2021
119a935
create redirect utils
ibelar Jul 14, 2021
e883987
improve loader
ibelar Jul 14, 2021
70f9b67
vp executor init
ibelar Jul 14, 2021
08eed64
clean up
ibelar Jul 14, 2021
c8418e0
js fix
ibelar Jul 14, 2021
8589246
phpstan fix
ibelar Jul 14, 2021
a01e5c9
add return type
ibelar Jul 14, 2021
f5a5937
phpstan fix
ibelar Jul 14, 2021
4143798
more stan fix
ibelar Jul 14, 2021
8447b0c
remove error in dist file
ibelar Jul 14, 2021
77f5eaa
add behat
ibelar Jul 14, 2021
ee00e00
split demo file
ibelar Jul 14, 2021
f3bb365
test and cs fix
ibelar Jul 14, 2021
7ee174d
fix
ibelar Jul 15, 2021
705e56f
set vp access to protected
ibelar Jul 15, 2021
61c2738
minor fix
ibelar Jul 15, 2021
0ce3b75
Merge branch 'feature/callback-url' into feature/panel-executor
ibelar Jul 15, 2021
26357d6
fix return type
ibelar Jul 15, 2021
6b69cf4
phpstan
ibelar Jul 15, 2021
2b6c90a
Merge branch 'feature/vp-executor' into feature/panel-executor
ibelar Jul 15, 2021
cfe4f65
php stan fix
ibelar Jul 15, 2021
ac31a6a
Merge branch 'feature/vp-executor' into feature/panel-executor
ibelar Jul 15, 2021
c4969a2
remove error ignore
ibelar Jul 15, 2021
20fa8be
Merge branch 'feature/vp-executor' into feature/panel-executor
ibelar Jul 15, 2021
6400f6e
panel executor
ibelar Jul 15, 2021
2ab02b4
fix phpstan
ibelar Jul 16, 2021
e8fd9d0
fix
ibelar Jul 16, 2021
cf20034
make action private
ibelar Jul 16, 2021
00a79b7
separate click and esc away event
ibelar Jul 16, 2021
c102079
fix coverage
ibelar Jul 16, 2021
289d7b0
add callback trigger test
ibelar Jul 16, 2021
a4c5d22
add getTriggeredValue test
ibelar Jul 16, 2021
b76c3d8
Merge branch 'feature/callback-url' into feature/panel-executor
ibelar Jul 16, 2021
2726128
phpstan fix
ibelar Jul 16, 2021
f6a5b68
Merge branch 'develop' into pr/1650
ibelar Jul 25, 2021
74836d7
merge
ibelar Jul 25, 2021
e5b4b0e
add panel executor test
ibelar Jul 25, 2021
353cfdb
cs fix
ibelar Jul 25, 2021
b5e99f5
Merge branch 'develop' into feature/panel-executor
ibelar Oct 4, 2021
f0b5335
fix stan
ibelar Oct 4, 2021
1f35ea3
fix js
ibelar Oct 4, 2021
661574d
fresh js install
ibelar Oct 4, 2021
f8da73f
remove duplicate action-setup.php
mvorisek Oct 4, 2021
135be90
must always include, not only once
mvorisek Oct 5, 2021
6321a2d
fix card action
ibelar Oct 5, 2021
d59f2b7
fix panel service
ibelar Oct 5, 2021
348cdf6
reset app catch callback
ibelar Oct 5, 2021
e759e7c
reset CardDeck paginator
ibelar Oct 5, 2021
d7f565c
fix template
ibelar Oct 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/collection/crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function addFormTo(\Atk4\Ui\View $view): \Atk4\Ui\Form

if ($this->action->getEntity()->get(File::hinting()->fieldName()->is_folder)) {
\Atk4\Ui\Grid::addTo($right, ['menu' => false, 'ipp' => 5])
->setModel(File::assertInstanceOf($this->action->getModel())->SubFolder);
->setModel(File::assertInstanceOf($this->getAction()->getModel())->SubFolder);
} else {
\Atk4\Ui\Message::addTo($right, ['Not a folder', 'warning']);
}
Expand Down
40 changes: 40 additions & 0 deletions demos/data-action/action-setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Atk4\Ui\Demos;

// Demo for Model action

use Atk4\Ui\App;
use Atk4\Ui\Message;

/** @var App $app */
$country = new CountryLock($app->db);
$entity = $country->tryLoadAny();
$countryId = $entity->getId();

// Model actions for this file are setup in DemoActionUtil.
DemoActionsUtil::setupDemoActions($country);

\Atk4\Ui\Header::addTo($app, ['Assign Model action to button event', 'subHeader' => 'Execute model action on this country record by clicking on the appropriate button on the right.']);

$msg = Message::addTo($app, ['Notes', 'type' => 'info']);
$msg->text->addParagraph('When passing an action to a button event, Ui will determine what executor is required base on the action properties.');
$msg->text->addParagraph('If action require arguments, fields and/or preview, then a ModalExecutor will be use.');

\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']);

$gl = \Atk4\Ui\GridLayout::addTo($app, ['rows' => 1, 'columns' => 2]);
$c = \Atk4\Ui\Card::addTo($gl, ['useLabel' => true], ['r1c1']);
$c->addContent(new \Atk4\Ui\Header(['Using country: ']));
$c->setModel($entity, [$country->fieldName()->iso, $country->fieldName()->iso3, $country->fieldName()->phonecode]);

$buttons = \Atk4\Ui\View::addTo($gl, ['ui' => 'vertical basic buttons'], ['r1c2']);

// Create a button for every action in Country model.
foreach ($country->getUserActions() as $action) {
$b = \Atk4\Ui\Button::addTo($buttons, [$action->getCaption()]);
// Assign action to button using current model id as url arguments.
$b->on('click', $action, ['args' => ['id' => $countryId]]);
}
15 changes: 15 additions & 0 deletions demos/data-action/jsactions-panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Atk4\Ui\Demos;

use Atk4\Ui\UserAction\PanelExecutor;

/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';

$factory = $app->getExecutorFactory();
$factory->registerTypeExecutor($factory::STEP_EXECUTOR, [PanelExecutor::class]);

require_once 'action-setup.php';
1 change: 1 addition & 0 deletions demos/init-app.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
$layout->addMenuItem(['Executor Examples'], [$path . 'actions'], $menu);
$layout->addMenuItem(['Assign action to event'], [$path . 'jsactions'], $menu);
$layout->addMenuItem(['Assign action to button (Modal)'], [$path . 'jsactions2'], $menu);
$layout->addMenuItem(['Assign action to button (Panel)'], [$path . 'jsactions-panel'], $menu);
$layout->addMenuItem(['Assign action to button (V. Page)'], [$path . 'jsactions-vp'], $menu);
$layout->addMenuItem(['Execute from Grid'], [$path . 'jsactionsgrid'], $menu);
$layout->addMenuItem(['Execute from Crud'], [$path . 'jsactionscrud'], $menu);
Expand Down
61 changes: 34 additions & 27 deletions demos/layout/layout-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,76 @@

namespace Atk4\Ui\Demos;

use Atk4\Ui\Header;
use Atk4\Ui\Message;
use Atk4\Ui\Panel\Right;
use Atk4\Ui\View;

/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';

$country = new CountryLock($app->db);
DemoActionsUtil::setupDemoActions($country);

\Atk4\Ui\Header::addTo($app, ['Right Panel', 'subHeader' => 'Content on the fly!']);
Header::addTo($app, ['Right Panel', 'subHeader' => 'Content on the fly!']);

// PANEL

\Atk4\Ui\Header::addTo($app, ['Static', 'size' => 4, 'subHeader' => 'Panel may have static content only.']);
$panel = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right(['dynamic' => false]));
\Atk4\Ui\Message::addTo($panel, ['This panel contains only static content.']);
Header::addTo($app, ['Static', 'size' => 4, 'subHeader' => 'Panel may have static content only.']);
$panel = Right::addTo($app, ['dynamic' => []]);
Message::addTo($panel, ['This panel contains only static content.']);
$btn = \Atk4\Ui\Button::addTo($app, ['Open Static']);
$btn->on('click', $panel->jsOpen());
\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
View::addTo($app, ['ui' => 'divider']);

// PANEL_1

\Atk4\Ui\Header::addTo($app, ['Dynamic', 'size' => 4, 'subHeader' => 'Panel can load content dynamically']);
$panel1 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right());
\Atk4\Ui\Message::addTo($panel1, ['This panel will load content dynamically below according to button select on the right.']);
Header::addTo($app, ['Dynamic', 'size' => 4, 'subHeader' => 'Panel can load content dynamically']);
$panel1 = Right::addTo($app);

Message::addTo($panel1, ['This panel will load content dynamically below according to button select on the right.']);
$btn = \Atk4\Ui\Button::addTo($app, ['Button 1']);
$btn->js(true)->data('btn', '1');
$btn->on('click', $panel1->jsOpen(['btn'], 'orange'));
$btn->on('click', $panel1->jsOpen([], ['btn'], 'orange'));

$btn = \Atk4\Ui\Button::addTo($app, ['Button 2']);
$btn->js(true)->data('btn', '2');
$btn->on('click', $panel1->jsOpen(['btn'], 'orange'));
$btn->on('click', $panel1->jsOpen([], ['btn'], 'orange'));

$view = \Atk4\Ui\View::addTo($app, ['ui' => 'segment']);
$view = View::addTo($app, ['ui' => 'segment']);
$text = \Atk4\Ui\Text::addTo($view);
$text->set($_GET['txt'] ?? 'Not Complete');

$panel1->onOpen(function ($p) use ($view) {
$panel = \Atk4\Ui\View::addTo($p, ['ui' => 'basic segment']);
$panel = View::addTo($p, ['ui' => 'basic segment']);
$buttonNumber = $panel->stickyGet('btn');

$panelText = 'You loaded panel content using button #' . $buttonNumber;
\Atk4\Ui\Message::addTo($panel, ['Panel 1', 'text' => $panelText]);
Message::addTo($panel, ['Panel 1', 'text' => $panelText]);

$reloadPanelButton = \Atk4\Ui\Button::addTo($panel, ['Reload Myself']);
$reloadPanelButton->on('click', new \Atk4\Ui\JsReload($panel));

\Atk4\Ui\View::addTo($panel, ['ui' => 'divider']);
View::addTo($panel, ['ui' => 'divider']);
$panelButton = \Atk4\Ui\Button::addTo($panel, ['Complete']);
$panelButton->on('click', [
$p->getOwner()->jsClose(),
new \Atk4\Ui\JsReload($view, ['txt' => 'Complete using button #' . $buttonNumber]),
]);
});

\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
View::addTo($app, ['ui' => 'divider']);

// PANEL_2

\Atk4\Ui\Header::addTo($app, ['Closing option', 'size' => 4, 'subHeader' => 'Panel can prevent from closing.']);
Header::addTo($app, ['Closing option', 'size' => 4, 'subHeader' => 'Panel can prevent from closing.']);

$panel2 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right(['hasClickAway' => false]));
$panel2 = Right::addTo($app, ['hasClickAway' => false]);
$icon = \Atk4\Ui\Icon::addTo($app, ['big cog'])->addStyle('cursor', 'pointer');
$icon->on('click', $panel2->jsOpen());
$panel2->addConfirmation('Changes will be lost. Are you sure?');

$msg = \Atk4\Ui\Message::addTo($panel2, ['Prevent close.']);
$msg = Message::addTo($panel2, ['Prevent close.']);

$txt = \Atk4\Ui\Text::addTo($msg);
$txt->addParagraph('This panel can only be closed via it\'s close icon at top right.');
Expand All @@ -88,28 +94,29 @@
];
});
});
\Atk4\Ui\View::addTo($app, ['ui' => 'divider']);
View::addTo($app, ['ui' => 'divider']);

// PANEL_3

$countryId = $app->stickyGet('id');
\Atk4\Ui\Header::addTo($app, ['UserAction Friendly', 'size' => 4, 'subHeader' => 'Panel can run model action.']);
$panel3 = $app->layout->addRightPanel(new \Atk4\Ui\Panel\Right());
$msg = \Atk4\Ui\Message::addTo($panel3, ['Run Country model action below.']);
Header::addTo($app, ['UserAction Friendly', 'size' => 4, 'subHeader' => 'Panel can run model action.']);

$panel3 = Right::addTo($app);
$msg = Message::addTo($panel3, ['Run Country model action below.']);

$deck = \Atk4\Ui\View::addTo($app, ['ui' => 'cards']);
$deck = View::addTo($app, ['ui' => 'cards']);
$country->setLimit(3);

foreach ($country as $ct) {
$c = \Atk4\Ui\Card::addTo($deck, ['useLabel' => true])->addStyle('cursor', 'pointer');
$c->setModel($ct);
$c->on('click', $panel3->jsOpen(['id'], 'orange'));
$c->on('click', $panel3->jsOpen([], ['id'], 'orange'));
}

$panel3->onOpen(function ($p) use ($country, $countryId) {
$seg = \Atk4\Ui\View::addTo($p, ['ui' => 'basic segment center aligned']);
\Atk4\Ui\Header::addTo($seg, [$country->load($countryId)->getTitle()]);
$buttons = \Atk4\Ui\View::addTo($seg, ['ui' => 'vertical basic buttons']);
$seg = View::addTo($p, ['ui' => 'basic segment center aligned']);
Header::addTo($seg, [$country->load($countryId)->getTitle()]);
$buttons = View::addTo($seg, ['ui' => 'vertical basic buttons']);
foreach ($country->getUserActions() as $action) {
$button = \Atk4\Ui\Button::addTo($buttons, [$action->getCaption()]);
$button->on('click', $action, ['args' => ['id' => $countryId]]);
Expand Down
6 changes: 6 additions & 0 deletions js/Release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Release note

### version 1.21.0 (2021-07-15)

- Implement Panel as portal view in order to properly manage them on reload.
- Changes in api service.
- Add remove panel to panel service. Will now remove panel from list of panels but also remove them from dom, like Modal.

### version 1.20.0 (2021-07-14)

- Add redirect utils method.
Expand Down
Loading