Browse Source

feat(nc-gui): ui acl

pull/7611/head
DarkPhoenix2704 10 months ago
parent
commit
4df95875ab
  1. 4
      packages/nc-gui/components/smartsheet/calendar/DayView.vue
  2. 17
      packages/nc-gui/components/smartsheet/calendar/MonthView.vue
  3. 4
      packages/nc-gui/components/smartsheet/calendar/RecordCard.vue
  4. 9
      packages/nc-gui/components/smartsheet/calendar/SideMenu.vue
  5. 9
      packages/nc-gui/components/smartsheet/calendar/WeekView.vue

4
packages/nc-gui/components/smartsheet/calendar/DayView.vue

@ -9,6 +9,8 @@ const fields = inject(FieldsInj, ref([]))
const container = ref() const container = ref()
const { isUIAllowed } = useRoles()
const displayField = computed(() => meta.value?.columns?.find((c) => c.pv && fields.value.includes(c)) ?? null) const displayField = computed(() => meta.value?.columns?.find((c) => c.pv && fields.value.includes(c)) ?? null)
const { selectedTime, selectedDate, calDataType, formattedData, formattedSideBarData, calendarRange, updateRowProperty } = const { selectedTime, selectedDate, calDataType, formattedData, formattedSideBarData, calendarRange, updateRowProperty } =
@ -109,6 +111,7 @@ const hours = computed(() => {
const dragElement = ref<HTMLElement | null>(null) const dragElement = ref<HTMLElement | null>(null)
const dragStart = (event: DragEvent, record: Row) => { const dragStart = (event: DragEvent, record: Row) => {
if (isUIAllowed('dataEdit')) return
dragElement.value = event.target as HTMLElement dragElement.value = event.target as HTMLElement
dragElement.value.classList.add('hide') dragElement.value.classList.add('hide')
@ -129,6 +132,7 @@ const dragStart = (event: DragEvent, record: Row) => {
} }
const dropEvent = (event: DragEvent) => { const dropEvent = (event: DragEvent) => {
if (isUIAllowed('dataEdit')) return
event.preventDefault() event.preventDefault()
const data = event.dataTransfer?.getData('text/plain') const data = event.dataTransfer?.getData('text/plain')
if (data) { if (data) {

17
packages/nc-gui/components/smartsheet/calendar/MonthView.vue

@ -19,6 +19,8 @@ const {
const isMondayFirst = ref(true) const isMondayFirst = ref(true)
const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())
const days = computed(() => { const days = computed(() => {
@ -357,6 +359,8 @@ const useDebouncedRowUpdate = useDebounceFn((row: Row, updateProperty: string[],
}, 500) }, 500)
const onResize = (event: MouseEvent) => { const onResize = (event: MouseEvent) => {
if (!isUIAllowed('dataEdit')) return
const { top, height, width, left } = calendarGridContainer.value.getBoundingClientRect() const { top, height, width, left } = calendarGridContainer.value.getBoundingClientRect()
const percentY = (event.clientY - top - window.scrollY) / height const percentY = (event.clientY - top - window.scrollY) / height
@ -438,6 +442,8 @@ const onResizeEnd = () => {
} }
const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: Row) => { const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: Row) => {
if (!isUIAllowed('dataEdit')) return
if (draggingId.value) return if (draggingId.value) return
resizeInProgress.value = true resizeInProgress.value = true
resizeDirection.value = direction resizeDirection.value = direction
@ -447,6 +453,8 @@ const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: R
} }
const stopDrag = (event: MouseEvent) => { const stopDrag = (event: MouseEvent) => {
if (!isUIAllowed('dataEdit')) return
event.preventDefault() event.preventDefault()
clearTimeout(dragTimeout.value) clearTimeout(dragTimeout.value)
@ -542,6 +550,7 @@ const stopDrag = (event: MouseEvent) => {
} }
const dragStart = (event: MouseEvent, record: Row) => { const dragStart = (event: MouseEvent, record: Row) => {
if (!isUIAllowed('dataEdit')) return
if (resizeInProgress.value) return if (resizeInProgress.value) return
let target = event.target as HTMLElement let target = event.target as HTMLElement
@ -621,7 +630,7 @@ onBeforeUnmount(() => {
class="text-right relative group text-sm h-full border-r-1 border-b-1 border-gray-200 font-semibold hover:bg-gray-50 text-gray-800 bg-white" class="text-right relative group text-sm h-full border-r-1 border-b-1 border-gray-200 font-semibold hover:bg-gray-50 text-gray-800 bg-white"
@click="selectDate(day)" @click="selectDate(day)"
> >
<div class="flex justify-between p-1"> <div v-if="isUIAllowed('dataEdit')" class="flex justify-between p-1">
<span <span
:class="{ :class="{
block: !isDateSelected(day), block: !isDateSelected(day),
@ -669,7 +678,6 @@ onBeforeUnmount(() => {
</template> </template>
</NcDropdown> </NcDropdown>
<NcButton <NcButton
v-else
:class="{ :class="{
'!block': isDateSelected(day), '!block': isDateSelected(day),
'!hidden': !isDateSelected(day), '!hidden': !isDateSelected(day),
@ -690,9 +698,10 @@ onBeforeUnmount(() => {
> >
<component :is="iconMap.plus" class="h-4 w-4" /> <component :is="iconMap.plus" class="h-4 w-4" />
</NcButton> </NcButton>
<span class="px-1 py-2">{{ dayjs(day).format('DD') }}</span> <span class="px-1 py-2">{{ dayjs(day).format('DD') }}</span>
</div> </div>
<div v-if="!isUIAllowed('dataEdit')" class="p-3">{{ dayjs(day).format('DD') }}</div>
<div <div
v-if=" v-if="
recordsToDisplay.count[dayjs(day).format('YYYY-MM-DD')] && recordsToDisplay.count[dayjs(day).format('YYYY-MM-DD')] &&
@ -732,7 +741,7 @@ onBeforeUnmount(() => {
:name="record.row[displayField.title]" :name="record.row[displayField.title]"
:position="record.rowMeta.position" :position="record.rowMeta.position"
:record="record" :record="record"
:resize="!!record.rowMeta.range?.fk_to_col" :resize="!!record.rowMeta.range?.fk_to_col && isUIAllowed('dataEdit')"
:selected=" :selected="
dragRecord dragRecord
? dragRecord.rowMeta.id === record.rowMeta.id ? dragRecord.rowMeta.id === record.rowMeta.id

4
packages/nc-gui/components/smartsheet/calendar/RecordCard.vue

@ -62,7 +62,7 @@ const emit = defineEmits(['resize-start'])
</div> </div>
<div <div
v-if="position === 'leftRounded' || (position === 'rounded' && resize)" v-if="(position === 'leftRounded' || position === 'rounded') && resize"
:class="{ :class="{
'!block border-2 rounded-lg border-brand-500': selected, '!block border-2 rounded-lg border-brand-500': selected,
}" }"
@ -80,7 +80,7 @@ const emit = defineEmits(['resize-start'])
<span v-if="position === 'leftRounded' || position === 'none'" class="absolute my-0 right-5"> .... </span> <span v-if="position === 'leftRounded' || position === 'none'" class="absolute my-0 right-5"> .... </span>
</div> </div>
<div <div
v-if="position === 'rightRounded' || (position === 'rounded' && resize)" v-if="(position === 'rightRounded' || position === 'rounded') && resize"
:class="{ :class="{
'!block border-2 rounded-lg border-brand-500': selected, '!block border-2 rounded-lg border-brand-500': selected,
}" }"

9
packages/nc-gui/components/smartsheet/calendar/SideMenu.vue

@ -12,6 +12,8 @@ const emit = defineEmits(['expand-record', 'new-record'])
const INFINITY_SCROLL_THRESHOLD = 100 const INFINITY_SCROLL_THRESHOLD = 100
const { isUIAllowed } = useRoles()
const { appInfo } = useGlobal() const { appInfo } = useGlobal()
const { t } = useI18n() const { t } = useI18n()
@ -282,7 +284,12 @@ const sideBarListScrollHandle = useDebounceFn(async (e: Event) => {
class="gap-2 flex flex-col nc-scrollbar-md overflow-y-auto nc-calendar-top-height" class="gap-2 flex flex-col nc-scrollbar-md overflow-y-auto nc-calendar-top-height"
@scroll="sideBarListScrollHandle" @scroll="sideBarListScrollHandle"
> >
<NcButton class="!absolute right-5 bottom-5 !h-12 !w-12" type="secondary" @click="emit('new-record', { row: {} })"> <NcButton
v-if="isUIAllowed('dataEdit')"
class="!absolute right-5 bottom-5 !h-12 !w-12"
type="secondary"
@click="emit('new-record', { row: {} })"
>
<div class="px-4 flex items-center gap-2 justify-center"> <div class="px-4 flex items-center gap-2 justify-center">
<component :is="iconMap.plus" class="h-6 w-6 text-lg text-brand-500" /> <component :is="iconMap.plus" class="h-6 w-6 text-lg text-brand-500" />
</div> </div>

9
packages/nc-gui/components/smartsheet/calendar/WeekView.vue

@ -20,6 +20,8 @@ const container = ref<null | HTMLElement>(null)
const { width: containerWidth } = useElementSize(container) const { width: containerWidth } = useElementSize(container)
const { isUIAllowed } = useRoles()
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())
const weekDates = computed(() => { const weekDates = computed(() => {
@ -220,6 +222,7 @@ const useDebouncedRowUpdate = useDebounceFn((row: Row, updateProperty: string[],
}, 500) }, 500)
const onResize = (event: MouseEvent) => { const onResize = (event: MouseEvent) => {
if (!isUIAllowed('dataEdit')) return
if (!container.value || !resizeRecord.value) return if (!container.value || !resizeRecord.value) return
const { width, left } = container.value.getBoundingClientRect() const { width, left } = container.value.getBoundingClientRect()
@ -299,6 +302,7 @@ const onResizeEnd = () => {
} }
const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: Row) => { const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: Row) => {
if (!isUIAllowed('dataEdit')) return
resizeInProgress.value = true resizeInProgress.value = true
resizeDirection.value = direction resizeDirection.value = direction
resizeRecord.value = record resizeRecord.value = record
@ -307,6 +311,7 @@ const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: R
} }
const onDrag = (event: MouseEvent) => { const onDrag = (event: MouseEvent) => {
if (!isUIAllowed('dataEdit')) return
if (!container.value || !dragRecord.value) return if (!container.value || !dragRecord.value) return
const { width, left } = container.value.getBoundingClientRect() const { width, left } = container.value.getBoundingClientRect()
@ -361,6 +366,7 @@ const onDrag = (event: MouseEvent) => {
const stopDrag = (event: MouseEvent) => { const stopDrag = (event: MouseEvent) => {
event.preventDefault() event.preventDefault()
if (!isUIAllowed('dataEdit')) return
if (!isDragging.value || !container.value || !dragRecord.value) return if (!isDragging.value || !container.value || !dragRecord.value) return
const { width, left } = container.value.getBoundingClientRect() const { width, left } = container.value.getBoundingClientRect()
@ -447,6 +453,7 @@ const stopDrag = (event: MouseEvent) => {
} }
const dragStart = (event: MouseEvent, record: Row) => { const dragStart = (event: MouseEvent, record: Row) => {
if (!isUIAllowed('dataEdit')) return
if (resizeInProgress.value) return if (resizeInProgress.value) return
let target = event.target as HTMLElement let target = event.target as HTMLElement
@ -521,7 +528,7 @@ const dragStart = (event: MouseEvent, record: Row) => {
:name="record.row[displayField!.title!]" :name="record.row[displayField!.title!]"
:position="record.rowMeta.position" :position="record.rowMeta.position"
:record="record" :record="record"
:resize="!!record.rowMeta.range?.fk_to_col" :resize="!!record.rowMeta.range?.fk_to_col && isUIAllowed('dataEdit')"
color="blue" color="blue"
@click="emits('expand-record', record)" @click="emits('expand-record', record)"
@resize-start="onResizeStart" @resize-start="onResizeStart"

Loading…
Cancel
Save