Permalink
Browse files

Change edit/add TODO item labels

  • Loading branch information...
1 parent dc60066 commit b8c5fa3d408734bcc9e6111a680184122e7f87a7 @chischaschos committed Feb 24, 2014
Showing with 22 additions and 13 deletions.
  1. +6 −10 assets/js/todo/templates/new_todo.jst.ejs
  2. +16 −3 assets/js/todo/views/new_todo_view.coffee
@@ -1,33 +1,29 @@
<form id='add-todo-form'>
<fieldset>
<legend>
- Add todo -
+ <%= title %>
<a href='#' id='cancel-todo'>cancel</a>
</legend>
<div id='messages' name='error'></div>
- Description <input type='text' id='description' name='description'
-value="<%= description %>"/>
+ Description <input type='text' id='description' name='description' value="<%= description %>"/>
<div id='description_error' name='error'></div>
<br>
- Priority <input type='text' id='priority' name='priority' value="<%=
-priority %>"/>
+ Priority <input type='text' id='priority' name='priority' value="<%= priority %>"/>
<div id='priority_error' name='error'></div>
<br>
- Completed <input type='checkbox' id='completed' name='completed' value="<%=
-completed %>"/>
+ Completed <input type='checkbox' id='completed' name='completed' value="<%= completed %>"/>
<div id='completed_error' name='error'></div>
<br>
- Due Date <input type='text' id='due_date' name='due_date'
-value="<%= due_date %>"/>
+ Due Date <input type='text' id='due_date' name='due_date' value="<%= due_date %>"/>
<div id='due_date_error' name='error'></div>
<br>
- <input type='submit' value='Create' />
+ <input type='submit' value='<%= action %>' />
</fieldset>
</form>
@@ -7,13 +7,21 @@ class App.NewTodoView extends App.BaseView
'submit #add-todo-form' : 'submitForm'
'change input' : 'changed'
+ messages:
+ edit:
+ title: 'Editing TODO item'
+ action: 'Save'
+ new:
+ title: 'Creating new TODO item'
+ action: 'Create'
+
initialize: (options) ->
@parent = options.parent
if options.model
- @edit = true
+ @type = 'edit'
@model = options.model
else
- @edit = false
+ @type = 'new'
@model = new App.TodoModel
back: (event) ->
@@ -22,7 +30,12 @@ class App.NewTodoView extends App.BaseView
@parent.render()
render: ->
- @$el.html(@template(@model.toJSON().list_item))
+ attributes = _.extend(
+ {},
+ @model.toJSON().list_item,
+ @messages[@type]
+ )
+ @$el.html(@template(attributes))
@
changed: (event) ->

0 comments on commit b8c5fa3

Please sign in to comment.