Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed May 21, 2022
1 parent a337b6b commit d869b6e
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 31 deletions.
6 changes: 3 additions & 3 deletions demos/form-control/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
Form\Control\Checkbox::addTo($app, ['Make my profile visible ticked'])->set(true);

View::addTo($app, ['ui' => 'divider']);
Form\Control\Checkbox::addTo($app, ['Accept terms and conditions', 'slider']);
Form\Control\Checkbox::addTo($app, ['Accept terms and conditions', 'class.slider' => true]);

View::addTo($app, ['ui' => 'divider']);
Form\Control\Checkbox::addTo($app, ['Subscribe to weekly newsletter', 'toggle']);
Form\Control\Checkbox::addTo($app, ['Subscribe to weekly newsletter', 'class.toggle' => true]);
View::addTo($app, ['ui' => 'divider']);
Form\Control\Checkbox::addTo($app, ['Look for the clues', 'disabled toggle'])->set(true);
Form\Control\Checkbox::addTo($app, ['Look for the clues', 'class.disabled toggle' => true])->set(true);

View::addTo($app, ['ui' => 'divider']);
Form\Control\Checkbox::addTo($app, ['Custom setting?'])->js(true)->checkbox('set indeterminate');
Expand Down
2 changes: 1 addition & 1 deletion demos/form/form-section-accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$section2->addControl('delivery_address', []);

// Terms field
$form->addControl('term', [Form\Control\Checkbox::class, 'caption' => 'Accept terms and conditions', null, 'slider']);
$form->addControl('term', [Form\Control\Checkbox::class, 'caption' => 'Accept terms and conditions', 'class.slider' => true]);

$accordionLayout->activate($contactSection);

Expand Down
4 changes: 2 additions & 2 deletions demos/form/jscondform.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
\Atk4\Ui\Header::addTo($app, ['Phone', 'size' => 2]);

$formPhone = Form::addTo($app, ['class.segment' => true]);
\Atk4\Ui\Label::addTo($formPhone, ['Add other phone field input. Note: phone1 required a number of at least 5 char.', 'top attached'], ['AboveControls']);
\Atk4\Ui\Label::addTo($formPhone, ['Add other phone field input. Note: phone1 required a number of at least 5 char.', 'class.top attached' => true], ['AboveControls']);

$formPhone->addControl('phone1');
$formPhone->addControl('phone2');
Expand All @@ -36,7 +36,7 @@
\Atk4\Ui\Label::addTo($formSubscribe, ['Click on subscribe and add email to receive your gift.', 'top attached'], ['AboveControls']);

$formSubscribe->addControl('name');
$formSubscribe->addControl('subscribe', [Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'toggle']);
$formSubscribe->addControl('subscribe', [Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'class.toggle' => true]);
$formSubscribe->addControl('email');
$formSubscribe->addControl('gender', [Form\Control\Radio::class], ['enum' => ['Female', 'Male']])->set('Female');
$formSubscribe->addControl('m_gift', [Form\Control\Dropdown::class, 'caption' => 'Gift for Men', 'values' => ['Beer Glass', 'Swiss Knife']]);
Expand Down
2 changes: 1 addition & 1 deletion demos/interactive/popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@ public function linkCart($cart, $jsAction = null)
$button = \Atk4\Ui\Button::addTo($app, [null, 'icon' => 'volume down']);
$buttonPopup = Popup::addTo($app, [$button, 'triggerOn' => 'hover'])->setHoverable();

Form\Control\Checkbox::addTo($buttonPopup, ['Just On/Off', 'slider'])->on('change', $button->js()->find('.icon')->toggleClass('up down'));
Form\Control\Checkbox::addTo($buttonPopup, ['Just On/Off', 'class.slider' => true])->on('change', $button->js()->find('.icon')->toggleClass('up down'));
2 changes: 1 addition & 1 deletion demos/obsolete/notify2.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function init(): void
// Unit test only.
$form->cb->setUrlTrigger('test_notify');

\Atk4\Ui\Label::addTo($form, ['Some of notification options that can be set.', 'top attached'], ['AboveControls']);
\Atk4\Ui\Label::addTo($form, ['Some of notification options that can be set.', 'class.top attached' => true], ['AboveControls']);
$form->buttonSave->set('Show');
$form->setModel((new $notifierClass($app->db))->createEntity(), []);

Expand Down
4 changes: 2 additions & 2 deletions docs/app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ active. (See :ref:`system_pattern`)::
          // Make sure user is valid
if (!$this->user->isLoaded()) {
$this->initLayout([\Atk4\Ui\Layout\Centered::class]);
Message::addTo($this, ['Login Required', 'error']);
Button::addTo($this, ['Login', 'primary'])->link('index.php');
Message::addTo($this, ['Login Required', 'type' => 'error']);
Button::addTo($this, ['Login', 'class.primary' => true])->link('index.php');
exit;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/autocomplete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use of Filters::


$form = \Atk4\Ui\Form::addTo($app, ['class.segment' => true]);
\Atk4\Ui\Label::addTo($form, ['Add city', 'top attached'], ['AboveControls']);
\Atk4\Ui\Label::addTo($form, ['Add city', 'class.top attached' => true], ['AboveControls']);

$l = $form->addControl('city',[\Atk4\Ui\Form\Control\Lookup::class]);

Expand Down
8 changes: 4 additions & 4 deletions docs/button.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Button Icon
Property $icon will place icon on your button and can be specified in one of the following two ways::

$button = Button::addTo($app, ['Like', 'blue', 'icon' => 'thumbs up']);
$button = Button::addTo($app, ['Like', 'class.blue' => true, 'icon' => 'thumbs up']);

// or

$button = Button::addTo($app, ['Like', 'blue', 'icon' => new Icon('thumbs up')]);
$button = Button::addTo($app, ['Like', 'class.blue' => true, 'icon' => new Icon('thumbs up')]);

or if you prefer initializing objects::

Expand Down Expand Up @@ -120,7 +120,7 @@ Knowledge of the Fomantic UI button (https://fomantic-ui.com/elements/button.htm
in creating more complex buttons::

$forks = new Button(['labeled' => true]); // Button, not Buttons!
Icon::addTo(Button::addTo($forks, ['Forks', 'blue']), ['fork']);
Label::addTo($forks, ['1,048', 'basic blue left pointing']);
Icon::addTo(Button::addTo($forks, ['Forks', 'class.blue' => true]), ['fork']);
Label::addTo($forks, ['1,048', 'class.basic blue left pointing' => true]);
$app->add($forks);

4 changes: 2 additions & 2 deletions docs/dataexecutor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ Example of changing button for Card, Crud and Modal executor globally within you
{
protected static $actionTriggerSeed = [
self::MODAL_BUTTON => [
'edit' => [Button::class, 'Save', 'green'],
'add' => [Button::class, 'Save', 'green'],
'edit' => [Button::class, 'Save', 'class.green' => true],
'add' => [Button::class, 'Save', 'class.green' => true],
],
self::TABLE_BUTTON => [
'edit' => [Button::class, null, 'icon' => 'pencil'],
Expand Down
4 changes: 2 additions & 2 deletions docs/form-control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Here are few ways to specify `icon` to an Input::

// Type-hinting friendly
$line = new \Atk4\Ui\Form\Control\Line();
$line->icon='search';
$line->icon = 'search';
$page->add($line);

// using class factory
Expand All @@ -239,7 +239,7 @@ be automatically substituted with `new Icon($icon)`. If you wish to be more spec
and pass some arguments to the icon, there are two options::

// compact
$line->icon=['search', 'big'];
$line->icon = ['search', 'big'];

// Type-hinting friendly
$line->icon = new Icon('search');
Expand Down
2 changes: 1 addition & 1 deletion docs/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ Here is a more advanced example::

$f_sub = Form::addTo($app);
$f_sub->addControl('name');
$f_sub->addControl('subscribe', [\Atk4\Ui\Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'toggle']);
$f_sub->addControl('subscribe', [\Atk4\Ui\Form\Control\Checkbox::class, 'Subscribe to weekly newsletter', 'class.toggle' => true]);
$f_sub->addControl('email');
$f_sub->addControl('gender', [\Atk4\Ui\Form\Control\Radio::class], ['enum' => ['Female', 'Male']])->set('Female');
$f_sub->addControl('m_gift', [\Atk4\Ui\Form\Control\Dropdown::class, 'caption' => 'Gift for Men', 'values' => ['Beer Glass', 'Swiss Knife']]);
Expand Down
2 changes: 1 addition & 1 deletion src/Accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Accordion extends View

public $ui = 'accordion';

/** @var array|string|null The css class for Fomantic-ui accordion type. */
/** @var array|string|null The CSS class for Fomantic-ui accordion type. */
public $type;

/** @var array Settings as per Fomantic-ui accordion settings. */
Expand Down
6 changes: 5 additions & 1 deletion src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Form extends View
*
* @var Button|array|false Button object, seed or false to not show button at all
*/
public $buttonSave = [Button::class, 'Save', 'primary'];
public $buttonSave = [Button::class, 'Save', 'class.primary' => true];

/**
* When form is submitted successfully, this template is used by method
Expand Down Expand Up @@ -135,6 +135,10 @@ class Form extends View

public function __construct(array $defaults = [])
{
if (func_num_args() > 1) { // prevent bad usage
throw new \Error('Too many method arguments');
}

parent::__construct($defaults); // TODO remove once parent::__construct() accepts only array
}

Expand Down
12 changes: 6 additions & 6 deletions src/Form/Control/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class Checkbox extends Form\Control
*/
public $label;

/**
* @param string|array $label
* @param string|array $class
*/
public function __construct($label = null, $class = null)
public function __construct($label = [])
{
parent::__construct($label, $class);
if (func_num_args() > 1) { // prevent bad usage
throw new \Error('Too many method arguments');
}

parent::__construct($label);

$this->label = $this->content;
$this->content = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class Message extends View
{
/** @var string Set to info | warning | error | success | positie | negative. */
/** @var string Set to info | warning | error | success | positive | negative. */
public $type;

/** @var Text|false Contains a text to be included below. */
Expand Down
4 changes: 4 additions & 0 deletions src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ class Table extends Lister

public function __construct(array $defaults = [])
{
if (func_num_args() > 1) { // prevent bad usage
throw new \Error('Too many method arguments');
}

parent::__construct($defaults); // TODO remove once parent::__construct() accepts only array
}

Expand Down
4 changes: 4 additions & 0 deletions src/Table/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class Column

public function __construct(array $defaults = [])
{
if (func_num_args() > 1) { // prevent bad usage
throw new \Error('Too many method arguments');
}

$this->setDefaults($defaults);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ protected function init(): void
$this->buttonPrev->link($this->getUrl($this->currentStep - 1));
}

$this->buttonNext = Button::addTo($this, ['Next', 'primary'], ['Right']);
$this->buttonFinish = Button::addTo($this, ['Finish', 'primary'], ['Right']);
$this->buttonNext = Button::addTo($this, ['Next', 'class.primary' => true], ['Right']);
$this->buttonFinish = Button::addTo($this, ['Finish', 'class.primary' => true], ['Right']);

$this->buttonNext->link($this->getUrl($this->currentStep + 1));
}
Expand Down

0 comments on commit d869b6e

Please sign in to comment.