diff --git a/composer.json b/composer.json index c7656b0..fdad08a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "require": { "silverstripe/admin": "^1", "silverstripe/framework": "^4", - "silverstripe/vendor-plugin": "^1" + "silverstripe/vendor-plugin": "^1", + "symbiote/silverstripe-gridfieldextensions": "^3.2.3" }, "extra": { "expose": [ diff --git a/src/Forms/FieldsProvider.php b/src/Forms/FieldsProvider.php index 96cfbc4..ece63e4 100644 --- a/src/Forms/FieldsProvider.php +++ b/src/Forms/FieldsProvider.php @@ -12,6 +12,7 @@ use SilverStripe\Forms\GridField\GridFieldFilterHeader; use SilverStripe\ORM\DataList; use SilverStripe\Versioned\GridFieldArchiveAction; +use Symbiote\GridFieldExtensions\GridFieldOrderableRows; /** * Class FieldsProvider diff --git a/src/Forms/GridFieldOrderableRows.php b/src/Forms/GridFieldOrderableRows.php deleted file mode 100644 index 9b2beb4..0000000 --- a/src/Forms/GridFieldOrderableRows.php +++ /dev/null @@ -1,100 +0,0 @@ -isManyMany($list)) { - $introspector = $this->getManyManyInspector($list); - $extra = $list instanceof ManyManyList ? - $introspector->getExtraFields() : - DataObjectSchema::create()->fieldSpecs($introspector->getJoinClass(), DataObjectSchema::DB_ONLY); - $key = $introspector->getLocalKey(); - $foreignKey = $introspector->getForeignIDKey(); - $foreignID = (int) $list->getForeignID(); - - if ($extra && array_key_exists($this->getSortField(), $extra)) { - return sprintf( - '"%s" %s AND "%s" = %d', - $key, - $value, - $foreignKey, - $foreignID - ); - } - } - - return "\"ID\" $value"; - } - - - /** - * Used to get sort orders from a many many through list relationship record, rather than the current - * record itself. - * - * @param ManyManyList|ManyManyThroughList $list - * @param mixed $sortField - * @return array|int[] Sort orders for the - */ - protected function getSortValuesFromManyManyThroughList($list, $sortField) - { - $manipulator = $this->getManyManyInspector($list); - - // Find the foreign key name, ID and class to look up - $joinClass = $manipulator->getJoinClass(); - $fromRelationName = $manipulator->getForeignIDKey(); - $toRelationName = $manipulator->getLocalKey(); - - // Create a list of the MMTL relations - $sortlist = DataList::create($joinClass)->filter([ - $toRelationName => $list->column('ID'), - // first() is safe as there are earlier checks to ensure our list to sort is valid - $fromRelationName => $list->first()->getJoin()->{$fromRelationName}, - ]); - - return $sortlist->map($toRelationName, $sortField)->toArray(); - } -} diff --git a/src/ModelAdmins/TaxonomyModelAdmin.php b/src/ModelAdmins/TaxonomyModelAdmin.php index 9060c2e..6d0cf4a 100644 --- a/src/ModelAdmins/TaxonomyModelAdmin.php +++ b/src/ModelAdmins/TaxonomyModelAdmin.php @@ -2,13 +2,13 @@ namespace Chrometoaster\AdvancedTaxonomies\ModelAdmins; -use Chrometoaster\AdvancedTaxonomies\Forms\GridFieldOrderableRows; use Chrometoaster\AdvancedTaxonomies\Models\TaxonomyTerm; use SilverStripe\Admin\ModelAdmin; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldAddNewButton; use SilverStripe\ORM\SS_List; use SilverStripe\View\Requirements; +use Symbiote\GridFieldExtensions\GridFieldOrderableRows; use UndefinedOffset\SortableGridField\Forms\GridFieldSortableRows; /** diff --git a/src/Models/TaxonomyTerm.php b/src/Models/TaxonomyTerm.php index a49a989..e23b116 100644 --- a/src/Models/TaxonomyTerm.php +++ b/src/Models/TaxonomyTerm.php @@ -3,7 +3,6 @@ namespace Chrometoaster\AdvancedTaxonomies\Models; use Chrometoaster\AdvancedTaxonomies\Forms\GridFieldAddTagsAutocompleter; -use Chrometoaster\AdvancedTaxonomies\Forms\GridFieldOrderableRows; use Chrometoaster\AdvancedTaxonomies\Generators\PluralGenerator; use Chrometoaster\AdvancedTaxonomies\Generators\URLSegmentGenerator; use Chrometoaster\AdvancedTaxonomies\ModelAdmins\TaxonomyModelAdmin; @@ -38,6 +37,7 @@ use SilverStripe\Versioned\GridFieldArchiveAction; use SilverStripe\View\ArrayData; use SilverStripe\View\ViewableData; +use Symbiote\GridFieldExtensions\GridFieldOrderableRows; use UndefinedOffset\SortableGridField\Forms\GridFieldSortableRows; /**