|
|
@ -278,29 +278,37 @@ export class ViewsService { |
|
|
|
NcError.viewNotFound(param.viewId); |
|
|
|
NcError.viewNotFound(param.viewId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let customUrl: CustomUrl | undefined; |
|
|
|
let customUrl: CustomUrl | undefined = await CustomUrl.get({ |
|
|
|
|
|
|
|
|
|
|
|
if (param.sharedView.custom_url_path !== undefined) { |
|
|
|
|
|
|
|
customUrl = await CustomUrl.get({ |
|
|
|
|
|
|
|
view_id: view.id, |
|
|
|
view_id: view.id, |
|
|
|
id: view.fk_custom_url_id, |
|
|
|
id: view.fk_custom_url_id, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update an existing custom URL if it exists
|
|
|
|
if (customUrl?.id) { |
|
|
|
if (customUrl?.id) { |
|
|
|
if (param.sharedView.custom_url_path) { |
|
|
|
if (param.sharedView.custom_url_path || param.sharedView.original_url) { |
|
|
|
await CustomUrl.update(view.fk_custom_url_id, { |
|
|
|
// Prepare updated fields conditionally
|
|
|
|
custom_path: param.sharedView.custom_url_path, |
|
|
|
const updates: Partial<CustomUrl> = {}; |
|
|
|
...(customUrl.original_path !== param.sharedView.original_url |
|
|
|
|
|
|
|
? { |
|
|
|
if (param.sharedView.custom_url_path !== undefined) { |
|
|
|
original_path: param.sharedView.original_url, |
|
|
|
updates.custom_path = param.sharedView.custom_url_path; |
|
|
|
} |
|
|
|
} |
|
|
|
: {}), |
|
|
|
|
|
|
|
}); |
|
|
|
if (customUrl.original_path !== param.sharedView.original_url) { |
|
|
|
} else { |
|
|
|
updates.original_path = param.sharedView.original_url; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Perform the update if there are changes
|
|
|
|
|
|
|
|
if (Object.keys(updates).length > 0) { |
|
|
|
|
|
|
|
await CustomUrl.update(view.fk_custom_url_id, updates); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (param.sharedView.custom_url_path !== undefined) { |
|
|
|
|
|
|
|
// Delete the custom URL if only the custom path is undefined
|
|
|
|
await CustomUrl.delete({ id: view.fk_custom_url_id as string }); |
|
|
|
await CustomUrl.delete({ id: view.fk_custom_url_id as string }); |
|
|
|
customUrl = undefined; |
|
|
|
customUrl = undefined; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (param.sharedView.custom_url_path) { |
|
|
|
} else if (param.sharedView.custom_url_path) { |
|
|
|
|
|
|
|
// Insert a new custom URL if it doesn't exist
|
|
|
|
|
|
|
|
|
|
|
|
customUrl = await CustomUrl.insert({ |
|
|
|
customUrl = await CustomUrl.insert({ |
|
|
|
fk_workspace_id: view.fk_workspace_id, |
|
|
|
fk_workspace_id: view.fk_workspace_id, |
|
|
|
base_id: view.base_id, |
|
|
|
base_id: view.base_id, |
|
|
@ -310,7 +318,6 @@ export class ViewsService { |
|
|
|
custom_path: param.sharedView.custom_url_path, |
|
|
|
custom_path: param.sharedView.custom_url_path, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await View.update(context, param.viewId, { |
|
|
|
const result = await View.update(context, param.viewId, { |
|
|
|
...param.sharedView, |
|
|
|
...param.sharedView, |
|
|
|