MCPcopy Index your code
hub / github.com/UI5/webcomponents / NextOptions

Class NextOptions

packages/main/src/dynamic-date-range-options/NextOptions.ts:33–139  ·  view source on GitHub ↗

* @class * @implements {IDynamicDateRangeOption} * @constructor * @public * @since 2.14.0

Source from the content-addressed store, hash-verified

31 * @since 2.14.0
32 */
33class NextOptions implements IDynamicDateRangeOption {
34 template: JsxTemplate = LastNextTemplate;
35 _operator: string;
36 i18nKey: I18nText;
37 options?: Array<string> = [];
38
39 constructor(operators?: Array<string>) {
40 this.options = operators;
41 this._operator = this.options?.[0] || "NEXTDAYS";
42 this.i18nKey = this._getI18nKeyForOperator(this._operator);
43 }
44
45 _getI18nKeyForOperator(operator: string): I18nText {
46 switch (operator) {
47 case "NEXTDAYS":
48 return DYNAMIC_DATE_RANGE_NEXT_DAYS_TEXT;
49 case "NEXTWEEKS":
50 return DYNAMIC_DATE_RANGE_NEXT_WEEKS_TEXT;
51 case "NEXTMONTHS":
52 return DYNAMIC_DATE_RANGE_NEXT_MONTHS_TEXT;
53 case "NEXTQUARTERS":
54 return DYNAMIC_DATE_RANGE_NEXT_QUARTERS_TEXT;
55 case "NEXTYEARS":
56 return DYNAMIC_DATE_RANGE_NEXT_YEARS_TEXT;
57 default:
58 return DYNAMIC_DATE_RANGE_NEXT_DAYS_TEXT;
59 }
60 }
61
62 parse(value: string): DynamicDateRangeValue | undefined {
63 const matchingOption = this.availableOptions.find(optionInfo => {
64 const tempOption = { operator: optionInfo.operator, text: optionInfo.text };
65 return isValidStringLastNext(value, tempOption as IDynamicDateRangeOption);
66 });
67
68 if (matchingOption) {
69 const tempOption = { operator: matchingOption.operator, text: matchingOption.text };
70 return parseLastNext(value, tempOption as IDynamicDateRangeOption);
71 }
72
73 return undefined;
74 }
75
76 format(value: DynamicDateRangeValue): string {
77 return formatLastNextValue(value, this);
78 }
79
80 toDates(value: DynamicDateRangeValue): Array<Date> {
81 return toDatesLastNext(value, { operator: value.operator } as IDynamicDateRangeOption);
82 }
83
84 isValidString(value: string): boolean {
85 return this.availableOptions.some(optionInfo => {
86 const tempOption = { operator: optionInfo.operator, text: optionInfo.text };
87 return isValidStringLastNext(value, tempOption as IDynamicDateRangeOption);
88 });
89 }
90

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected