Skip to content

Conversation

@bravadomizzou
Copy link
Contributor

@bravadomizzou bravadomizzou commented Jul 14, 2016

This is the work for #61

bravadomizzou and others added 6 commits July 14, 2016 10:08
Set default value for $sortedFields when $sorter is null
To enable, simply call `enableDataTables` on a Component.

Developer Notes:

table-main.js is built from table.js using webpack, as such some dependencies are missing since Dewdrop does not currently track node module dependencies.

In the mean time you can test this by running the following:
npm install webpack
npm install datatables.net
npm install datatables.net-bs
npm install imports-loader
npm install jquery-param

Also you may want to make your dewdrop directory that is in bower_components be a symbolic link to the corresponding one in this directory.

ToDo:
Add ability to globally enable DataTables (not just via Component)
@bravadomizzou
Copy link
Contributor Author

I added support for DataTables, still need to include webpack and get it checked out by others before merging. Waiting on development of others before committing node modules for DataTables and other dependencies to avoid conflicts.

@bravadomizzou
Copy link
Contributor Author

Note to self: Update the Contributing Wiki after this is merged as to how to use Yarn.

Moved DataTables logic into a listing handler, Index page now uses methods on the Listing to render critical sections such as the table and pagination.

To enable DataTables in your application:

For entire application:
    Pimple::getInstance()['listing-handler'] = new Listing\DataTables();
For a component:
    public function getListing()
    {
        if (!this->listing) {
            $this->listing = new Listing($adminListing, $primaryKey, $request, new Listing\DataTables();
        }
        return $this->listing;
    }
@bravadomizzou
Copy link
Contributor Author

Should I go ahead and merge this into master?

/**
* Get the field the Select is currently sorted by.
*
* @deprecated Use getSortedFields() instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious what the plan is for eventually removing these @deprecated methods (e.g., version 2.0.0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unaware of any roadmap for Dewdrop, would be happy to help start one. These methods are still supported at line 254


$out .= <<<HTML
<script type="text/javascript">
var INDEX_TABLE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this approach limit us to one table per request/page? I'm not sure offhand if we're already limited in this way, but I'd hesitate to introduce such a limitation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, we already are limited, at least on the frontend. The backend supports prefixes for multiple table views. There are few existing implementations of that and those are already custom. This entire feature is essentially opt in, so updating to it should introduce any unexpected behaviors.

$out = '';
$sortedFields = ($sorter) ? $sorter->getSortedFields() : [];

//var_dump($sortedFields);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spurious var_dump()

$out .= '</th>';
}

//die;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove //die;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, and the other comment about //var_dump have been resolved in 7057b71

package.json Outdated
@@ -0,0 +1,27 @@
{
"name": "dewdrop",
"version": "1.27.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to flag this for updating immediately prior to, or as part of, the release process?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was added by Yarn, I think I can just remove the version

@darbyfelton
Copy link
Contributor

I'm very much looking forward to the availability of these features in Dewdrop.

It would be nice if we had a CI system that would support feature branches to aid in determining whether the related changes are stable and ready for merging.

Perhaps this feature branch is already being successfully used by one or more projects?

I'm also curious if any projects that are not using the DataTables functionality successfully operate using this feature branch, or if there are any backward incompatibilities or risks that should be addressed?

@bravadomizzou
Copy link
Contributor Author

bravadomizzou commented Jan 4, 2017

@darbyfelton I am not aware of any project using this currently, there should not be any backwards compatibility issues.

We may want to put in the release notes how to enable these new features:

To enable DataTables in your application:

For entire application:

Pimple::getInstance()['listing-handler'] = new Listing\DataTables();

For a component:

public function getListing()
    {
        if (!this->listing) {
            $this->listing = new Listing($adminListing, $primaryKey, $request, new Listing\DataTables();
        }
        return $this->listing;
    }

@bravadomizzou
Copy link
Contributor Author

I found an issue when using this with listings that have bulk selections. So that will need to be updated before merging.

@bravadomizzou
Copy link
Contributor Author

Also need to add support for SortableListingInterface. Currently it just shows the sort index, not the sorting grabber.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants