Merge pull request #4791 from HDinger/fix/23786-confusing-project-list

[23786] Confusing project list
pull/4798/head
Oliver Günther 8 years ago committed by GitHub
commit 35d2d6ac6a
  1. 17
      frontend/app/components/wp-edit/field-types/wp-edit-select-field.module.ts

@ -48,14 +48,27 @@ export class SelectEditField extends EditField {
this.setValues(this.schema.allowedValues);
} else if (this.schema.allowedValues) {
this.schema.allowedValues.$load().then((values) => {
this.setValues(values.elements);
// The select options of the project shall be sorted
if(values.elements.first()._type === 'Project') {
this.setValues(values.elements, true)
} else {
this.setValues(values.elements);
}
});
} else {
this.setValues([]);
}
}
private setValues(availableValues) {
private setValues(availableValues, sortValuesByName = false) {
if (sortValuesByName) {
availableValues.sort(function(a, b) {
var nameA = a.name.toLowerCase();
var nameB = b.name.toLowerCase();
return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
});
}
this.options = availableValues;
this.addEmptyOption();
this.checkCurrentValueValidity();

Loading…
Cancel
Save