File tree Expand file tree Collapse file tree 2 files changed +71
-7
lines changed
Expand file tree Collapse file tree 2 files changed +71
-7
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,42 @@ export default defineInterface({
77 icon : 'sync' ,
88 description : 'Display a button to trigger custom APIs' ,
99 component : InterfaceComponent ,
10+ hideLabel : true ,
11+ hideLoader : true ,
1012 types : [ 'alias' ] ,
13+ localTypes : [ 'presentation' ] ,
1114 group : 'presentation' ,
1215 options : [
16+ {
17+ field : 'label' ,
18+ name : 'Label' ,
19+ type : 'string' ,
20+ meta : {
21+ width : 'half' ,
22+ interface : 'input' ,
23+ } ,
24+ } ,
25+ {
26+ field : 'size' ,
27+ name : 'Size' ,
28+ type : 'string' ,
29+ schema : {
30+ default_value : '' ,
31+ } ,
32+ meta : {
33+ width : 'half' ,
34+ interface : 'select-dropdown' ,
35+ options : {
36+ choices : [
37+ { text : 'x-small' , value : 'x-small' } ,
38+ { text : 'small' , value : 'small' } ,
39+ { text : 'default' , value : '' } ,
40+ { text : 'large' , value : 'large' } ,
41+ { text : 'x-large' , value : 'x-large' } ,
42+ ] ,
43+ } ,
44+ } ,
45+ } ,
1346 {
1447 field : 'url' ,
1548 name : 'URL' ,
Original file line number Diff line number Diff line change 11<template >
2- <div >{{ value }}</div >
2+ <div >
3+ <v-button v-bind =" { [size]: true, loading }" @click =" onClick" >{{ label }}</v-button >
4+ </div >
35</template >
46
57<script lang="ts">
6- import { defineComponent } from ' vue' ;
8+ import { defineComponent , ref } from ' vue' ;
9+ import { useApi } from ' @directus/extensions-sdk' ;
710
811export default defineComponent ({
912 props: {
10- value : {
11- type: [ String , Number ] ,
13+ label : {
14+ type: String ,
1215 default: null ,
1316 },
14- field : {
17+ size : {
1518 type: String ,
1619 default: null ,
1720 },
21+ url: {
22+ type: String ,
23+ default: ' ' ,
24+ },
25+ method: {
26+ type: String ,
27+ default: ' GET' ,
28+ },
1829 },
19- emits: [' input' ],
20- setup(props , { emit }) {
30+ setup(props ) {
31+ const api = useApi ();
32+
33+ const loading = ref (false );
34+
35+ return { loading , onClick };
36+
37+ async function onClick() {
38+ loading .value = true ;
39+
40+ try {
41+ const data = await api .request ({
42+ method: props .method ,
43+ url: props .url ,
44+ });
45+ console .log (data );
46+ } catch (error ) {
47+ console .log (error );
48+ } finally {
49+ loading .value = false ;
50+ }
51+ }
2152 },
2253});
2354 </script >
You can’t perform that action at this time.
0 commit comments