Browse Source

fix: shared view for user field

pull/7202/head
mertmit 1 year ago
parent
commit
c88c23b1ad
  1. 10
      packages/nc-gui/components/cell/User.vue
  2. 8
      packages/nc-gui/composables/useSharedView.ts
  3. 15
      packages/nocodb/src/services/public-metas.service.ts

10
packages/nc-gui/components/cell/User.vue

@ -37,6 +37,8 @@ const emit = defineEmits(['update:modelValue'])
const { isMobileMode } = useGlobal()
const meta = inject(MetaInj)!
const column = inject(ColumnInj)!
const readOnly = inject(ReadonlyInj)!
@ -45,13 +47,11 @@ const isEditable = inject(EditModeInj, ref(false))
const activeCell = inject(ActiveCellInj, ref(false))
const isPublic = inject(IsPublicInj, ref(false))
const basesStore = useBases()
const { basesUser, activeProjectId } = storeToRefs(basesStore)
const { basesUser } = storeToRefs(basesStore)
const baseUsers = computed(() => (activeProjectId.value ? basesUser.value.get(activeProjectId.value) || [] : []))
const baseUsers = computed(() => (meta.value.base_id ? basesUser.value.get(meta.value.base_id) || [] : []))
// use both ActiveCellInj or EditModeInj to determine the active state
// since active will be false in case of form view
@ -260,7 +260,7 @@ const filterOption = (input: string, option: any) => {
<template>
<div class="nc-user-select h-full w-full flex items-center" :class="{ 'read-only': readOnly }" @click="toggleMenu">
<div
v-if="!active || isPublic"
v-if="!active"
class="flex flex-wrap"
:style="{
'display': '-webkit-box',

8
packages/nc-gui/composables/useSharedView.ts

@ -19,6 +19,10 @@ export function useSharedView() {
const baseStore = useBase()
const basesStore = useBases()
const { basesUser } = storeToRefs(basesStore)
const { base } = storeToRefs(baseStore)
const appInfoDefaultLimit = appInfo.value.defaultLimit || 25
@ -99,6 +103,10 @@ export function useSharedView() {
const relatedMetas = { ...viewMeta.relatedMetas }
Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key]))
if (viewMeta.users) {
basesUser.value.set(viewMeta.base_id, viewMeta.users)
}
}
const fetchSharedViewData = async (param: {

15
packages/nocodb/src/services/public-metas.service.ts

@ -3,13 +3,14 @@ import { ErrorMessages, RelationTypes, UITypes } from 'nocodb-sdk';
import { isLinksOrLTAR } from 'nocodb-sdk';
import type { LinkToAnotherRecordColumn, LookupColumn } from '~/models';
import { NcError } from '~/helpers/catchError';
import { Base, Column, Model, Source, View } from '~/models';
import { Base, BaseUser, Column, Model, Source, View } from '~/models';
@Injectable()
export class PublicMetasService {
async viewMetaGet(param: { sharedViewUuid: string; password: string }) {
const view: View & {
relatedMetas?: { [ket: string]: Model };
users?: { id: string; display_name: string; email: string }[];
client?: string;
} = await View.getByUUID(param.sharedViewUuid);
@ -68,6 +69,18 @@ export class PublicMetasService {
view.relatedMetas = relatedMetas;
if (view.model.columns.some((c) => c.uidt === UITypes.User)) {
const baseUsers = await BaseUser.getUsersList({
base_id: view.model.base_id,
});
view.users = baseUsers.map((u) => ({
id: u.id,
display_name: u.display_name,
email: u.email,
}));
}
return view;
}

Loading…
Cancel
Save