diff --git a/.editorconfig b/.editorconfig index 3a050c04..8c863121 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,12 +12,10 @@ insert_final_newline = true trim_trailing_whitespace = true [*.yml] -indent_style = space indent_size = 2 -[*.js] -indent_style = space -indent_size = 4 - [Makefile] indent_style = tab + +[*.neon] +indent_style = tab diff --git a/.gitattributes b/.gitattributes index 76a35dd6..6d2ed281 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,3 +11,6 @@ docs export-ignore .github export-ignore .coveralls.yml export-ignore Makefile export-ignore +phpstan.neon export-ignore +phpstan-baseline.neon export-ignore +psalm.xml export-ignore 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/.stickler.yml b/.stickler.yml index d78d6bd9..b8f57db8 100644 --- a/.stickler.yml +++ b/.stickler.yml @@ -1,8 +1,8 @@ --- linters: phpcs: - standard: CakePHP - extensions: 'php,ctp' + standard: CakePHP4 + extensions: 'php' fixer: true fixers: diff --git a/.travis.yml b/.travis.yml index a5a51405..fcfdfade 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ language: php php: - - 5.6 - - 7.0 - - 7.1 - 7.2 + - 7.3 + - 7.4 env: global: @@ -15,33 +14,33 @@ matrix: fast_finish: true include: - - php: 7.0 + - php: 7.2 env: PHPCS=1 DEFAULT=0 - - php: 7.0 - env: PHPSTAN=1 DEFAULT=0 - + - php: 7.2 + env: STATIC_ANALYSIS=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.3 ]]; 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 - - if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:dev-master; fi - - if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan:^0.9; fi + - if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:^4.2; fi + - if [[ $STATIC_ANALYSIS = 1 ]]; then composer require phpstan/phpstan:^0.12 psalm/phar:^3.7; 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.3 ]]; then vendor/bin/phpunit; fi + - if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; 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 + - if [[ $STATIC_ANALYSIS = 1 ]]; then vendor/bin/phpstan.phar analyse src && vendor/bin/psalm.phar; 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.3 ]]; then bash <(curl -s https://codecov.io/bash); fi notifications: email: false diff --git a/README.md b/README.md index f7c53299..9929ffe3 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ Automated admin backend based on your [Crud](https://github.com/friendsofcake/cr # Installation -For CakePHP 3.x: - ```shell composer require friendsofcake/crud-view ``` diff --git a/composer.json b/composer.json index df3096e4..8ac8a0d4 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.0", + "friendsofcake/crud": "^6.0", + "friendsofcake/bootstrap-ui": "^3.0" }, "require-dev": { - "friendsofcake/cakephp-test-utilities": "^1.0", - "markstory/asset_compress": "^3.2", - "phpunit/phpunit": "^5.7.14|^6.0" + "friendsofcake/cakephp-test-utilities": "^2.0", + "markstory/asset_compress": "^4.0", + "phpunit/phpunit": "~8.5.0" }, "autoload": { "psr-4": { @@ -53,5 +53,6 @@ "issues": "https://github.com/FriendsOfCake/crud-view/issues", "wiki": "http://cakephp.nu/cakephp-crud/", "irc": "irc://irc.freenode.org/friendsofcake" - } + }, + "prefer-stable": true } diff --git a/config/asset_compress.ini b/config/asset_compress.ini index 9e2a1de9..a54b68e2 100644 --- a/config/asset_compress.ini +++ b/config/asset_compress.ini @@ -1,16 +1,16 @@ [crudview.css] -files[]=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.css -files[]=https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css -files[]=https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.bootstrap3.min.css +files[]=https://cdn.jsdelivr.net/npm/bootstrap@^4.5/dist/css/bootstrap.min.css +files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6/dist/flatpickr.min.css +files[]=https://cdn.jsdelivr.net/npm/select2@4.0/dist/css/select2.min.css +files[]=https://cdn.jsdelivr.net/npm/@ttskch/select2-bootstrap4-theme@1.2/dist/select2-bootstrap4.css files[]=plugin:CrudView:css/local.css [crudview_head.js] -files[]=https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js -files[]=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js -files[]=https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js -files[]=https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js -files[]=https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js -files[]=https://cdn.jsdelivr.net/jquery.dirtyforms/1.2.3/jquery.dirtyforms.min.js +files[]=https://cdn.jsdelivr.net/npm/jquery@^3.4/dist/jquery.min.js +files[]=https://cdn.jsdelivr.net/npm/bootstrap@^4.5/dist/js/bootstrap.min.js +files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6 +files[]=https://cdn.jsdelivr.net/npm/select2@4.0 +files[]=https://cdn.jsdelivr.net/npm/jquery.dirtyforms@2/jquery.dirtyforms.min.js [crudview.js] files[]=plugin:CrudView:js/local.js diff --git a/config/defaults.php b/config/defaults.php index d4241418..c7003bc0 100644 --- a/config/defaults.php +++ b/config/defaults.php @@ -1,4 +1,7 @@ $assets['crudview_head.js']['files'], 'script' => $assets['crudview.js']['files'], ], - 'timezoneAwareDateTimeWidget' => false, + 'datetimePicker' => false, 'useAssetCompress' => Plugin::isLoaded('AssetCompress'), 'tablesBlacklist' => [ 'phinxlog', ], - ] + ], ]; diff --git a/config/forms.php b/config/forms.php index 39d3eed4..7c31f88b 100644 --- a/config/forms.php +++ b/config/forms.php @@ -1,5 +1,5 @@ '{{content}}', 'formGroup' => '{{label}}
= $this->Html->link($link->get('title'), $link->get('url'), $link->get('options')) ?> | get('actions')) : ?> 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 99% rename from src/Template/Element/action-button.ctp rename to templates/element/action-button.php index 93d75df8..2a47c23f 100644 --- a/src/Template/Element/action-button.ctp +++ b/templates/element/action-button.php @@ -1,11 +1,13 @@ Form->postLink($config['title'], $config['url'], $config['options']); + return; } diff --git a/templates/element/action-groups.php b/templates/element/action-groups.php new file mode 100644 index 00000000..6ac81752 --- /dev/null +++ b/templates/element/action-groups.php @@ -0,0 +1,40 @@ + $group) { + $exists = false; + foreach ($group as $action => $config) { + $subaction = is_array($config) ? $action : $config; + if (array_key_exists($subaction, $links)) { + $exists = true; + } + } + if (!$exists) { + unset($groups[$key]); + } +} +?> + + $group) : ?> +Paginator->sort($field, isset($options['title']) ? $options['title'] : null, $options); + echo $this->Paginator->sort($field, $options['title'] ?? null, $options); } ?> | - += __d('crud', 'Actions'); ?> | = $this->element('actions', [ 'singularVar' => $singularVar, - 'actions' => $actions['entity'] + 'actions' => $actions['entity'], ]); ?> | diff --git a/src/Template/Element/index/table_columns.ctp b/templates/element/index/table_columns.php similarity index 74% rename from src/Template/Element/index/table_columns.ctp rename to templates/element/index/table_columns.php index 8028a4d6..77505cb5 100644 --- a/src/Template/Element/index/table_columns.ctp +++ b/templates/element/index/table_columns.php @@ -1,6 +1,6 @@ $options) { - $tdOptions = isset($options['td']) ? $options['td'] : []; + $tdOptions = $options['td'] ?? []; unset($options['td']); echo $this->Html->tag('td', $this->CrudView->process($field, $singularVar, $options), $tdOptions); 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 52% rename from src/Template/Element/search.ctp rename to templates/element/search.php index 42fa2f2c..990e513d 100644 --- a/src/Template/Element/search.ctp +++ b/templates/element/search.php @@ -4,19 +4,22 @@ } ?> -
---|