Skip to content

Commit

Permalink
add push to action responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeus authored and Zeus committed Apr 13, 2020
1 parent a475228 commit 548fa4d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions resources/js/components/CustomIndexToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ export default {
document.body.removeChild(link)
} else if (response.redirect) {
window.location = response.redirect
} else if (response.push) {
this.$router.push(response.push).catch(err => { this.$router.go() })
} else if (response.openInNewTab) {
window.open(response.openInNewTab, '_blank')
} else {
Expand Down
17 changes: 17 additions & 0 deletions src/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ public static function redirect($url)
return ['redirect' => $url];
}

/**
* Return a Vue router response from the action.
*
* @param string $path
* @param array $query
* @return array
*/
public static function push($path, $query = [])
{
return [
'push' => [
'path' => $path,
'query' => $query,
],
];
}

/**
* Return an open new tab response from the action.
*
Expand Down

0 comments on commit 548fa4d

Please sign in to comment.