export class OrgSelectComponent implements OnInit {
static domId = 0;
+ showCombinedNames = false; // Managed via user/workstation setting
+
selected: OrgDisplay;
click$ = new Subject<string>();
valueFromSetting: number = null;
ngOnInit() {
- // Sort the tree and reabsorb to propagate the sorted nodes to
- // the org.list() used by this component. Maintain our own
- // copy of the org list in case the org service is sorted in a
- // different manner by other parts of the code.
- this.org.sortTree(this.displayField);
- this.org.absorbTree();
- this.sortedOrgs = this.org.list();
- const promise = this.persistKey ?
+ let promise = this.persistKey ?
this.getFromSetting() : Promise.resolve(null);
+ promise = promise.then(startupOrg => {
+ return this.serverStore.getItem('eg.orgselect.show_combined_names')
+ .then(show => {
+ const sortField = show ? 'name' : this.displayField;
+
+ // Sort the tree and reabsorb to propagate the sorted
+ // nodes to the org.list() used by this component.
+ // Maintain our own copy of the org list in case the
+ // org service is sorted in a different manner by other
+ // parts of the code.
+ this.org.sortTree(sortField);
+ this.org.absorbTree();
+ this.sortedOrgs = this.org.list();
+
+ this.showCombinedNames = show;
+ })
+ .then(_ => startupOrg);
+ });
+
promise.then((startupOrgId: number) => {
if (!startupOrgId) {
});
}
+ getDisplayLabel(org: IdlObject): string {
+ if (this.showCombinedNames) {
+ return `${org.name()} (${org.shortname()})`;
+ } else {
+ return org[this.displayField]();
+ }
+ }
+
getFromSetting(): Promise<number> {
const key = `eg.orgselect.${this.persistKey}`;
// Format for display in the selector drop-down and input.
formatForDisplay(org: IdlObject): OrgDisplay {
- let label = org[this.displayField]();
+ let label = this.getDisplayLabel(org);
if (!this.readOnly) {
label = PAD_SPACE.repeat(org.ou_type().depth()) + label;
}
// org units.
orgs = orgs.filter(org => {
return term === '' || // show all
- org[this.displayField]()
+ this.getDisplayLabel(org)
.toLowerCase().indexOf(term.toLowerCase()) > -1;
});
--- /dev/null
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
+
+INSERT into config.workstation_setting_type (name, grp, datatype, label)
+VALUES (
+ 'eg.orgselect.show_combined_names', 'gui', 'bool',
+ oils_i18n_gettext(
+ 'eg.orgselect.show_combined_names',
+ 'Library Selector Show Combined Names',
+ 'cwst', 'label'
+ )
+);
+
+COMMIT;
$scope.disable_sound = val;
});
+ egCore.hatch.getItem('eg.orgselect.show_combined_names').then(function(val) {
+ $scope.orgselect_combo_names = val;
+ });
+
egCore.hatch.getItem('eg.search.search_lib').then(function(val) {
$scope.search_lib = egCore.org.get(val);
});
}
}
+ $scope.apply_orgselect_combob_names = function() {
+ if ($scope.orgselect_combo_names) {
+ egCore.hatch.setItem('eg.orgselect.show_combined_names', true);
+ } else {
+ egCore.hatch.removeItem('eg.orgselect.show_combined_names');
+ }
+ }
+
$scope.test_audio = function(sound) {
egCore.audio.play(sound);
}