-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,20 @@ | |
// Copyright Alexandre Díaz <[email protected]> | ||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import {Record} from '@terminal/core/recordset'; | ||
import encodeHTML from '@terminal/utils/encode_html'; | ||
import prettyObjectString from '@terminal/utils/pretty_object_string'; | ||
|
||
export default function (model: string, field: string, item: {[string]: string | number}): string { | ||
const item_val = item[field]; | ||
if ( | ||
if (item instanceof Record && item.__info[field]?.type === 'binary') { | ||
return `<span class='btn terminal-btn-secondary o_terminal_click o_terminal_read_bin_field' data-model='${model}' data-id='${item.id}' data-field='${field}'>Try Read Field</span>`; | ||
} else if ( | ||
item_val !== null && | ||
typeof item_val !== 'undefined' && | ||
typeof item_val === 'object' && | ||
item_val.oterm && | ||
item_val.binary | ||
!(item_val instanceof Array) | ||
) { | ||
return `<span class='btn terminal-btn-secondary o_terminal_click o_terminal_read_bin_field' data-model='${model}' data-id='${item.id}' data-field='${field}'>Try Read Field</span>`; | ||
return prettyObjectString(item_val); | ||
} | ||
return encodeHTML(String(item_val)); | ||
} |