Reverted input field back to richtext because of line wrapping issues

Added priority, project, and context selection to the edit view
Fixed replace flag when closing popups to avoid race conditions
This commit is contained in:
Morgan McMillian 2012-03-11 15:04:46 -04:00
parent 23991a26de
commit 7316f8c67e
3 changed files with 123 additions and 3 deletions

View file

@ -22,9 +22,28 @@ enyo.kind({
"onSave": ""
},
components: [
{name: "insertPopup", kind: "ModalDialog", dismissWithClick: true,
components: [
{name: "projects", kind: "RowGroup", caption: "Projects"},
{name: "contexts", kind: "RowGroup", caption: "Contexts"},
{kind: "Button", caption: "Dismiss", onclick: "closePopup"}
]},
{name: "filterToolbar", kind: "Toolbar", pack: "justify", className: "enyo-toolbar-light",
components: [
{kind: "RadioGroup", name: "priGroup",
onChange: "setPriority", components: [
{caption: "-", value: "-"},
{caption: "A", value: "A"},
{caption: "B", value: "B"},
{caption: "C", value: "C"},
{caption: "D", value: "D"},
{caption: "E", value: "E"}
]},
{kind: "Button", caption: "+", onclick: "showInsert"}
]
},
{flex: 1, kind: "Scroller", components: [
{kind: "Input", name: "tododetail"},
{kind: "RichText", name: "tododetail", richContent: false},
]},
{name: "editToolbar", kind: "Toolbar", pack: "justify", className: "enyo-toolbar-light",
components: [
@ -35,6 +54,63 @@ enyo.kind({
]
}
]
],
setPriority: function(inSender) {
var pri = inSender.getValue();
var val = this.$.tododetail.getValue();
val = val.replace(/^\([A-E]\)\s/,"")
if (pri.match(/[A-E]/)) {
this.$.tododetail.setValue(
"(" + pri + ") " + val);
} else {
this.$.tododetail.setValue( val );
}
},
showInsert: function() {
this.$.insertPopup.openAtCenter();
this.projectList = this.owner.$.listView.getProjectList();
for (i=0; i<this.projectList.length; i++) {
var project = this.projectList[i];
var name = project.replace(/^\+/,"PRJ_");
this.$.projects.createComponent(
{content: project, name: name, owner: this,
onclick: "insert"}
);
}
this.$.projects.render();
this.contextList = this.owner.$.listView.getContextList();
for (i=0; i<this.contextList.length; i++) {
var context = this.contextList[i];
var name = context.replace(/^@/,"CTX_");
this.$.contexts.createComponent(
{content: context, name: name, owner: this,
onclick: "insert"}
);
}
this.$.contexts.render();
},
closePopup: function() {
for (i=0; i<this.projectList.length; i++) {
var name = this.projectList[i].replace(/^\+/,"PRJ_");
eval("this.$."+name+".destroy()");
}
this.$.projects.render();
for (i=0; i<this.contextList.length; i++) {
var name = this.contextList[i].replace(/^@/,"CTX_");
eval("this.$."+name+".destroy()");
}
this.$.contexts.render();
this.$.insertPopup.close();
},
insert: function(inSender, inEvent) {
var val = this.$.tododetail.getValue();
this.$.tododetail.setValue(val + " " + inSender.content);
this.closePopup();
this.$.tododetail.forceFocus();
}
});

View file

@ -23,6 +23,9 @@ enyo.kind({
sortOrder: "pri",
cacheChanges: "NO",
searchFilter: null,
priorityList: [],
projectList: [],
contextList: [],
sortedList: undefined
},
events: {
@ -105,6 +108,35 @@ enyo.kind({
var r = this.sortedList[inIndex];
if (r) {
//TODO: currently not used, is it needed in future?
if (this.priorityListReset) {
this.priorityList = [];
this.priorityListReset = false;
}
if (r.pri) {
if (this.priorityList.indexOf(r.pri[0]) == -1)
this.priorityList.push(r.pri[0]);
} //TODO: end quetionable code
if (this.projectListReset) {
this.projectList = [];
this.projectListReset = false;
}
var project = r.detail.match(/\+[^\s]+/);
if (project) {
project = project[0].replace(/\./,"");
if (this.projectList.indexOf(project) == -1)
this.projectList.push(project);
}
if (this.contextListReset) {
this.contextList = [];
this.contextListReset = false;
}
var context = r.detail.match(/\@[^\s]+/);
if (context) {
context = context[0].replace(/\./,"");
if (this.contextList.indexOf(context) == -1)
this.contextList.push(context);
}
var filtered = false;
var s = r.detail.replace(/^x\s/,"");
var s = s.replace(/^\([A-E]\)\s/,"");
@ -134,6 +166,9 @@ enyo.kind({
this.$.todoRow.hide();
}
return true;
} else {
this.priorityListReset = true;
this.projectListReset = true;
}
},
@ -186,6 +221,13 @@ enyo.kind({
},
updateTodoItem: function() {
if (this.owner.todoList[this.selectedId].pri) {
var pri = this.owner.todoList[this.selectedId].pri[0];
pri = pri.replace(/^\(([A-E])\)\s.*$/,"$1");
this.owner.$.editView.$.priGroup.setValue(pri);
} else {
this.owner.$.editView.$.priGroup.setValue("-");
}
this.owner.$.editView.$.tododetail.setValue(this.owner.todoList[this.selectedId].detail);
this.replaceItem = true;
this.owner.showEditView();

View file

@ -200,6 +200,7 @@ enyo.kind({
this.$.viewTitle.setContent("update task");
} else {
this.$.viewTitle.setContent("add task");
this.$.editView.$.priGroup.setValue("-");
}
this.$.editView.$.tododetail.forceFocus();
},
@ -230,6 +231,7 @@ enyo.kind({
},
closeView: function() {
this.$.listView.setReplaceItem(false);
this.$.editView.$.tododetail.setValue("");
this.$.pane.selectViewByName("listView");
},