allow custom titles for list column images

This commit is contained in:
2022-04-26 11:55:48 +02:00
parent 63c0cb8484
commit fe32873621
2 changed files with 8 additions and 5 deletions
@@ -195,14 +195,15 @@ class ListColumn
/**
* Output an image by using the value media ID
* @param {function} [titleFunc] - Custom function to render a title
* @returns {ListColumn}
*/
image()
image(titleFunc: any = null)
{
this._type = 'image';
this._asHtml = true;
// TODO correct app ID
this._func = (value, opts) =>
this._funcOptions = { titleFunc };
this._func = (value, opts, model) =>
{
let id = value;
@@ -216,7 +217,9 @@ class ListColumn
return '';
}
return `<img src="/zero/api/hofbauer/backoffice/ui/thumbnail/${(id)}-thumb.tmp" onerror="this.classList.add('is-error')" class="ui-table-field-image">`;
let title = typeof opts.titleFunc == 'function' ? opts.titleFunc(value, model) : '';
return `<img src="/zero/api/hofbauer/backoffice/ui/thumbnail/${(id)}-thumb.tmp" onerror="this.classList.add('is-error')" title="${title}" class="ui-table-field-image">`;
};
return this;
}
File diff suppressed because one or more lines are too long