-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generalize field handling; fields may habe multiple entries now
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
import { ValueField } from "./base"; | ||
|
||
export default class DateField extends ValueField<string> {} | ||
export default class DateField extends ValueField<string> { | ||
private get endDateFieldName(): string { | ||
return `${this.element.uuid}_endDate`; | ||
} | ||
|
||
public get date(): string { | ||
return this.value; | ||
} | ||
|
||
public get startDate(): string { | ||
return this.value; | ||
} | ||
|
||
public get endDate(): string | null { | ||
const val = this.entry[this.endDateFieldName]; | ||
if (val === null) { | ||
return null; | ||
} | ||
return val as string; | ||
} | ||
|
||
public setEndDate(dateString: string | null): void { | ||
this.entry[this.endDateFieldName] = dateString; | ||
this.edited = true; | ||
} | ||
|
||
public getData(): Array<{ field: string; value: string | null }> { | ||
const res = super.getData(); | ||
res.push({ field: this.endDateFieldName, value: this.endDate }); | ||
return res; | ||
} | ||
} |