Added header_row2 option to nextmatch widget to allow including an additional custom template after the row count in a new line.

This commit is contained in:
Alexandros Sigalas 2024-02-18 10:27:12 +02:00 committed by Ralf Becker
parent 0a5c5a432b
commit 08a2e4cdb8

View File

@ -149,6 +149,11 @@ interface ActiveFilters
* +--------------+-----------+-------+
* | header_right | favorites | count |
* +--------------+-----------+-------+
* then comes...
* +- nextmatch_header +
* + header_row2 |
* +-------------------+
*
* @augments et2_DOMWidget
*/
export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2_IInput, et2_IPrint
@ -175,13 +180,19 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
"header_right": {
"name": "Right custom template",
"type": "string",
"description": "Customise the nextmatch - right side. Provided template becomes a child of nextmatch, and any input widgets are automatically bound to refresh the nextmatch on change. Any inputs with an onChange attribute can trigger the nextmatch to refresh by returning true.",
"description": "Customise the nextmatch - right side, before favorites and row count. Provided template becomes a child of nextmatch, and any input widgets are automatically bound to refresh the nextmatch on change. Any inputs with an onChange attribute can trigger the nextmatch to refresh by returning true.",
"default": ""
},
"header_row": {
"name": "Inline custom template",
"type": "string",
"description": "Customise the nextmatch - inline, after row count. Provided template becomes a child of nextmatch, and any input widgets are automatically bound to refresh the nextmatch on change. Any inputs with an onChange attribute can trigger the nextmatch to refresh by returning true.",
"description": "Customise the nextmatch - inline, after search before category,filter,filter2,header_right,favorites,row count. Provided template becomes a child of nextmatch, and any input widgets are automatically bound to refresh the nextmatch on change. Any inputs with an onChange attribute can trigger the nextmatch to refresh by returning true.",
"default": ""
},
"header_row2": {
"name": "Inline custom template",
"type": "string",
"description": "Customise the nextmatch - inline, after row count in new line. Provided template becomes a child of nextmatch, and any input widgets are automatically bound to refresh the nextmatch on change. Any inputs with an onChange attribute can trigger the nextmatch to refresh by returning true.",
"default": ""
},
"no_filter": {
@ -2569,6 +2580,11 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
this.header._build_header("row", template);
}
set_header_row2(template : string)
{
this.header._build_header("row2", template);
}
set_no_filter(bool, filter_name)
{
if(typeof filter_name == 'undefined')
@ -3399,7 +3415,8 @@ export class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INext
this.headers = [
{id: this.nextmatch.options.header_left},
{id: this.nextmatch.options.header_right},
{id: this.nextmatch.options.header_row}
{id: this.nextmatch.options.header_row},
{id: this.nextmatch.options.header_row2}
];
// The rest of the header
@ -3622,9 +3639,9 @@ export class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INext
* @param {string} location One of left, right, or row
* @param {string} template_name Name of the template to load into the location
*/
_build_header(location : "left" | "right" | "row", template_name : string)
_build_header(location : "left" | "right" | "row" | "row2", template_name : string)
{
const id = location == "left" ? 0 : (location == "right" ? 1 : 2);
const id = location == "left" ? 0 : (location == "right" ? 1 : (location == "row" ? 2 : 3) );
const existing = this.headers[id];
// @ts-ignore
if(existing && existing._type)
@ -3661,6 +3678,12 @@ export class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INext
jQuery(header.getDOMNode()).insertAfter(self.header_div.find('div.search'));
}, 1);
break;
case 3: // header_row2: below everything
window.setTimeout(function()
{ // otherwise we might end up after filters
jQuery(header.getDOMNode()).insertAfter(self.header_div);
}, 1);
break;
}
self._bindHeaderInput(header);
});