diff options
author | crupest <crupest@outlook.com> | 2021-01-12 22:01:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-12 22:01:51 +0800 |
commit | 07eb0d4d777c36da7ea62ea55a2ac3f68e899694 (patch) | |
tree | a8692dd0d0673089dc4319aa8bb548dc3743c590 /FrontEnd/src | |
parent | 11724294f107b23c68b0718530262664ea5e0efc (diff) | |
download | timeline-07eb0d4d777c36da7ea62ea55a2ac3f68e899694.tar.gz timeline-07eb0d4d777c36da7ea62ea55a2ac3f68e899694.tar.bz2 timeline-07eb0d4d777c36da7ea62ea55a2ac3f68e899694.zip |
...
Diffstat (limited to 'FrontEnd/src')
3 files changed, 18 insertions, 30 deletions
diff --git a/FrontEnd/src/app/services/timeline.ts b/FrontEnd/src/app/services/timeline.ts index 7d239fbf..4e2530cc 100644 --- a/FrontEnd/src/app/services/timeline.ts +++ b/FrontEnd/src/app/services/timeline.ts @@ -175,15 +175,12 @@ export class TimelineService { changeTimelineProperty( timelineName: string, req: TimelineChangePropertyRequest - ): Observable<TimelineInfo> { - return from( - getHttpTimelineClient() - .patchTimeline(timelineName, req) - .then((timeline) => { - void this.syncTimeline(timelineName); - return timeline; - }) - ); + ): Promise<void> { + return getHttpTimelineClient() + .patchTimeline(timelineName, req) + .then(() => { + void this.syncTimeline(timelineName); + }); } deleteTimeline(timelineName: string): Observable<unknown> { diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index e4d414b9..8422077a 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -173,14 +173,8 @@ export default function TimelinePageTemplate<TManageItem>( <TimelinePropertyChangeDialog open close={closeDialog} - oldInfo={{ - title: timeline.title, - visibility: timeline.visibility, - description: timeline.description, - }} - onProcess={(req) => { - return service.changeTimelineProperty(name, req).toPromise().then(); - }} + timeline={timeline} + onProcess={(req) => service.changeTimelineProperty(name, req)} /> ); } else if (dialog === "member") { diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePropertyChangeDialog.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePropertyChangeDialog.tsx index aae227e6..ab3285f5 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePropertyChangeDialog.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePropertyChangeDialog.tsx @@ -4,20 +4,15 @@ import { TimelineVisibility, kTimelineVisibilities, TimelineChangePropertyRequest, + TimelineInfo, } from "@/services/timeline"; import OperationDialog from "../common/OperationDialog"; -export interface TimelinePropertyInfo { - title: string; - visibility: TimelineVisibility; - description: string; -} - export interface TimelinePropertyChangeDialogProps { open: boolean; close: () => void; - oldInfo: TimelinePropertyInfo; + timeline: TimelineInfo; onProcess: (request: TimelineChangePropertyRequest) => Promise<void>; } @@ -30,6 +25,8 @@ const labelMap: { [key in TimelineVisibility]: string } = { const TimelinePropertyChangeDialog: React.FC<TimelinePropertyChangeDialogProps> = ( props ) => { + const { timeline } = props; + return ( <OperationDialog title={"timeline.dialogChangeProperty.title"} @@ -37,7 +34,7 @@ const TimelinePropertyChangeDialog: React.FC<TimelinePropertyChangeDialogProps> { type: "text", label: "timeline.dialogChangeProperty.titleField", - initValue: props.oldInfo.title, + initValue: timeline.title, }, { type: "select", @@ -46,25 +43,25 @@ const TimelinePropertyChangeDialog: React.FC<TimelinePropertyChangeDialogProps> label: labelMap[v], value: v, })), - initValue: props.oldInfo.visibility, + initValue: timeline.visibility, }, { type: "text", label: "timeline.dialogChangeProperty.description", - initValue: props.oldInfo.description, + initValue: timeline.description, }, ]} open={props.open} close={props.close} onProcess={([newTitle, newVisibility, newDescription]) => { const req: TimelineChangePropertyRequest = {}; - if (newTitle !== props.oldInfo.title) { + if (newTitle !== timeline.title) { req.title = newTitle; } - if (newVisibility !== props.oldInfo.visibility) { + if (newVisibility !== timeline.visibility) { req.visibility = newVisibility as TimelineVisibility; } - if (newDescription !== props.oldInfo.description) { + if (newDescription !== timeline.description) { req.description = newDescription; } return props.onProcess(req); |