Skip to content

Commit 79943d3

Browse files
committed
feat: hookup ability to togle trust tree mode
1 parent e0b81ce commit 79943d3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/views/TrustSettings.vue

+14-3
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,45 @@ import { usersApi } from '@/api'
5050
import { AuthStore } from '@/composables/stores/auth'
5151
// import TrustFeedbackModal from '@/components/modals/trust/Feedback.vue'
5252
import TrustList from '@/components/trust/TrustList.vue'
53+
import { useRoute, useRouter } from 'vue-router'
5354
5455
export default {
5556
name: 'TrustSettings',
5657
components: { TrustList },
5758
beforeRouteEnter(to, from, next) {
5859
next(vm => {
60+
vm.hierarchy = to.query.hierarchy
5961
usersApi.trust.getTrustList()
6062
.then(d => vm.trustData = d)
6163
.catch(() => {})
62-
usersApi.trust.getTrustTree()
64+
usersApi.trust.getTrustTree({ hierarchy: to.query.hierarchy })
6365
.then(d => vm.trustTree = d)
6466
.catch(() => {})
6567
})
6668
},
6769
beforeRouteUpdate(to, from, next) {
70+
this.hierarchy = to.query.hierarchy
6871
usersApi.trust.getTrustList()
6972
.then(d => this.trustData = d)
7073
.catch(() => {})
71-
usersApi.trust.getTrustTree()
74+
usersApi.trust.getTrustTree({ hierarchy: to.query.hierarchy })
7275
.then(d => this.trustTree = d)
7376
.catch(() => {})
7477
next()
7578
},
7679
setup() {
77-
const changeTrustView = () => console.log('changeTrustView')
80+
const changeTrustView = () => {
81+
let query = { hierarchy: v.hierarchy }
82+
if (query.hierarchy) delete query.hierarchy
83+
else query.hierarchy = true
84+
$router.replace({ name: $route.name, params: $route.params, query })
85+
}
86+
7887
const trustListCallback = () => console.log('trustListCallback')
7988
8089
const $auth = inject(AuthStore)
90+
const $router = useRouter()
91+
const $route = useRoute()
8192
8293
const v = reactive({
8394
authedUser: $auth.user,

0 commit comments

Comments
 (0)