Skip to content

Commit

Permalink
Adjustments after review (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
reisfmb committed May 19, 2022
1 parent cf78f7f commit 952a78f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {IdProviderKey} from './IdProviderKey';
import {Principal} from './Principal';
import {PrincipalKey} from './PrincipalKey';
import {GetPrincipalsByKeysRequest} from './GetPrincipalsByKeysRequest';
import {BaseLoader} from '../util/loader/BaseLoader';

export class PrincipalLoader
extends PostLoader<Principal> {
Expand Down Expand Up @@ -65,8 +66,8 @@ export class PrincipalLoader
return this.getRequest().isPartiallyLoaded();
}

setUsePreData(bool: boolean): PrincipalLoader {
super.setUsePreData(bool);
setUseDataPreLoad(bool: boolean): PrincipalLoader {
super.setUseDataPreLoad(bool);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {SelectedOptionEvent} from './SelectedOptionEvent';
import {BaseSelectedOptionView, BaseSelectedOptionViewBuilder} from './BaseSelectedOptionView';
import {assertNotNull} from '../../../util/Assert';
import {PEl} from '../../../dom/PEl';
import {i18n} from '../../../util/Messages';

export class BaseSelectedOptionsView<T>
extends DivEl
Expand Down Expand Up @@ -72,8 +73,8 @@ export class BaseSelectedOptionsView<T>
return new SelectedOption<T>(new BaseSelectedOptionView(builder), this.count());
}

// Will mark all options as selected, but if there are more options than {MAX_TO_APPEND}
// it'll append only {MAX_TO_APPEND} of them to the view in order to improve performance.
/* Will mark all options as selected, but if there are more options than {MAX_TO_APPEND}
it'll append only {MAX_TO_APPEND} of them to the view in order to improve performance. */
addOptions(options: Option<T>[], silent: boolean = false, keyCode: number): boolean {
let result: boolean;

Expand All @@ -86,7 +87,7 @@ export class BaseSelectedOptionsView<T>
const selectedOptions: SelectedOption<T>[] = options.map((option, index) => {
const selectedOption = this.createSelectedOption(option);

if(index <= BaseSelectedOptionsView.MAX_TO_APPEND) {
if (index <= BaseSelectedOptionsView.MAX_TO_APPEND) {
const optionView = selectedOption.getOptionView();
optionView.onRemoveClicked(() => this.removeOption(option));
this.appendChild(optionView);
Expand All @@ -97,7 +98,7 @@ export class BaseSelectedOptionsView<T>

this.list = selectedOptions;

this.appendChild(new PEl().setHtml('Too many users to list'));
this.appendChild(new PEl('warning-truncated-users').setHtml(i18n('warning.optionsview.truncated')));
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ export class ComboBox<OPTION_DISPLAY_VALUE>
selectOptions(options: Option<OPTION_DISPLAY_VALUE>[], silent: boolean = false, keyCode: number = -1): void {
assertNotNull(options, 'options cannot be null');

let added = this.selectedOptionsView.addOptions(options, silent, keyCode);
const added = this.selectedOptionsView.addOptions(options, silent, keyCode);

if(!added) { return; }
if (!added) { return; }

this.comboBoxDropdown.markSelections(options);

Expand All @@ -449,7 +449,7 @@ export class ComboBox<OPTION_DISPLAY_VALUE>
return;
}

let added = this.selectedOptionsView.addOption(option, silent, keyCode);
const added = this.selectedOptionsView.addOption(option, silent, keyCode);

if (!added) { return; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class BaseLoader<OBJECT> {

private comparator: Comparator<OBJECT>;

private usePreData: boolean = false;
private useDataPreLoad: boolean = false;

constructor(request?: HttpRequest<OBJECT[]>) {
this.setRequest(request || this.createRequest());
Expand All @@ -54,8 +54,8 @@ export class BaseLoader<OBJECT> {

let promise: Q.Promise<OBJECT[]>;

if(this.usePreData) {
promise = this.preData(searchString);
if (this.useDataPreLoad) {
promise = this.preLoadData(searchString);
} else {
promise = this.sendPreLoadRequest(searchString);
}
Expand Down Expand Up @@ -183,12 +183,12 @@ export class BaseLoader<OBJECT> {
});
}

setUsePreData(bool: boolean): BaseLoader<OBJECT> {
this.usePreData = bool;
setUseDataPreLoad(bool: boolean): BaseLoader<OBJECT> {
this.useDataPreLoad = bool;
return this;
}

preData(searchString: string): Q.Promise<OBJECT[]> {
preLoadData(searchString: string): Q.Promise<OBJECT[]> {
throw new Error('Must be implemented in deriving classes!');
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/i18n/common.properties
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,8 @@ tooltip.filterPanel.show=Show Search Panel
tooltip.filterPanel.hide=Hide Search Panel
tooltip.header.expand=Click to expand
tooltip.header.collapse=Click to collapse

#
# Warnings
#
warning.optionsview.truncated = The list of users is truncated

0 comments on commit 952a78f

Please sign in to comment.