mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-10 17:33:24 +01:00
Complete duplicate action for rest.
This commit is contained in:
parent
86d78935f0
commit
0d7cf3e5b1
@ -57,7 +57,7 @@ export default class RestClient extends MockClient {
|
||||
}
|
||||
|
||||
createMap(model: BasicMapInfo): Promise<number> {
|
||||
const handler = (success: (mapId:number) => void, reject: (error: ErrorInfo) => void) => {
|
||||
const handler = (success: (mapId: number) => void, reject: (error: ErrorInfo) => void) => {
|
||||
axios.post(this.baseUrl + `/c/restful/maps?title=${model.title}&description=${model.description ? model.description : ''}`,
|
||||
null,
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
@ -160,5 +160,23 @@ export default class RestClient extends MockClient {
|
||||
}
|
||||
return new Promise(handler);
|
||||
}
|
||||
|
||||
duplicateMap(id: number, basicInfo: BasicMapInfo): Promise<number> {
|
||||
|
||||
const handler = (success: (mapId: number) => void, reject: (error: ErrorInfo) => void) => {
|
||||
axios.post(this.baseUrl + `/c/restful/maps/${id}`,
|
||||
JSON.stringify(basicInfo),
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
).then(response => {
|
||||
const mapId = response.headers.resourceid;
|
||||
success(mapId);
|
||||
}).catch(error => {
|
||||
const response = error.response;
|
||||
const errorInfo = this.parseResponseOnError(response);
|
||||
reject(errorInfo);
|
||||
});
|
||||
}
|
||||
return new Promise(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ const DuplicateDialog = (props: DialogProps) => {
|
||||
return service.duplicateMap(id, rest);
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
handleOnMutationSuccess(props.onClose, queryClient);
|
||||
onSuccess: (mapId) => {
|
||||
window.location.href = `/c/maps/${mapId}/edit`;
|
||||
},
|
||||
onError: (error) => {
|
||||
setError(error);
|
||||
|
Loading…
Reference in New Issue
Block a user