test on empty task-text entry, for #330

This commit is contained in:
Tyler Renelle 2013-02-11 13:12:15 -05:00
parent edee8d2719
commit 031b4029c6
2 changed files with 11 additions and 11 deletions

View file

@ -43,8 +43,10 @@ module.exports.app = (appExports, model) ->
list = model.at "_#{type}List"
newModel = model.at('_new' + type.charAt(0).toUpperCase() + type.slice(1))
text = newModel.get()
# Don't add a blank todo
return if /^(\s)*$/.test(text)
# Don't add a blank task
if /^(\s)*$/.test(text)
console.error "Task text entered was an empty string."
return
newModel.set ''
switch type

View file

@ -308,22 +308,20 @@ do a find for the string after "→"
<!--helpTitle & helpContent moved to tour -->
<div class="span3 well habits">
<h2>Habits</h2>
<!--removing for now, help-info in the tour instead-->
<!--<span class="help-icon" rel="popover" data-placement="bottom" data-trigger="hover" data-original-title="{{{helpTitle}}}" data-content="{{{helpContent}}}"><i class="icon-question-sign"></i></span>-->
<app:newTask type=habit><input value={_newHabit} type="text" name=new-task placeholder="New Habit"/></app:newTask>
<ul class='habits'>{#each _habitList as :task}<app:task />{/}</ul>
<app:newTask type="habit"><input value="{_newHabit}" type="text" name="new-task" placeholder="New Habit"/></app:newTask>
<ul class="habits">{#each _habitList as :task}<app:task />{/}</ul>
</div>
<div class="span3 well dailys">
<h2>Daily</h2>
<app:newTask type=daily><input value={_newDaily} type="text" name=new-task placeholder="New Daily"/></app:newTask>
<app:newTask type="daily"><input value={_newDaily} type="text" name=new-task placeholder="New Daily"/></app:newTask>
<ul class='dailys'>{#each _dailyList as :task}<app:task />{/}</ul>
</div>
<div class="span3 well todos context-enabled context-uncompleted tabbable tabs-below" id="todo-well">
<h2>Todos</h2>
<div class="display-context-dependant show-for-uncompleted">
<app:newTask type=todo><input value={_newTodo} type="text" name=new-task placeholder="New Todo"/></app:newTask>
<app:newTask type="todo"><input value={_newTodo} type="text" name=new-task placeholder="New Todo"/></app:newTask>
</div>
<ul class='todos task-list'>
{#each _todoList as :task}<app:task />{/}
@ -363,7 +361,7 @@ do a find for the string after "→"
{/}
</div>
</div>
<app:newTask type=reward><input value={_newReward} type="text" name=new-task placeholder="New Reward"/></app:newTask>
<app:newTask type="reward"><input value={_newReward} type="text" name=new-task placeholder="New Reward"/></app:newTask>
{#if _user.flags.petsEnabled}
<div class='tabbable tabs-below'>
@ -523,9 +521,9 @@ do a find for the string after "→"
<!--<span class="well pull-right">Tokens: {tokens(_user.balance)}</span>-->
<newTask: nonvoid>
<form class="form-inline new-task-form" id=new-{{@type}} data-task-type={{@type}} x-bind=submit:addTask>
<form class="form-inline new-task-form" id="new-{{@type}}" data-task-type="{{@type}}" x-bind="submit:addTask">
{{@content}}
<input class="btn" type=submit value=Add />
<input class="btn" type="submit" value="Add" />
</form>
<task:>