Skip to content

Commit

Permalink
various bugsfixed, tag related
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Aug 19, 2014
1 parent c81687b commit 7062bf4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ module.exports = {
view.setActive(closest)
}
},

undo: function (view, model) {
var before
for (var i=this.saved.length-1; i>=0; i--) {
Expand Down Expand Up @@ -266,6 +267,7 @@ module.exports = {
view.setActive(ids[ids.length-1])
}
},

undo: function (view, model) {
var id = this.newids[this.newids.length-1]
var closest = model.closestNonChild(id)
Expand All @@ -278,10 +280,8 @@ module.exports = {
} else {
view.setActive(closest)
}
// view.remove(this.newid)
// this.saved = model.remove(this.newid)
model.clipboard = this.saved
},

redo: function (view, model) {
// var before = model.readd(this.saved)
// view.addTree(this.saved.node, before)
Expand Down
14 changes: 11 additions & 3 deletions skins/workflowy/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ WFModel.prototype.readd = function (saved) {
return before
}

WFModel.prototype.dumpData = function (id, noids) {
var data = Model.prototype.dumpData.call(this, id, noids)
if (!noids) return data
delete data.meta.references
delete data.meta.tags
return data
}

WFModel.prototype.remove = function (id) {
// remove the references and tags

Expand All @@ -99,9 +107,6 @@ WFModel.prototype.remove = function (id) {
var ids = this.ids

function process(node) {
for (var i=0; i<node.children.length; i++) {
process(ids[node.children[i]])
}

if (node.meta.tags) {
node.meta.tags.forEach(function (id) {
Expand All @@ -118,6 +123,9 @@ WFModel.prototype.remove = function (id) {
tags.splice(tags.indexOf(node.id), 1)
})
}
for (var i=0; i<node.children.length; i++) {
process(ids[node.children[i]])
}
}

process(n)
Expand Down
3 changes: 3 additions & 0 deletions skins/workflowy/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,20 @@ Tags.prototype = {
if (!this.value.length) return
var last = this.value.pop()
this.remove(last.id)
this.resetSearch()
},

remove: function (id) {
this.tags.removeChild(this.dom[id])
delete this.dom[id]
},

removeFull: function (id) {
for (var i=0; i<this.value.length; i++) {
if (this.value[i].id === id) {
this.value.splice(i, 1)
this.remove(id)
this.resetSearch()
return
}
}
Expand Down

0 comments on commit 7062bf4

Please sign in to comment.