|
Lines 2-16
Link Here
|
| 2 |
import { inject } from "vue" |
2 |
import { inject } from "vue" |
| 3 |
|
3 |
|
| 4 |
export default { |
4 |
export default { |
| 5 |
setup() { |
5 |
setup(props) { |
| 6 |
//global setup for all resource (list and show for now, but maybe others?) components here |
6 |
//global setup for all resource (list and show for now, but maybe others?) components here |
| 7 |
const { setConfirmationDialog, setMessage, setError } = |
7 |
const { setConfirmationDialog, setMessage, setError } = |
| 8 |
inject("mainStore") |
8 |
inject("mainStore") |
| 9 |
return { setConfirmationDialog, setMessage, setError } |
9 |
return { ...props, setConfirmationDialog, setMessage, setError } |
| 10 |
}, |
10 |
}, |
| 11 |
methods: { |
11 |
methods: { |
| 12 |
// goToResourceEdit: function () {}, |
12 |
/** |
|
|
13 |
* Navigates to the edit page of the given resource. |
| 14 |
* |
| 15 |
* @param {Object} resource - The resource to navigate to (optional) |
| 16 |
* @return {void} |
| 17 |
*/ |
| 18 |
goToResourceEdit: function (resource) { |
| 19 |
this.$router.push({ |
| 20 |
name: this.edit_component, |
| 21 |
params: { |
| 22 |
[this.id_attr]: resource |
| 23 |
? resource[this.id_attr] |
| 24 |
: this[this.resource_name][this.id_attr], |
| 25 |
}, |
| 26 |
}) |
| 27 |
}, |
| 28 |
/** |
| 29 |
* Navigates to the creation page of the given resource. |
| 30 |
* |
| 31 |
* @return {void} |
| 32 |
*/ |
| 33 |
goToResourceAdd: function () { |
| 34 |
this.$router.push({ |
| 35 |
name: this.add_component, |
| 36 |
}) |
| 37 |
}, |
| 13 |
}, |
38 |
}, |
| 14 |
name: "BaseResource", |
39 |
name: "BaseResource", |
|
|
40 |
props: { |
| 41 |
resource_name: String, |
| 42 |
id_attr: String, |
| 43 |
add_component: String, |
| 44 |
edit_component: String, |
| 45 |
}, |
| 15 |
} |
46 |
} |
| 16 |
</script> |
47 |
</script> |