Skip to content

Commit

Permalink
Add template for url
Browse files Browse the repository at this point in the history
  • Loading branch information
duydvu committed Sep 13, 2022
1 parent c73fc13 commit be284fd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/interface.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
:class="[trigger.type]"
:loading="loadings[index].value"
v-bind="{ [trigger.size]: true }"
@click="onClick(trigger.method, trigger.url, index)"
@click="onClick(trigger.method, parsedUrls[index], index)"
>
{{ trigger.label }}
</v-button>
</div>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import { computed, defineComponent, inject, PropType, ref } from 'vue';
import { useApi, useStores } from '@directus/extensions-sdk';
import { render } from 'micromustache';
type Trigger = {
label: string;
Expand All @@ -43,9 +44,12 @@ export default defineComponent({
const { useNotificationsStore } = useStores();
const store = useNotificationsStore();
const values = inject('values', ref<Record<string, any>>({}));
const parsedUrls = computed(() => props.triggers.map((trigger) => render(trigger.url ?? '', values.value)));
const loadings = props.triggers.map(() => ref(false));
return { loadings, onClick };
return { loadings, parsedUrls, onClick };
async function onClick(method: string, url: string, index: number) {
const loading = loadings[index];
Expand Down

0 comments on commit be284fd

Please sign in to comment.