1111 />
1212 </div >
1313 <div class =" buttons" >
14+ <a class =" button" v-on:click.prevent =" showActionDropDown = !showActionDropDown" >
15+ <font-awesome-icon icon =" angle-right" v-if =" !showActionDropDown" />
16+ <font-awesome-icon icon =" angle-down" v-if =" showActionDropDown" />
17+ Actions
18+ <a class =" actions-dropdown" >
19+ <DropDownMenu v-if =" showActionDropDown" >
20+ <li v-for =" action in allActions" >
21+ <a href =" #" class =" button" v-on:click =" executeAction(action.action_id)" >
22+ <span >{{ action.action_name }}</span >
23+ </a >
24+ </li >
25+ </DropDownMenu >
26+ </a >
27+ </a >
1428 <a
1529 class =" button"
1630 href =" #"
2741 v-if =" selectedRows.length > 0"
2842 v-on:triggered =" deleteRows"
2943 />
30-
44+
45+
3146 <router-link
3247 :to =" {
3348 name: 'addRow',
4055 <span >{{ $t("Add Row") }}</span >
4156 </router-link >
4257
58+
4359 <a
4460 class =" button"
4561 href =" #"
299315 "
300316 />
301317 </li >
302- <li >
303- <CallbackButton
304- :includeTitle =" true"
305- class =" "
306- v-on:triggered ="
307- executeCallback(
308- row[pkName]
309- )
310- "
311- />
312- </li >
313318 </DropDownMenu >
314319 </span >
315320 </td >
@@ -381,7 +386,6 @@ import BulkUpdateModal from "../components/BulkUpdateModal.vue"
381386import BulkDeleteButton from " ../components/BulkDeleteButton.vue"
382387import CSVButton from " ../components/CSVButton.vue"
383388import DeleteButton from " ../components/DeleteButton.vue"
384- import CallbackButton from " ../components/CallbackButton.vue"
385389import DropDownMenu from " ../components/DropDownMenu.vue"
386390import ChangePageSize from " ../components/ChangePageSize.vue"
387391import MediaViewer from " ../components/MediaViewer.vue"
@@ -409,7 +413,8 @@ export default Vue.extend({
409413 showUpdateModal: false ,
410414 visibleDropdown: null ,
411415 showMediaViewer: false ,
412- mediaViewerConfig: null as MediaViewerConfig
416+ mediaViewerConfig: null as MediaViewerConfig ,
417+ showActionDropDown: false ,
413418 }
414419 },
415420 components: {
@@ -420,7 +425,6 @@ export default Vue.extend({
420425 ChangePageSize ,
421426 CSVButton ,
422427 DeleteButton ,
423- CallbackButton ,
424428 DropDownMenu ,
425429 MediaViewer ,
426430 Pagination ,
@@ -448,6 +452,9 @@ export default Vue.extend({
448452 schema() {
449453 return this .$store .state .schema
450454 },
455+ allActions() {
456+ return this .$store .state .actions
457+ },
451458 rowCount() {
452459 return this .$store .state .rowCount
453460 },
@@ -579,24 +586,22 @@ export default Vue.extend({
579586 this .showSuccess (" Successfully deleted row" )
580587 }
581588 },
582- async executeCallback(rowID ) {
583- if (confirm (` Are you sure you want to run callback for this row? ` )) {
584- console .log (" Requesting to run callback!" )
589+ async executeAction(action_id ) {
590+ if (confirm (` Are you sure you want to run action for this row? ` )) {
585591 try {
586- let response = await this .$store .dispatch (" executeCallback " , {
592+ let response = await this .$store .dispatch (" executeAction " , {
587593 tableName: this .tableName ,
588- rowID
594+ rowIDs: this .selectedRows ,
595+ actionId: action_id
589596 })
590- this .showSuccess (` Successfully ran callback and got response: ${response .data } ` , 10000 )
597+ this .showSuccess (` Successfully ran action and got response: ${response .data } ` , 10000 )
591598 } catch (error ) {
592599 if (error .response .status == 404 ) {
593- console .log (error .response .status )
594600 this .$store .commit (" updateApiResponseMessage" , {
595- contents: " This table is not configured for callback action " ,
601+ contents: " This table is not configured for any actions " ,
596602 type: " error"
597603 })
598604 } else {
599- console .log (error .response .status )
600605 this .$store .commit (" updateApiResponseMessage" , {
601606 contents: " Something went wrong" ,
602607 type: " error"
@@ -623,6 +628,9 @@ export default Vue.extend({
623628 },
624629 async fetchSchema() {
625630 await this .$store .dispatch (" fetchSchema" , this .tableName )
631+ },
632+ async fetchActions() {
633+ await this .$store .dispatch (" fetchActions" , this .tableName )
626634 }
627635 },
628636 watch: {
@@ -650,7 +658,7 @@ export default Vue.extend({
650658 this .$router .currentRoute .query
651659 )
652660
653- await Promise .all ([this .fetchRows (), this .fetchSchema ()])
661+ await Promise .all ([this .fetchRows (), this .fetchSchema (), this . fetchActions () ])
654662 }
655663})
656664 </script >
@@ -727,6 +735,10 @@ div.wrapper {
727735 & :first-child {
728736 margin-left : 0 ;
729737 }
738+
739+ a .actions-dropdown {
740+ position : relative ;
741+ }
730742 }
731743 }
732744 }
0 commit comments