refactor: vuex re-org + modal-create-page
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<template lang="pug">
|
||||
.modal(v-if='isShown')
|
||||
.modal(v-bind:class='{ "is-active": isShown }')
|
||||
.modal-background
|
||||
.modal-container
|
||||
.modal-content
|
||||
header.is-light-blue Create New Document
|
||||
section
|
||||
label.label Enter the new document path:
|
||||
p.control.is-fullwidth(v-class='{ "is-loading": isLoading }')
|
||||
p.control.is-fullwidth(v-bind:class='{ "is-loading": isLoading }')
|
||||
input.input(type='text', placeholder='page-name', v-model='entrypath', autofocus)
|
||||
span.help.is-danger(v-show='isInvalid') This document path is invalid!
|
||||
footer
|
||||
@@ -15,30 +15,29 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isEmpty } from 'lodash'
|
||||
// import { makeSafePath } from '../helpers/pages'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'modal-create',
|
||||
name: 'modal-create-page',
|
||||
props: ['basepath'],
|
||||
data () {
|
||||
return {
|
||||
isLoading: false
|
||||
}
|
||||
},
|
||||
computed: mapState('createPage', {
|
||||
entrypath: '',
|
||||
isShown: 'shown',
|
||||
isInvalid: 'invalid'
|
||||
}),
|
||||
computed: {
|
||||
entrypath () { return this.$store.state.modalCreatePage.entrypath }
|
||||
isShown () { return this.$store.state.modalCreatePage.shown }
|
||||
isInvalid () { return this.$store.state.modalCreatePage.invalid }
|
||||
},
|
||||
methods: {
|
||||
cancel: function () {
|
||||
this.$store.dispatch('createPageClose')
|
||||
this.$store.dispatch('modalCreatePage/close')
|
||||
},
|
||||
create: function () {
|
||||
this.isInvalid = false
|
||||
let newDocPath = makeSafePath(this.entrypath)
|
||||
if (isEmpty(newDocPath)) {
|
||||
let newDocPath = this.helpers.pages.makeSafePath(this.entrypath)
|
||||
if (this._.isEmpty(newDocPath)) {
|
||||
this.$store.createPage.commit('')
|
||||
} else {
|
||||
this.isLoading = true
|
||||
@@ -47,7 +46,7 @@
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
// this.entrypath = currentBasePath + '/new-page'
|
||||
this.$store.commit('modalCreatePage/pathChange', this.basepath + '/new-page')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'admin-users-create',
|
||||
name: 'modal-create-user',
|
||||
data () {
|
||||
return {
|
||||
email: '',
|
||||
@@ -48,12 +48,12 @@
|
||||
},
|
||||
computed: {
|
||||
isShown () {
|
||||
return this.$store.state.adminUsersCreate.shown
|
||||
return this.$store.state.modalCreateUser.shown
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cancel () {
|
||||
this.$store.dispatch('adminUsersCreateClose')
|
||||
this.$store.dispatch('modalCreateUser/close')
|
||||
this.email = ''
|
||||
this.provider = 'local'
|
||||
},
|
||||
|
@@ -1,13 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
import $ from 'jquery'
|
||||
import delay from 'lodash/delay'
|
||||
import _ from 'lodash'
|
||||
|
||||
module.exports = {
|
||||
|
||||
complete () {
|
||||
complete() {
|
||||
$('#page-loader').addClass('is-loaded')
|
||||
delay(() => {
|
||||
_.delay(() => {
|
||||
$('#page-loader').addClass('is-hidden')
|
||||
}, 1100)
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as _ from 'lodash'
|
||||
import * as $ from 'jquery'
|
||||
|
||||
export default {
|
||||
@@ -44,7 +43,7 @@
|
||||
socket.emit('search', { terms: val }, (data) => {
|
||||
self.searchres = data.match
|
||||
self.searchsuggest = data.suggest
|
||||
self.searchmovearr = _.concat([], self.searchres, self.searchsuggest)
|
||||
self.searchmovearr = self._.concat([], self.searchres, self.searchsuggest)
|
||||
if (self.searchload > 0) { self.searchload-- }
|
||||
})
|
||||
} else {
|
||||
|
@@ -15,8 +15,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as _ from 'lodash'
|
||||
|
||||
export default {
|
||||
name: '',
|
||||
data () {
|
||||
@@ -31,9 +29,9 @@
|
||||
self.$nextTick(() => {
|
||||
socket.emit('treeFetch', { basePath }, (data) => {
|
||||
if (self.tree.length > 0) {
|
||||
let branch = _.last(self.tree)
|
||||
let branch = self._.last(self.tree)
|
||||
branch.hasChildren = true
|
||||
_.find(branch.pages, { _id: basePath }).isActive = true
|
||||
self._.find(branch.pages, { _id: basePath }).isActive = true
|
||||
}
|
||||
self.tree.push({
|
||||
hasChildren: false,
|
||||
@@ -49,14 +47,14 @@
|
||||
unfold (entryPath) {
|
||||
let self = this
|
||||
let lastIndex = 0
|
||||
_.forEach(self.tree, branch => {
|
||||
self._.forEach(self.tree, branch => {
|
||||
lastIndex++
|
||||
if (_.find(branch.pages, { _id: entryPath }) !== undefined) {
|
||||
if (self._.find(branch.pages, { _id: entryPath }) !== undefined) {
|
||||
return false
|
||||
}
|
||||
})
|
||||
self.tree = _.slice(self.tree, 0, lastIndex)
|
||||
let branch = _.last(self.tree)
|
||||
self.tree = self._.slice(self.tree, 0, lastIndex)
|
||||
let branch = self._.last(self.tree)
|
||||
branch.hasChildren = false
|
||||
branch.pages.forEach(page => {
|
||||
page.isActive = false
|
||||
|
Reference in New Issue
Block a user