Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sunzhengjie committed Oct 28, 2017
1 parent 13a8ffa commit 3f2cf01
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ui/src/external/index.js
Expand Up @@ -66,7 +66,7 @@ function render({appName, pageName}, token) {
}
}
store.commit('soulModule/setPageSoul', pageSoul)
store.commit('soulModule/setSoul', pageSoul['/index'])
store.commit('soulModule/setSoul', pageSoul['index'])

if(!getConfig('type')){
Vue.directive('droppable',emptyDirective)
Expand Down
10 changes: 4 additions & 6 deletions ui/src/helper/user_operation.js
Expand Up @@ -73,18 +73,16 @@ function clear() {
})
}

function init(draggableControls,isDel) {
function init(draggableControls) {

let dropPanelSoul = findSoul(100, draggableControls),
copy = deepCopy(dropPanelSoul);//before drop ,must copy drag control
copy.uid = generateUid() //dropped control has unique uid

store.commit('dragModule/setSoul', copy)
if(isDel){
store.commit('dragModule/setPageSoul', {pageSoul:{}})//now we have no pages
}else {
store.commit('dragModule/setPageSoul', {pageSoul:copy})//now we have no pages
}

let pageSoul = {'index':copy}
store.commit('dragModule/setPageSoul', {pageSoul})//now we have no pages
}

function saveSoul() {
Expand Down
1 change: 0 additions & 1 deletion ui/src/resource/assemble_resource.js
Expand Up @@ -108,7 +108,6 @@ function delPage(id) {

function updatePage() {
let pageSoul = store.getters['dragModule/pageSoul']

resetModel(pageSoul)
pageSoul.maxUid = currentUid()
this.opModel.pageSoul = stringify(pageSoul)
Expand Down
26 changes: 18 additions & 8 deletions ui/src/store/drag_module.js
@@ -1,4 +1,4 @@
import {generateUid} from '../helper/soul_helper'
import {generateUid, findSoul} from '../helper/soul_helper'
import {deepCopy, getQueryParam,isPlain} from '../util/assist'

export default {
Expand Down Expand Up @@ -35,14 +35,24 @@ export default {
state.pageSoul[state.currentRouterPath] = soul
},
setPageSoul(state, {pageSoul}){
if(!isPlain(pageSoul)){
state.soul = pageSoul['index']
state.pageSoul = pageSoul
}else {
for(let key in state.pageSoul){
delete pageSoul[key]
}
let copy = deepCopy(pageSoul)
//vue bug
delete state.pageSoul
delete state.pageSoul
state.soul = copy['index']
state.pageSoul = copy
},
clearPageSoul(state){
for(let key in state.pageSoul){
//maybe vue's bug
delete state.pageSoul[key]
delete state.pageSoul[key]
}
let dropPanelSoul = findSoul(100, this.draggableControls),
copy = deepCopy(dropPanelSoul);//before drop ,must copy drag control
copy.uid = generateUid() //dropped control has unique uid
state.soul = copy
state.pageSoul['index'] = copy
},
setDraggableControls(state, draggableControls){
state.draggableControls = draggableControls
Expand Down
4 changes: 2 additions & 2 deletions ui/src/view/esview/assemble/assemble_page.vue
Expand Up @@ -132,7 +132,7 @@
...mapGetters('dragModule', ['soul', 'editSoul', 'editLayer', 'rightClickMenu', 'draggableControls'])
},
methods: {
...mapMutations('dragModule', ['setSoul', 'clear', 'setDraggableControls', 'setPageSoul', 'setOriginSoul']),
...mapMutations('dragModule', ['setSoul', 'clear', 'setDraggableControls', 'setPageSoul', 'setOriginSoul','clearPageSoul']),
...mapMutations('userModule', ['changePage']),
deleteControl(){
this.editControlSoul = findNode(this.rightClickMenu.uid)
Expand All @@ -141,7 +141,7 @@
let index = pSoul.children.indexOf(this.editControlSoul);
pSoul.children.splice(index,1)
}else {
init(this.draggableControls,true)
store.commit('dragModule/clearPageSoul')
}
this.clear()
saveSoul()
Expand Down

0 comments on commit 3f2cf01

Please sign in to comment.