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

Use orthogonal data for DataTables #865

Merged

Conversation

alistair3149
Copy link
Contributor

@alistair3149 alistair3149 commented Nov 23, 2024

This will make DataTables easier to expand and maintain. Now we can assign different attributes to the data, and this will resolve any sorting and filtering issues that we had.

Added

Instead of assigning HTML directly as data, we can assign an object with the following keys:

  • display - The display value of the data (same as what we had)
  • filter - Value used for filtering (e.g. SearchBuilder)
  • sort - Value used for sorting

Removed

  • any-number - Not needed anymore because sort key are always sortable
  • datatables-column.type - Same reason as above

https://datatables.net/manual/data/orthogonal-data

Fix #831

Instead of assigning HTML directly as data, we can use assign an object with the following keys:

- display - The display value of the data (same as what we had)

- filter - Value used for filtering (e.g. SearchBuilder)

- order - Value used for sorting

This will make DataTables easier to expand in the long run. Since we can assign different

attributes to the data.

Also fixes SemanticMediaWiki#831
We don't need it anymore because values are assigned a sorting key
@JeroenDeDauw
Copy link
Member

Looks good. @thomas-topway-it can you also check this?

@malberts
Copy link
Contributor

The code change looks fine, although I didn't do any manual tests.

Are there any possible backward compatibility issues here? Since this changes what the PHP outputs, I imagine pages with outdated caches will serve the old HTML with the new Javascript and then break. (Again, not manually confirmed, just checking.)

@alistair3149
Copy link
Contributor Author

The code change looks fine, although I didn't do any manual tests.

Are there any possible backward compatibility issues here? Since this changes what the PHP outputs, I imagine pages with outdated caches will serve the old HTML with the new Javascript and then break. (Again, not manually confirmed, just checking.)

It would not be backward compatible and require a parser purge on the affected pages.

@thomas-topway-it
Copy link
Contributor

for some reason I've missed this pull request until today. I've still to test it by the way it is great that you are moving to use orthogonal data (which as far as I understand are suitable to display structured data, like sub-objects in the context of SMW).

Regarding the sorting enhancement it seems an optimal solution, I will test with one of our demo (with the sorting relying on any-number to double check how it works)

@malberts you are correct, the old html may break the new javascript, however I don't see this as a "backward compatibility issue", just the requirement to update the pages

@JeroenDeDauw
Copy link
Member

@thomas-topway-it so you will test this soonish?

@thomas-topway-it
Copy link
Contributor

@JeroenDeDauw I cannot access the demo server currently, however it looks a cutting-edge solution, so if there is any issue I or @alistair3149 can fix it afterwards

@thomas-topway-it
Copy link
Contributor

@alistair3149
Copy link
Contributor Author

this can also be merged https://github.com/SemanticMediaWiki/SemanticResultFormats/compare/master...OpenSemanticLab:SemanticResultFormats:dev?expand=1

but I guess it should be rebased @simontaurus

Is it the same as this PR? #861

@alistair3149
Copy link
Contributor Author

@thomas-topway-it would you be able to review the PR?

@thomas-topway-it
Copy link
Contributor

@alistair3149 I'm testing, a few minutes ... I have seen the new theme, is really beautiful but shouldn't be enabled via a parameter ?

@thomas-topway-it
Copy link
Contributor

I have tested and think I understood how it works. Could we add

		if ( !count( $dataValues ) ) {
			return [
				'display' => $html,
				'filter' => '',
				'sort' => ''
			];
		}

or something similar before

$sortKey = $dataValues[0]->getDataItem()->getSortKey();

since $dataValues could be empty (it triggered an error on my test article)

Also, the idea is really clever, and of course the best solution so I totally agree to commit it, however how pseudo numeric titles are handled, like :

-- 1_Some title
-- 2_Some title
etc. ?

I think there was something similar in one of our demos ...

@alistair3149
Copy link
Contributor Author

@alistair3149 I'm testing, a few minutes ... I have seen the new theme, is really beautiful but shouldn't be enabled via a parameter ?

We can either add a MW config key to disable that globally or/and add a datatable parameter to disable that . We did some modifications on both the styles and script to build the UI so we might have to refactor the changes together into the same place.

@alistair3149
Copy link
Contributor Author

since $dataValues could be empty (it triggered an error on my test article)

It should be handled now. Would you be able to test it again?

however how pseudo numeric titles are handled, like :
-- 1_Some title
-- 2_Some title
etc. ?
I think there was something similar in one of our demos ...

I'm not quite grasping the concept. Would you mind elaborating further?

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@33eaad7). Learn more about missing BASE report.
Report is 33 commits behind head on master.

Files with missing lines Patch % Lines
formats/datatables/SearchPanes.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #865   +/-   ##
=========================================
  Coverage          ?   45.51%           
  Complexity        ?     2320           
=========================================
  Files             ?       80           
  Lines             ?     9043           
  Branches          ?        0           
=========================================
  Hits              ?     4116           
  Misses            ?     4927           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@thomas-topway-it thomas-topway-it left a comment

Choose a reason for hiding this comment

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

I have tested, thanks a lot

@alistair3149 alistair3149 merged commit b40de8d into SemanticMediaWiki:master Jan 8, 2025
7 checks passed
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.

[datatables] Datatables should sort Quantity data numerically
5 participants