diff --git a/frontend/app/components/wp-edit/field-types/wp-edit-select-field.module.ts b/frontend/app/components/wp-edit/field-types/wp-edit-select-field.module.ts index 5f8639e448..0ca85f2749 100644 --- a/frontend/app/components/wp-edit/field-types/wp-edit-select-field.module.ts +++ b/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();