yarn run v1.22.10
$ /mnt/data/home/thomas/devel/flaschengeist/flaschengeist-frontend/node_modules/.bin/prettier src/components/navigation/EssentialExpansionLink.vue
<template>
  <q-expansion-item v-if="isGranted(entry)" clickable :label="getTitle(entry)" :icon="entry.icon" expand-separator>
    <q-list class="q-ml-lg">
      <div v-for="child in entry.children" :key="child.link">
        <q-item v-if="isGranted(child)" clickable :to="{ name: child.link }">
          <q-menu context-menu>
            <q-btn v-close-popup label="Verknüpfung erstellen" dense @click="addShortCut(child)" />
          </q-menu>
          <q-item-section avatar>
            <q-icon :name="child.icon" />
          </q-item-section>
          <q-item-section>
            <q-item-label>
              {{ getTitle(child) }}
            </q-item-label>
          </q-item-section>
        </q-item>
      </div>
    </q-list>
  </q-expansion-item>
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue';
import { hasPermissions } from '@flaschengeist/api';
import { FG_Plugin } from '@flaschengeist/types';

export default defineComponent({
  name: 'EssentialExpansionLink',
  components: {},
  props: {
    entry: {
      type: Object as PropType<FG_Plugin.MenuLink>,
      required: true,
    },
  },
  emits: {
    addShortCut: (val: FG_Plugin.MenuLink) => val.link,
  },
  setup(props, { emit }) {
    function isGranted(val: FG_Plugin.MenuLink) {
      return computed(() => hasPermissions(val.permissions || []));
    }
    function getTitle(entry: FG_Plugin.MenuLink) {
      return computed(() => (typeof entry.title === 'function' ? entry.title() : entry.title)).value;
    }

    function addShortCut(val: FG_Plugin.MenuLink) {
      emit('addShortCut', val);
    }

    return { isGranted, getTitle, addShortCut };
  },
});
</script>
Done in 0.67s.
