fantasia-archive/src/layouts/DocumentLayout.vue

191 lines
4.1 KiB
Vue
Raw Normal View History

2021-03-04 13:27:07 +13:00
<template>
<q-layout view="hHh LpR lfr">
<!-- Header -->
2021-04-03 12:33:49 +13:00
<appHeader/>
2021-03-04 13:27:07 +13:00
2021-03-18 10:26:08 +13:00
<q-splitter
v-model="splitterModel"
unit="px"
emit-immediately
:class="splitterClass"
@input="onChange"
:limits="[limiterWidth, Infinity]"
2021-03-18 10:26:08 +13:00
class="pageSplitter"
2021-03-04 13:27:07 +13:00
>
<template
v-if="!hideHierarchyTree"
#before>
2021-03-18 10:26:08 +13:00
<!-- Left drawer -->
<q-drawer
content-class="bg-dark text-cultured sideWrapper"
v-model="leftDrawerOpen"
side="left"
2021-04-06 01:28:33 +12:00
:width="splitterModel"
2021-03-18 10:26:08 +13:00
:breakpoint="0"
show-if-above
>
<objectTree
/>
2021-03-18 10:26:08 +13:00
</q-drawer>
</template>
<template #after>
<q-page-container :style="compPadding">
<documentControl/>
<transition
enter-active-class="animated fadeIn"
leave-active-class="animated fadeOut"
appear
2021-04-03 12:33:49 +13:00
:duration="50"
2021-03-18 10:26:08 +13:00
>
<router-view :key="$route.path" />
</transition>
</q-page-container>
</template>
</q-splitter>
2021-03-04 13:27:07 +13:00
</q-layout>
</template>
<script lang="ts">
2021-03-18 10:26:08 +13:00
import { Component, Watch } from "vue-property-decorator"
2021-03-04 13:27:07 +13:00
import BaseClass from "src/BaseClass"
import objectTree from "src/components/ObjectTree.vue"
import appHeader from "src/components/AppHeader.vue"
import documentControl from "src/components/DocumentControl.vue"
2021-03-18 10:26:08 +13:00
import { extend } from "quasar"
import { OptionsStateInteface } from "src/store/module-options/state"
2021-03-04 13:27:07 +13:00
@Component({
components: {
objectTree,
appHeader,
documentControl
}
})
export default class DocumentLayout extends BaseClass {
/****************************************************************/
2021-04-06 01:28:33 +12:00
// BASIC COMPONENT DATA
2021-03-04 13:27:07 +13:00
/****************************************************************/
/**
* Model for the left drawer of the app containing the hierarchical tree
*/
leftDrawerOpen = true
2021-03-18 10:26:08 +13:00
2021-04-06 01:28:33 +12:00
/**
* Width of the splitted model
*/
splitterModel = 375
/**
* Special class for the splitter
*/
get splitterClass () {
return !this.leftDrawerOpen ? "splitt" : ""
}
/**
* Special padding reset for the main page
*/
get compPadding () {
return this.leftDrawerOpen ? { paddingLeft: "0px" } : ""
}
2021-03-18 10:26:08 +13:00
2021-04-06 01:28:33 +12:00
/****************************************************************/
// LOCAL SETTINGS
/****************************************************************/
2021-03-18 10:26:08 +13:00
2021-04-06 01:28:33 +12:00
/**
* React to changes on the options store
*/
2021-03-18 10:26:08 +13:00
@Watch("SGET_options", { immediate: true, deep: true })
onSettingsChange () {
const options = this.SGET_options
this.hideHierarchyTree = options.hideHierarchyTree
if (options.treeWidth && !this.hideHierarchyTree) {
2021-03-18 10:26:08 +13:00
this.splitterModel = options.treeWidth
}
else {
this.splitterModel = 0
}
2021-03-18 10:26:08 +13:00
}
get limiterWidth () {
return (!this.hideHierarchyTree) ? 374 : 0
}
hideHierarchyTree = false
2021-04-06 01:28:33 +12:00
/****************************************************************/
// OPTTION UPDATER
/****************************************************************/
2021-03-18 10:26:08 +13:00
2021-04-06 01:28:33 +12:00
/**
* Debounce timer to prevent infinite dragging
*/
2021-03-18 10:26:08 +13:00
pullTimer = null as any
2021-04-06 01:28:33 +12:00
/**
* Snapshop of the current settings in the store for further modification
*/
optionsSnapShot = {} as OptionsStateInteface
/**
* React to dragging of the splitter
*/
2021-03-18 10:26:08 +13:00
onChange (value: number) {
this.leftDrawerOpen = value > 0
2021-04-06 01:28:33 +12:00
this.optionsSnapShot = extend(true, {}, this.SGET_options)
2021-03-18 10:26:08 +13:00
2021-04-06 01:28:33 +12:00
this.optionsSnapShot.treeWidth = this.splitterModel
2021-03-18 10:26:08 +13:00
clearTimeout(this.pullTimer)
this.pullTimer = setTimeout(() => {
2021-04-06 01:28:33 +12:00
this.SSET_options(this.optionsSnapShot)
2021-03-18 10:26:08 +13:00
}, 500)
}
2021-03-04 13:27:07 +13:00
}
2021-03-18 10:26:08 +13:00
2021-03-04 13:27:07 +13:00
</script>
<style lang="scss">
2021-04-17 00:46:34 +12:00
.sideWrapper {
height: calc(100% - 40px) !important;
}
2021-03-04 13:27:07 +13:00
.q-layout {
outline: none !important;
}
2021-03-18 10:26:08 +13:00
.splitt {
.q-splitter__before {
transition: width 0.2s ease-out;
width: 0 !important;
}
}
.pageSplitter {
aside {
height: calc(100% - 55px) !important;
margin-top: 55px !important;
}
.q-splitter__separator {
background-color: transparent;
height: calc(100vh - 95px);
bottom: 0;
top: 95px;
2021-04-17 00:46:34 +12:00
position: sticky;
2021-03-18 10:26:08 +13:00
}
}
2021-03-04 13:27:07 +13:00
</style>