Add multi-workspace selector scope
This commit is contained in:
@@ -24,6 +24,10 @@ export const useContentItemDetailStore = defineStore('content-item-detail', () =
|
||||
status: false,
|
||||
});
|
||||
|
||||
function currentItemWorkspaceId() {
|
||||
return item.value?.workspaceId ?? workspaceStore.activeWorkspaceId;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
item.value = null;
|
||||
revisions.value = [];
|
||||
@@ -54,7 +58,7 @@ export const useContentItemDetailStore = defineStore('content-item-detail', () =
|
||||
client.get('/api/approvals', { params: { contentItemId } }),
|
||||
client.get('/api/notifications', {
|
||||
params: {
|
||||
workspaceId: workspaceStore.activeWorkspaceId,
|
||||
workspaceId: workspaceStore.activeWorkspaceId ?? undefined,
|
||||
contentItemId,
|
||||
},
|
||||
}),
|
||||
@@ -97,7 +101,7 @@ export const useContentItemDetailStore = defineStore('content-item-detail', () =
|
||||
const response = await client.post('/api/assets/google-drive', {
|
||||
...payload,
|
||||
contentItemId,
|
||||
workspaceId: workspaceStore.activeWorkspaceId,
|
||||
workspaceId: currentItemWorkspaceId(),
|
||||
});
|
||||
if (response.data) {
|
||||
assets.value = [...assets.value, response.data];
|
||||
@@ -131,7 +135,7 @@ export const useContentItemDetailStore = defineStore('content-item-detail', () =
|
||||
const response = await client.post('/api/comments', {
|
||||
...payload,
|
||||
contentItemId,
|
||||
workspaceId: workspaceStore.activeWorkspaceId,
|
||||
workspaceId: currentItemWorkspaceId(),
|
||||
});
|
||||
if (response.data) {
|
||||
comments.value = [...comments.value, response.data];
|
||||
@@ -202,7 +206,7 @@ export const useContentItemDetailStore = defineStore('content-item-detail', () =
|
||||
async function fetchNotifications(contentItemId) {
|
||||
const response = await client.get('/api/notifications', {
|
||||
params: {
|
||||
workspaceId: workspaceStore.activeWorkspaceId,
|
||||
workspaceId: currentItemWorkspaceId() ?? undefined,
|
||||
contentItemId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ export const useContentItemsStore = defineStore('content-items', () => {
|
||||
);
|
||||
|
||||
async function fetchContentItems(filters = {}) {
|
||||
if (!authStore.isAuthenticated || !workspaceStore.activeWorkspaceId) {
|
||||
if (!authStore.isAuthenticated) {
|
||||
items.value = [];
|
||||
error.value = null;
|
||||
return;
|
||||
@@ -32,13 +32,15 @@ export const useContentItemsStore = defineStore('content-items', () => {
|
||||
try {
|
||||
const response = await client.get('/api/content-items', {
|
||||
params: {
|
||||
workspaceId: workspaceStore.activeWorkspaceId,
|
||||
workspaceId: workspaceStore.activeWorkspaceId ?? undefined,
|
||||
clientId: filters.clientId,
|
||||
campaignId: filters.campaignId,
|
||||
},
|
||||
});
|
||||
|
||||
items.value = response.data ?? [];
|
||||
items.value = (response.data ?? []).filter(item =>
|
||||
workspaceStore.isWorkspaceVisible(item.workspaceId)
|
||||
);
|
||||
} catch (fetchError) {
|
||||
console.error('Failed to fetch content items:', fetchError);
|
||||
items.value = [];
|
||||
@@ -86,9 +88,9 @@ export const useContentItemsStore = defineStore('content-items', () => {
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [authStore.isAuthenticated, workspaceStore.activeWorkspaceId],
|
||||
async ([isAuthenticated, workspaceId]) => {
|
||||
if (!isAuthenticated || !workspaceId) {
|
||||
() => [authStore.isAuthenticated, workspaceStore.workspaceScopeKey],
|
||||
async ([isAuthenticated]) => {
|
||||
if (!isAuthenticated) {
|
||||
items.value = [];
|
||||
error.value = null;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user