Problem/Motivation

On the module page it says that 1.9.x of https://www.datatables.net/download/ is required.
In datatables.libraries.yml it says

datatables_core:
  version: 1.10

While there is already a version 1.13.x available.

Does it produce problems upgrading to the current 2.x-dev while not updating the library from 1.9.4 to 1.10 or higher?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#16 2024-09-25_11-08-22.jpg109.24 KBnicholass
#9 before.png55.39 KBindranil roy

Issue fork datatables-3399504

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

maxilein created an issue. See original summary.

chris64’s picture

Indeed @maxilein, the library version is an important subject. The new 2.0 module release allows to use the 1.10 datatables library version. See #2999400: [META] Keep track of DataTables library versions. In the installed system it is possible to know the datatables library 1.10 version used using command composer show datatables/datatables. Actually 1.10.21.

chris64’s picture

Status: Active » Needs review
maxilein’s picture

Thank you. Now I can figure out which problems come from a higher library ...

Maybe it is possible to add a warning on the status page if the library is not the expected version. That always helps a lot to identify problems.

Something like:

datatables needs datatables/datatables 1.10.21. The version in the libraries folder is 1.XX and not currently supported.
To correct the problem execute composer require datatables/datatables:~1.10.x

chris64’s picture

@maxilein, actually installing the datatables library with composer is possible but rather not simple.The next step now is to install this library in simple way via composer (See #3415937: The module needs a composer.json file). The means to get the library version with the drush show command would be explained in the README.md file. However, indeed, this version should be reflected in a code file, like .libraries.yml as you suggest in the IS.

kingfisher64’s picture

Hello,

I'm trying to install the data tables module, however, it doesn't look like the library is installed properly. Every now and again I get the following notice:

Warning: file_get_contents(libraries/datatables/media/js/jquery.dataTables.js): Failed to open stream: No such file or directory in Drupal\Core\Asset\JsOptimizer->optimize() (line 39 of core/lib/Drupal/Core/Asset/JsOptimizer.php).

I have copied the library from vendor to libraries/datatables/datatables as the documentation.

Is there a way to put the library status under "status report"? I only suggest there as webform and other mods put it there.

Edit: I believe the library is installed now as the error isn't showing but still would be good to have a library install status :)

Arijit Acharya made their first commit to this issue’s fork.

indranil roy’s picture

StatusFileSize
new55.39 KB

Hi,

I have tested the MR, and it is working fine for me. Here are the steps I followed:

1. Installed the module.
2. Applied the MR.
3. Installed the required libraries as described in the readme file.

After installing the libraries properly, the error message no longer appears on the status report page.

indranil roy’s picture

Status: Needs review » Reviewed & tested by the community
dqd’s picture

Title: Make transparent which library is required » Add hook_requirements() to check library and print status report

Good finding and good work. +1

dqd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nicholass’s picture

I am confused, I have updated datatables, but status report says I am missing assets.

This added a check for the following assets
https://git.drupalcode.org/project/datatables/-/blob/2.x/datatables.modu...

// Check if the essential CSS and JavaScript files exist.
    $essential_assets = [
      'css' => ['jquery.dataTables.css', 'dataTables.bootstrap.css'],
      'js' => ['jquery.dataTables.js', 'dataTables.bootstrap.js'],
    ];

But the libraries.yml only loads the non-bootstrap assets.

datatables_core:
  version: 1.10
  js:
    /libraries/datatables/media/js/jquery.dataTables.js: {}
  css:
    component:
      /libraries/datatables/media/css/jquery.dataTables.css: {}
  dependencies:
    - core/jquery

So how are we supposed to load the dataTables.bootstrap.css dataTables.bootstrap.js assets? There is nothing in the readme about that. It seems like those should be removed from the status page check for correct assets, some projects don't use bootstrap.

nicholass’s picture

StatusFileSize
new109.24 KB

Looks like the path to check for assets is incorrect, composer does not place the datatables library in a subfolder called datatables.

Should just be libraries/datatables/* not libraries/datatables/datatables/*

I'll create a new issue about this.