Problem/Motivation

Given that Tablefield supports integration with Filmanet Group's Tablesaw through the Responsive Tables Filter module, it would be nice to provide extra configuration options, like selecting the Tablesaw mode, to site builders and content managers using tablefield.

Proposed resolution

The attached patch is a starting point that adds Tablesaw's Stack, Column Toggle, and Swipe modes to the global default tablefield settings.

Remaining tasks

  • Determine where this should be controlled in field settings or on each tablefield
  • Provide ability to override default based on decision above
  • Add tests

User interface changes

In my opinion, this should be controlled on each tablefield. We should provide another group (underneath the 'Change Columns...' and 'Import CSV...' options) that allows a content manager to select the type of Tablesaw mode via radios or a dropdown.

API changes

Data model changes

A field might need to be added to the database, depending on implementation.

Comments

rwanth created an issue. See original summary.

lolandese’s picture

Status: Active » Needs review

Thanks for this.

As an initial patch has been posted, there is something to review.

lolandese’s picture

Issue summary: View changes
Status: Needs review » Needs work

Applies cleanly:

martin@martin-XPS-13-9370 /var/www/html/brown.localhost/web/modules/tablefield (8.x-2.x=) $ git apply -v tablefield--configurable-tablesaw-mode.patch
Checking patch config/install/tablefield.settings.yml...
Checking patch config/schema/tablefield.schema.yml...
Checking patch src/Form/TablefieldConfigForm.php...
Checking patch src/Plugin/Field/FieldFormatter/TablefieldFormatter.php...
Applied patch config/install/tablefield.settings.yml cleanly.
Applied patch config/schema/tablefield.schema.yml cleanly.
Applied patch src/Form/TablefieldConfigForm.php cleanly.
Applied patch src/Plugin/Field/FieldFormatter/TablefieldFormatter.php cleanly.

Some Codesniffer issues:

martin@martin-XPS-13-9370 /var/www/html/brown.localhost/web/modules (master *) $ drupalcs tablefield/

FILE: ...l/brown.localhost/web/modules/tablefield/src/Form/TablefieldConfigForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 75 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...modules/tablefield/src/Plugin/Field/FieldFormatter/TablefieldFormatter.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 233 | ERROR | [x] Concat operator must be surrounded by a single space
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 499ms; Memory: 10Mb

On an existing site with the Tablefield module already enabled we get for example:
<table id="tablefield-node-28-field_table-0" class="tablefield tablesaw tablesaw-" data-striping="1">

Ideally, this is a setting to put under "Manage display" settings with optionally allowing to override it per individual table (permission-based).