mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
4.5 KiB
153 lines
4.5 KiB
3 years ago
|
<template>
|
||
|
<div>
|
||
3 years ago
|
<v-menu offset-y transition="slide-y-transition">
|
||
3 years ago
|
<template #activator="{ on }">
|
||
3 years ago
|
<v-btn
|
||
|
v-show="isDashboard && _isUIAllowed('previewAs')"
|
||
|
small
|
||
|
light
|
||
|
color="#fff3"
|
||
|
class="white--text nc-btn-preview"
|
||
|
v-on="on"
|
||
|
>
|
||
3 years ago
|
<v-icon small class="mr-1"> mdi-play-circle </v-icon>
|
||
3 years ago
|
Preview
|
||
3 years ago
|
<v-icon small> mdi-menu-down </v-icon>
|
||
3 years ago
|
</v-btn>
|
||
|
</template>
|
||
|
<v-list dense>
|
||
3 years ago
|
<template v-for="role in rolesList">
|
||
3 years ago
|
<v-list-item
|
||
|
:key="role.title"
|
||
|
:class="`pointer nc-preview-${role.title}`"
|
||
|
@click="setPreviewUser(role.title)"
|
||
|
>
|
||
|
<v-list-item-title>
|
||
3 years ago
|
<v-icon small class="mr-1" :color="role.title === previewAs ? 'x-active' : ''">
|
||
3 years ago
|
{{ roleIcon[role.title] }}
|
||
|
</v-icon>
|
||
3 years ago
|
<span class="caption text-capitalize" :class="{ 'x-active--text': role.title === previewAs }">{{
|
||
|
role.title
|
||
|
}}</span>
|
||
3 years ago
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</template>
|
||
|
|
||
|
<template v-if="previewAs">
|
||
|
<!-- <v-divider></v-divider>-->
|
||
|
<v-list-item @click="setPreviewUser(null)">
|
||
3 years ago
|
<v-icon small class="mr-1"> mdi-close </v-icon>
|
||
3 years ago
|
<!-- Reset Preview -->
|
||
3 years ago
|
<span class="caption nc-preview-reset">{{ $t('activity.resetReview') }}</span>
|
||
3 years ago
|
</v-list-item>
|
||
|
</template>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
|
||
|
<v-menu
|
||
|
:position-x="position.x"
|
||
|
:position-y="position.y"
|
||
|
:value="previewAs"
|
||
|
activator=""
|
||
|
:close-on-click="false"
|
||
|
:close-on-content-click="false"
|
||
|
>
|
||
3 years ago
|
<div
|
||
|
class="floating-reset-btn white py-1 pr-3 caption primary lighten-2 white--text font-weight-bold d-flex align-center nc-floating-preview-btn"
|
||
|
style="overflow-y: hidden"
|
||
|
>
|
||
3 years ago
|
<v-icon style="cursor: move" color="white" @mousedown="mouseDown"> mdi-drag </v-icon>
|
||
3 years ago
|
|
||
|
<v-divider vertical class="mr-2" />
|
||
|
|
||
|
<div class="d-inline pointer d-flex align-center">
|
||
|
<span>Preview as :</span>
|
||
3 years ago
|
<v-radio-group :value="previewAs" dense row class="mt-0 pt-0" hide-details @change="setPreviewUser($event)">
|
||
3 years ago
|
<v-radio
|
||
3 years ago
|
v-for="role in rolesList"
|
||
3 years ago
|
:key="role.title"
|
||
|
:value="role.title"
|
||
|
color="white"
|
||
|
dark
|
||
|
:class="`ml-1 nc-floating-preview-${role.title}`"
|
||
|
>
|
||
|
<template #label>
|
||
3 years ago
|
<span class="white--text caption text-capitalize">{{ role.title }}</span>
|
||
3 years ago
|
</template>
|
||
|
</v-radio>
|
||
|
</v-radio-group>
|
||
|
<v-divider vertical class="mr-2" />
|
||
3 years ago
|
<span class="pointer" @click="setPreviewUser(null)">
|
||
3 years ago
|
<v-icon small color="white">mdi-exit-to-app</v-icon> Exit</span
|
||
|
>
|
||
3 years ago
|
</div>
|
||
|
</div>
|
||
|
</v-menu>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
3 years ago
|
name: 'PreviewAs',
|
||
3 years ago
|
data: () => ({
|
||
|
roleIcon: {
|
||
3 years ago
|
owner: 'mdi-account-star',
|
||
|
creator: 'mdi-account-hard-hat',
|
||
|
editor: 'mdi-account-edit',
|
||
|
viewer: 'mdi-eye-outline',
|
||
3 years ago
|
commenter: 'mdi-comment-account-outline',
|
||
3 years ago
|
},
|
||
3 years ago
|
rolesList: [{ title: 'editor' }, { title: 'commenter' }, { title: 'viewer' }],
|
||
3 years ago
|
position: {
|
||
3 years ago
|
x: 9999,
|
||
3 years ago
|
y: 9999,
|
||
|
},
|
||
3 years ago
|
}),
|
||
|
computed: {
|
||
|
previewAs: {
|
||
|
get() {
|
||
3 years ago
|
return this.$store.state.users.previewAs;
|
||
3 years ago
|
},
|
||
|
set(previewAs) {
|
||
3 years ago
|
this.$store.commit('users/MutPreviewAs', previewAs);
|
||
|
},
|
||
|
},
|
||
3 years ago
|
},
|
||
|
mounted() {
|
||
|
this.position = {
|
||
|
y: window.innerHeight - 100,
|
||
3 years ago
|
x: window.innerWidth / 2 - 250,
|
||
|
};
|
||
3 years ago
|
|
||
3 years ago
|
window.addEventListener('mouseup', this.mouseUp, false);
|
||
3 years ago
|
},
|
||
|
beforeDestroy() {
|
||
3 years ago
|
window.removeEventListener('mousemove', this.divMove, true);
|
||
|
window.removeEventListener('mouseup', this.mouseUp, false);
|
||
3 years ago
|
},
|
||
|
methods: {
|
||
|
setPreviewUser(previewAs) {
|
||
3 years ago
|
this.$e('a:navdraw:preview', { role: previewAs });
|
||
3 years ago
|
if (!process.env.EE) {
|
||
3 years ago
|
this.$toast.info('Available in Enterprise edition').goAway(3000);
|
||
3 years ago
|
} else {
|
||
3 years ago
|
this.previewAs = previewAs;
|
||
|
window.location.reload();
|
||
3 years ago
|
}
|
||
|
},
|
||
|
mouseUp() {
|
||
3 years ago
|
window.removeEventListener('mousemove', this.divMove, true);
|
||
3 years ago
|
},
|
||
|
mouseDown(e) {
|
||
3 years ago
|
window.addEventListener('mousemove', this.divMove, true);
|
||
3 years ago
|
},
|
||
|
|
||
|
divMove(e) {
|
||
3 years ago
|
this.position = { y: e.clientY - 10, x: e.clientX - 18 };
|
||
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
3 years ago
|
<style scoped></style>
|