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

Datatables improvements #833

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions formats/datatables/DataTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,13 @@ protected function getResultText( QueryResult $res, $outputmode ) {

$formattedOptions = $this->formatOptions( $datatablesOptions );

// for the order @see https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/825
$result = $this->getResultJson( $res, $outputmode );

// @TODO use only one between printouts and printrequests
$resultArray = $res->toArray();
$printrequests = $resultArray['printrequests'];

$result = $this->getResultJson( $res, $outputmode );

$this->htmlTable = new HtmlTable();
foreach ( $headerList as $text ) {
$attributes = [];
Expand Down Expand Up @@ -801,7 +802,7 @@ private function formatOptions( $params ) {
'lengthMenu' => "number",
'buttons' => "string",
'searchPanes.columns' => "number",
'mark.ignorePunctuation' => "number",
'mark.ignorePunctuation' => "",
// ...
];

Expand All @@ -810,12 +811,19 @@ private function formatOptions( $params ) {

// transform csv to array
if ( array_key_exists( $key, $arrayTypes ) ) {
$value = preg_split( "/\s*,\s*/", $value, -1, PREG_SPLIT_NO_EMPTY );

if ( $arrayTypes[$key] === 'number' ) {
$value = array_map( static function ( $value ) {
return (int)$value;
}, $value );
// https://markjs.io/#mark
if ( $arrayTypes[$key] === '' ) {
$value = str_split( $value );

} else {
$value = preg_split( "/\s*,\s*/", $value, -1, PREG_SPLIT_NO_EMPTY );

if ( $arrayTypes[$key] === 'number' ) {
$value = array_map( static function ( $value ) {
return (int)$value;
}, $value );
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion formats/datatables/resources/ext.srf.formats.datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@
// value for all columns
if (!options.columns.type) {
options.columns.type =
entityCollation === "numeric" && property.typeid === "_wpg"
( entityCollation === 'numeric' && property.typeid === '_wpg' )
|| [ '_num', '_tem', '_qty' ].indexOf(property.typeid) !== -1
? "any-number"
: null;
}
Expand Down