Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MH-13295 Handle null for presentable value extraction #635

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -86,29 +86,32 @@ angular.module('adminNg.services')
this.extractPresentableValue = function (field) {
var actualValue = field.value;
var presentableValue = '';
if (field.collection) {
if (angular.isArray(actualValue)) {
angular.forEach(actualValue, function (item, index) {
presentableValue += item;
if ((index + 1) < actualValue.length) {
presentableValue += ', ';
}
});
field.presentableValue = presentableValue;
} else {
if (field.collection.hasOwnProperty(actualValue)) {
presentableValue = field.collection[actualValue];

if (actualValue !== undefined && actualValue !== '' && actualValue !== null) {
if (field.collection) {
if (angular.isArray(actualValue)) {
angular.forEach(actualValue, function (item, index) {
presentableValue += item;
if ((index + 1) < actualValue.length) {
presentableValue += ', ';
}
});
field.presentableValue = presentableValue;
} else {
// this should work in older browsers, albeit looking clumsy
var matchingKey = Object.keys(field.collection)
.filter(function(key) {return field.collection[key] === actualValue;})[0];
presentableValue = field.type === 'ordered_text'
? JSON.parse(matchingKey)['label']
: matchingKey;
if (field.collection.hasOwnProperty(actualValue)) {
presentableValue = field.collection[actualValue];
} else {
// this should work in older browsers, albeit looking clumsy
var matchingKey = Object.keys(field.collection)
.filter(function(key) {return field.collection[key] === actualValue;})[0];
presentableValue = field.type === 'ordered_text'
? JSON.parse(matchingKey)['label']
: matchingKey;
}
}
} else {
presentableValue = actualValue;
}
} else {
presentableValue = actualValue;
}
return presentableValue;
};
Expand Down
Expand Up @@ -81,29 +81,32 @@ angular.module('adminNg.services')
this.extractPresentableValue = function (field) {
var actualValue = field.value;
var presentableValue = '';
if (field.collection) {
if (angular.isArray(actualValue)) {
angular.forEach(actualValue, function (item, index) {
presentableValue += item;
if ((index + 1) < actualValue.length) {
presentableValue += ', ';
}
});
field.presentableValue = presentableValue;
} else {
if (field.collection.hasOwnProperty(actualValue)) {
presentableValue = field.collection[actualValue];

if (actualValue !== undefined && actualValue !== '' && actualValue !== null) {
if (field.collection) {
if (angular.isArray(actualValue)) {
angular.forEach(actualValue, function (item, index) {
presentableValue += item;
if ((index + 1) < actualValue.length) {
presentableValue += ', ';
}
});
field.presentableValue = presentableValue;
} else {
// this should work in older browsers, albeit looking clumsy
var matchingKey = Object.keys(field.collection)
.filter(function(key) {return field.collection[key] === actualValue;})[0];
presentableValue = field.type === 'ordered_text'
? JSON.parse(matchingKey)['label']
: matchingKey;
if (field.collection.hasOwnProperty(actualValue)) {
presentableValue = field.collection[actualValue];
} else {
// this should work in older browsers, albeit looking clumsy
var matchingKey = Object.keys(field.collection)
.filter(function(key) {return field.collection[key] === actualValue;})[0];
presentableValue = field.type === 'ordered_text'
? JSON.parse(matchingKey)['label']
: matchingKey;
}
}
} else {
presentableValue = actualValue;
}
} else {
presentableValue = actualValue;
}
return presentableValue;
};
Expand Down