From ea7aa9815a7ca6e82efad95ef31f3a5e516a3820 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 23 Sep 2012 21:30:48 -0400 Subject: [PATCH] added edit abilities --- app/assets/stylesheets/application.css | 10 ++++++++++ app/assets/stylesheets/groups.css.scss | 12 ++++++++++-- app/assets/stylesheets/items.css.scss | 12 ++++++++++-- app/assets/stylesheets/people.css.scss | 12 ++++++++++-- app/controllers/items_controller.rb | 13 ++++++++++--- app/views/groups/_group.html.erb | 4 +++- app/views/groups/edit.html.erb | 10 ++++++++++ app/views/groups/new.html.erb | 8 +++++--- app/views/groups/show.html.erb | 19 +++++++++++-------- app/views/items/_item.html.erb | 3 ++- app/views/items/edit.html.erb | 12 ++++++++++++ app/views/items/new.html.erb | 12 ++++++++---- app/views/items/show.html.erb | 15 +++++++++------ app/views/layouts/application.html.erb | 14 ++++++++++---- app/views/people/_person.html.erb | 3 ++- app/views/people/edit.html.erb | 10 ++++++++++ app/views/people/new.html.erb | 10 +++++++--- app/views/people/show.html.erb | 9 +++++---- app/views/sessions/new.html.erb | 11 ++++++----- app/views/users/new.html.erb | 5 ++--- config/database.yml | 24 ++++++++++++------------ 21 files changed, 164 insertions(+), 64 deletions(-) create mode 100644 app/views/groups/edit.html.erb create mode 100644 app/views/items/edit.html.erb create mode 100644 app/views/people/edit.html.erb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 547a4d12..33613cf6 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -26,6 +26,13 @@ h2 {display:block; text-align:center; background: #333; font-size:24px;} a {color:#2d6a5d; text-decoration:none;} .clearfloat {clear:both;} +form { display: block; width: 350px; margin: 0 auto; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; } + +label, select, input, textarea { display:block; } + +label { margin-top:5px; } +input[type="submit"] { margin-top:5px; } + .contentarea p, .contentarea ul , .contentarea ol, .contentarea table {font-size:14px; line-height:1.55em; padding:0.5em 0} .contentarea ul li {padding:0.2em 0; } .contentarea ol li {padding:0.2em 0; } @@ -56,3 +63,6 @@ a {color:#2d6a5d; text-decoration:none;} .focus .desc { font-style:italic; padding:10px; } .focus .desc h3 { font-style:normal; } .focus .link { padding:0 0 0 10px; display:block; width:90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + +.divider { margin: 20px 50px 20px 50px; border-bottom:2px solid #FFF; } +.empty { margin-left:50px; } \ No newline at end of file diff --git a/app/assets/stylesheets/groups.css.scss b/app/assets/stylesheets/groups.css.scss index ebfd0b05..5e6387aa 100644 --- a/app/assets/stylesheets/groups.css.scss +++ b/app/assets/stylesheets/groups.css.scss @@ -2,13 +2,21 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -.group { display:block; float:left; position:relative; width:155px; height:265px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:15px 0 15px 50px; color:#000; } +.group { display:block; float:left; position:relative; width:155px; height:265px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:30px 0 30px 50px; color:#000; } + +.group .type {position: absolute; +color: white; +top: -22px; +right: 0; +font-weight: bold; +font-size: 20px; +line-height: 24px;} .group .icon { position:absolute; top:117px; left:-25px; } .group .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } -.group .desc { font-style:italic; } +.group .desc { font-style:italic; overflow-y:scroll;} .group .desc h3 { font-style:normal; margin-top:5px; } .group .link { position:absolute; width:155px; top:260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } diff --git a/app/assets/stylesheets/items.css.scss b/app/assets/stylesheets/items.css.scss index dab98508..2948309f 100644 --- a/app/assets/stylesheets/items.css.scss +++ b/app/assets/stylesheets/items.css.scss @@ -2,13 +2,21 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -.item { display:block; float:left; position:relative; width:155px; height:265px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:15px 0 15px 50px; color:#000; } +.item { display:block; float:left; position:relative; width:155px; height:265px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:30px 0 30px 50px; color:#000; } + +.item .type {position: absolute; +color: white; +top: -22px; +right: 0; +font-weight: bold; +font-size: 20px; +line-height: 24px;} .item .icon { position:absolute; top:117px; left:-25px; } .item .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } -.item .desc { font-style:italic; } +.item .desc { font-style:italic; overflow-y:scroll;} .item .desc h3 { font-style:normal; margin-top:5px; } .item .link { position:absolute; width:155px; top:260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } diff --git a/app/assets/stylesheets/people.css.scss b/app/assets/stylesheets/people.css.scss index c9b8e210..3a98b641 100644 --- a/app/assets/stylesheets/people.css.scss +++ b/app/assets/stylesheets/people.css.scss @@ -2,13 +2,21 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -.person { display:block; float:left; position:relative; width:155px; height:265px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:15px 0 15px 50px; color:#000; } +.person { display:block; float:left; position:relative; width:155px; height:265px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:30px 0 30px 50px; color:#000; } + +.person .type {position: absolute; +color: white; +top: -22px; +right: 0; +font-weight: bold; +font-size: 20px; +line-height: 24px;} .person .icon { position:absolute; top:117px; left:-25px; } .person .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } -.person .desc { font-style:italic; } +.person .desc { font-style:italic; overflow-y:scroll;} .person .desc h3 { font-style:normal; margin-top:5px; } .person .link { position:absolute; width:155px; top:260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } \ No newline at end of file diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index f9aded64..9a8fab24 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -63,10 +63,17 @@ class ItemsController < ApplicationController def update @user = current_user @item = Item.find_by_id(params[:id]) - @item.attributes = params[:action] if @item - - @item.save if @item + if @item + @item.name = params[:item][:name] + @item.desc = params[:item][:desc] + @item.link = params[:item][:link] + @item.item_category = ItemCategory.find(params[:category]) + @item.user = @user + + @item.save + end + respond_with(@user, location: restore(default: root_url)) do |format| end end diff --git a/app/views/groups/_group.html.erb b/app/views/groups/_group.html.erb index 0f07e4c8..d50a2dbc 100644 --- a/app/views/groups/_group.html.erb +++ b/app/views/groups/_group.html.erb @@ -1,6 +1,8 @@ + <%= div_for group do %> +

Group

<%= image_tag "group.png", :class => 'icon' %> <%= link_to group.name, group_url(group), :class => 'title' %> -

About

<%= group.desc %>
+

<%= group.desc %>

<%= link_to group.link, group.link, :class => 'link' %> <% end %> \ No newline at end of file diff --git a/app/views/groups/edit.html.erb b/app/views/groups/edit.html.erb new file mode 100644 index 00000000..9af4ffdf --- /dev/null +++ b/app/views/groups/edit.html.erb @@ -0,0 +1,10 @@ +<%= form_for @group, url: group_url do |form| %> +

Edit Group

+ + <%= form.text_field :name, label: "Name", class: "name" %> + + <%= form.text_area :desc, label: "Description", class: "description", :rows => 5 %> + + <%= form.text_field :link, label: "Link", class: "link" %> + <%= form.submit "Update", class: "update" %> +<% end %> \ No newline at end of file diff --git a/app/views/groups/new.html.erb b/app/views/groups/new.html.erb index 787b9eb2..00b13075 100644 --- a/app/views/groups/new.html.erb +++ b/app/views/groups/new.html.erb @@ -1,8 +1,10 @@ <%= form_for @group || Group.new, url: groups_path do |form| %> - +

Add Group

+ <%= form.text_field :name, label: "Name", class: "name" %> - <%= form.text_field :desc, label: "Description", class: "description" %> + + <%= form.text_area :desc, label: "Description", class: "description", :rows => 5 %> + <%= form.text_field :link, label: "Link", class: "link" %> <%= form.submit "Add Group", class: "add" %> - <% end %> \ No newline at end of file diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb index eb25f2bf..ba14010c 100644 --- a/app/views/groups/show.html.erb +++ b/app/views/groups/show.html.erb @@ -4,9 +4,8 @@ <%= image_tag "group.png", :class => 'icon' %>
-

<%= @group.name %>

+

<%= @group.name %> <%= link_to "[edit]", edit_group_path(@group) %>

-

About

<%= @group.desc %>

@@ -18,41 +17,45 @@
+
<%= @group.name %> is included in these groups
<% @gparents.each do |group| %> <%= render group %> <% end %> <% if @gparents.empty? %> -


Shucks, there are no groups.

- <% end %> +

Shucks, there are no groups.

+ <% end %>
+
<%= @group.name %> includes these groups
<% @gchildren.each do |group| %> <%= render group %> <% end %> <% if @gchildren.empty? %> -


Shucks, there are no groups.

- <% end %> +

Shucks, there are no groups.

+ <% end %>
+
<%= @group.name %> includes these people
<% @pchildren.each do |people| %> <%= render people %> <% end %> <% if @pchildren.empty? %> -


Shucks, there are no people.

+

Shucks, there are no people.

<% end %>
+
<%= @group.name %> includes these items
<% @ichildren.each do |item| %> <%= render item %> <% end %> <% if @ichildren.empty? %> -


Shucks, there are no items.

+

Shucks, there are no items.

<% end %>
\ No newline at end of file diff --git a/app/views/items/_item.html.erb b/app/views/items/_item.html.erb index 91fa231b..5afb3a3b 100644 --- a/app/views/items/_item.html.erb +++ b/app/views/items/_item.html.erb @@ -1,6 +1,7 @@ <%= div_for item do %> +

<%= item.item_category.name %>

<%= image_tag item.item_category.icon, :class => 'icon' %> <%= link_to item.name, item_url(item), :class => 'title' %> -

About

<%=item.desc %>
+

<%=item.desc %>

<%= link_to item.link, item.link, :class => 'link' %> <% end %> \ No newline at end of file diff --git a/app/views/items/edit.html.erb b/app/views/items/edit.html.erb new file mode 100644 index 00000000..64039cd9 --- /dev/null +++ b/app/views/items/edit.html.erb @@ -0,0 +1,12 @@ +<%= form_for @item, url: item_url do |form| %> +

Edit Item

+ + <%= select_tag "category", options_from_collection_for_select(ItemCategory.all, "id", "name") %> + + <%= form.text_field :name %> + + <%= form.text_area :desc, class: "description", :rows => 5 %> + + <%= form.text_field :link, class: "link" %> + <%= form.submit "Update", class: "update" %> +<% end %> \ No newline at end of file diff --git a/app/views/items/new.html.erb b/app/views/items/new.html.erb index 51a76af8..86e51d70 100644 --- a/app/views/items/new.html.erb +++ b/app/views/items/new.html.erb @@ -1,8 +1,12 @@ <%= form_for @item || Item.new, url: items_path do |form| %> +

Add Item

+ <%= select_tag "category", options_from_collection_for_select(ItemCategory.all, "id", "name") %> - <%= form.text_field :name, label: "Name", class: "name" %> - <%= form.text_field :desc, label: "Description", class: "description" %> - <%= form.text_field :link, label: "Link", class: "link" %> + + <%= form.text_field :name %> + + <%= form.text_area :desc, class: "description", :rows => 5 %> + + <%= form.text_field :link, class: "link" %> <%= form.submit "Add Item", class: "add" %> - <% end %> \ No newline at end of file diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index 62ef5ed0..4e33cc65 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -5,9 +5,8 @@ <%= image_tag @item.item_category.icon, :class => 'icon' %>
-

<%= @item.name %>

+

<%= @item.name %> <%= link_to "[edit]", edit_item_path(@item) %>

-

About

<%= @item.desc %>

@@ -19,41 +18,45 @@
+
<%= @item.name %> is included in these groups
<% @gparents.each do |group| %> <%= render group %> <% end %> <% if @gparents.empty? %> -


Shucks, there are no groups.

+

Shucks, there are no groups.

<% end %>
+
<%= @item.name %> is included by these people
<% @pparents.each do |person| %> <%= render person %> <% end %> <% if @pparents.empty? %> -


Shucks, there are no people.

+

Shucks, there are no people.

<% end %>
+
<%= @item.name %> is included by these items
<% @iparents.each do |item| %> <%= render item %> <% end %> <% if @iparents.empty? %> -


Shucks, there are no items.

+

Shucks, there are no items.

<% end %>
+
<%= @item.name %> includes these items
<% @ichildren.each do |item| %> <%= render item %> <% end %> <% if @ichildren.empty? %> -


Shucks, there are no items.

+

Shucks, there are no items.

<% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2deaa245..38b60bd6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,7 +3,6 @@ Metamap <%= stylesheet_link_tag "application", :media => "all" %> - <%= stylesheet_link_tag 'style.css' %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> @@ -15,16 +14,23 @@ <% unless authenticated? %> <% end %> <% if authenticated? %> <% end %> diff --git a/app/views/people/_person.html.erb b/app/views/people/_person.html.erb index 83fc5160..01826769 100644 --- a/app/views/people/_person.html.erb +++ b/app/views/people/_person.html.erb @@ -1,6 +1,7 @@ <%= div_for person do %> +

Person

<%= image_tag "person.png", :class => 'icon' %> <%= link_to person.name, person_url(person), :class => 'title' %> -

About

<%=person.desc %>
+

<%=person.desc %>

<%= link_to person.link, person.link, :class => 'link' %> <% end %> \ No newline at end of file diff --git a/app/views/people/edit.html.erb b/app/views/people/edit.html.erb new file mode 100644 index 00000000..18236e8b --- /dev/null +++ b/app/views/people/edit.html.erb @@ -0,0 +1,10 @@ +<%= form_for @person, url: person_url do |form| %> +

Edit Person

+ + <%= form.text_field :name, label: "Name", class: "name" %> + + <%= form.text_area :desc, label: "Description", class: "description", :rows => 5 %> + + <%= form.text_field :link, label: "Link", class: "link" %> + <%= form.submit "Update", class: "update" %> +<% end %> \ No newline at end of file diff --git a/app/views/people/new.html.erb b/app/views/people/new.html.erb index ec9c4913..7cb2942b 100644 --- a/app/views/people/new.html.erb +++ b/app/views/people/new.html.erb @@ -1,8 +1,12 @@ <%= form_for @person || Person.new, url: people_path do |form| %> +

Add Person

+ <%= form.text_field :name, label: "Name", class: "name" %> - <%= form.text_field :desc, label: "Description", class: "description" %> + + <%= form.text_area :desc, label: "Description", class: "description", :rows => 5 %> + <%= form.text_field :link, label: "Link", class: "link" %> + <%= select_tag "ingroups", options_from_collection_for_select(Group.all, "id", "name"), { :multiple => true } %> - <%= form.submit "Add Person", class: "add" %> - + <%= form.submit "Add Person", class: "add" %> <% end %> \ No newline at end of file diff --git a/app/views/people/show.html.erb b/app/views/people/show.html.erb index 908fa63c..92da0d91 100644 --- a/app/views/people/show.html.erb +++ b/app/views/people/show.html.erb @@ -4,9 +4,8 @@ <%= image_tag "person.png", :class => 'icon' %>
-

<%= @person.name %>

+

<%= @person.name %> <%= link_to "[edit]", edit_person_path(@person) %>

-

About

<%= @person.desc %>

@@ -19,21 +18,23 @@
+
<%= @person.name %> is included in these groups
<% @gparents.each do |group| %> <%= render group %> <% end %> <% if @gparents.empty? %> -


Shucks, there are no groups.

+

Shucks, there are no groups.

<% end %>
+
<%= @person.name %> includes these items
<% @ichildren.each do |item| %> <%= render item %> <% end %> <% if @ichildren.empty? %> -


Shucks, there are no items.

+

Shucks, there are no items.

<% end %>
\ No newline at end of file diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 675bda11..94387feb 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,7 +1,8 @@ <%= form_for @session || Session.new, url: session_path do |form| %> - - <%= form.text_field :email, label: "Email", class: "email" %> - <%= form.password_field :password, label: "Password", class: "password" %> - <%= form.submit "Login", class: "add" %> - +

Login

+ + <%= form.text_field :email, class: "email" %> + + <%= form.password_field :password, class: "password" %> + <%= form.submit "Login", class: "add" %> <% end %> \ No newline at end of file diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index ea52e670..3e36ec4a 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,10 +1,9 @@ <%= formula_form_for @user, url: user_url do |form| %> - +

Create Account

<%= form.input :name, label: "Name", class: "name" %> <%= form.input :email, label: "Email", class: "email" %> <%= form.input :password, label: "Password", class: "password" %> - <%= form.submit "Login", class: "add" %> - + <%= form.submit "Login", class: "add" %> <% end %> diff --git a/config/database.yml b/config/database.yml index 7b4766e5..dd462777 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,32 +1,32 @@ development: min_messages: WARNING adapter: postgresql - host: 127.0.0.1 + host: ec2-54-243-217-241.compute-1.amazonaws.com port: 5432 encoding: unicode - database: issad-development + database: dbct9hosrirq2h pool: 5 - username: postgres - password: "3112" + username: tkbwavghytilon + password: "To6z-64f1Lr3LqpWrcLBPG2Xdv" test: min_messages: WARNING adapter: postgresql - host: 127.0.0.1 + host: ec2-54-243-217-241.compute-1.amazonaws.com port: 5432 encoding: unicode - database: issad-test + database: dbct9hosrirq2h pool: 5 - username: postgres - password: "3112" + username: tkbwavghytilon + password: "To6z-64f1Lr3LqpWrcLBPG2Xdv" production: min_messages: WARNING adapter: postgresql - host: 127.0.0.1 + host: ec2-54-243-217-241.compute-1.amazonaws.com port: 5432 encoding: unicode - database: issad-production + database: dbct9hosrirq2h pool: 5 - username: postgres - password: "3112" \ No newline at end of file + username: tkbwavghytilon + password: "To6z-64f1Lr3LqpWrcLBPG2Xdv"