From f2861a5bc731c66862739020ac10c74be08a4adf Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 6 Feb 2005 14:36:55 +0000 Subject: [PATCH] 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 --- tracks/app/controllers/application.rb | 19 +++------- tracks/app/controllers/context_controller.rb | 20 +++++++++- tracks/app/controllers/project_controller.rb | 20 +++++++++- tracks/app/helpers/application_helper.rb | 11 ------ tracks/app/models/todo.rb | 10 ++--- tracks/app/views/context/_edit_context.rhtml | 8 ++++ tracks/app/views/context/edit.rhtml | 12 ++++++ tracks/app/views/context/list.rhtml | 4 +- tracks/app/views/layouts/standard.rhtml | 1 + tracks/app/views/project/_edit_project.rhtml | 5 +++ tracks/app/views/project/edit.rhtml | 12 ++++++ tracks/app/views/project/list.rhtml | 2 +- tracks/app/views/todo/_item.rhtml | 13 ++++--- tracks/app/views/todo/edit.rhtml | 2 +- tracks/app/views/todo/list.rhtml | 1 - tracks/doc/CHANGENOTES.txt | 3 ++ tracks/public/.htaccess | 2 +- tracks/public/favicon.ico | Bin 0 -> 1406 bytes tracks/public/stylesheets/standard.css | 37 ++++++++++++++----- 19 files changed, 128 insertions(+), 54 deletions(-) create mode 100644 tracks/app/views/context/_edit_context.rhtml create mode 100644 tracks/app/views/context/edit.rhtml create mode 100644 tracks/app/views/project/_edit_project.rhtml create mode 100644 tracks/app/views/project/edit.rhtml create mode 100644 tracks/public/favicon.ico diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index fec00457..60208eef 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -6,23 +6,14 @@ require_dependency "redcloth" require_dependency "iCal" require 'date' -$delete_img = "" -$edit_img = "" -$notes_img = "" -$done_img = "" +$delete_img = "" +$edit_img = "" +$notes_img = "" +$done_img = "" 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 \ No newline at end of file diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index 56e6cc0d..e8e0bd91 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -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. /context/show/ shows just . # diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index b38911e3..74706851 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -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 # diff --git a/tracks/app/helpers/application_helper.rb b/tracks/app/helpers/application_helper.rb index b350c528..f51db968 100644 --- a/tracks/app/helpers/application_helper.rb +++ b/tracks/app/helpers/application_helper.rb @@ -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 diff --git a/tracks/app/models/todo.rb b/tracks/app/models/todo.rb index 2ce2f6f8..b9c1721b 100644 --- a/tracks/app/models/todo.rb +++ b/tracks/app/models/todo.rb @@ -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 diff --git a/tracks/app/views/context/_edit_context.rhtml b/tracks/app/views/context/_edit_context.rhtml new file mode 100644 index 00000000..4c96fbe6 --- /dev/null +++ b/tracks/app/views/context/_edit_context.rhtml @@ -0,0 +1,8 @@ +<%= hidden_field( "context", "id" ) %> +
+<%= text_field( "context", "name" ) %> +
+ +<%= check_box( "context", "hide" ) %> +
+
\ No newline at end of file diff --git a/tracks/app/views/context/edit.rhtml b/tracks/app/views/context/edit.rhtml new file mode 100644 index 00000000..9d47fefb --- /dev/null +++ b/tracks/app/views/context/edit.rhtml @@ -0,0 +1,12 @@ +
+

Edit context

+
+ <%= render_partial "edit_context", "@context" %> + +
+ + <%= link_to 'Cancel', :action => 'list' %> +
+ +<% if @flash["confirmation"] %>
<%= @flash["confirmation"] %>
<% end %> +<% if @flash["warning"] %>
<%= @flash["warning"] %>
<% end %> diff --git a/tracks/app/views/context/list.rhtml b/tracks/app/views/context/list.rhtml index ecc6b0e4..a8f86a17 100644 --- a/tracks/app/views/context/list.rhtml +++ b/tracks/app/views/context/list.rhtml @@ -26,14 +26,14 @@
-

Add context


<%= text_field("new_context", "name") %>
-
+ <%= check_box( "new_context", "hide" ) %>
+
diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index ec21696e..123df133 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -7,6 +7,7 @@ + <%= @page_title %> diff --git a/tracks/app/views/project/_edit_project.rhtml b/tracks/app/views/project/_edit_project.rhtml new file mode 100644 index 00000000..e2d377af --- /dev/null +++ b/tracks/app/views/project/_edit_project.rhtml @@ -0,0 +1,5 @@ +<%= hidden_field( "project", "id" ) %> +
+<%= text_field( "project", "name" ) %> +
+
\ No newline at end of file diff --git a/tracks/app/views/project/edit.rhtml b/tracks/app/views/project/edit.rhtml new file mode 100644 index 00000000..8f73008a --- /dev/null +++ b/tracks/app/views/project/edit.rhtml @@ -0,0 +1,12 @@ +
+

Edit project

+
+ <%= render_partial "edit_project", "@project" %> + +
+ + <%= link_to 'Cancel', :action => 'list' %> +
+ +<% if @flash["confirmation"] %>
<%= @flash["confirmation"] %>
<% end %> +<% if @flash["warning"] %>
<%= @flash["warning"] %>
<% end %> diff --git a/tracks/app/views/project/list.rhtml b/tracks/app/views/project/list.rhtml index ba936023..7d4d0453 100644 --- a/tracks/app/views/project/list.rhtml +++ b/tracks/app/views/project/list.rhtml @@ -19,11 +19,11 @@
-

Add project


<%= text_field( "new_project", "name" ) %>
+
diff --git a/tracks/app/views/todo/_item.rhtml b/tracks/app/views/todo/_item.rhtml index bd12a8b9..d1736f7b 100644 --- a/tracks/app/views/todo/_item.rhtml +++ b/tracks/app/views/todo/_item.rhtml @@ -1,12 +1,12 @@ <%= hidden_field( "item", "id" ) %>
-<%= text_field( "item", "description" ) %> +<%= text_field( "item", "description", "tabindex" => 1 ) %>

-<%= text_area( "item", "notes", "cols" => 35, "rows" => 15 ) %> +<%= text_area( "item", "notes", "tabindex" => 2, "cols" => 35, "rows" => 15 ) %>

- <% for @place in @places %> <% if @item %> <% if @place.id == @item.context_id %> @@ -21,7 +21,7 @@

- <% if @belongs == nil %> <% end %> @@ -35,6 +35,7 @@ <% end %>
-
-<%= date_select( "item", "due", :include_blank => true ) %> +
+<%= date_select( "item", "due", :include_blank => true, "tabindex" => 5 ) %> +

diff --git a/tracks/app/views/todo/edit.rhtml b/tracks/app/views/todo/edit.rhtml index fefddad0..6ebc65c7 100644 --- a/tracks/app/views/todo/edit.rhtml +++ b/tracks/app/views/todo/edit.rhtml @@ -1,5 +1,5 @@
-

Update task

+

Edit task

<%= render_partial "todo/item", "@item" %> diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index ce7bccd7..cced3b8e 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -27,7 +27,6 @@
-

Add next action

<%= render_partial "todo/item", @item %> diff --git a/tracks/doc/CHANGENOTES.txt b/tracks/doc/CHANGENOTES.txt index a1eacb9f..fee53359 100644 --- a/tracks/doc/CHANGENOTES.txt +++ b/tracks/doc/CHANGENOTES.txt @@ -13,6 +13,9 @@ Project 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 diff --git a/tracks/public/.htaccess b/tracks/public/.htaccess index 5dd8ecd6..ab6f0e83 100644 --- a/tracks/public/.htaccess +++ b/tracks/public/.htaccess @@ -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] diff --git a/tracks/public/favicon.ico b/tracks/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..861f34a38418986a1a91da26c4bcef0d6fadd431 GIT binary patch literal 1406 zcmeHFS4@*p6#jli#f=O1M#WJFA}wuYi*0}S8D&&NRB+ZowN?~y<08hG=!;PkMJ0&h zh?JI=s_{vUsDN<*iXeo@&?uBDEv={En~y%3cy8_)UvBRG&UY@r&~kG_mu=_;xKrjy z+X+pg&A^pB5WsYWKb*tiz?z3~xLcivcVA!QWa$AcE$~6Jr4i|mw;=oNIm8>5;C`JR zW}6wGT0i2@voxH2m4(vg5^zQ_5{n~{SCtKmxdX~aiRkF;z=!XZh|~w+blDL|4SeKO zUIeEVqrqH(G6gBaZYkc(3<58_PO3E1pbND2g~X|0A-?+dn2h$ur4?$z8xW=R^jA~E$5 z0ISW4>Tgw$>G%jM5+cqRiiBboD@+{hb_eVZJKAmSXt$ctVrfE?sRzlIxCSCCtE8P_T^4}5 zX9saGQ%@3_kEDPPDcvv83Q%vZrCdO7QPc^DqX4xur&{WXEfkR+La;g!!t_FL#DgPE zI0Hq}w!Gy9%1DWj6}(J%^@;m z3YlxfJQs#pki73V5We3p(8;*}ghUOGr%712)LGF9uYjrJ_Ri;zRCd=4voUtrz%BBw I>Tf6b3o`IY8vp