cabinet/frontend/src/views/Console.vue

121 lines
3.0 KiB
Vue
Raw Normal View History

2019-10-31 15:14:27 +00:00
<template>
2019-11-01 17:09:17 +00:00
<b-container fluid>
<b-row>
<b-col md="5">
2019-11-16 13:49:07 +00:00
<div>
<b-tabs content-class="mt-3">
<b-tab active>
<template v-slot:title>
Scratchpad
</template>
<ScratchPad />
</b-tab>
</b-tabs>
</div>
2019-11-01 17:09:17 +00:00
</b-col>
2019-11-16 13:49:07 +00:00
2019-11-01 17:09:17 +00:00
<b-col md="5">
2019-11-08 01:54:00 +00:00
<div>
2019-11-08 04:39:16 +00:00
<b-tabs content-class="mt-3" v-model="tabIndex">
2019-11-08 01:54:00 +00:00
<b-tab active>
<template v-slot:title>
Editor <span v-bind:class="{ dirty: isDirty, clean: !isDirty }">&bull;</span>
</template>
<MainEditor :slug="$route.params.slug" @markDirty="markDirty"/>
</b-tab>
<b-tab title="Viewer">
<MainView :slug="$route.params.slug" />
</b-tab>
</b-tabs>
</div>
2019-11-01 17:09:17 +00:00
</b-col>
<b-col md="2">
2019-11-16 13:49:07 +00:00
<div>
<b-tabs content-class="mt-3">
<b-tab active>
<template v-slot:title>
Search
</template>
<SearchResults :editMode="true" target="console-slug" />
</b-tab>
</b-tabs>
</div>
2019-11-01 17:09:17 +00:00
</b-col>
</b-row>
</b-container>
2019-10-31 15:14:27 +00:00
</template>
<script>
// @ is an alias to /src
2019-11-01 17:09:17 +00:00
import MainEditor from "../components/MainEditor";
2019-11-08 01:54:00 +00:00
import MainView from "../components/MainView";
2019-11-01 17:09:17 +00:00
import ScratchPad from "../components/ScratchPad";
import SearchResults from "../components/Search";
2019-10-31 15:14:27 +00:00
export default {
name: 'home',
components: {
2019-11-01 17:09:17 +00:00
SearchResults,
ScratchPad,
2019-11-08 01:54:00 +00:00
MainEditor,
MainView
},
data: function() {
return {
isDirty: false,
2019-11-08 04:39:16 +00:00
tabIndex: 0
2019-11-08 01:54:00 +00:00
}
},
methods: {
markDirty: function(dirty) {
this.isDirty = dirty
}
},
beforeRouteEnter (to, from, next) {
// called before the route that renders this component is confirmed.
// does NOT have access to `this` component instance,
// because it has not been created yet when this guard is called!
next()
},
beforeRouteUpdate (to, from, next) {
// called when the route that renders this component has changed,
// but this component is reused in the new route.
// For example, for a route with dynamic params `/foo/:id`, when we
// navigate between `/foo/1` and `/foo/2`, the same `Foo` component instance
// will be reused, and this hook will be called when that happens.
// has access to `this` component instance.
if (this.isDirty) {
const answer = window.confirm('Do you really want to leave? you have unsaved changes!')
if (answer) {
next()
} else {
next(false)
}
}
2019-11-08 04:39:16 +00:00
this.tabIndex = 0
2019-11-08 01:54:00 +00:00
next()
},
beforeRouteLeave (to, from, next) {
// called when the route that renders this component is about to
// be navigated away from.
// has access to `this` component instance.
next()
2019-10-31 15:14:27 +00:00
}
}
</script>
2019-11-01 17:09:17 +00:00
<style scoped>
h2 {
font-size: large;
}
2019-11-08 01:54:00 +00:00
.dirty {
color: red;
}
.clean {
display: none;
}
2019-11-01 17:09:17 +00:00
</style>