Update interactive block view login

masks
Warinyourself 4 years ago
parent 1024118066
commit b072663de0

@ -6,6 +6,7 @@ export interface InteractiveBlock {
openAfterDestroy?: InteractiveBlockIds[]; openAfterDestroy?: InteractiveBlockIds[];
closeBeforeMount?: InteractiveBlockIds[]; closeBeforeMount?: InteractiveBlockIds[];
callbackBeforeClose?: Array<() => boolean>; callbackBeforeClose?: Array<() => boolean>;
mayOpen?: () => boolean;
} }
export interface PageTimestamp { export interface PageTimestamp {

@ -31,8 +31,6 @@ export interface AppState extends AppSettings {
users: LightdmUsers[]; users: LightdmUsers[];
} }
let inputErrorTimer: null | any
@Module({ dynamic: true, store, name: 'app' }) @Module({ dynamic: true, store, name: 'app' })
class App extends VuexModule implements AppState { class App extends VuexModule implements AppState {
version = '2.0.0' version = '2.0.0'

@ -6,25 +6,18 @@ import {
Action Action
} from 'vuex-module-decorators' } from 'vuex-module-decorators'
import store from '@/store/index' import store from '@/store/index'
import { InteractiveBlock, InteractiveBlockIds, AppMenu, LoginPosition, AppMenuMain } from '@/models/page' import { InteractiveBlock, InteractiveBlockIds, AppMenu, LoginPosition, AppMenuMain, DialogInterface } from '@/models/page'
import { AppModule } from './app' import { AppModule } from './app'
export interface PageState {
menu: AppMenuMain | AppMenu;
language: string;
languages: string[];
loginPosition: LoginPosition;
activeBlocks: InteractiveBlock[];
interactiveBlocks: InteractiveBlock[];
}
@Module({ dynamic: true, store, name: 'page' }) @Module({ dynamic: true, store, name: 'page' })
class Page extends VuexModule implements PageState { class Page extends VuexModule {
menu: AppMenuMain | AppMenu = { menu: AppMenuMain | AppMenu = {
view: false, view: false,
items: [] items: []
} }
dialog: DialogInterface | null = null
mainTabIndex = 0 mainTabIndex = 0
language = '' language = ''
loginPosition: LoginPosition = 'center' loginPosition: LoginPosition = 'center'
@ -33,7 +26,8 @@ class Page extends VuexModule implements PageState {
interactiveBlocks: InteractiveBlock[] = [ interactiveBlocks: InteractiveBlock[] = [
{ {
id: 'login', id: 'login',
closeBeforeMount: ['settings'] closeBeforeMount: ['settings'],
mayOpen: () => !AppModule.viewThemeOnly
}, },
{ {
id: 'settings', id: 'settings',
@ -79,10 +73,13 @@ class Page extends VuexModule implements PageState {
@Mutation @Mutation
OPEN_ACTIVE_BLOCK(id: InteractiveBlockIds) { OPEN_ACTIVE_BLOCK(id: InteractiveBlockIds) {
const activeBlock = this.interactiveBlocks.find((block) => block.id === id) const activeBlock = this.interactiveBlocks.find((block) => block.id === id)
if (activeBlock) { if (!activeBlock) { return }
const canOpen = activeBlock?.mayOpen ? activeBlock?.mayOpen() : true
if (!canOpen) { return }
this.activeBlocks.push(activeBlock) this.activeBlocks.push(activeBlock)
} }
}
@Mutation @Mutation
CLOSE_ACTIVE_BLOCK(idBlock?: string) { CLOSE_ACTIVE_BLOCK(idBlock?: string) {
@ -127,6 +124,19 @@ class Page extends VuexModule implements PageState {
this.SET_STATE_PAGE({ key: 'mainTabIndex', value: updatedTabIndex }) this.SET_STATE_PAGE({ key: 'mainTabIndex', value: updatedTabIndex })
} }
@Action
openFirstBlock() {
for (let i = 0; i < this.interactiveBlocks.length; i++) {
const block = this.interactiveBlocks[i]
const open = block.mayOpen ? block.mayOpen() : true
if (open) {
this.OPEN_ACTIVE_BLOCK(block.id)
break
}
}
}
@Action @Action
async openBlock(settings: { id: InteractiveBlockIds }) { async openBlock(settings: { id: InteractiveBlockIds }) {
settings = settings || {} settings = settings || {}
@ -158,6 +168,7 @@ class Page extends VuexModule implements PageState {
if (!block) { return } if (!block) { return }
const openBlocks = block.openAfterDestroy const openBlocks = block.openAfterDestroy
if (openBlocks) { if (openBlocks) {
openBlocks.forEach((id) => this.OPEN_ACTIVE_BLOCK(id)) openBlocks.forEach((id) => this.OPEN_ACTIVE_BLOCK(id))
} }
@ -171,6 +182,16 @@ class Page extends VuexModule implements PageState {
this.CLOSE_ACTIVE_BLOCK(id) this.CLOSE_ACTIVE_BLOCK(id)
} }
} }
@Action
openDialog(dialog: DialogInterface) {
this.SET_STATE_PAGE({ key: 'dialog', value: dialog })
}
@Action
closeDialog() {
this.SET_STATE_PAGE({ key: 'dialog', value: null })
}
} }
export const PageModule = getModule(Page) export const PageModule = getModule(Page)

@ -5,6 +5,7 @@ import { AppModule } from '@/store/app'
import { PageModule } from '@/store/page' import { PageModule } from '@/store/page'
import AppMenu from '@/components/app/AppMenu' import AppMenu from '@/components/app/AppMenu'
import AppDialog from '@/components/app/AppDialog'
import SettingsComponent from '@/components/base/SettingsComponent' import SettingsComponent from '@/components/base/SettingsComponent'
import LoginComponent from '@/components/base/LoginComponent' import LoginComponent from '@/components/base/LoginComponent'
import FrameRateBlock from '@/components/base/FrameRateBlock' import FrameRateBlock from '@/components/base/FrameRateBlock'
@ -40,6 +41,10 @@ export default class HomePage extends Vue {
return PageModule.isOpenBlock('login') return PageModule.isOpenBlock('login')
} }
get isOpenBlock() {
return !!PageModule.activeBlock
}
get isOpenSettings() { get isOpenSettings() {
return PageModule.isOpenBlock('settings') return PageModule.isOpenBlock('settings')
} }
@ -48,6 +53,14 @@ export default class HomePage extends Vue {
return AppModule.viewThemeOnly return AppModule.viewThemeOnly
} }
get isGithubMode() {
return AppModule.isGithubMode
}
get showGithubButton() {
return this.isGithubMode && this.isOpenBlock
}
get showLogin() { get showLogin() {
return !this.isViewThemeOnly && this.isOpenLogin return !this.isViewThemeOnly && this.isOpenLogin
} }
@ -71,7 +84,7 @@ export default class HomePage extends Vue {
handleClick(event: MouseEvent) { handleClick(event: MouseEvent) {
if (!this.activeBlock) { if (!this.activeBlock) {
return PageModule.openBlock({ id: 'login' }) return PageModule.openFirstBlock()
} }
const target = event.target as Node const target = event.target as Node
@ -98,7 +111,7 @@ export default class HomePage extends Vue {
</transition-group> </transition-group>
{ !this.isViewThemeOnly && <ShutdownButton /> } { !this.isViewThemeOnly && <ShutdownButton /> }
{ !this.isViewThemeOnly && <GithubButton /> } { this.showGithubButton && <GithubButton /> }
<AppMenu /> <AppMenu />
</div> </div>
} }

Loading…
Cancel
Save