Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ angular.module('dashboard.directives.ModelFieldReference', [
scope.selected.items = []; //for multi-select
scope.selected.item = null; //for single select; initialize to null so placeholder is displayed
scope.list = [];
scope.isDefaultSet = false;

/**
* Watch for scope.data. If it has no data, it will clear the selected item/s.
Expand Down Expand Up @@ -167,12 +168,19 @@ angular.module('dashboard.directives.ModelFieldReference', [
scope.list.unshift(addNewItem);

}
if (typeof scope.options.defaultIndex === 'number') {
if (typeof scope.options.defaultIndex === 'number' && !scope.isDefaultSet) {
if (response[scope.options.defaultIndex]) {
//scope.selected.items = [response[scope.options.defaultIndex]];
scope.isDefaultSet = true;
scope.onSelect(response[scope.options.defaultIndex]);
}
}
if (typeof scope.options.autofill === 'boolean' && scope.options.autofill && !scope.isDefaultSet) {
_.forEach(response, function(item) {
scope.onSelect(item);
});
scope.isDefaultSet = true;
}
});
};

Expand Down