From 232a19d7dfe0e3847b3a9a9a9be83485ffb9031c Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 30 May 2020 16:23:25 +0800 Subject: Merge front end to this repo. But I need to wait for aspnet core support for custom port and package manager for dev server. --- .../src/timeline/TimelinePropertyChangeDialog.tsx | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Timeline/ClientApp/src/timeline/TimelinePropertyChangeDialog.tsx (limited to 'Timeline/ClientApp/src/timeline/TimelinePropertyChangeDialog.tsx') diff --git a/Timeline/ClientApp/src/timeline/TimelinePropertyChangeDialog.tsx b/Timeline/ClientApp/src/timeline/TimelinePropertyChangeDialog.tsx new file mode 100644 index 00000000..9ab725a6 --- /dev/null +++ b/Timeline/ClientApp/src/timeline/TimelinePropertyChangeDialog.tsx @@ -0,0 +1,70 @@ +import React from 'react'; + +import { + TimelineVisibility, + kTimelineVisibilities, + PersonalTimelineChangePropertyRequest +} from '../data/timeline'; + +import OperationDialog, { + OperationSelectInputInfoOption +} from '../common/OperationDialog'; + +export interface TimelinePropertyInfo { + visibility: TimelineVisibility; + description: string; +} + +export interface TimelinePropertyChangeDialogProps { + open: boolean; + close: () => void; + oldInfo: TimelinePropertyInfo; + onProcess: (request: PersonalTimelineChangePropertyRequest) => Promise; +} + +const labelMap: { [key in TimelineVisibility]: string } = { + Private: 'timeline.visibility.private', + Public: 'timeline.visibility.public', + Register: 'timeline.visibility.register' +}; + +const TimelinePropertyChangeDialog: React.FC = props => { + return ( + ( + v => ({ + label: labelMap[v], + value: v + }) + ), + initValue: props.oldInfo.visibility + }, + { + type: 'text', + label: 'timeline.dialogChangeProperty.description', + initValue: props.oldInfo.description + } + ]} + open={props.open} + close={props.close} + onProcess={([newVisibility, newDescription]) => { + const req: PersonalTimelineChangePropertyRequest = {}; + if (newVisibility !== props.oldInfo.visibility) { + req.visibility = newVisibility as TimelineVisibility; + } + if (newDescription !== props.oldInfo.description) { + req.description = newDescription as string; + } + return props.onProcess(req); + }} + /> + ); +}; + +export default TimelinePropertyChangeDialog; -- cgit v1.2.3