Skip to content

Commit

Permalink
core.Util: isRecord() #5389
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiu committed Apr 12, 2024
1 parent f7f1521 commit 5acf083
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/core/Util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ class Util extends Base {
return value?.constructor?.name === 'Object' || false
}

/**
* Returns true if the passed value is a neo data record
* @param {Object} value The value to test
* @returns {Boolean}
*/
static isRecord(value) {
return value?.constructor?.name === 'Record' || false
}

/**
* Returns true if the passed value is a string
* @param {String} value The value to test
Expand Down Expand Up @@ -224,6 +233,7 @@ Neo.applyFromNs(Neo, Util, {
isFunction : 'isFunction',
isNumber : 'isNumber',
isObject : 'isObject',
isRecord : 'isRecord',
isString : 'isString',
toArray : 'toArray'
}, true);
Expand Down
4 changes: 2 additions & 2 deletions src/form/field/ComboBox.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class ComboBox extends Picker {
record;

// getting a record, nothing to do
if (Neo.isObject(value)) {
if (Neo.isRecord(value)) {
return value
}

Expand Down Expand Up @@ -687,7 +687,7 @@ class ComboBox extends Picker {
updateInputValueFromValue(value) {
let inputValue = null;

if (Neo.isObject(value)) {
if (Neo.isRecord(value)) {
inputValue = value[this.displayField]
}

Expand Down

0 comments on commit 5acf083

Please sign in to comment.