WIP - sharing list views
This commit is contained in:
@@ -186,6 +186,8 @@ interface Props {
|
||||
objectApiName: string;
|
||||
recordId: string;
|
||||
ownerId?: string;
|
||||
/** Optional base URL override for shares API. Defaults to /runtime/objects/{objectApiName}/records/{recordId}/shares */
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -193,6 +195,11 @@ const props = defineProps<Props>();
|
||||
const { api } = useApi();
|
||||
const { toast } = useToast();
|
||||
|
||||
/** Computed base path for all share API calls */
|
||||
const sharesBasePath = computed(() =>
|
||||
props.basePath || `/runtime/objects/${props.objectApiName}/records/${props.recordId}/shares`
|
||||
);
|
||||
|
||||
const loading = ref(true);
|
||||
const sharing = ref(false);
|
||||
const removing = ref<string | null>(null);
|
||||
@@ -236,9 +243,7 @@ const loadShares = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
const response = await api.get(
|
||||
`/runtime/objects/${props.objectApiName}/records/${props.recordId}/shares`
|
||||
);
|
||||
const response = await api.get(sharesBasePath.value);
|
||||
shares.value = response || [];
|
||||
} catch (e: any) {
|
||||
console.error('Failed to load shares:', e);
|
||||
@@ -286,7 +291,7 @@ const createShare = async () => {
|
||||
console.log('Final payload:', payload);
|
||||
|
||||
await api.post(
|
||||
`/runtime/objects/${props.objectApiName}/records/${props.recordId}/shares`,
|
||||
sharesBasePath.value,
|
||||
payload
|
||||
);
|
||||
toast.success('Record shared successfully');
|
||||
@@ -313,7 +318,7 @@ const removeShare = async (shareId: string) => {
|
||||
try {
|
||||
removing.value = shareId;
|
||||
await api.delete(
|
||||
`/runtime/objects/${props.objectApiName}/records/${props.recordId}/shares/${shareId}`
|
||||
`${sharesBasePath.value}/${shareId}`
|
||||
);
|
||||
toast.success('Share removed successfully');
|
||||
await loadShares();
|
||||
|
||||
Reference in New Issue
Block a user