Removed the last of the scaffolding from the project and context controllers, which was just supporting the editing of individual context or project names.

Tinkered a bit with the form layout and appearance.



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@18 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-02-06 14:36:55 +00:00
parent 14298d1787
commit f2861a5bc7
19 changed files with 128 additions and 54 deletions

View file

@ -6,23 +6,14 @@ require_dependency "redcloth"
require_dependency "iCal"
require 'date'
$delete_img = "<img src=\"/images/delete.png\" width=\"10\" height=\"10\" />"
$edit_img = "<img src=\"/images/edit.png\" width=\"10\" height=\"10\" />"
$notes_img = "<img src=\"/images/notes.png\" width=\"10\" height=\"10\" />"
$done_img = "<img src=\"/images/done.png\" width=\"16\" height=\"16\" />"
$delete_img = "<img src=\"/images/delete.png\" width=\"10\" height=\"10\" border=\"0\" />"
$edit_img = "<img src=\"/images/edit.png\" width=\"10\" height=\"10\" border=\"0\" />"
$notes_img = "<img src=\"/images/notes.png\" width=\"10\" height=\"10\" border=\"0\" />"
$done_img = "<img src=\"/images/done.png\" width=\"16\" height=\"16\" border=\"0\" />"
class ApplicationController < ActionController::Base
helper :application
include LoginSystem
# Convert a date entered in the format in settings.yml
# to database-compatible YYYY-MM-DD format
def date_to_YMD(date)
date_fmt = app_configurations["formats"]["date"]
formatted_date = DateTime.strptime(date, "#{date_fmt}")
formatted_date.strftime("%Y-%m-%d")
end
end

View file

@ -3,7 +3,6 @@ class ContextController < ApplicationController
helper :context
model :project
scaffold :context
before_filter :login_required
# caches_action :list, :show
@ -36,6 +35,25 @@ class ContextController < ApplicationController
end
def edit
@context = Context.find(@params['id'])
@page_title = "Edit context: #{@context.name.capitalize}"
end
def update
@context = Context.find(@params['context']['id'])
@context.attributes = @params['context']
if @context.save
flash["confirmation"] = 'Context was successfully updated'
redirect_to :action => 'list'
else
flash["warning"] = 'Context could not be updated'
redirect_to :action => 'list'
end
end
# Filter the contexts to show just the one passed in the URL
# e.g. <home>/context/show/<context_id> shows just <context_id>.
#

View file

@ -3,7 +3,6 @@ class ProjectController < ApplicationController
helper :project
model :context
model :todo
scaffold :project
before_filter :login_required
# caches_action :list, :show
@ -30,6 +29,25 @@ class ProjectController < ApplicationController
end
def edit
@project = Project.find(@params['id'])
@page_title = "Edit project: #{@project.name.capitalize}"
end
def update
@project = Project.find(@params['project']['id'])
@project.attributes = @params['project']
if @project.save
flash["confirmation"] = 'Project was successfully updated'
redirect_to :action => 'list'
else
flash["warning"] = 'Project could not be updated'
redirect_to :action => 'list'
end
end
# Called by a form button
# Parameters from form fields should be passed to create new project
#

View file

@ -48,15 +48,4 @@ module ApplicationHelper
end
end
def get_projects()
@projects = Project.find_all
return @@projects
end
def get_contexts()
@places = Context.find_all
return @@places
end
end

View file

@ -8,14 +8,12 @@ class Todo < ActiveRecord::Base
validates_presence_of :description, :message => "no description provided"
validates_length_of :description, :maximum => 100, :message => "description is too long"
validates_length_of :notes, :maximum => 60000, :message => "notes are too long"
#validates_format_of :due, :with => /^[\d]{2,2}\/[\d]{2,2}\/[\d]{4,4}$/, :message => "date format incorrect"
# Add a creation date (Ruby object format) to item before it's saved
# if there is no existing creation date (this prevents creation date
# being reset to completion date when item is completed)
#
def before_save
# Add a creation date (Ruby object format) to item before it's saved
# if there is no existing creation date (this prevents creation date
# being reset to completion date when item is completed)
#
if self.created == nil
self.created = Time.now()
end

View file

@ -0,0 +1,8 @@
<%= hidden_field( "context", "id" ) %>
<label for="context_name">Context name</label><br />
<%= text_field( "context", "name" ) %>
<br />
<label for="new_context_on_front">Hide from front page?</label>
<%= check_box( "context", "hide" ) %>
<br />
<br />

View file

@ -0,0 +1,12 @@
<div id="display_box">
<h2>Edit context</h2>
<form action="/context/update" method="post">
<%= render_partial "edit_context", "@context" %>
<input type="submit" value="Update" />
</form>
<%= link_to 'Cancel', :action => 'list' %>
</div>
<% if @flash["confirmation"] %><div class="confirmation"><%= @flash["confirmation"] %></div><% end %>
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>

View file

@ -26,14 +26,14 @@
</div><!- End of display_box -->
<div id="input_box">
<h2>Add context</h2>
<form method="post" action="add_context">
<label for="new_context_name">New context</label><br />
<%= text_field("new_context", "name") %>
<br />
<label for="new_context_one_front">Hide from front page?</label><br />
<label for="new_context_one_front">Hide from front page?</label>
<%= check_box( "new_context", "hide" ) %>
<br />
<br />
<input type="submit" value="Add context">
</form>
</div>

View file

@ -7,6 +7,7 @@
<script type="text/javascript" src="/javascripts/toggle_notes.js"></script>
<script type="text/javascript" language="JavaScript" src="/javascripts/xmlhttp.js"></script>
<link rel="shortcut icon" href="/favicon.ico" />
<title><%= @page_title %></title>
</head>

View file

@ -0,0 +1,5 @@
<%= hidden_field( "project", "id" ) %>
<label for="project_name">Project name</label><br />
<%= text_field( "project", "name" ) %>
<br />
<br />

View file

@ -0,0 +1,12 @@
<div id="display_box">
<h2>Edit project</h2>
<form action="/project/update" method="post">
<%= render_partial "edit_project", "@project" %>
<input type="submit" value="Update" />
</form>
<%= link_to 'Cancel', :action => 'list' %>
</div>
<% if @flash["confirmation"] %><div class="confirmation"><%= @flash["confirmation"] %></div><% end %>
<% if @flash["warning"] %><div class="warning"><%= @flash["warning"] %></div><% end %>

View file

@ -19,11 +19,11 @@
</div><!- End of display_box -->
<div id="input_box">
<h2>Add project</h2>
<form method="post" action="add_project">
<label for="new_project_name">New Project</label><br />
<%= text_field( "new_project", "name" ) %>
<br />
<br />
<input type="submit" value="Add project">
</form>
</div>

View file

@ -1,12 +1,12 @@
<%= hidden_field( "item", "id" ) %>
<label for="item_description">Next action</label><br />
<%= text_field( "item", "description" ) %>
<%= text_field( "item", "description", "tabindex" => 1 ) %>
<br />
<label for="item_notes">Notes</label><br />
<%= text_area( "item", "notes", "cols" => 35, "rows" => 15 ) %>
<%= text_area( "item", "notes", "tabindex" => 2, "cols" => 35, "rows" => 15 ) %>
<br />
<label for="item_context_id">Context</label><br />
<select name="item[context_id]" id="item_context_id">
<select name="item[context_id]" id="item_context_id" tabindex="3">
<% for @place in @places %>
<% if @item %>
<% if @place.id == @item.context_id %>
@ -21,7 +21,7 @@
</select>
<br />
<label for="new_item_project_id">Project</label><br />
<select name="item[project_id]" id="item_project_id">
<select name="item[project_id]" id="item_project_id" tabindex="4">
<% if @belongs == nil %>
<option value="" selected="selected">None</option>
<% end %>
@ -35,6 +35,7 @@
<% end %>
</select>
<br />
<label for="item_due">Due</label><br />
<%= date_select( "item", "due", :include_blank => true ) %>
<label for="item_due" tab>Due</label><br />
<%= date_select( "item", "due", :include_blank => true, "tabindex" => 5 ) %>
<br />
<br />

View file

@ -1,5 +1,5 @@
<div id="display_box">
<h2>Update task</h2>
<h2>Edit task</h2>
<form action="/todo/update" method="post">
<%= render_partial "todo/item", "@item" %>
<input type="submit" value="Update" />

View file

@ -27,7 +27,6 @@
</div><!- End of display_box -->
<div id="input_box">
<h2>Add next action</h2>
<form method="post" action="add_item">
<%= render_partial "todo/item", @item %>
<input type="submit" value="Add item">

View file

@ -13,6 +13,9 @@ Project wiki: <http://www.rousette.org.uk/projects/wiki/>
4. Did a bit of refactoring to try to make page loading a bit more efficient.
5. Added a new row to the context table: 'hide'. This determines whether a particular context gets hidden on the main page. If the checkbox on the add new context form is checked, the context is hidden, and isn't listed on the front (todo/list) page. This is useful for contexts like 'wish list' or 'someday/maybe' that you don't want taking up your attention all the time.
6. Added a list of links to the hidden contexts at the bottom of the page.
7. Changed the method of adding due dates to drop-down option lists. It's more obvious and less error prone than typing in the date. Your preferences for date formatting are still honoured when displaying due dates.
8. Added a favicon, kindly produced by Jim Ray.
9. Added border="0" to the button images to stop Firefox putting a red border around them.
## Version 1.01

View file

@ -10,7 +10,7 @@ RewriteEngine On
RewriteBase /dispatch.fcgi
# Enable this rewrite rule to point to the controller/action that should serve root.
# RewriteRule ^$ /controller/action [R]
RewriteRule ^$ /todo/list [R]
# Add missing slash
RewriteRule ^([-_a-zA-Z0-9]+)$ /$1/ [R]

BIN
tracks/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -44,7 +44,7 @@ a:hover {
#navcontainer {
margin: 15px;
width: 820px;
width: 822px;
}
#navlist {
@ -107,19 +107,22 @@ h2 a:hover {
}
#input_box {
margin: 20px 50px 20px 490px;
margin-left: 490px;
margin-top: 20px;
width: 313px;
padding: 0px 15px 0px 15px;
border: 1px solid #999;
/* border: 1px solid #999; */
}
#input_box h2 {
background: #CCC;
/* background: #CCC;
padding: 5px;
margin-top: 0px;
margin: 0px;
margin-left: -15px;
margin-right: -15px;
color: #fff;
text-shadow: rgba(0,0,0,.4) 0px 2px 5px;
margin-right: -15px;
text-shadow: rgba(0,0,0,.4) 0px 2px 5px; */
color: #999;
}
.box {
@ -257,4 +260,20 @@ table.list {
.next_actions td {
border: none;
padding-bottom: 5px;
}
}
/* Form elements */
form {
border: 1px solid #CCC;
padding: 10px;
margin: 0px;
width: 313px;
}
label {
font-weight: bold;
}
input {
margin-bottom: 5px;
}