Skip to content

Commit

Permalink
Added header_row2 option to nextmatch widget to allow including an ad…
Browse files Browse the repository at this point in the history
…ditional custom template after the row count in a new line.
  • Loading branch information
asig2016 authored and ralfbecker committed Apr 7, 2024
1 parent 0a5c5a4 commit 08a2e4c
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions api/js/etemplate/et2_extension_nextmatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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": {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 08a2e4c

Please sign in to comment.