From 26d152efdd436516297eee874baa33bf7fdafc59 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 18 Jul 2019 18:21:53 +0530 Subject: [PATCH 01/91] Update for Cake 4. --- .gitignore | 1 + composer.json | 16 +++++++++------- phpunit.xml.dist | 1 - src/Listener/Traits/FormTypeTrait.php | 2 +- src/Listener/Traits/IndexTypeTrait.php | 2 +- src/Listener/Traits/SidebarNavigationTrait.php | 2 +- src/Listener/Traits/SiteTitleTrait.php | 2 +- src/Listener/Traits/UtilityNavigationTrait.php | 2 +- src/Plugin.php | 8 ++++++++ src/View/CrudView.php | 8 ++++---- src/View/Helper/CrudViewHelper.php | 4 ++-- src/View/Widget/DateTimeWidget.php | 4 ++-- .../TestCase/View/Helper/CrudViewHelperTest.php | 2 +- .../TestCase/View/Widget/DateTimeWidgetTest.php | 2 +- tests/bootstrap.php | 2 +- 15 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 src/Plugin.php diff --git a/.gitignore b/.gitignore index 2e8ba9c3..5209c916 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ phpunit.xml vendor/ composer.lock tmp +.phpunit.result.cache diff --git a/composer.json b/composer.json index df3096e4..97a1a6f3 100644 --- a/composer.json +++ b/composer.json @@ -29,14 +29,14 @@ } ], "require": { - "cakephp/cakephp": "^3.7", - "friendsofcake/crud": "^5.4", - "friendsofcake/bootstrap-ui": "^1.4" + "cakephp/cakephp": "4.x-dev", + "friendsofcake/crud": "dev-cake-4.x", + "friendsofcake/bootstrap-ui": "dev-cake-4-bs-4" }, "require-dev": { - "friendsofcake/cakephp-test-utilities": "^1.0", - "markstory/asset_compress": "^3.2", - "phpunit/phpunit": "^5.7.14|^6.0" + "friendsofcake/cakephp-test-utilities": "dev-cake-4.x", + "markstory/asset_compress": "4.x-dev", + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { @@ -53,5 +53,7 @@ "issues": "https://github.com/FriendsOfCake/crud-view/issues", "wiki": "http://cakephp.nu/cakephp-crud/", "irc": "irc://irc.freenode.org/friendsofcake" - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 445791ae..279d1795 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,6 @@ colors="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="./tests/bootstrap.php" > diff --git a/src/Listener/Traits/FormTypeTrait.php b/src/Listener/Traits/FormTypeTrait.php index f966a13f..a7e40d1c 100644 --- a/src/Listener/Traits/FormTypeTrait.php +++ b/src/Listener/Traits/FormTypeTrait.php @@ -165,5 +165,5 @@ abstract protected function _controller(); /** * {@inheritDoc} */ - abstract protected function _action($name = null); + abstract protected function _action(?string $name = null); } diff --git a/src/Listener/Traits/IndexTypeTrait.php b/src/Listener/Traits/IndexTypeTrait.php index 599ef77d..bb69aaf0 100644 --- a/src/Listener/Traits/IndexTypeTrait.php +++ b/src/Listener/Traits/IndexTypeTrait.php @@ -145,7 +145,7 @@ abstract protected function _controller(); /** * {@inheritDoc} */ - abstract protected function _action($name = null); + abstract protected function _action(?string $name = null); /** * {@inheritDoc} diff --git a/src/Listener/Traits/SidebarNavigationTrait.php b/src/Listener/Traits/SidebarNavigationTrait.php index d4fea72c..24abecc1 100644 --- a/src/Listener/Traits/SidebarNavigationTrait.php +++ b/src/Listener/Traits/SidebarNavigationTrait.php @@ -36,5 +36,5 @@ abstract protected function _controller(); /** * {@inheritDoc} */ - abstract protected function _action($name = null); + abstract protected function _action(?string $name = null); } diff --git a/src/Listener/Traits/SiteTitleTrait.php b/src/Listener/Traits/SiteTitleTrait.php index b1c71187..c55b75e3 100644 --- a/src/Listener/Traits/SiteTitleTrait.php +++ b/src/Listener/Traits/SiteTitleTrait.php @@ -78,5 +78,5 @@ abstract protected function _controller(); /** * {@inheritDoc} */ - abstract protected function _action($name = null); + abstract protected function _action(?string $name = null); } diff --git a/src/Listener/Traits/UtilityNavigationTrait.php b/src/Listener/Traits/UtilityNavigationTrait.php index 147003c0..e4c44ae7 100644 --- a/src/Listener/Traits/UtilityNavigationTrait.php +++ b/src/Listener/Traits/UtilityNavigationTrait.php @@ -44,5 +44,5 @@ abstract protected function _controller(); /** * {@inheritDoc} */ - abstract protected function _action($name = null); + abstract protected function _action(?string $name = null); } diff --git a/src/Plugin.php b/src/Plugin.php new file mode 100644 index 00000000..525b58b9 --- /dev/null +++ b/src/Plugin.php @@ -0,0 +1,8 @@ + 'beforeLayout', @@ -158,7 +158,7 @@ protected function _setupPaths() * @return string default The block content or $default if the block does not exist. * @see ViewBlock::get() */ - public function fetch($name, $default = '') + public function fetch(string $name, string $default = ''): string { $viewblock = ''; $viewblocks = $this->get('viewblocks', []); @@ -178,7 +178,7 @@ public function fetch($name, $default = '') * * @return bool */ - public function exists($name) + public function exists(string $name): bool { $viewblocks = $this->get('viewblocks', []); diff --git a/src/View/Helper/CrudViewHelper.php b/src/View/Helper/CrudViewHelper.php index 4014b8a4..bf0d9e2e 100644 --- a/src/View/Helper/CrudViewHelper.php +++ b/src/View/Helper/CrudViewHelper.php @@ -420,9 +420,9 @@ public function associations() * @param string $key View variable to get. * @return mixed */ - public function getViewVar($key = null) + public function getViewVar($key) { - return Hash::get($this->_View->viewVars, $key); + return $this->_View->get($key); } /** diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 7602e038..5bde16b8 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -19,7 +19,7 @@ class DateTimeWidget extends \Cake\View\Widget\DateTimeWidget * @return string A generated select box. * @throws \RuntimeException When option data is invalid. */ - public function render(array $data, ContextInterface $context) + public function render(array $data, ContextInterface $context): string { $id = $data['id']; $name = $data['name']; @@ -161,7 +161,7 @@ protected function _convertPHPToMomentFormat($format) /** * {@inheritDoc} */ - public function secureFields(array $data) + public function secureFields(array $data): array { if (!isset($data['name']) || $data['name'] === '') { return []; diff --git a/tests/TestCase/View/Helper/CrudViewHelperTest.php b/tests/TestCase/View/Helper/CrudViewHelperTest.php index e22a9b93..81f883d6 100644 --- a/tests/TestCase/View/Helper/CrudViewHelperTest.php +++ b/tests/TestCase/View/Helper/CrudViewHelperTest.php @@ -30,7 +30,7 @@ class CrudViewHelperTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/TestCase/View/Widget/DateTimeWidgetTest.php b/tests/TestCase/View/Widget/DateTimeWidgetTest.php index 2f73da4d..5ae51c96 100644 --- a/tests/TestCase/View/Widget/DateTimeWidgetTest.php +++ b/tests/TestCase/View/Widget/DateTimeWidgetTest.php @@ -16,7 +16,7 @@ class DateTimeWidgetTest extends TestCase { use CompareTrait; - public function setUp() + public function setUp(): void { parent::setUp(); $this->initComparePath(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4f4d373d..864192e8 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -23,4 +23,4 @@ chdir($root); require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php'; -Plugin::load('CrudView', ['path' => dirname(dirname(__FILE__)) . DS]); +Plugin::getCollection()->add(new \CrudView\Plugin()); From e61f6e8d12c0aef95b9e39ac4890686e1a97e125 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 18 Jul 2019 18:22:31 +0530 Subject: [PATCH 02/91] Update travis config --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5a51405..f64431f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: php php: - - 5.6 - - 7.0 - - 7.1 - 7.2 + - 7.3 env: global: @@ -15,17 +13,17 @@ matrix: fast_finish: true include: - - php: 7.0 + - php: 7.2 env: PHPCS=1 DEFAULT=0 - - php: 7.0 + - php: 7.2 env: PHPSTAN=1 DEFAULT=0 - + - php: 7.2 env: DEFAULT=1 LOWEST=1 before_script: - - if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi + - if [[ $TRAVIS_PHP_VERSION != 7.2 ]]; then phpenv config-rm xdebug.ini; fi - if [[ $LOWEST = 0 ]]; then composer install --prefer-dist --no-interaction; fi - if [[ $LOWEST = 1 ]]; then composer update --prefer-lowest --prefer-dist --no-interaction; fi @@ -34,14 +32,14 @@ before_script: - if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan:^0.9; fi script: - - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi - - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.2 ]]; then vendor/bin/phpunit; fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.2 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi - if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ config/; fi - if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 5 src; fi after_success: - - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.2 ]]; then bash <(curl -s https://codecov.io/bash); fi notifications: email: false From 237dc1463b34408a327c3c89707f527bc7de0576 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 18 Jul 2019 18:35:34 +0530 Subject: [PATCH 03/91] Fix CS errors. --- src/Action/DashboardAction.php | 4 ++- src/Breadcrumb/ActiveBreadcrumb.php | 4 +-- src/Breadcrumb/Breadcrumb.php | 2 ++ src/Dashboard/Dashboard.php | 4 ++- src/Dashboard/Module/ActionLinkItem.php | 4 +-- src/Dashboard/Module/LinkItem.php | 4 ++- .../DeprecatedConfigurationKeyTrait.php | 3 +- src/Listener/Traits/FormTypeTrait.php | 3 ++ src/Listener/Traits/IndexTypeTrait.php | 2 ++ .../Traits/SidebarNavigationTrait.php | 4 ++- src/Listener/Traits/SiteTitleTrait.php | 2 ++ .../Traits/UtilityNavigationTrait.php | 2 ++ src/Listener/ViewListener.php | 36 ++++++++++++------- src/Listener/ViewSearchListener.php | 12 +++---- src/Menu/MenuDivider.php | 2 ++ src/Menu/MenuDropdown.php | 2 ++ src/Menu/MenuItem.php | 2 ++ src/Plugin.php | 2 ++ src/Traits/CrudViewConfigTrait.php | 2 ++ src/View/Cell/DashboardTableCell.php | 2 ++ src/View/Cell/TablesListCell.php | 5 +-- src/View/CrudView.php | 5 +-- src/View/Helper/CrudViewHelper.php | 18 +++++----- src/View/Widget/DateTimeWidget.php | 9 ++--- tests/TestCase/Dashboard/DashboardTest.php | 8 +++-- .../Dashboard/Module/ActionLinkItemTest.php | 2 ++ .../Dashboard/Module/LinkItemTest.php | 2 ++ tests/TestCase/View/CrudViewTest.php | 12 ++++--- .../View/Helper/CrudViewHelperTest.php | 2 ++ .../View/Widget/DateTimeWidgetTest.php | 10 +++--- tests/bootstrap.php | 2 ++ 31 files changed, 116 insertions(+), 57 deletions(-) diff --git a/src/Action/DashboardAction.php b/src/Action/DashboardAction.php index e9f6e534..fd8b12b1 100644 --- a/src/Action/DashboardAction.php +++ b/src/Action/DashboardAction.php @@ -1,9 +1,11 @@ _controller(); $sidebarNavigation = $this->_getSidebarNavigation(); - $controller->set('disableSidebar', ($sidebarNavigation === false) ? true : false); + $controller->set('disableSidebar', $sidebarNavigation === false ? true : false); $controller->set('sidebarNavigation', $sidebarNavigation); } diff --git a/src/Listener/Traits/SiteTitleTrait.php b/src/Listener/Traits/SiteTitleTrait.php index c55b75e3..bc422ba9 100644 --- a/src/Listener/Traits/SiteTitleTrait.php +++ b/src/Listener/Traits/SiteTitleTrait.php @@ -1,4 +1,6 @@ $controller->modelClass, - 'singularHumanName' => Inflector::humanize(Inflector::underscore(Inflector::singularize($controller->modelClass))), + 'singularHumanName' => Inflector::humanize( + Inflector::underscore(Inflector::singularize($controller->modelClass)) + ), 'pluralHumanName' => Inflector::humanize(Inflector::underscore($controller->getName())), 'singularVar' => Inflector::singularize($controller->getName()), 'pluralVar' => Inflector::variable($controller->getName()), @@ -281,7 +284,7 @@ protected function _getPageVariables() if ($scope === 'entity') { $data += [ - 'primaryKeyValue' => $this->_primaryKeyValue() + 'primaryKeyValue' => $this->_primaryKeyValue(), ]; } @@ -310,7 +313,7 @@ protected function _scaffoldFields(array $associations = []) if ($scope === 'entity' && !empty($associations['manyToMany'])) { foreach ($associations['manyToMany'] as $alias => $options) { $cols[sprintf('%s._ids', $options['entities'])] = [ - 'multiple' => true + 'multiple' => true, ]; } } @@ -379,7 +382,7 @@ protected function _getControllerActions() $actions = $this->_getAllowedActions(); foreach ($actions as $actionName => $config) { - list($scope, $actionConfig) = $this->_getControllerActionConfiguration($actionName, $config); + [$scope, $actionConfig] = $this->_getControllerActionConfiguration($actionName, $config); ${$scope}[$actionName] = $actionConfig; } @@ -394,7 +397,7 @@ protected function _getControllerActions() if ($config === null) { $config = []; } - list($scope, $actionConfig) = $this->_getControllerActionConfiguration($actionName, $config); + [$scope, $actionConfig] = $this->_getControllerActionConfiguration($actionName, $config); $realAction = Hash::get($actionConfig, 'url.action', $actionName); if (!isset(${$scope}[$realAction])) { continue; @@ -440,10 +443,12 @@ protected function _getControllerActionConfiguration($actionName, $config) } // apply defaults if necessary - $scope = isset($config['scope']) ? $config['scope'] : 'entity'; - $method = isset($config['method']) ? $config['method'] : 'GET'; + $scope = $config['scope'] ?? 'entity'; + $method = $config['method'] ?? 'GET'; - $title = !empty($config['link_title']) ? $config['link_title'] : Inflector::humanize(Inflector::underscore($actionName)); + $title = !empty($config['link_title']) + ? $config['link_title'] + : Inflector::humanize(Inflector::underscore($actionName)); $url = ['action' => $realAction]; if (isset($config['url'])) { $url = $config['url'] + $url; @@ -456,7 +461,7 @@ protected function _getControllerActionConfiguration($actionName, $config) 'options' => array_diff_key( $config, array_flip(['method', 'scope', 'link_title', 'url', 'scaffold', 'callback']) - ) + ), ]; if (!empty($config['callback'])) { $actionConfig['callback'] = $config['callback']; @@ -556,10 +561,15 @@ protected function _associations(array $whitelist = []) $associationConfiguration[$type][$assocKey]['propertyName'] = $association->getProperty(); $associationConfiguration[$type][$assocKey]['plugin'] = pluginSplit($association->getClassName())[0]; $associationConfiguration[$type][$assocKey]['controller'] = $assocKey; - $associationConfiguration[$type][$assocKey]['entity'] = Inflector::singularize(Inflector::underscore($assocKey)); + $associationConfiguration[$type][$assocKey]['entity'] = Inflector::singularize( + Inflector::underscore($assocKey) + ); $associationConfiguration[$type][$assocKey]['entities'] = Inflector::underscore($assocKey); - $associationConfiguration[$type][$assocKey] = array_merge($associationConfiguration[$type][$assocKey], $this->_action()->getConfig('association.' . $assocKey) ?: []); + $associationConfiguration[$type][$assocKey] = array_merge( + $associationConfiguration[$type][$assocKey], + $this->_action()->getConfig('association.' . $assocKey) ?: [] + ); } return $associationConfiguration; diff --git a/src/Listener/ViewSearchListener.php b/src/Listener/ViewSearchListener.php index 0b01ffd4..19560bf1 100644 --- a/src/Listener/ViewSearchListener.php +++ b/src/Listener/ViewSearchListener.php @@ -1,14 +1,14 @@ true, 'selectize' => true, 'collection' => 'default', - 'fields' => null + 'fields' => null, ]; /** @@ -40,7 +40,7 @@ class ViewSearchListener extends BaseListener public function implementedEvents() { return [ - 'Crud.afterPaginate' => ['callable' => 'afterPaginate'] + 'Crud.afterPaginate' => ['callable' => 'afterPaginate'], ]; } @@ -107,7 +107,7 @@ protected function _deriveFields() $field = $filter->name(); $input = [ 'required' => false, - 'type' => 'text' + 'type' => 'text', ]; if (substr($field, -3) === '_id' && $field !== '_id') { @@ -143,7 +143,7 @@ protected function _deriveFields() $urlArgs = []; - $fieldKeys = isset($input['fields']) ? $input['fields'] : ['id' => $field, 'value' => $field]; + $fieldKeys = $input['fields'] ?? ['id' => $field, 'value' => $field]; if (is_array($fieldKeys)) { foreach ($fieldKeys as $key => $val) { $urlArgs[$key] = $val; diff --git a/src/Menu/MenuDivider.php b/src/Menu/MenuDivider.php index d776cc6b..9903aa8f 100644 --- a/src/Menu/MenuDivider.php +++ b/src/Menu/MenuDivider.php @@ -1,4 +1,6 @@ 'index', 'title' => Inflector::humanize($table), - 'controller' => Inflector::camelize($table) + 'controller' => Inflector::camelize($table), ]; $normal[$table] = $config; diff --git a/src/View/CrudView.php b/src/View/CrudView.php index 280ac13c..428f4eca 100644 --- a/src/View/CrudView.php +++ b/src/View/CrudView.php @@ -1,9 +1,10 @@ [ 'className' => 'BootstrapUI.Form', 'widgets' => [ - 'datetime' => ['CrudView\View\Widget\DateTimeWidget', 'select'] + 'datetime' => ['CrudView\View\Widget\DateTimeWidget', 'select'], ], ], 'Flash' => ['className' => 'BootstrapUI.Flash'], diff --git a/src/View/Helper/CrudViewHelper.php b/src/View/Helper/CrudViewHelper.php index bf0d9e2e..2f5e70c4 100644 --- a/src/View/Helper/CrudViewHelper.php +++ b/src/View/Helper/CrudViewHelper.php @@ -1,8 +1,9 @@ null + 'fieldFormatters' => null, ]; /** @@ -224,7 +224,7 @@ public function formatTime($field, $value, array $options) if ($value === null) { return $this->Html->label(__d('crud', 'N/A'), ['type' => 'info']); } - $format = isset($options['format']) ? $options['format'] : null; + $format = $options['format'] ?? null; if (is_int($value) || is_string($value) || $value instanceof DateTime || $value instanceof DateTimeImmutable) { return $this->Time->nice($value, $format); @@ -293,8 +293,8 @@ public function relation($field) 'plugin' => $details['plugin'], 'controller' => $details['controller'], 'action' => 'view', - $entity->{$details['primaryKey']} - ]) + $entity->{$details['primaryKey']}, + ]), ]; } @@ -329,7 +329,7 @@ public function redirectUrl() 'name' => '_redirect_url', 'value' => $redirectUrl, 'id' => null, - 'secure' => FormHelper::SECURE_SKIP + 'secure' => FormHelper::SECURE_SKIP, ]); } @@ -351,8 +351,8 @@ public function createRelationLink($alias, $relation, $options = []) 'action' => 'add', '?' => [ $relation['foreignKey'] => $this->getViewVar('primaryKeyValue'), - '_redirect_url' => $this->getView()->getRequest()->getUri()->getPath() - ] + '_redirect_url' => $this->getView()->getRequest()->getUri()->getPath(), + ], ], $options ); diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 5bde16b8..26012270 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -1,4 +1,6 @@ format('U'); $dateTimeZone = new DateTimeZone(date_default_timezone_get()); - $timezoneOffset = ($dateTimeZone->getOffset($val) / 60); + $timezoneOffset = $dateTimeZone->getOffset($val) / 60; } $val = $val->format($type === 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'); } diff --git a/tests/TestCase/Dashboard/DashboardTest.php b/tests/TestCase/Dashboard/DashboardTest.php index 3e53eba0..854883ab 100644 --- a/tests/TestCase/Dashboard/DashboardTest.php +++ b/tests/TestCase/Dashboard/DashboardTest.php @@ -1,4 +1,6 @@ assertEquals($expected, $dashboard->get('title')); @@ -38,11 +40,11 @@ public function testInvalidConstruct() public function testColumnChildren() { - $dashboard = new Dashboard; + $dashboard = new Dashboard(); $expected = []; $this->assertEquals($expected, $dashboard->getColumnChildren(1)); - $cell = new DashboardTableCell; + $cell = new DashboardTableCell(); $return = $dashboard->addToColumn($cell); $this->assertEquals($dashboard, $return); $this->assertEquals([$cell], $dashboard->getColumnChildren(1)); diff --git a/tests/TestCase/Dashboard/Module/ActionLinkItemTest.php b/tests/TestCase/Dashboard/Module/ActionLinkItemTest.php index 95140b6f..189718e5 100644 --- a/tests/TestCase/Dashboard/Module/ActionLinkItemTest.php +++ b/tests/TestCase/Dashboard/Module/ActionLinkItemTest.php @@ -1,4 +1,6 @@ [ 'CrudView' => [ 'className' => 'CrudView.CrudView', - 'fieldFormatters' => ['datetime' => 'formatTime'] - ] - ] + 'fieldFormatters' => ['datetime' => 'formatTime'], + ], + ], ] ); diff --git a/tests/TestCase/View/Helper/CrudViewHelperTest.php b/tests/TestCase/View/Helper/CrudViewHelperTest.php index 81f883d6..8cebf7ec 100644 --- a/tests/TestCase/View/Helper/CrudViewHelperTest.php +++ b/tests/TestCase/View/Helper/CrudViewHelperTest.php @@ -1,4 +1,6 @@ 'the-id', 'name' => 'the-name', 'val' => '', 'type' => 'x', 'required' => false] + ['id' => 'the-id', 'name' => 'the-name', 'val' => '', 'type' => 'x', 'required' => false], ], [ 'with-string-value.html', - ['id' => 'the-id', 'name' => 'the-name', 'val' => '2000-01-01', 'type' => 'x', 'required' => false] + ['id' => 'the-id', 'name' => 'the-name', 'val' => '2000-01-01', 'type' => 'x', 'required' => false], ], [ 'with-date-value.html', - ['id' => 'the-id', 'name' => 'the-name', 'val' => (new FrozenTime(strtotime('2000-01-01'))), 'type' => 'x', 'required' => false] - ] + ['id' => 'the-id', 'name' => 'the-name', 'val' => (new FrozenTime(strtotime('2000-01-01'))), 'type' => 'x', 'required' => false], + ], ]; } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 864192e8..edfce42b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,6 @@ Date: Thu, 18 Jul 2019 18:45:46 +0530 Subject: [PATCH 04/91] Move/rename template files. --- .../display.ctp => templates/Cell/DashboardTable/display.php | 0 .../display.ctp => templates/Cell/TablesList/display.php | 0 .../action-button.ctp => templates/Element/action-button.php | 0 .../action-groups.ctp => templates/Element/action-groups.php | 0 .../action-header.ctp => templates/Element/action-header.php | 0 src/Template/Element/actions.ctp => templates/Element/actions.php | 0 .../Element/breadcrumbs.ctp => templates/Element/breadcrumbs.php | 0 src/Template/Element/form.ctp => templates/Element/form.php | 0 .../form/buttons.ctp => templates/Element/form/buttons.php | 0 .../Element/form/tabs.ctp => templates/Element/form/tabs.php | 0 .../Element/index/blog.ctp => templates/Element/index/blog.php | 0 .../Element/index/bulk_actions/form_end.php | 0 .../Element/index/bulk_actions/form_start.php | 0 .../record.ctp => templates/Element/index/bulk_actions/record.php | 0 .../table.ctp => templates/Element/index/bulk_actions/table.php | 0 .../Element/index/download_formats.php | 0 .../Element/index/finder_scopes.php | 0 .../index/gallery.ctp => templates/Element/index/gallery.php | 0 .../pagination.ctp => templates/Element/index/pagination.php | 0 .../Element/index/table.ctp => templates/Element/index/table.php | 0 .../Element/index/table_columns.php | 0 .../menu/divider.ctp => templates/Element/menu/divider.php | 0 .../menu/dropdown.ctp => templates/Element/menu/dropdown.php | 0 .../Element/menu/item.ctp => templates/Element/menu/item.php | 0 src/Template/Element/search.ctp => templates/Element/search.php | 0 src/Template/Element/sidebar.ctp => templates/Element/sidebar.php | 0 src/Template/Element/topbar.ctp => templates/Element/topbar.php | 0 .../view/related.ctp => templates/Element/view/related.php | 0 .../has_many.ctp => templates/Element/view/related/has_many.php | 0 .../has_one.ctp => templates/Element/view/related/has_one.php | 0 src/Template/Layout/default.ctp => templates/Layout/default.php | 0 src/Template/Scaffold/add.ctp => templates/Scaffold/add.php | 0 .../Scaffold/dashboard.ctp => templates/Scaffold/dashboard.php | 0 src/Template/Scaffold/edit.ctp => templates/Scaffold/edit.php | 0 src/Template/Scaffold/index.ctp => templates/Scaffold/index.php | 0 src/Template/Scaffold/view.ctp => templates/Scaffold/view.php | 0 36 files changed, 0 insertions(+), 0 deletions(-) rename src/Template/Cell/DashboardTable/display.ctp => templates/Cell/DashboardTable/display.php (100%) rename src/Template/Cell/TablesList/display.ctp => templates/Cell/TablesList/display.php (100%) rename src/Template/Element/action-button.ctp => templates/Element/action-button.php (100%) rename src/Template/Element/action-groups.ctp => templates/Element/action-groups.php (100%) rename src/Template/Element/action-header.ctp => templates/Element/action-header.php (100%) rename src/Template/Element/actions.ctp => templates/Element/actions.php (100%) rename src/Template/Element/breadcrumbs.ctp => templates/Element/breadcrumbs.php (100%) rename src/Template/Element/form.ctp => templates/Element/form.php (100%) rename src/Template/Element/form/buttons.ctp => templates/Element/form/buttons.php (100%) rename src/Template/Element/form/tabs.ctp => templates/Element/form/tabs.php (100%) rename src/Template/Element/index/blog.ctp => templates/Element/index/blog.php (100%) rename src/Template/Element/index/bulk_actions/form_end.ctp => templates/Element/index/bulk_actions/form_end.php (100%) rename src/Template/Element/index/bulk_actions/form_start.ctp => templates/Element/index/bulk_actions/form_start.php (100%) rename src/Template/Element/index/bulk_actions/record.ctp => templates/Element/index/bulk_actions/record.php (100%) rename src/Template/Element/index/bulk_actions/table.ctp => templates/Element/index/bulk_actions/table.php (100%) rename src/Template/Element/index/download_formats.ctp => templates/Element/index/download_formats.php (100%) rename src/Template/Element/index/finder_scopes.ctp => templates/Element/index/finder_scopes.php (100%) rename src/Template/Element/index/gallery.ctp => templates/Element/index/gallery.php (100%) rename src/Template/Element/index/pagination.ctp => templates/Element/index/pagination.php (100%) rename src/Template/Element/index/table.ctp => templates/Element/index/table.php (100%) rename src/Template/Element/index/table_columns.ctp => templates/Element/index/table_columns.php (100%) rename src/Template/Element/menu/divider.ctp => templates/Element/menu/divider.php (100%) rename src/Template/Element/menu/dropdown.ctp => templates/Element/menu/dropdown.php (100%) rename src/Template/Element/menu/item.ctp => templates/Element/menu/item.php (100%) rename src/Template/Element/search.ctp => templates/Element/search.php (100%) rename src/Template/Element/sidebar.ctp => templates/Element/sidebar.php (100%) rename src/Template/Element/topbar.ctp => templates/Element/topbar.php (100%) rename src/Template/Element/view/related.ctp => templates/Element/view/related.php (100%) rename src/Template/Element/view/related/has_many.ctp => templates/Element/view/related/has_many.php (100%) rename src/Template/Element/view/related/has_one.ctp => templates/Element/view/related/has_one.php (100%) rename src/Template/Layout/default.ctp => templates/Layout/default.php (100%) rename src/Template/Scaffold/add.ctp => templates/Scaffold/add.php (100%) rename src/Template/Scaffold/dashboard.ctp => templates/Scaffold/dashboard.php (100%) rename src/Template/Scaffold/edit.ctp => templates/Scaffold/edit.php (100%) rename src/Template/Scaffold/index.ctp => templates/Scaffold/index.php (100%) rename src/Template/Scaffold/view.ctp => templates/Scaffold/view.php (100%) diff --git a/src/Template/Cell/DashboardTable/display.ctp b/templates/Cell/DashboardTable/display.php similarity index 100% rename from src/Template/Cell/DashboardTable/display.ctp rename to templates/Cell/DashboardTable/display.php diff --git a/src/Template/Cell/TablesList/display.ctp b/templates/Cell/TablesList/display.php similarity index 100% rename from src/Template/Cell/TablesList/display.ctp rename to templates/Cell/TablesList/display.php diff --git a/src/Template/Element/action-button.ctp b/templates/Element/action-button.php similarity index 100% rename from src/Template/Element/action-button.ctp rename to templates/Element/action-button.php diff --git a/src/Template/Element/action-groups.ctp b/templates/Element/action-groups.php similarity index 100% rename from src/Template/Element/action-groups.ctp rename to templates/Element/action-groups.php diff --git a/src/Template/Element/action-header.ctp b/templates/Element/action-header.php similarity index 100% rename from src/Template/Element/action-header.ctp rename to templates/Element/action-header.php diff --git a/src/Template/Element/actions.ctp b/templates/Element/actions.php similarity index 100% rename from src/Template/Element/actions.ctp rename to templates/Element/actions.php diff --git a/src/Template/Element/breadcrumbs.ctp b/templates/Element/breadcrumbs.php similarity index 100% rename from src/Template/Element/breadcrumbs.ctp rename to templates/Element/breadcrumbs.php diff --git a/src/Template/Element/form.ctp b/templates/Element/form.php similarity index 100% rename from src/Template/Element/form.ctp rename to templates/Element/form.php diff --git a/src/Template/Element/form/buttons.ctp b/templates/Element/form/buttons.php similarity index 100% rename from src/Template/Element/form/buttons.ctp rename to templates/Element/form/buttons.php diff --git a/src/Template/Element/form/tabs.ctp b/templates/Element/form/tabs.php similarity index 100% rename from src/Template/Element/form/tabs.ctp rename to templates/Element/form/tabs.php diff --git a/src/Template/Element/index/blog.ctp b/templates/Element/index/blog.php similarity index 100% rename from src/Template/Element/index/blog.ctp rename to templates/Element/index/blog.php diff --git a/src/Template/Element/index/bulk_actions/form_end.ctp b/templates/Element/index/bulk_actions/form_end.php similarity index 100% rename from src/Template/Element/index/bulk_actions/form_end.ctp rename to templates/Element/index/bulk_actions/form_end.php diff --git a/src/Template/Element/index/bulk_actions/form_start.ctp b/templates/Element/index/bulk_actions/form_start.php similarity index 100% rename from src/Template/Element/index/bulk_actions/form_start.ctp rename to templates/Element/index/bulk_actions/form_start.php diff --git a/src/Template/Element/index/bulk_actions/record.ctp b/templates/Element/index/bulk_actions/record.php similarity index 100% rename from src/Template/Element/index/bulk_actions/record.ctp rename to templates/Element/index/bulk_actions/record.php diff --git a/src/Template/Element/index/bulk_actions/table.ctp b/templates/Element/index/bulk_actions/table.php similarity index 100% rename from src/Template/Element/index/bulk_actions/table.ctp rename to templates/Element/index/bulk_actions/table.php diff --git a/src/Template/Element/index/download_formats.ctp b/templates/Element/index/download_formats.php similarity index 100% rename from src/Template/Element/index/download_formats.ctp rename to templates/Element/index/download_formats.php diff --git a/src/Template/Element/index/finder_scopes.ctp b/templates/Element/index/finder_scopes.php similarity index 100% rename from src/Template/Element/index/finder_scopes.ctp rename to templates/Element/index/finder_scopes.php diff --git a/src/Template/Element/index/gallery.ctp b/templates/Element/index/gallery.php similarity index 100% rename from src/Template/Element/index/gallery.ctp rename to templates/Element/index/gallery.php diff --git a/src/Template/Element/index/pagination.ctp b/templates/Element/index/pagination.php similarity index 100% rename from src/Template/Element/index/pagination.ctp rename to templates/Element/index/pagination.php diff --git a/src/Template/Element/index/table.ctp b/templates/Element/index/table.php similarity index 100% rename from src/Template/Element/index/table.ctp rename to templates/Element/index/table.php diff --git a/src/Template/Element/index/table_columns.ctp b/templates/Element/index/table_columns.php similarity index 100% rename from src/Template/Element/index/table_columns.ctp rename to templates/Element/index/table_columns.php diff --git a/src/Template/Element/menu/divider.ctp b/templates/Element/menu/divider.php similarity index 100% rename from src/Template/Element/menu/divider.ctp rename to templates/Element/menu/divider.php diff --git a/src/Template/Element/menu/dropdown.ctp b/templates/Element/menu/dropdown.php similarity index 100% rename from src/Template/Element/menu/dropdown.ctp rename to templates/Element/menu/dropdown.php diff --git a/src/Template/Element/menu/item.ctp b/templates/Element/menu/item.php similarity index 100% rename from src/Template/Element/menu/item.ctp rename to templates/Element/menu/item.php diff --git a/src/Template/Element/search.ctp b/templates/Element/search.php similarity index 100% rename from src/Template/Element/search.ctp rename to templates/Element/search.php diff --git a/src/Template/Element/sidebar.ctp b/templates/Element/sidebar.php similarity index 100% rename from src/Template/Element/sidebar.ctp rename to templates/Element/sidebar.php diff --git a/src/Template/Element/topbar.ctp b/templates/Element/topbar.php similarity index 100% rename from src/Template/Element/topbar.ctp rename to templates/Element/topbar.php diff --git a/src/Template/Element/view/related.ctp b/templates/Element/view/related.php similarity index 100% rename from src/Template/Element/view/related.ctp rename to templates/Element/view/related.php diff --git a/src/Template/Element/view/related/has_many.ctp b/templates/Element/view/related/has_many.php similarity index 100% rename from src/Template/Element/view/related/has_many.ctp rename to templates/Element/view/related/has_many.php diff --git a/src/Template/Element/view/related/has_one.ctp b/templates/Element/view/related/has_one.php similarity index 100% rename from src/Template/Element/view/related/has_one.ctp rename to templates/Element/view/related/has_one.php diff --git a/src/Template/Layout/default.ctp b/templates/Layout/default.php similarity index 100% rename from src/Template/Layout/default.ctp rename to templates/Layout/default.php diff --git a/src/Template/Scaffold/add.ctp b/templates/Scaffold/add.php similarity index 100% rename from src/Template/Scaffold/add.ctp rename to templates/Scaffold/add.php diff --git a/src/Template/Scaffold/dashboard.ctp b/templates/Scaffold/dashboard.php similarity index 100% rename from src/Template/Scaffold/dashboard.ctp rename to templates/Scaffold/dashboard.php diff --git a/src/Template/Scaffold/edit.ctp b/templates/Scaffold/edit.php similarity index 100% rename from src/Template/Scaffold/edit.ctp rename to templates/Scaffold/edit.php diff --git a/src/Template/Scaffold/index.ctp b/templates/Scaffold/index.php similarity index 100% rename from src/Template/Scaffold/index.ctp rename to templates/Scaffold/index.php diff --git a/src/Template/Scaffold/view.ctp b/templates/Scaffold/view.php similarity index 100% rename from src/Template/Scaffold/view.ctp rename to templates/Scaffold/view.php From d8708cf32913f1ecac32d66a74f6f064e453659b Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 18 Jul 2019 19:11:00 +0530 Subject: [PATCH 05/91] Fix model class usage. --- src/Listener/ViewListener.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Listener/ViewListener.php b/src/Listener/ViewListener.php index 3b2892f4..5ede52f5 100644 --- a/src/Listener/ViewListener.php +++ b/src/Listener/ViewListener.php @@ -259,13 +259,14 @@ protected function _blacklist() protected function _getPageVariables() { $table = $this->_table(); + $modelClass = $table->getAlias(); $controller = $this->_controller(); $scope = $this->_action()->getConfig('scope'); $data = [ - 'modelClass' => $controller->modelClass, + 'modelClass' => $modelClass, 'singularHumanName' => Inflector::humanize( - Inflector::underscore(Inflector::singularize($controller->modelClass)) + Inflector::underscore(Inflector::singularize($modelClass)) ), 'pluralHumanName' => Inflector::humanize(Inflector::underscore($controller->getName())), 'singularVar' => Inflector::singularize($controller->getName()), @@ -619,6 +620,7 @@ protected function _displayFieldValue() protected function _deriveFieldFromContext($field) { $controller = $this->_controller(); + $modelClass = $table->getAlias(); $entity = $this->_entity(); $request = $this->_request(); $value = $entity->get($field); @@ -627,12 +629,12 @@ protected function _deriveFieldFromContext($field) return $value; } - $path = "{$controller->modelClass}.{$field}"; + $path = "{$modelClass}.{$field}"; if (!empty($request->getData())) { $value = Hash::get((array)$request->getData(), $path); } - $singularVar = Inflector::variable($controller->modelClass); + $singularVar = Inflector::variable($modelClass); if (!empty($controller->viewVars[$singularVar])) { $value = $entity->get($field); } From cb866ea2f6fa5eb39f9edcf5b425a9aa24538d0d Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 00:24:23 +0530 Subject: [PATCH 06/91] Fix typehint --- src/Listener/ViewSearchListener.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Listener/ViewSearchListener.php b/src/Listener/ViewSearchListener.php index 19560bf1..b01deb48 100644 --- a/src/Listener/ViewSearchListener.php +++ b/src/Listener/ViewSearchListener.php @@ -37,7 +37,7 @@ class ViewSearchListener extends BaseListener * * @return array */ - public function implementedEvents() + public function implementedEvents(): array { return [ 'Crud.afterPaginate' => ['callable' => 'afterPaginate'], @@ -50,10 +50,10 @@ public function implementedEvents() * Only after a crud paginate call does this listener do anything. So listen * for that * - * @param \Cake\Event\Event $event Event. + * @param \Cake\Event\EventInterface $event Event. * @return void */ - public function afterPaginate(Event $event) + public function afterPaginate(EventInterface $event) { $event; if (!$this->_table()->behaviors()->has('Search')) { From 3ab3e16d33c25c893bb8f8c073918056344e240f Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 00:35:18 +0530 Subject: [PATCH 07/91] Fix variable/property usage. --- src/Listener/ViewListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Listener/ViewListener.php b/src/Listener/ViewListener.php index 5ede52f5..c6e87e1e 100644 --- a/src/Listener/ViewListener.php +++ b/src/Listener/ViewListener.php @@ -620,7 +620,7 @@ protected function _displayFieldValue() protected function _deriveFieldFromContext($field) { $controller = $this->_controller(); - $modelClass = $table->getAlias(); + $modelClass = $this->_table()->getAlias(); $entity = $this->_entity(); $request = $this->_request(); $value = $entity->get($field); @@ -635,7 +635,7 @@ protected function _deriveFieldFromContext($field) } $singularVar = Inflector::variable($modelClass); - if (!empty($controller->viewVars[$singularVar])) { + if ($controller->viewBuilder()->getVar($singularVar)) { $value = $entity->get($field); } From 76b65ae9a4fd03a2d19fe940868a6fed7de291b2 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 01:11:44 +0530 Subject: [PATCH 08/91] Fix property visibility. --- src/View/CrudView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/CrudView.php b/src/View/CrudView.php index 428f4eca..66d27fce 100644 --- a/src/View/CrudView.php +++ b/src/View/CrudView.php @@ -24,7 +24,7 @@ class CrudView extends View implements EventListenerInterface * * @var string */ - public $layout = 'CrudView.default'; + protected $layout = 'CrudView.default'; /** * Initialization hook method. From 3cc8470c9faed577a3b1710bf86d725571be490f Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 01:20:59 +0530 Subject: [PATCH 09/91] Fix templates path. --- src/View/CrudView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/CrudView.php b/src/View/CrudView.php index 66d27fce..81fb91ba 100644 --- a/src/View/CrudView.php +++ b/src/View/CrudView.php @@ -145,7 +145,7 @@ protected function _setupPaths() if (!empty($extraPaths)) { $paths = array_merge($paths, (array)$extraPaths); } - $paths[] = Plugin::classPath('CrudView') . 'Template' . DS; + $paths[] = Plugin::templatePath('CrudView'); Configure::write('App.paths.templates', $paths); } From 67c07fc12fa94c90c8a11249cd1f6f5560e7e13a Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 01:50:36 +0530 Subject: [PATCH 10/91] Fix "use" statement. --- src/Listener/ViewSearchListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Listener/ViewSearchListener.php b/src/Listener/ViewSearchListener.php index b01deb48..8daef1b0 100644 --- a/src/Listener/ViewSearchListener.php +++ b/src/Listener/ViewSearchListener.php @@ -3,7 +3,7 @@ namespace CrudView\Listener; -use Cake\Event\Event; +use Cake\Event\EventInterface; use Cake\Routing\Router; use Crud\Listener\BaseListener; From 77a43d268e1413216ee63801698058cbc64d1cb0 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 02:25:40 +0530 Subject: [PATCH 11/91] Update method for template file name. --- src/View/CrudView.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/View/CrudView.php b/src/View/CrudView.php index 81fb91ba..fe749e64 100644 --- a/src/View/CrudView.php +++ b/src/View/CrudView.php @@ -211,28 +211,29 @@ protected function _createViewblock($data) return $output; } + /** - * Returns filename of given action's template file (.ctp) as a string. + * Returns filename of given action's template file as a string. * * @param string|null $name Controller action to find template filename for. * @return string Template filename * @throws \Cake\View\Exception\MissingTemplateException When a view file could not be found. */ - protected function _getViewFileName($name = null) + protected function _getTemplateFileName(?string $name = null): string { if ($this->templatePath === 'Error') { - return parent::_getViewFileName($name); + return parent::_getTemplateFileName($name); } try { - return parent::_getViewFileName($name); + return parent::_getTemplateFileName($name); } catch (MissingTemplateException $exception) { - $this->subDir = null; + $this->subDir = ''; $this->templatePath = 'Scaffold'; } try { - return parent::_getViewFileName($this->template); + return parent::_getTemplateFileName($this->template); } catch (MissingTemplateException $exception) { - return parent::_getViewFileName($name); + return parent::_getTemplateFileName($name); } } } From 3f090562aca821181c8cd73a46f8c8eef2dd592d Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 19 Jul 2019 02:27:07 +0530 Subject: [PATCH 12/91] Fix template folder casing. --- templates/{Cell => cell}/DashboardTable/display.php | 0 templates/{Cell => cell}/TablesList/display.php | 0 templates/{Element => element}/action-button.php | 0 templates/{Element => element}/action-groups.php | 0 templates/{Element => element}/action-header.php | 0 templates/{Element => element}/actions.php | 0 templates/{Element => element}/breadcrumbs.php | 0 templates/{Element => element}/form.php | 0 templates/{Element => element}/form/buttons.php | 0 templates/{Element => element}/form/tabs.php | 0 templates/{Element => element}/index/blog.php | 0 templates/{Element => element}/index/bulk_actions/form_end.php | 0 templates/{Element => element}/index/bulk_actions/form_start.php | 0 templates/{Element => element}/index/bulk_actions/record.php | 0 templates/{Element => element}/index/bulk_actions/table.php | 0 templates/{Element => element}/index/download_formats.php | 0 templates/{Element => element}/index/finder_scopes.php | 0 templates/{Element => element}/index/gallery.php | 0 templates/{Element => element}/index/pagination.php | 0 templates/{Element => element}/index/table.php | 0 templates/{Element => element}/index/table_columns.php | 0 templates/{Element => element}/menu/divider.php | 0 templates/{Element => element}/menu/dropdown.php | 0 templates/{Element => element}/menu/item.php | 0 templates/{Element => element}/search.php | 0 templates/{Element => element}/sidebar.php | 0 templates/{Element => element}/topbar.php | 0 templates/{Element => element}/view/related.php | 0 templates/{Element => element}/view/related/has_many.php | 0 templates/{Element => element}/view/related/has_one.php | 0 templates/{Layout => layout}/default.php | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename templates/{Cell => cell}/DashboardTable/display.php (100%) rename templates/{Cell => cell}/TablesList/display.php (100%) rename templates/{Element => element}/action-button.php (100%) rename templates/{Element => element}/action-groups.php (100%) rename templates/{Element => element}/action-header.php (100%) rename templates/{Element => element}/actions.php (100%) rename templates/{Element => element}/breadcrumbs.php (100%) rename templates/{Element => element}/form.php (100%) rename templates/{Element => element}/form/buttons.php (100%) rename templates/{Element => element}/form/tabs.php (100%) rename templates/{Element => element}/index/blog.php (100%) rename templates/{Element => element}/index/bulk_actions/form_end.php (100%) rename templates/{Element => element}/index/bulk_actions/form_start.php (100%) rename templates/{Element => element}/index/bulk_actions/record.php (100%) rename templates/{Element => element}/index/bulk_actions/table.php (100%) rename templates/{Element => element}/index/download_formats.php (100%) rename templates/{Element => element}/index/finder_scopes.php (100%) rename templates/{Element => element}/index/gallery.php (100%) rename templates/{Element => element}/index/pagination.php (100%) rename templates/{Element => element}/index/table.php (100%) rename templates/{Element => element}/index/table_columns.php (100%) rename templates/{Element => element}/menu/divider.php (100%) rename templates/{Element => element}/menu/dropdown.php (100%) rename templates/{Element => element}/menu/item.php (100%) rename templates/{Element => element}/search.php (100%) rename templates/{Element => element}/sidebar.php (100%) rename templates/{Element => element}/topbar.php (100%) rename templates/{Element => element}/view/related.php (100%) rename templates/{Element => element}/view/related/has_many.php (100%) rename templates/{Element => element}/view/related/has_one.php (100%) rename templates/{Layout => layout}/default.php (100%) diff --git a/templates/Cell/DashboardTable/display.php b/templates/cell/DashboardTable/display.php similarity index 100% rename from templates/Cell/DashboardTable/display.php rename to templates/cell/DashboardTable/display.php diff --git a/templates/Cell/TablesList/display.php b/templates/cell/TablesList/display.php similarity index 100% rename from templates/Cell/TablesList/display.php rename to templates/cell/TablesList/display.php diff --git a/templates/Element/action-button.php b/templates/element/action-button.php similarity index 100% rename from templates/Element/action-button.php rename to templates/element/action-button.php diff --git a/templates/Element/action-groups.php b/templates/element/action-groups.php similarity index 100% rename from templates/Element/action-groups.php rename to templates/element/action-groups.php diff --git a/templates/Element/action-header.php b/templates/element/action-header.php similarity index 100% rename from templates/Element/action-header.php rename to templates/element/action-header.php diff --git a/templates/Element/actions.php b/templates/element/actions.php similarity index 100% rename from templates/Element/actions.php rename to templates/element/actions.php diff --git a/templates/Element/breadcrumbs.php b/templates/element/breadcrumbs.php similarity index 100% rename from templates/Element/breadcrumbs.php rename to templates/element/breadcrumbs.php diff --git a/templates/Element/form.php b/templates/element/form.php similarity index 100% rename from templates/Element/form.php rename to templates/element/form.php diff --git a/templates/Element/form/buttons.php b/templates/element/form/buttons.php similarity index 100% rename from templates/Element/form/buttons.php rename to templates/element/form/buttons.php diff --git a/templates/Element/form/tabs.php b/templates/element/form/tabs.php similarity index 100% rename from templates/Element/form/tabs.php rename to templates/element/form/tabs.php diff --git a/templates/Element/index/blog.php b/templates/element/index/blog.php similarity index 100% rename from templates/Element/index/blog.php rename to templates/element/index/blog.php diff --git a/templates/Element/index/bulk_actions/form_end.php b/templates/element/index/bulk_actions/form_end.php similarity index 100% rename from templates/Element/index/bulk_actions/form_end.php rename to templates/element/index/bulk_actions/form_end.php diff --git a/templates/Element/index/bulk_actions/form_start.php b/templates/element/index/bulk_actions/form_start.php similarity index 100% rename from templates/Element/index/bulk_actions/form_start.php rename to templates/element/index/bulk_actions/form_start.php diff --git a/templates/Element/index/bulk_actions/record.php b/templates/element/index/bulk_actions/record.php similarity index 100% rename from templates/Element/index/bulk_actions/record.php rename to templates/element/index/bulk_actions/record.php diff --git a/templates/Element/index/bulk_actions/table.php b/templates/element/index/bulk_actions/table.php similarity index 100% rename from templates/Element/index/bulk_actions/table.php rename to templates/element/index/bulk_actions/table.php diff --git a/templates/Element/index/download_formats.php b/templates/element/index/download_formats.php similarity index 100% rename from templates/Element/index/download_formats.php rename to templates/element/index/download_formats.php diff --git a/templates/Element/index/finder_scopes.php b/templates/element/index/finder_scopes.php similarity index 100% rename from templates/Element/index/finder_scopes.php rename to templates/element/index/finder_scopes.php diff --git a/templates/Element/index/gallery.php b/templates/element/index/gallery.php similarity index 100% rename from templates/Element/index/gallery.php rename to templates/element/index/gallery.php diff --git a/templates/Element/index/pagination.php b/templates/element/index/pagination.php similarity index 100% rename from templates/Element/index/pagination.php rename to templates/element/index/pagination.php diff --git a/templates/Element/index/table.php b/templates/element/index/table.php similarity index 100% rename from templates/Element/index/table.php rename to templates/element/index/table.php diff --git a/templates/Element/index/table_columns.php b/templates/element/index/table_columns.php similarity index 100% rename from templates/Element/index/table_columns.php rename to templates/element/index/table_columns.php diff --git a/templates/Element/menu/divider.php b/templates/element/menu/divider.php similarity index 100% rename from templates/Element/menu/divider.php rename to templates/element/menu/divider.php diff --git a/templates/Element/menu/dropdown.php b/templates/element/menu/dropdown.php similarity index 100% rename from templates/Element/menu/dropdown.php rename to templates/element/menu/dropdown.php diff --git a/templates/Element/menu/item.php b/templates/element/menu/item.php similarity index 100% rename from templates/Element/menu/item.php rename to templates/element/menu/item.php diff --git a/templates/Element/search.php b/templates/element/search.php similarity index 100% rename from templates/Element/search.php rename to templates/element/search.php diff --git a/templates/Element/sidebar.php b/templates/element/sidebar.php similarity index 100% rename from templates/Element/sidebar.php rename to templates/element/sidebar.php diff --git a/templates/Element/topbar.php b/templates/element/topbar.php similarity index 100% rename from templates/Element/topbar.php rename to templates/element/topbar.php diff --git a/templates/Element/view/related.php b/templates/element/view/related.php similarity index 100% rename from templates/Element/view/related.php rename to templates/element/view/related.php diff --git a/templates/Element/view/related/has_many.php b/templates/element/view/related/has_many.php similarity index 100% rename from templates/Element/view/related/has_many.php rename to templates/element/view/related/has_many.php diff --git a/templates/Element/view/related/has_one.php b/templates/element/view/related/has_one.php similarity index 100% rename from templates/Element/view/related/has_one.php rename to templates/element/view/related/has_one.php diff --git a/templates/Layout/default.php b/templates/layout/default.php similarity index 100% rename from templates/Layout/default.php rename to templates/layout/default.php From 11c891e8befe6d801581bf6d4c95741bec5b9335 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 23 Jul 2019 12:21:03 +0530 Subject: [PATCH 13/91] Add CSS class for button group items. --- templates/element/action-groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/element/action-groups.php b/templates/element/action-groups.php index f4142087..47379231 100644 --- a/templates/element/action-groups.php +++ b/templates/element/action-groups.php @@ -25,7 +25,7 @@ $config) : ?> -
  • element('action-button', ['config' => $links[$subaction]]); ?>
  • + From 7ad3621f7f437c52922899b6e27fae5988c35e19 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 19 Aug 2019 18:57:18 +0530 Subject: [PATCH 14/91] Don't auto add "delete" button if it's blacklisted --- src/Listener/Traits/FormTypeTrait.php | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Listener/Traits/FormTypeTrait.php b/src/Listener/Traits/FormTypeTrait.php index 469c9094..e7281bd6 100644 --- a/src/Listener/Traits/FormTypeTrait.php +++ b/src/Listener/Traits/FormTypeTrait.php @@ -130,19 +130,22 @@ protected function _getDefaultExtraLeftButtons() $action = $this->_action(); if ($action instanceof EditAction) { - $buttons[] = [ - 'title' => __d('crud', 'Delete'), - 'url' => ['action' => 'delete'], - 'options' => [ - 'block' => 'form.after_end', - 'class' => 'btn btn-danger btn-delete', - 'confirm' => __d('crud', 'Are you sure you want to delete this record?'), - 'name' => '_delete', - 'style' => 'margin-left: 0', - ], - 'type' => 'postLink', - '_label' => 'delete', - ]; + $blacklist = $action->getConfig('scaffold.actions_blacklist', []); + if (!in_array('delete', $blacklist, true)) { + $buttons[] = [ + 'title' => __d('crud', 'Delete'), + 'url' => ['action' => 'delete'], + 'options' => [ + 'block' => 'form.after_end', + 'class' => 'btn btn-danger btn-delete', + 'confirm' => __d('crud', 'Are you sure you want to delete this record?'), + 'name' => '_delete', + 'style' => 'margin-left: 0', + ], + 'type' => 'postLink', + '_label' => 'delete', + ]; + } } return $buttons; From 90e094804f0e9088138c36b45a86f2d50c139b19 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 9 Sep 2019 18:16:55 +0530 Subject: [PATCH 15/91] Updates as per core changes --- tests/TestCase/Dashboard/DashboardTest.php | 13 ++++----- .../Dashboard/Module/LinkItemTest.php | 27 +++++++++---------- .../View/Widget/DateTimeWidgetTest.php | 20 +++++++------- .../View/Widget/DateTimeWidget/simple.html | 4 +-- .../DateTimeWidget/with-date-value.html | 12 ++++----- .../DateTimeWidget/with-string-value.html | 10 +++---- 6 files changed, 42 insertions(+), 44 deletions(-) diff --git a/tests/TestCase/Dashboard/DashboardTest.php b/tests/TestCase/Dashboard/DashboardTest.php index 854883ab..576e600d 100644 --- a/tests/TestCase/Dashboard/DashboardTest.php +++ b/tests/TestCase/Dashboard/DashboardTest.php @@ -3,6 +3,8 @@ namespace CrudView\Test\TestCase\Dashboard; +use Cake\Http\Response; +use Cake\Http\ServerRequest; use Cake\TestSuite\TestCase; use CrudView\Dashboard\Dashboard; use CrudView\View\Cell\DashboardTableCell; @@ -29,13 +31,12 @@ public function testConstruct() $this->assertEquals($expected, $dashboard->get('title')); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Valid columns value must be one of [1, 2, 3, 4, 6, 12] - */ public function testInvalidConstruct() { - $dashboard = new Dashboard(null, 0); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Valid columns value must be one of [1, 2, 3, 4, 6, 12]'); + + new Dashboard(null, 0); } public function testColumnChildren() @@ -44,7 +45,7 @@ public function testColumnChildren() $expected = []; $this->assertEquals($expected, $dashboard->getColumnChildren(1)); - $cell = new DashboardTableCell(); + $cell = new DashboardTableCell(new ServerRequest(), new Response()); $return = $dashboard->addToColumn($cell); $this->assertEquals($dashboard, $return); $this->assertEquals([$cell], $dashboard->getColumnChildren(1)); diff --git a/tests/TestCase/Dashboard/Module/LinkItemTest.php b/tests/TestCase/Dashboard/Module/LinkItemTest.php index d777532c..2cdeaebd 100644 --- a/tests/TestCase/Dashboard/Module/LinkItemTest.php +++ b/tests/TestCase/Dashboard/Module/LinkItemTest.php @@ -25,31 +25,28 @@ public function testConstruct() $this->assertEquals($expected, $item->get('options')); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Missing title for LinkItem action - */ public function testInvalidTitle() { - $item = new LinkItem('', null); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Missing title for LinkItem action'); + + new LinkItem('', null); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid url specified for LinkItem - */ public function testInvalidNullUrl() { - $item = new LinkItem('Title', null); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid url specified for LinkItem'); + + new LinkItem('Title', null); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid url specified for LinkItem - */ public function testInvalidEmptyUrl() { - $item = new LinkItem('Title', ''); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid url specified for LinkItem'); + + new LinkItem('Title', ''); } public function testOptions() diff --git a/tests/TestCase/View/Widget/DateTimeWidgetTest.php b/tests/TestCase/View/Widget/DateTimeWidgetTest.php index c7d123a3..b576236b 100644 --- a/tests/TestCase/View/Widget/DateTimeWidgetTest.php +++ b/tests/TestCase/View/Widget/DateTimeWidgetTest.php @@ -3,7 +3,7 @@ namespace CrudView\Test\TestCase\View\Widget; -use Cake\I18n\FrozenTime; +use Cake\I18n\FrozenDate; use Cake\TestSuite\TestCase; use Cake\View\Form\ContextInterface; use Cake\View\StringTemplate; @@ -52,17 +52,17 @@ public function testRenderSimple($compareFileName, $data) public function renderProvider() { return [ - [ - 'simple.html', - ['id' => 'the-id', 'name' => 'the-name', 'val' => '', 'type' => 'x', 'required' => false], - ], - [ - 'with-string-value.html', - ['id' => 'the-id', 'name' => 'the-name', 'val' => '2000-01-01', 'type' => 'x', 'required' => false], - ], + // [ + // 'simple.html', + // ['id' => 'the-id', 'name' => 'the-name', 'val' => '', 'type' => 'date', 'required' => false], + // ], + // [ + // 'with-string-value.html', + // ['id' => 'the-id2', 'name' => 'the-name2', 'val' => '2000-01-01', 'type' => 'date', 'required' => false], + // ], [ 'with-date-value.html', - ['id' => 'the-id', 'name' => 'the-name', 'val' => (new FrozenTime(strtotime('2000-01-01'))), 'type' => 'x', 'required' => false], + ['id' => 'the-id3', 'name' => 'the-name3', 'val' => new FrozenDate('2000-01-01'), 'type' => 'date', 'required' => false], ], ]; } diff --git a/tests/comparisons/View/Widget/DateTimeWidget/simple.html b/tests/comparisons/View/Widget/DateTimeWidget/simple.html index b68d94cf..f3d5ea09 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/simple.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/simple.html @@ -1,5 +1,5 @@
    + class="input-group date"> + data-format="L" />
    From 051a8432918bffb79ad1759637d45368c5fb0a6f Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 30 Sep 2019 03:07:48 +0530 Subject: [PATCH 24/91] Move back picker icon to the right --- src/View/Widget/DateTimeWidget.php | 4 ++-- .../View/Widget/DateTimeWidget/simple.html | 16 ++++++++-------- .../Widget/DateTimeWidget/with-date-value.html | 16 ++++++++-------- .../Widget/DateTimeWidget/with-string-value.html | 16 ++++++++-------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 46b43fcf..260c81e9 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -88,10 +88,10 @@ public function render(array $data, ContextInterface $context): string $this->_templates->add([ 'datetimePicker' => '
    ' - . '
    ' + . '{{input}}' + . '
    ' . '' . '
    ' - . '{{input}}' . '
    ', ]); } diff --git a/tests/comparisons/View/Widget/DateTimeWidget/simple.html b/tests/comparisons/View/Widget/DateTimeWidget/simple.html index 93a62658..52d1ebe7 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/simple.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/simple.html @@ -3,8 +3,15 @@ data-wrap="true" data-date-format="Y-m-d" class="input-group flatpickr"> +
    + class="input-group-append">
    -
    diff --git a/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html b/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html index 37f4d7c0..37588e4f 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html @@ -3,8 +3,15 @@ data-wrap="true" data-date-format="Y-m-d" class="input-group flatpickr"> +
    + class="input-group-append">
    - diff --git a/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html b/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html index 8f2bd0f0..f0e47317 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html @@ -3,8 +3,15 @@ data-wrap="true" data-date-format="Y-m-d" class="input-group flatpickr"> +
    + class="input-group-append">
    - From 90b46ef39c845b6ba1118cfea09f78cecf38e405 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 30 Sep 2019 12:22:30 +0530 Subject: [PATCH 25/91] Add clear button for picker --- src/View/Widget/DateTimeWidget.php | 1 + tests/comparisons/View/Widget/DateTimeWidget/simple.html | 6 ++++++ .../View/Widget/DateTimeWidget/with-date-value.html | 6 ++++++ .../View/Widget/DateTimeWidget/with-string-value.html | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 260c81e9..90e15d5f 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -91,6 +91,7 @@ public function render(array $data, ContextInterface $context): string . '{{input}}' . '
    ' . '' + . '' . '
    ' . '', ]); diff --git a/tests/comparisons/View/Widget/DateTimeWidget/simple.html b/tests/comparisons/View/Widget/DateTimeWidget/simple.html index 52d1ebe7..0fa0aa51 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/simple.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/simple.html @@ -18,5 +18,11 @@ class="fa fa-calendar-alt">
    + + + + diff --git a/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html b/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html index 37588e4f..f9203941 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html @@ -18,5 +18,11 @@ class="fa fa-calendar-alt">
    + + + + diff --git a/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html b/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html index f0e47317..fbffeeec 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html @@ -18,5 +18,11 @@ class="fa fa-calendar-alt">
    + + + + From 0eed4823a1c8d9085945d2f9ae15d0ff738d11b5 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 30 Sep 2019 19:28:58 +0530 Subject: [PATCH 26/91] Use button class and fix icon display --- src/View/Widget/DateTimeWidget.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 90e15d5f..411f317a 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -85,16 +85,18 @@ public function render(array $data, ContextInterface $context): string unset($datetimePicker['iconClass']); if ($this->_templates->get('datetimePicker') === null) { + // phpcs:disable $this->_templates->add([ 'datetimePicker' => '
    ' . '{{input}}' . '
    ' - . '' - . '' + . '' + . '' . '
    ' . '
    ', ]); + // phpcs:enable } $data = $this->_templates->addClass($data, 'form-control'); From 767dc7d71a71aea7c0114489a5c8eba97821cd20 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 1 Oct 2019 00:27:23 +0530 Subject: [PATCH 27/91] By default use select2 only for select tags with "multiple" attribute. Default boostrap styled single value selects look good enough and have no usability issues. Devs can turn select2 explicity by using "selec2" class. --- webroot/js/local.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webroot/js/local.js b/webroot/js/local.js index 1629beac..41b38b1f 100644 --- a/webroot/js/local.js +++ b/webroot/js/local.js @@ -117,7 +117,7 @@ var CrudView = { initialize: function() { this.bulkActionForm('.bulk-actions'); this.datePicker('[role=datetime-picker]'); - this.select2('select:not(.autocomplete, .no-select2)'); + this.select2('select[multiple]:not(.no-select2), .select2'); this.autocomplete('input.autocomplete, select.autocomplete'); this.dirtyForms(); this.dropdown(); From 2d7492e1fac6c601e7bfe4606eb00c059dff2751 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 1 Oct 2019 18:45:42 +0530 Subject: [PATCH 28/91] Fix tests --- src/View/Widget/DateTimeWidget.php | 6 +++--- .../View/Widget/DateTimeWidget/simple.html | 14 ++++++++------ .../Widget/DateTimeWidget/with-date-value.html | 14 ++++++++------ .../Widget/DateTimeWidget/with-string-value.html | 14 ++++++++------ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 411f317a..c649d57f 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -75,7 +75,7 @@ public function render(array $data, ContextInterface $context): string $datetimePicker += ['data-enable-seconds' => 'true']; } - $iconClass = 'fa fa-calendar'; + $iconClass = 'fa fa-calendar-alt'; if (isset($datetimePicker['iconClass'])) { $iconClass = $data['iconClass']; } elseif ($data['type'] === 'time') { @@ -91,8 +91,8 @@ public function render(array $data, ContextInterface $context): string '
    ' . '{{input}}' . '
    ' - . '' - . '' + . '' + . '' . '
    ' . '
    ', ]); diff --git a/tests/comparisons/View/Widget/DateTimeWidget/simple.html b/tests/comparisons/View/Widget/DateTimeWidget/simple.html index 0fa0aa51..7e68fff5 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/simple.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/simple.html @@ -12,17 +12,19 @@ class="form-control"/>
    - + +
    diff --git a/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html b/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html index f9203941..2cf1b71c 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/with-date-value.html @@ -12,17 +12,19 @@ class="form-control"/>
    - + +
    diff --git a/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html b/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html index fbffeeec..26bd06ee 100644 --- a/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html +++ b/tests/comparisons/View/Widget/DateTimeWidget/with-string-value.html @@ -12,17 +12,19 @@ class="form-control"/>
    - + +
    From 0f39164e4f64b17a212b2a1c6681b4a423d5eeea Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 1 Oct 2019 18:46:48 +0530 Subject: [PATCH 29/91] Fix CS errors --- src/Action/DashboardAction.php | 1 - src/Breadcrumb/ActiveBreadcrumb.php | 1 - src/Breadcrumb/Breadcrumb.php | 1 - src/Dashboard/Dashboard.php | 1 - src/Dashboard/Module/ActionLinkItem.php | 1 - src/Dashboard/Module/LinkItem.php | 1 - src/Listener/Traits/DeprecatedConfigurationKeyTrait.php | 1 - src/Listener/Traits/FormTypeTrait.php | 1 - src/Listener/Traits/IndexTypeTrait.php | 1 - src/Listener/Traits/SidebarNavigationTrait.php | 1 - src/Listener/Traits/SiteTitleTrait.php | 1 - src/Listener/Traits/UtilityNavigationTrait.php | 1 - src/Listener/ViewListener.php | 1 - src/Listener/ViewSearchListener.php | 1 - src/Menu/MenuDivider.php | 1 - src/Menu/MenuDropdown.php | 1 - src/Menu/MenuItem.php | 1 - src/Plugin.php | 1 - src/Traits/CrudViewConfigTrait.php | 1 - src/View/Cell/DashboardTableCell.php | 1 - src/View/Cell/TablesListCell.php | 1 - src/View/CrudView.php | 1 - src/View/Helper/CrudViewHelper.php | 1 - src/View/Widget/DateTimeWidget.php | 8 +++++++- tests/TestCase/Dashboard/DashboardTest.php | 1 - tests/TestCase/Dashboard/Module/ActionLinkItemTest.php | 1 - tests/TestCase/Dashboard/Module/LinkItemTest.php | 1 - tests/TestCase/View/CrudViewTest.php | 1 - tests/TestCase/View/Helper/CrudViewHelperTest.php | 1 - tests/TestCase/View/Widget/DateTimeWidgetTest.php | 1 - tests/bootstrap.php | 1 - 31 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/Action/DashboardAction.php b/src/Action/DashboardAction.php index ee6427e3..fd8b12b1 100644 --- a/src/Action/DashboardAction.php +++ b/src/Action/DashboardAction.php @@ -1,5 +1,4 @@ Date: Mon, 30 Sep 2019 19:11:31 +0530 Subject: [PATCH 30/91] Don't add margins to all buttons by default. This causes design issue when using additional themes / widgets. Just use whitespace for spacing between action buttons. See https://getbootstrap.com/docs/4.3/components/buttons/ --- templates/element/actions.php | 10 ++++++++-- templates/element/form/buttons.php | 28 ++++++++++++++-------------- webroot/css/local.css | 3 --- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/templates/element/actions.php b/templates/element/actions.php index 92f6d951..4a9abcf5 100644 --- a/templates/element/actions.php +++ b/templates/element/actions.php @@ -67,6 +67,7 @@ ?> element('action-button', ['config' => $config]); + $btns[] = $this->element('action-button', ['config' => $config]); } unset($actionGroups['primary']); // render grouped actions -echo $this->element('action-groups', ['groups' => $actionGroups, 'links' => $links]); +$groupedBtns = trim($this->element('action-groups', ['groups' => $actionGroups, 'links' => $links])); +if ($groupedBtns) { + $btns[] = $groupedBtns; +} + +echo implode(' ', $btns); diff --git a/templates/element/form/buttons.php b/templates/element/form/buttons.php index 81690b2d..42e25919 100644 --- a/templates/element/form/buttons.php +++ b/templates/element/form/buttons.php @@ -1,20 +1,20 @@ - +
    Form->button($button['title'], $button['options']); - } elseif ($button['type'] === 'link') { - echo $this->Html->link($button['title'], $button['url'], $button['options']); - } elseif ($button['type'] === 'postLink') { - if (is_array($button['url'])) { - $button['url'][] = $$viewVar->get($primaryKey); - } - echo $this->Form->postLink($button['title'], $button['url'], $button['options']); + $btns = []; + foreach ($formSubmitExtraLeftButtons as $button) { + if ($button['type'] === 'button') { + $btns[] = $this->Form->button($button['title'], $button['options']); + } elseif ($button['type'] === 'link') { + $btns[] = $this->Html->link($button['title'], $button['url'], $button['options']); + } elseif ($button['type'] === 'postLink') { + if (is_array($button['url'])) { + $button['url'][] = $$viewVar->get($primaryKey); } + $btns[] = $this->Form->postLink($button['title'], $button['url'], $button['options']); } } + echo implode(' ', $btns); ?>
    @@ -28,9 +28,9 @@ if (!empty($formSubmitExtraButtons)) { foreach ($formSubmitExtraButtons as $button) { if ($button['type'] === 'button') { - echo $this->Form->button($button['title'], $button['options']); + echo ' ' . $this->Form->button($button['title'], $button['options']); } elseif ($button['type'] === 'link') { - echo $this->Html->link($button['title'], $button['url'], $button['options']); + echo ' ' . $this->Html->link($button['title'], $button['url'], $button['options']); } } } diff --git a/webroot/css/local.css b/webroot/css/local.css index b2b73514..02adaab6 100644 --- a/webroot/css/local.css +++ b/webroot/css/local.css @@ -48,9 +48,6 @@ div.input { margin-bottom: 10px } -.btn { - margin-left: 5px -} h2 .actions { margin-left: 15px; } From ba83561ee9120fd33c4fa9b7cb15e50777781153 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 30 Sep 2019 20:25:51 +0530 Subject: [PATCH 31/91] Fix class in button group dropdown --- templates/element/action-groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/element/action-groups.php b/templates/element/action-groups.php index 47379231..044b9f85 100644 --- a/templates/element/action-groups.php +++ b/templates/element/action-groups.php @@ -21,7 +21,7 @@ '#', ['class' => 'btn btn-default dropdown-toggle', 'escape' => false, 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false] ) ?> -