Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose DataTables customisation options #25

Merged
merged 2 commits into from
Jul 5, 2018
Merged

Expose DataTables customisation options #25

merged 2 commits into from
Jul 5, 2018

Conversation

rob-duplock
Copy link
Collaborator

@rob-duplock rob-duplock commented Jul 3, 2018

  • Added page length and searching options.
  • Refactored couple comments.
  • Drupal coding standard updates.
  • Code review changes

- Refactored couple comments.
- Drupal coding standard updates (DH)
Copy link
Contributor

@jorgegc jorgegc left a comment

Choose a reason for hiding this comment

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

Sorry @rob-duplock I have left quite a few comments for you to address. I am being super strict because we area aiming for a release soon and I don't want anything to go in that we will need to change later.

js/dvfTables.js Outdated
@@ -9,7 +9,7 @@
attach: function (context) {
$('[data-dvftables]', context).each(function () {
var $table = $(this),
tableId = $table.data('dvftables');
tableId = $table.data('dvftables');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we undo this change please?

'#type' => 'select',
'#title' => $this->t('Page length'),
'#options' => $this->getPageLengthOptions(),
'#description' => $this->t('Number of rows to display on a single page when using pagination.'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Pagination is always enabled. Can we please change this to:

Number of rows per page.

'#default_value' => $this->config('table', 'table_options', 'page_length'),
];

$form['table']['table_options']['enable_searching'] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency with the other settings, can this please be renamed to searching?


$form['table']['table_options']['enable_searching'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable Searching'),
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency again, Searching should be lowercase.

@@ -94,4 +113,21 @@ protected function rowHeaderField() {
return $this->config('table', 'row_header_field');
}

/**
* Returns Page length options.
Copy link
Contributor

Choose a reason for hiding this comment

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

Returns page length options.

@@ -22,6 +22,10 @@ public function defaultConfiguration() {
'table' => [
'table_header_field' => '',
'row_header_field' => '',
'table_options' => [
Copy link
Contributor

Choose a reason for hiding this comment

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

'options' => [

@@ -28,6 +28,7 @@
this
.parseData()
.parseColumns()
.getTableOptions()
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, this should be .parseTableOptions.

return this;
},

getTableOptions: function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please rename this to parseTableOptions?

},

getTableOptions: function () {
this.config = $.extend(this.config, this.options.tableOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

After all my suggestions this.options.tableOptions may not be set so we need to check before using it.

parseTableOptions: function () {
  if (this.options.tableOptions) {
    this.config = $.extend(this.config, this.options.tableOptions);
  }

  return this;
}

/**
* {@inheritdoc}
*/
protected function getTableOptions() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be removed. Please see my comments below.

@rob-duplock
Copy link
Collaborator Author

Thanks @jorgegc please see latest commit.

Copy link
Contributor

@jorgegc jorgegc left a comment

Choose a reason for hiding this comment

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

Solid work @rob-duplock. Sorry about the annoying comments!

@jorgegc jorgegc requested a review from tobybellwood July 5, 2018 00:34
Copy link
Contributor

@tobybellwood tobybellwood left a comment

Choose a reason for hiding this comment

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

I'm happy for @jorgegc to merge.

@jorgegc jorgegc merged commit 5bc5f3e into govCMS:8.x-1.x Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants