From ec8fc71ff8be43ae94175a3bf32738f42588663e Mon Sep 17 00:00:00 2001 From: "Thomas R. Koll" Date: Sun, 23 Aug 2009 01:49:44 +0200 Subject: [PATCH] Made anthill form look nice Some work on dashboard Some minor CSS work on forms --- app/models/anthill.rb | 2 -- app/views/anthills/_form.html.haml | 10 ++++++---- app/views/ants/_ant.html.haml | 7 +++++++ app/views/ants/_form.html.haml | 4 ++++ app/views/ants/edit.html.haml | 11 +++++++++++ app/views/ants/index.html.haml | 5 +++++ app/views/ants/new.html.haml | 9 +++++++++ app/views/ants/show.html.haml | 9 +++++++++ app/views/dashboard/_anthill.haml | 7 +++++++ app/views/dashboard/index.html.haml | 3 ++- config/locales/en.yml | 11 +++++++++++ public/stylesheets/sass/forms.sass | 3 ++- 12 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 app/views/ants/_ant.html.haml create mode 100644 app/views/ants/_form.html.haml create mode 100644 app/views/ants/edit.html.haml create mode 100644 app/views/ants/index.html.haml create mode 100644 app/views/ants/new.html.haml create mode 100644 app/views/ants/show.html.haml diff --git a/app/models/anthill.rb b/app/models/anthill.rb index 69f7b93..07c75bc 100644 --- a/app/models/anthill.rb +++ b/app/models/anthill.rb @@ -21,7 +21,5 @@ def set_position self.latitude = rand(self.map.width) self.longitude = rand(self.map.height) - - puts y self end end diff --git a/app/views/anthills/_form.html.haml b/app/views/anthills/_form.html.haml index 0f9b815..557d621 100644 --- a/app/views/anthills/_form.html.haml +++ b/app/views/anthills/_form.html.haml @@ -1,11 +1,13 @@ -%p - = form.label :name, t(:'.name') - = form.text_field :name +%fieldset + %legend= t(:'.details') + %p + = form.label :name, t(:'.name') + = form.text_field :name %fieldset %legend= t(:'.maps') - Map.open.all(:limit => 10).each do |map| - %p + %p.checkbox = form.radio_button :map_id, map.id = form.label "map_id_#{map.id}", map.name \ No newline at end of file diff --git a/app/views/ants/_ant.html.haml b/app/views/ants/_ant.html.haml new file mode 100644 index 0000000..3ce4e7e --- /dev/null +++ b/app/views/ants/_ant.html.haml @@ -0,0 +1,7 @@ +%div[ant] + + = link_to 'Show', object_path(ant) + | + = link_to 'Edit', edit_object_path(ant) + | + = link_to 'Destroy', object_path(ant), :confirm => 'Really destroy ant?', :method => :delete diff --git a/app/views/ants/_form.html.haml b/app/views/ants/_form.html.haml new file mode 100644 index 0000000..cc7741d --- /dev/null +++ b/app/views/ants/_form.html.haml @@ -0,0 +1,4 @@ += form.hidden_field :type +%p + There aren't any options yet when creating a new queen. Later you can + choose from standard types or something like that. \ No newline at end of file diff --git a/app/views/ants/edit.html.haml b/app/views/ants/edit.html.haml new file mode 100644 index 0000000..9340717 --- /dev/null +++ b/app/views/ants/edit.html.haml @@ -0,0 +1,11 @@ +%h1 Editing ant + += error_messages_for :ant + +- form_for(:ant, :url => object_url, :html => { :method => :put }) do |f| + = render :partial => "form", :locals => {:f => f} + %p= submit_tag "Update" + += link_to 'Show', object_path +| += link_to 'Back', objects_path diff --git a/app/views/ants/index.html.haml b/app/views/ants/index.html.haml new file mode 100644 index 0000000..c1bc6f5 --- /dev/null +++ b/app/views/ants/index.html.haml @@ -0,0 +1,5 @@ +%h1 Listing ants + += render :partial => 'ant', :collection => current_objects + += link_to 'New ant', new_object_path diff --git a/app/views/ants/new.html.haml b/app/views/ants/new.html.haml new file mode 100644 index 0000000..b19145e --- /dev/null +++ b/app/views/ants/new.html.haml @@ -0,0 +1,9 @@ +- @page_title = t(:'.page_title', :name => current_model_name) + += error_messages_for :ant + +- form_for(:ant, :url => anthill_ants_url) do |form| + = render :partial => "form", :object => form + %p.submit + = submit_tag t(:'.submit', :name => current_model_name) + diff --git a/app/views/ants/show.html.haml b/app/views/ants/show.html.haml new file mode 100644 index 0000000..504b4de --- /dev/null +++ b/app/views/ants/show.html.haml @@ -0,0 +1,9 @@ +%h1 Viewing ant + +%div[current_object] + += link_to 'Edit', edit_object_path +| += link_to 'Destroy', object_path, :confirm => 'Really destroy ant?', :method => :delete +| += link_to 'Back', objects_path diff --git a/app/views/dashboard/_anthill.haml b/app/views/dashboard/_anthill.haml index e69de29..f44623d 100644 --- a/app/views/dashboard/_anthill.haml +++ b/app/views/dashboard/_anthill.haml @@ -0,0 +1,7 @@ + +%div[anthill] + .name= link_to anthill.name, anthill_path(anthill) + %ul + %li.created_at.datetime= anthill.created_at + %li.worker_count= t(:'.workers', :count => anthill.worker_count) + %li.soldier_count= t(:'.soldiers', :count => anthill.soldier_count) \ No newline at end of file diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index 4b01dc8..bc752e3 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -3,6 +3,7 @@ %p= render :partial => 'intro' %h2.anthills= t(:'.anthills') -=link_to t(:'.create_new_anthill'), new_anthill_path - current_user.anthills.each do |anthill| = render :partial => 'anthill', :object => anthill + +.new=link_to t(:'.create_new_anthill'), new_anthill_path diff --git a/config/locales/en.yml b/config/locales/en.yml index 1bafcd6..791b098 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -8,6 +8,7 @@ en: navigation: login: 'Login' logout: 'Logout' + signup: 'Signup' dashboard: 'Dashboard' sessions: @@ -36,20 +37,30 @@ en: anthills: 'anthills' events: 'events' communication: 'communication' + anthill: + soldiers: '{{count}} soldiers' + workers: '{{count}} workers' anthills: new: page_title: 'Create a new anthill' submit: 'Create my anthill' form: + details: 'Details on your new anthill' name: 'Name (e.g. Southwestern Union Anthill)' + maps: 'Maps (only those still accepting new players are shown)' show: page_title: 'Anthill "{{name}}" by {{user}}' queen: 'Queen' queen_missing: "You don't have a queen yet in your anthill." plant_queen: 'Plant a new queen in your anthill' + ants: + new: + page_title: 'Plant a new {{name}}' + submit: 'Plant {{name}}' maps: index: stats: '{{anthills_count}} of {{max_anthills}}' states: + open: 'open for all' active: 'active' inactive: 'inactive' diff --git a/public/stylesheets/sass/forms.sass b/public/stylesheets/sass/forms.sass index f292486..65f7af9 100644 --- a/public/stylesheets/sass/forms.sass +++ b/public/stylesheets/sass/forms.sass @@ -11,8 +11,9 @@ label .checkbox label display: inline -input[type=text], input[type=password] +input[type=text], input[type=password], input[type=submit] :font-size 1.4em + :background-color = !color_title_background + #050505 input:focus, input:active :background-color = !color_title_background