[core] draggable shortcutlinks
This commit is contained in:
		
							parent
							
								
									3c7d711f59
								
							
						
					
					
						commit
						95867428a8
					
				| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <q-btn v-if="isGranted" flat dense :icon="shortcut.icon" :to="{ name: shortcut.link }" round>
 | 
					  <q-btn v-if="isGranted" flat dense :icon="shortcut.icon" :to="{ name: shortcut.link }" round>
 | 
				
			||||||
    <q-menu v-if='context' context-menu>
 | 
					    <q-menu v-if="context" context-menu>
 | 
				
			||||||
      <q-btn v-close-popup label='Verknüpfung entfernen' @click='deleteShortcut'/>
 | 
					      <q-btn v-close-popup label="Verknüpfung entfernen" @click="deleteShortcut" />
 | 
				
			||||||
    </q-menu>
 | 
					    </q-menu>
 | 
				
			||||||
  </q-btn>
 | 
					  </q-btn>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
| 
						 | 
					@ -21,17 +21,17 @@ export default defineComponent({
 | 
				
			||||||
    context: {
 | 
					    context: {
 | 
				
			||||||
      type: Boolean,
 | 
					      type: Boolean,
 | 
				
			||||||
      default: false,
 | 
					      default: false,
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  emits: {
 | 
					  emits: {
 | 
				
			||||||
    deleteShortcut: (val: FG_Plugin.MenuLink| FG_Plugin.Shortcut) => val.link
 | 
					    deleteShortcut: (val: FG_Plugin.MenuLink | FG_Plugin.Shortcut) => val.link,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  setup(props, {emit}) {
 | 
					  setup(props, { emit }) {
 | 
				
			||||||
    const isGranted = computed(() => hasPermissions(props.shortcut.permissions || []));
 | 
					    const isGranted = computed(() => hasPermissions(props.shortcut.permissions || []));
 | 
				
			||||||
    function deleteShortcut() {
 | 
					    function deleteShortcut() {
 | 
				
			||||||
      emit('deleteShortcut', props.shortcut)
 | 
					      emit('deleteShortcut', props.shortcut);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return { isGranted, deleteShortcut};
 | 
					    return { isGranted, deleteShortcut };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,8 +14,10 @@
 | 
				
			||||||
        </q-toolbar-title>
 | 
					        </q-toolbar-title>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <!-- Hier kommen die Shortlinks hin -->
 | 
					        <!-- Hier kommen die Shortlinks hin -->
 | 
				
			||||||
        <q-btn icon="mdi-message-bulleted" flat dense
 | 
					        <q-btn icon="mdi-message-bulleted" flat dense round>
 | 
				
			||||||
          ><q-badge color="negative" floating>{{ notifications.length }}</q-badge>
 | 
					          <q-badge color="negative" floating>
 | 
				
			||||||
 | 
					            {{ notifications.length }}
 | 
				
			||||||
 | 
					          </q-badge>
 | 
				
			||||||
          <q-menu style="max-height: 400px; overflow: auto">
 | 
					          <q-menu style="max-height: 400px; overflow: auto">
 | 
				
			||||||
            <q-btn
 | 
					            <q-btn
 | 
				
			||||||
              v-if="useNative && noPermission"
 | 
					              v-if="useNative && noPermission"
 | 
				
			||||||
| 
						 | 
					@ -33,18 +35,11 @@
 | 
				
			||||||
            <div v-else class="q-pa-sm">Keine neuen Benachrichtigungen</div>
 | 
					            <div v-else class="q-pa-sm">Keine neuen Benachrichtigungen</div>
 | 
				
			||||||
          </q-menu>
 | 
					          </q-menu>
 | 
				
			||||||
        </q-btn>
 | 
					        </q-btn>
 | 
				
			||||||
        <!--<shortcut-link
 | 
					        <drag v-model="shortCuts" item-key="link" ghost-class="ghost">
 | 
				
			||||||
          v-for="(shortcut, index) in shortcuts"
 | 
					          <template #item="{ element }">
 | 
				
			||||||
          :key="'shortcut' + index"
 | 
					            <shortcut-link :shortcut="element" context @delete-shortcut="deleteShortcut" />
 | 
				
			||||||
          :shortcut="shortcut"
 | 
					          </template>
 | 
				
			||||||
        />-->
 | 
					        </drag>
 | 
				
			||||||
        <shortcut-link
 | 
					 | 
				
			||||||
          v-for="(shortcut, index) in shortCuts"
 | 
					 | 
				
			||||||
          :key="'shortcut' + index"
 | 
					 | 
				
			||||||
          :shortcut="shortcut"
 | 
					 | 
				
			||||||
          context
 | 
					 | 
				
			||||||
          @delete-shortcut="deleteShortcut"
 | 
					 | 
				
			||||||
        />
 | 
					 | 
				
			||||||
        <q-btn flat round dense icon="mdi-exit-to-app" @click="logout()" />
 | 
					        <q-btn flat round dense icon="mdi-exit-to-app" @click="logout()" />
 | 
				
			||||||
      </q-toolbar>
 | 
					      </q-toolbar>
 | 
				
			||||||
    </q-header>
 | 
					    </q-header>
 | 
				
			||||||
| 
						 | 
					@ -64,13 +59,6 @@
 | 
				
			||||||
          :entry="entry"
 | 
					          :entry="entry"
 | 
				
			||||||
          @add-short-cut="addShortcut"
 | 
					          @add-short-cut="addShortcut"
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
        <!--<q-separator />
 | 
					 | 
				
			||||||
        Plugin functions
 | 
					 | 
				
			||||||
        <essential-link
 | 
					 | 
				
			||||||
          v-for="(entry, index) in subLinks"
 | 
					 | 
				
			||||||
          :key="'childPlugin' + index"
 | 
					 | 
				
			||||||
          :entry="entry"
 | 
					 | 
				
			||||||
        />-->
 | 
					 | 
				
			||||||
      </q-list>
 | 
					      </q-list>
 | 
				
			||||||
      <q-separator />
 | 
					      <q-separator />
 | 
				
			||||||
      <essential-link
 | 
					      <essential-link
 | 
				
			||||||
| 
						 | 
					@ -89,13 +77,23 @@
 | 
				
			||||||
import EssentialLink from 'src/components/navigation/EssentialLink.vue';
 | 
					import EssentialLink from 'src/components/navigation/EssentialLink.vue';
 | 
				
			||||||
import ShortcutLink from 'src/components/navigation/ShortcutLink.vue';
 | 
					import ShortcutLink from 'src/components/navigation/ShortcutLink.vue';
 | 
				
			||||||
import Notification from 'src/components/Notification.vue';
 | 
					import Notification from 'src/components/Notification.vue';
 | 
				
			||||||
import { defineComponent, ref, inject, computed, onBeforeMount, onBeforeUnmount } from 'vue';
 | 
					import {
 | 
				
			||||||
 | 
					  defineComponent,
 | 
				
			||||||
 | 
					  ref,
 | 
				
			||||||
 | 
					  inject,
 | 
				
			||||||
 | 
					  computed,
 | 
				
			||||||
 | 
					  onBeforeMount,
 | 
				
			||||||
 | 
					  onBeforeUnmount,
 | 
				
			||||||
 | 
					  ComponentPublicInstance,
 | 
				
			||||||
 | 
					} from 'vue';
 | 
				
			||||||
import { useMainStore } from 'src/stores';
 | 
					import { useMainStore } from 'src/stores';
 | 
				
			||||||
import { FG_Plugin } from 'src/plugins';
 | 
					import { FG_Plugin } from 'src/plugins';
 | 
				
			||||||
import { useRouter } from 'vue-router';
 | 
					import { useRouter } from 'vue-router';
 | 
				
			||||||
import { Screen } from 'quasar';
 | 
					import { Screen } from 'quasar';
 | 
				
			||||||
import config from 'src/config';
 | 
					import config from 'src/config';
 | 
				
			||||||
import EssentialExpansionLink from 'components/navigation/EssentialExpansionLink.vue';
 | 
					import EssentialExpansionLink from 'components/navigation/EssentialExpansionLink.vue';
 | 
				
			||||||
 | 
					import draggable from 'vuedraggable';
 | 
				
			||||||
 | 
					const drag: ComponentPublicInstance = <ComponentPublicInstance>draggable;
 | 
				
			||||||
const essentials: FG_Plugin.MenuLink[] = [
 | 
					const essentials: FG_Plugin.MenuLink[] = [
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    title: 'Über Flaschengeist',
 | 
					    title: 'Über Flaschengeist',
 | 
				
			||||||
| 
						 | 
					@ -106,7 +104,7 @@ const essentials: FG_Plugin.MenuLink[] = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default defineComponent({
 | 
					export default defineComponent({
 | 
				
			||||||
  name: 'MainLayout',
 | 
					  name: 'MainLayout',
 | 
				
			||||||
  components: { EssentialExpansionLink, EssentialLink, ShortcutLink, Notification },
 | 
					  components: { EssentialExpansionLink, EssentialLink, ShortcutLink, Notification, drag },
 | 
				
			||||||
  setup() {
 | 
					  setup() {
 | 
				
			||||||
    const router = useRouter();
 | 
					    const router = useRouter();
 | 
				
			||||||
    const mainStore = useMainStore();
 | 
					    const mainStore = useMainStore();
 | 
				
			||||||
| 
						 | 
					@ -171,8 +169,8 @@ export default defineComponent({
 | 
				
			||||||
    const shortCuts = computed({
 | 
					    const shortCuts = computed({
 | 
				
			||||||
      get: () => mainStore.shortcuts,
 | 
					      get: () => mainStore.shortcuts,
 | 
				
			||||||
      set: (val: Array<FG_Plugin.MenuLink>) => {
 | 
					      set: (val: Array<FG_Plugin.MenuLink>) => {
 | 
				
			||||||
        console.log('hier bin ich', val);
 | 
					 | 
				
			||||||
        mainStore.shortcuts = val;
 | 
					        mainStore.shortcuts = val;
 | 
				
			||||||
 | 
					        void mainStore.setShortcuts();
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -185,7 +183,6 @@ export default defineComponent({
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function deleteShortcut(val: FG_Plugin.MenuLink) {
 | 
					    function deleteShortcut(val: FG_Plugin.MenuLink) {
 | 
				
			||||||
      console.log('deleteShortcut');
 | 
					 | 
				
			||||||
      const idx = shortCuts.value.findIndex((a: FG_Plugin.MenuLink) => a.link === val.link);
 | 
					      const idx = shortCuts.value.findIndex((a: FG_Plugin.MenuLink) => a.link === val.link);
 | 
				
			||||||
      if (idx > -1) {
 | 
					      if (idx > -1) {
 | 
				
			||||||
        shortCuts.value.splice(idx, 1);
 | 
					        shortCuts.value.splice(idx, 1);
 | 
				
			||||||
| 
						 | 
					@ -212,3 +209,8 @@ export default defineComponent({
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					<style scoped lang="sass">
 | 
				
			||||||
 | 
					.ghost
 | 
				
			||||||
 | 
					  opacity: 0.5
 | 
				
			||||||
 | 
					  background: $accent
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,9 +36,15 @@
 | 
				
			||||||
        </q-form>
 | 
					        </q-form>
 | 
				
			||||||
      </q-card-section>
 | 
					      </q-card-section>
 | 
				
			||||||
      <div class="row justify-end">
 | 
					      <div class="row justify-end">
 | 
				
			||||||
        <q-btn v-if='$q.platform.is.cordova || $q.platform.is.electron' flat round icon="mdi-menu-down"  @click="openServerSettings" />
 | 
					        <q-btn
 | 
				
			||||||
 | 
					          v-if="$q.platform.is.cordova || $q.platform.is.electron"
 | 
				
			||||||
 | 
					          flat
 | 
				
			||||||
 | 
					          round
 | 
				
			||||||
 | 
					          icon="mdi-menu-down"
 | 
				
			||||||
 | 
					          @click="openServerSettings"
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <q-slide-transition v-if='$q.platform.is.cordova || $q.platform.is.electron'>
 | 
					      <q-slide-transition v-if="$q.platform.is.cordova || $q.platform.is.electron">
 | 
				
			||||||
        <div v-show="visible">
 | 
					        <div v-show="visible">
 | 
				
			||||||
          <q-separator />
 | 
					          <q-separator />
 | 
				
			||||||
          <q-card-section>
 | 
					          <q-card-section>
 | 
				
			||||||
| 
						 | 
					@ -78,7 +84,7 @@ export default defineComponent({
 | 
				
			||||||
    const password = ref('');
 | 
					    const password = ref('');
 | 
				
			||||||
    const server = ref<string | undefined>(api.defaults.baseURL);
 | 
					    const server = ref<string | undefined>(api.defaults.baseURL);
 | 
				
			||||||
    const visible = ref(false);
 | 
					    const visible = ref(false);
 | 
				
			||||||
    const $q = useQuasar()
 | 
					    const $q = useQuasar();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function openServerSettings() {
 | 
					    function openServerSettings() {
 | 
				
			||||||
      visible.value = !visible.value;
 | 
					      visible.value = !visible.value;
 | 
				
			||||||
| 
						 | 
					@ -152,7 +158,7 @@ export default defineComponent({
 | 
				
			||||||
      server,
 | 
					      server,
 | 
				
			||||||
      userid,
 | 
					      userid,
 | 
				
			||||||
      visible,
 | 
					      visible,
 | 
				
			||||||
      $q
 | 
					      $q,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue