|
27 | 27 | v-if="selectedRows.length > 0" |
28 | 28 | v-on:triggered="deleteRows" |
29 | 29 | /> |
30 | | - |
| 30 | + |
| 31 | + <ActionDropDownMenu class="button" v-on:triggered="executeAction"/> |
| 32 | + |
31 | 33 | <router-link |
32 | 34 | :to="{ |
33 | 35 | name: 'addRow', |
|
40 | 42 | <span>{{ $t("Add Row") }}</span> |
41 | 43 | </router-link> |
42 | 44 |
|
| 45 | + |
43 | 46 | <a |
44 | 47 | class="button" |
45 | 48 | href="#" |
|
300 | 303 | /> |
301 | 304 | </li> |
302 | 305 | <li> |
303 | | - <CallbackButton |
| 306 | + <ActionButton |
304 | 307 | :includeTitle="true" |
305 | 308 | class="" |
306 | | - v-on:triggered=" |
307 | | - executeCallback( |
308 | | - row[pkName] |
309 | | - ) |
310 | | - " |
| 309 | + v-on:triggered="executeAction" |
311 | 310 | /> |
312 | 311 | </li> |
313 | 312 | </DropDownMenu> |
@@ -381,7 +380,8 @@ import BulkUpdateModal from "../components/BulkUpdateModal.vue" |
381 | 380 | import BulkDeleteButton from "../components/BulkDeleteButton.vue" |
382 | 381 | import CSVButton from "../components/CSVButton.vue" |
383 | 382 | import DeleteButton from "../components/DeleteButton.vue" |
384 | | -import CallbackButton from "../components/CallbackButton.vue" |
| 383 | +import ActionButton from "../components/ActionButton.vue" |
| 384 | +import ActionDropDownMenu from "../components/ActionDropDownMenu.vue" |
385 | 385 | import DropDownMenu from "../components/DropDownMenu.vue" |
386 | 386 | import ChangePageSize from "../components/ChangePageSize.vue" |
387 | 387 | import MediaViewer from "../components/MediaViewer.vue" |
@@ -420,7 +420,8 @@ export default Vue.extend({ |
420 | 420 | ChangePageSize, |
421 | 421 | CSVButton, |
422 | 422 | DeleteButton, |
423 | | - CallbackButton, |
| 423 | + ActionButton, |
| 424 | + ActionDropDownMenu, |
424 | 425 | DropDownMenu, |
425 | 426 | MediaViewer, |
426 | 427 | Pagination, |
@@ -448,6 +449,9 @@ export default Vue.extend({ |
448 | 449 | schema() { |
449 | 450 | return this.$store.state.schema |
450 | 451 | }, |
| 452 | + actions() { |
| 453 | + return this.$store.state.actions |
| 454 | + }, |
451 | 455 | rowCount() { |
452 | 456 | return this.$store.state.rowCount |
453 | 457 | }, |
@@ -579,20 +583,25 @@ export default Vue.extend({ |
579 | 583 | this.showSuccess("Successfully deleted row") |
580 | 584 | } |
581 | 585 | }, |
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!") |
| 586 | + async executeAction() { |
| 587 | + console.log("RUNNING"); |
| 588 | + |
| 589 | + if (confirm(`Are you sure you want to run action for this row?`)) { |
| 590 | + console.log("Requesting to run action!") |
585 | 591 | try { |
586 | | - let response = await this.$store.dispatch("executeCallback", { |
587 | | - tableName: this.tableName, |
588 | | - rowID |
589 | | - }) |
590 | | - this.showSuccess(`Successfully ran callback and got response: ${response.data}`, 10000) |
| 592 | + for (let i = 0; i < this.selectedRows.length; i++) { |
| 593 | + let response = await this.$store.dispatch("executeAction", { |
| 594 | + tableName: this.tableName, |
| 595 | + rowID: this.selectedRows[i], |
| 596 | + actionId: 1 |
| 597 | + }) |
| 598 | + this.showSuccess(`Successfully ran action and got response: ${response.data}`, 10000) |
| 599 | + } |
591 | 600 | } catch (error) { |
592 | 601 | if (error.response.status == 404) { |
593 | 602 | console.log(error.response.status) |
594 | 603 | this.$store.commit("updateApiResponseMessage", { |
595 | | - contents: "This table is not configured for callback action", |
| 604 | + contents: "This table is not configured for any actions", |
596 | 605 | type: "error" |
597 | 606 | }) |
598 | 607 | } else { |
@@ -623,6 +632,9 @@ export default Vue.extend({ |
623 | 632 | }, |
624 | 633 | async fetchSchema() { |
625 | 634 | await this.$store.dispatch("fetchSchema", this.tableName) |
| 635 | + }, |
| 636 | + async fetchActions() { |
| 637 | + await this.$store.dispatch("fetchActions", this.tableName) |
626 | 638 | } |
627 | 639 | }, |
628 | 640 | watch: { |
@@ -650,7 +662,7 @@ export default Vue.extend({ |
650 | 662 | this.$router.currentRoute.query |
651 | 663 | ) |
652 | 664 |
|
653 | | - await Promise.all([this.fetchRows(), this.fetchSchema()]) |
| 665 | + await Promise.all([this.fetchRows(), this.fetchSchema(), this.fetchActions()]) |
654 | 666 | } |
655 | 667 | }) |
656 | 668 | </script> |
|
0 commit comments