From a34d6242a5100ac9b74632b47eb68a25b4e589f1 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 31 Aug 2017 14:45:42 +1200 Subject: [PATCH 01/10] Update branch alias --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5b0b50b..4dd634c 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "extra": { "installer-name": "gridfieldextensions", "branch-alias": { - "2.x-dev": "2.0.x-dev" + "2.x-dev": "2.1.x-dev" }, "screenshots": [ "docs/en/_images/editable-rows.png", From 23c0a58e481296f8561ba874dfeabb9b037b2afc Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Fri, 22 Sep 2017 13:50:25 +0100 Subject: [PATCH 02/10] TEST Cover base table last edited update --- tests/GridFieldOrderableRowsTest.php | 52 ++++++++++++++++++++++++++++ tests/GridFieldOrderableRowsTest.yml | 31 +++++++++++++---- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/tests/GridFieldOrderableRowsTest.php b/tests/GridFieldOrderableRowsTest.php index 1b10f66..4d88606 100644 --- a/tests/GridFieldOrderableRowsTest.php +++ b/tests/GridFieldOrderableRowsTest.php @@ -12,6 +12,8 @@ class GridFieldOrderableRowsTest extends SapphireTest { 'GridFieldOrderableRowsTest_Parent', 'GridFieldOrderableRowsTest_Ordered', 'GridFieldOrderableRowsTest_Subclass', + 'GridFieldOrderableRowsTest_Unorderable', + 'GridFieldOrderableRowsTest_OrderableChild', ); public function testReorderItems() { @@ -49,6 +51,35 @@ class GridFieldOrderableRowsTest extends SapphireTest { } + public function testSortableChildClass() { + $orderable = new GridFieldOrderableRows('Sort'); + $reflection = new ReflectionMethod($orderable, 'executeReorder'); + $reflection->setAccessible(true); + + $parent = $this->objFromFixture('GridFieldOrderableRowsTest_Ordered', 'nestedtest'); + + $config = new GridFieldConfig_RelationEditor(); + $config->addComponent($orderable); + + $grid = new GridField( + 'Children', + 'Children', + $parent->Children(), + $config + ); + + $originalOrder = $parent->Children()->column('ID'); + $desiredOrder = array_reverse($originalOrder); + + $this->assertNotEquals($originalOrder, $desiredOrder); + + $reflection->invoke($orderable, $grid, $desiredOrder); + + $newOrder = $parent->Children()->column('ID'); + + $this->assertEquals($desiredOrder, $newOrder); + } + /** * @covers GridFieldOrderableRows::getSortTable */ @@ -112,6 +143,10 @@ class GridFieldOrderableRowsTest_Ordered extends DataObject implements TestOnly 'Parent' => 'GridFieldOrderableRowsTest_Parent' ); + private static $has_many = array( + 'Children' => 'GridFieldOrderableRowsTest_OrderableChild', + ); + private static $belongs_many_many =array( 'MyManyMany' => 'GridFieldOrderableRowsTest_Parent', ); @@ -121,4 +156,21 @@ class GridFieldOrderableRowsTest_Ordered extends DataObject implements TestOnly class GridFieldOrderableRowsTest_Subclass extends GridFieldOrderableRowsTest_Ordered implements TestOnly { } +class GridFieldOrderableRowsTest_Unorderable extends DataObject implements TestOnly { +} + +class GridFieldOrderableRowsTest_OrderableChild extends GridFieldOrderableRowsTest_Unorderable implements TestOnly { + + private static $db = array( + 'Sort' => 'Int', + ); + + private static $has_one = array( + 'Parent' => 'GridFieldOrderableRowsTest_Ordered', + ); + + private static $default_sort = '"Sort" ASC'; + +} + /**#@-*/ diff --git a/tests/GridFieldOrderableRowsTest.yml b/tests/GridFieldOrderableRowsTest.yml index 30b7e79..87c5961 100644 --- a/tests/GridFieldOrderableRowsTest.yml +++ b/tests/GridFieldOrderableRowsTest.yml @@ -1,10 +1,3 @@ -GridFieldOrderableRowsTest_Ordered: - item1: - item2: - item3: - item4: - item5: - item6: GridFieldOrderableRowsTest_Parent: parent: MyManyMany: @@ -20,3 +13,27 @@ GridFieldOrderableRowsTest_Parent: ManyManySort: 108 - 5: =>GridFieldOrderableRowsTest_Ordered.item6 ManyManySort: 108 +GridFieldOrderableRowsTest_OrderableChild: + item1: + Sort: 1 + item2: + Sort: 2 + item3: + Sort: 3 + item4: + Sort: 4 +GridFieldOrderableRowsTest_Ordered: + item1: + Sort: 1 + item2: + Sort: 2 + item3: + Sort: 3 + item4: + Sort: 4 + item5: + Sort: 5 + item6: + Sort: 6 + nestedtest: + Children: =>GridFieldOrderableRowsTest_OrderableChild.item1,=>GridFieldOrderableRowsTest_OrderableChild.item2,=>GridFieldOrderableRowsTest_OrderableChild.item3,=>GridFieldOrderableRowsTest_OrderableChild.item4 From b28ded715cb2177ae4ea6dca9ea6f516a1afeac2 Mon Sep 17 00:00:00 2001 From: matej Date: Fri, 7 Sep 2018 09:46:43 +0200 Subject: [PATCH 03/10] added support for PHP 7.2 --- _config.php | 5 +++++ code/GridFieldAddNewInlineButton.php | 2 +- code/GridFieldAddNewMultiClass.php | 2 +- code/GridFieldEditableColumns.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 _config.php diff --git a/_config.php b/_config.php new file mode 100644 index 0000000..d62e0cd --- /dev/null +++ b/_config.php @@ -0,0 +1,5 @@ +getDisplayFields($grid)); if($grid->getList()) { - $record = Object::create($grid->getModelClass()); + $record = SS_Object::create($grid->getModelClass()); } else { $record = null; } diff --git a/code/GridFieldAddNewMultiClass.php b/code/GridFieldAddNewMultiClass.php index 108e434..3a341ac 100755 --- a/code/GridFieldAddNewMultiClass.php +++ b/code/GridFieldAddNewMultiClass.php @@ -174,7 +174,7 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL } $unsanitisedClass = $this->unsanitiseClassName($class); - $handler = Object::create($this->itemRequestClass, + $handler = SS_Object::create($this->itemRequestClass, $grid, $component, new $unsanitisedClass(), $grid->getForm()->getController(), 'add-multi-class' ); $handler->setTemplate($component->getTemplate()); diff --git a/code/GridFieldEditableColumns.php b/code/GridFieldEditableColumns.php index 996dbf9..9abe931 100644 --- a/code/GridFieldEditableColumns.php +++ b/code/GridFieldEditableColumns.php @@ -196,7 +196,7 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements $extra = $list->getExtraFields(); if($extra && array_key_exists($col, $extra)) { - $field = Object::create_from_string($extra[$col], $col)->scaffoldFormField(); + $field = SS_Object::create_from_string($extra[$col], $col)->scaffoldFormField(); } } From 299086ea998b57940f9159a7f3c9a47b68c1b783 Mon Sep 17 00:00:00 2001 From: zemiacsik Date: Fri, 7 Sep 2018 10:12:01 +0200 Subject: [PATCH 04/10] updated styling to follow PSR-2 --- _config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_config.php b/_config.php index d62e0cd..e2cf530 100644 --- a/_config.php +++ b/_config.php @@ -2,4 +2,6 @@ // Ensure compatibility with PHP 7.2 ("object" is a reserved word), // with SilverStripe 3.6 (using Object) and SilverStripe 3.7 (using SS_Object) -if (!class_exists('SS_Object')) class_alias('Object', 'SS_Object'); +if (!class_exists('SS_Object')) { + class_alias('Object', 'SS_Object'); +} From 1cd4d99b6cee161e53a41fe9ed07d48fcb8d07a0 Mon Sep 17 00:00:00 2001 From: zemiacsik Date: Fri, 7 Sep 2018 10:17:01 +0200 Subject: [PATCH 05/10] indent with 4 spaces instead of tab --- _config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.php b/_config.php index e2cf530..8b68529 100644 --- a/_config.php +++ b/_config.php @@ -3,5 +3,5 @@ // Ensure compatibility with PHP 7.2 ("object" is a reserved word), // with SilverStripe 3.6 (using Object) and SilverStripe 3.7 (using SS_Object) if (!class_exists('SS_Object')) { - class_alias('Object', 'SS_Object'); + class_alias('Object', 'SS_Object'); } From 4346fd57e6469a403d16b36141f083ffd61cc104 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 20 Sep 2018 17:05:45 +0200 Subject: [PATCH 06/10] Remove obsolete branch alias --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 4dd634c..0421c76 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,6 @@ }, "extra": { "installer-name": "gridfieldextensions", - "branch-alias": { - "2.x-dev": "2.1.x-dev" - }, "screenshots": [ "docs/en/_images/editable-rows.png", "docs/en/_images/add-existing-search.png" From d88b60a7c2461ce43c0e04c2704a94cc79162f60 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 20 Sep 2018 17:06:52 +0200 Subject: [PATCH 07/10] Remove branch alias for 2.x --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index 4dd634c..0421c76 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,6 @@ }, "extra": { "installer-name": "gridfieldextensions", - "branch-alias": { - "2.x-dev": "2.1.x-dev" - }, "screenshots": [ "docs/en/_images/editable-rows.png", "docs/en/_images/add-existing-search.png" From aef80e1aec7ebbff867520d56bcf3dbaaf54e989 Mon Sep 17 00:00:00 2001 From: Mohamed Alsharaf Date: Tue, 13 Nov 2018 16:37:51 +1300 Subject: [PATCH 08/10] FIX: Prevent tmpl.js include on ajax request Including tmpl.js from the framework third party directory interfere with an upload field within a grid field edit form. --- code/GridFieldAddNewInlineButton.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/GridFieldAddNewInlineButton.php b/code/GridFieldAddNewInlineButton.php index 7fa0295..e8da8fc 100755 --- a/code/GridFieldAddNewInlineButton.php +++ b/code/GridFieldAddNewInlineButton.php @@ -67,7 +67,9 @@ class GridFieldAddNewInlineButton implements GridField_HTMLProvider, GridField_S throw new Exception('Inline adding requires the editable columns component'); } - Requirements::javascript(THIRDPARTY_DIR . '/javascript-templates/tmpl.js'); + if (!Director::is_ajax()) { + Requirements::javascript(THIRDPARTY_DIR . '/javascript-templates/tmpl.js'); + } GridFieldExtensions::include_requirements(); $data = new ArrayData(array( From ce4d579e67184ddd91cd4dfc1928c7bb36aef64c Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 12 Dec 2018 15:49:25 +1100 Subject: [PATCH 09/10] FIX(Composer): The 1.5 branch should now resolve correctly. This affects older versions running `silverstripe-australia/` modules. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 4f171c4..151fb79 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ ] }, "replace": { + "silverstripe-australia/gridfieldextensions": "self.version", "ajshort/silverstripe-gridfieldextensions": "self.version" } } From 8eb66bc2ebdf6fadfc90724a804d86df9e49f4da Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 24 Jul 2019 12:37:26 +0200 Subject: [PATCH 10/10] Update Travis builds to include PHP 7, update PHPUnit to 5.7 --- .travis.yml | 35 +++++++++++++---------------------- composer.json | 3 +++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 62bfe15..b38514c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,25 @@ -# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details - -sudo: false +# See https://github.com/silverstripe/silverstripe-travis-support for setup details language: php -dist: precise - -php: - - 5.4 - - 5.5 - - 5.6 - -env: - - DB=MYSQL CORE_RELEASE=3.2 +dist: trusty matrix: include: - - php: 5.6 - env: DB=MYSQL CORE_RELEASE=3 - - php: 5.6 - env: DB=PGSQL CORE_RELEASE=3.1 - - php: 5.6 - env: DB=PGSQL CORE_RELEASE=3.3 - - php: 5.6 - env: DB=PGSQL CORE_RELEASE=3.4 - fast_finish: true + - php: '5.6' + env: DB=MYSQL CORE_RELEASE=3.6 + - php: '7.0' + env: DB=PGSQL CORE_RELEASE=3.7 + - php: '7.1' + env: DB=MYSQL CORE_RELEASE=3.7 + - php: '7.2' + env: DB=MYSQL CORE_RELEASE=3.7 + - php: '7.3' + env: DB=MYSQL CORE_RELEASE=3.7 before_script: - composer self-update || true - - git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support + - git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss - cd ~/builds/ss - composer install diff --git a/composer.json b/composer.json index 0421c76..ef5238d 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,9 @@ "require": { "silverstripe/framework": "~3.1" }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, "extra": { "installer-name": "gridfieldextensions", "screenshots": [