pm-controls
Version:
ProModel Controls
61 lines (52 loc) • 1.99 kB
text/typescript
import {
ComponentFactory,
Input
} from '@angular/core';
import { Property } from '../../../objects/request/properties/property';
import { PropertyType } from '../../../objects/request/properties/property-type';
import { PropertyLabel } from '../../../objects/request/property-label';
import { SelectionMode } from '../../../objects/enums/selection-mode';
import { Orientation } from '../../../objects/enums/orientation';
export class ComboBoxProperty extends Property implements PropertyType {
constructor(
public Label: PropertyLabel,
item?: any,
displayMemberPath?: string,
watermark?: string,
selectionMode?: SelectionMode,
items?: any,
itemsSource?: any,
orientation?: Orientation,
isHidden?: boolean,
isDisabled?: boolean) {
super(Label, orientation, isHidden, isDisabled);
this.IsComboBox = true;
this.Item = item;
this.Items = items || [];
this.ItemsSource = itemsSource;
this.Watermark = watermark;
this.DisplayMemberPath = displayMemberPath;
this.SelectionMode = selectionMode || SelectionMode.Single;
}
Item: any;
Items: any;
ItemsSource: any;
Watermark: string;
DisplayMemberPath: string;
SelectionMode: SelectionMode;
Text: string;
get HasValue(): boolean {
if (this.SelectionMode == SelectionMode.Single && this.Item)
return true;
else if (this.SelectionMode == SelectionMode.Multiple && this.Items && this.Items.length > 0)
return true;
return false;
}
Clear() {
if (this.SelectionMode == SelectionMode.Single)
this.Item = undefined;
else if (this.SelectionMode == SelectionMode.Multiple && this.Items)
this.Items.length = 0;
this.Text = '';
}
}