Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Do not change titleMap order if null value in it.
  • Loading branch information
ulion committed Mar 20, 2015
commit 34c9c29fb56cdd98f891b35fa000e4e3c6841d0f
16 changes: 7 additions & 9 deletions src/services/schema-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,16 @@ angular.module('schemaForm').provider('schemaForm',
}
}

if (obj.type === 'select' && obj.titleMap && obj.allowAutoNullOption !== false) {
// when allowNull === false, we leave titleMap as it is.
// else we filter out the null value and setup allowNull to the label
// so the select template will behaviour different according to it.
obj.titleMap = obj.titleMap.filter(function(item) {
if (obj.type === 'select' && obj.titleMap) {
// we check whether null value is in titleMap. if so, we fix possible null
// label and set allowAutoNullOption to false, then leave the titleMap as it is
obj.titleMap.forEach(function(item) {
if (item.value === null) {
// so we have null value option, setup the label and make it always selectable.
if (obj.allowAutoNullOption === undefined)
obj.allowAutoNullOption = item.name === null ? '' : item.name;
return false;
obj.allowAutoNullOption = false;
if (item.name === null)
item.name = '';
}
return true;
});
}

Expand Down