From 11473aa23a6387742e28e75c39a6b5f7dc1f1204 Mon Sep 17 00:00:00 2001 From: Alinson Santos Date: Tue, 4 Mar 2008 07:05:15 -0300 Subject: [PATCH] Mudancas no dashboard, calendario e noticias --- app/controllers/users_controller.rb | 4 +- app/models/event.rb | 4 +- app/views/courses/index.html.haml | 15 ++- app/views/events/_form.html.haml | 6 +- app/views/events/index.html.haml | 52 ++++---- app/views/log/index.html.haml | 29 +++-- app/views/news/index.html.haml | 35 ++--- app/views/stylesheets/wiki.css.erb | 120 ++++++++---------- app/views/users/dashboard.html.erb | 49 ------- app/views/widgets/calendario.html.erb | 6 +- app/views/widgets/menu_user.html.haml | 2 +- app/views/wiki/versions.html.haml | 39 +++--- db/schema.rb | 4 +- lib/authentication_system.rb | 2 +- vendor/plugins/brazilian-rails/init.rb | 2 +- .../plugins/brazilian-rails/test/time_test.rb | 2 +- 16 files changed, 155 insertions(+), 216 deletions(-) delete mode 100644 app/views/users/dashboard.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1c0e739..b399c22 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -112,9 +112,9 @@ class UsersController < ApplicationController unless @current_user.courses.empty? @news = News.find(:all, :conditions => [ 'receiver_id in (?)', @current_user.courses ], - :order => 'timestamp desc') + :order => 'timestamp desc', :limit => 5) @events = Event.find(:all, :conditions => [ 'course_id in (?) and (date > ?) and (date < ?)', - @current_user.courses, 1.day.ago, 14.days.from_now ], :order => 'date, time') + @current_user.courses, 1.day.ago, 21.days.from_now ], :order => 'date') end end diff --git a/app/models/event.rb b/app/models/event.rb index 6cd5b97..7f4ea4c 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -21,8 +21,8 @@ class Event < ActiveRecord::Base courses.each do |course| course.events.each do |user_event| event = Icalendar::Event.new - event.start = user_event.date - event.end = user_event.date + event.start = user_event.time + event.end = user_event.time event.summary = "#{course.short_name}: #{user_event.title}" event.description = user_event.description cal.add(event) diff --git a/app/views/courses/index.html.haml b/app/views/courses/index.html.haml index 3d6149a..fd02168 100644 --- a/app/views/courses/index.html.haml +++ b/app/views/courses/index.html.haml @@ -8,13 +8,14 @@ .box %ul - if logged_in? - - unless @current_user.courses.empty? - %h3 Disciplinas matriculadas - - for course in @current_user.courses - %li{highlight(course.id)} - .right - = action_icon('subtract', 'Desmatricular-se', unenroll_course_url(course)) - = link_to h(course.full_name), course_url(course) + %h3 Disciplinas Matriculadas + - if @current_user.courses.empty? + %li.no_itens Nenhuma disciplina matriculada + - for course in @current_user.courses + %li{highlight(course.id)} + .right + = action_icon('subtract', 'Desmatricular-se', unenroll_course_url(course)) + = link_to h(course.full_name), course_url(course) - old_period = 0 - for course in @courses diff --git a/app/views/events/_form.html.haml b/app/views/events/_form.html.haml index 1116f06..82f2446 100644 --- a/app/views/events/_form.html.haml +++ b/app/views/events/_form.html.haml @@ -6,12 +6,12 @@ %dd= text_field 'event', 'title' %dt - %label{:for => "event_date"} Data - %dd= date_select 'event', 'date', :order => [:day, :month, :year] + %label{:for => "event_time"} Data + %dd= date_select 'event', 'time', :order => [:day, :month, :year] %dt %label{:for => "event_time"} Horário - %dd= time_select 'event', 'time' + %dd= time_select 'event', 'time', { :minute_step => 5 } %dt %label{:for => "event_description"} Descrição diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml index ff1da13..310340b 100644 --- a/app/views/events/index.html.haml +++ b/app/views/events/index.html.haml @@ -1,6 +1,8 @@ += javascript_include_tag 'events' + - cache do - - last_event = nil + - last_date = nil .cmd = action_icon 'add', 'Adicionar evento', new_course_event_url @@ -9,31 +11,27 @@ %h1.title Calendário .box.div_calendario - - - @events.each do |event| - - if last_event != event.date - = "" if last_event - .date= event.date.strftime("%d de %B") - = "
" if !@events.empty? - - - if @events.empty? - .box - %ul - %li.grey Nenhum evento + - if !@events.empty? + %table + - @events.each do |event| + %tr[event] + %td.top.aright{:width => '1%'} + = event.time.strftime("%d de %B") #unless event.time == last_date + %td.top{:width => '1%'} + = event.time.strftime("%H:%M") + %td.top + .title=link_to h(event.title), course_event_url(@course, event) + .description{:style => (event.id == params[:id].to_i ? '' : 'display: none')} + %div.cmd + = action_icon 'edit', 'Editar', edit_course_event_url(@course, event) + = action_icon 'trash', 'Excluir', course_event_url(@course, event), :confirm => 'Tem certeza que deseja excluir?', :method => :delete + = h(event.description) + = "Sem descrição" if event.description.empty? + + - last_date = event.time + - else + .box + %ul + %li.no_itens Nenhum evento %br diff --git a/app/views/log/index.html.haml b/app/views/log/index.html.haml index bc3623d..a5cbc06 100644 --- a/app/views/log/index.html.haml +++ b/app/views/log/index.html.haml @@ -1,18 +1,19 @@ %h4.title= h(@course.full_name) %h1.title Mudanças recentes -%table.log - %tr - %th Data - %th Usuário - %th Descrição - - @log_entries.each do |entry| +.box + %table %tr - %td= entry.created_at.strftime("%d/%m/%y %H:%M:%S") - %td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user) - %td - = render(:partial => 'log/attachment_log_entry', :locals => { :entry => entry }) if entry.kind_of?(AttachmentLogEntry) - = render(:partial => 'log/event_log_entry', :locals => { :entry => entry }) if entry.kind_of?(EventLogEntry) - = render(:partial => 'log/news_log_entry', :locals => { :entry => entry }) if entry.kind_of?(NewsLogEntry) - = render(:partial => 'log/wiki_log_entry', :locals => { :entry => entry }) if entry.kind_of?(WikiLogEntry) - = "(" + link_to("undo", undo_course_log_url(@course, entry)) + ")" if entry.reversible? + %th Data + %th Usuário + %th Descrição + - @log_entries.each do |entry| + %tr + %td= entry.created_at.strftime("%d/%m/%y %H:%M:%S") + %td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user) + %td + = render(:partial => 'log/attachment_log_entry', :locals => { :entry => entry }) if entry.kind_of?(AttachmentLogEntry) + = render(:partial => 'log/event_log_entry', :locals => { :entry => entry }) if entry.kind_of?(EventLogEntry) + = render(:partial => 'log/news_log_entry', :locals => { :entry => entry }) if entry.kind_of?(NewsLogEntry) + = render(:partial => 'log/wiki_log_entry', :locals => { :entry => entry }) if entry.kind_of?(WikiLogEntry) + = "(" + link_to("undo", undo_course_log_url(@course, entry)) + ")" if entry.reversible? diff --git a/app/views/news/index.html.haml b/app/views/news/index.html.haml index 508344f..cc8832c 100644 --- a/app/views/news/index.html.haml +++ b/app/views/news/index.html.haml @@ -1,3 +1,5 @@ += javascript_include_tag 'news' + - cache do .cmd @@ -8,21 +10,22 @@ = auto_discovery_link_tag :rss, formatted_course_news_index_url(@course, :rss) - .news - - @course.news.each do |n| - .line{:class => 'new', :id => "news_#{n.id}"} - .cmd{:style => (n.id == params[:id].to_i ? '' : 'display: none')} - = action_icon 'edit', 'Editar', edit_course_news_url(@course, n) - = action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete - - .left= n.timestamp.strftime("%d de %B") - %h4 - = link_to h(n.title), course_news_url(@course, n) - - %p{:style => (n.id == params[:id].to_i ? '' : 'display: none')} - = h(n.body) - - - if @course.news.empty? + .box.div_news + - if !@course.news.empty? + %table + - @course.news.each do |n| + %tr[n] + %td.top.aright + = n.timestamp.strftime("%d de %B") + %td + .title= link_to h(n.title), course_news_url(@course, n) + .description{:style => (n.id == params[:id].to_i ? '' : 'display: none')} + .cmd + = action_icon 'edit', 'Editar', edit_course_news_url(@course, n) + = action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete + = h(n.body) + = "Sem descrição" if n.body.empty? + - else .box %ul - %li.grey Nenhuma notícia + %li.no_itens Nenhuma notícia diff --git a/app/views/stylesheets/wiki.css.erb b/app/views/stylesheets/wiki.css.erb index 7aa72ce..2a97f98 100644 --- a/app/views/stylesheets/wiki.css.erb +++ b/app/views/stylesheets/wiki.css.erb @@ -254,9 +254,6 @@ body { font-size: 24px; } -.content p:first-child { - margin-top: 9px; -} #innerwrapper_2column { padding: 0em 0px 0em 208px; @@ -388,7 +385,7 @@ h4.title, h1.title { margin: 18px 0px; } -.box h3, .box th { +.box h3 { line-height: 34px; margin: 0px; border-bottom: 1px solid #eee; @@ -408,37 +405,21 @@ h4.title, h1.title { border-bottom: 1px solid #f4f4f4; } -.div_calendario .date { - line-height: 36px; - width: 105px; - text-align: right; - float: left; -} - -.div_calendario ul { - padding-left: 115px; - margin-top: -1px; - margin-bottom: 0em; - border-top: 1px solid #eee; - list-style: none !important; -} - -.div_calendario li { - border-bottom: 1px solid #eee; +.div_calendario table, .div_news table { + width: 100%; } - -.div_calendario .time { - padding-right: 1em; - width: 3em; - float: left; +.div_calendario table tr td, .div_news table tr td { + padding-top: 9px; + padding-bottom: 9px; } -.div_calendario .description { - padding-left: 4em; +.div_calendario table tr td:first-child, .div_news table tr td:first-child { + padding-left: 18px; } -.news { - margin-top: 18px; +.div_calendario .cmd, .div_news .cmd { + margin-top: -9px; + line-weigth: 9px; } @@ -532,30 +513,6 @@ select { margin-top: 9px; } -.news .left { - float: left; - line-height: 18px; - margin: 0px; - width: 105px; - padding-top: 8px; - padding-right: 15px; - text-align: right; -} - -.news h4 { - margin: 8px 0px; - padding: 0px; -} - -.news p { - padding-left: 120px; - margin-top: 8px; -} - -.news .line { - border-top: 1px solid #eee; - margin-bottom: 9px; -} .history { @@ -662,9 +619,6 @@ textarea { border-top: 1px solid #bbb; } -xbody { background-image: url(<%= App.base_path %>/prototype/line.png); } -xhtml * { background-color: transparent !important; } - .menu, .content, #location { border-right: 2px solid #ddd; border-bottom: 2px solid #ddd; @@ -741,38 +695,40 @@ text-align: center; margin-top: -1px; } -ul.log li { +/*.box ul li { border-top: 1px solid #eee; - padding: 4px 0px 4px 15px; + padding: 9px 0px 9px 15px; background-position: 0px 12px; -} +}*/ -table.log { - margin-top: 18px; +.box table { + margin-bottom: 2px; border-collapse: collapse; - /*width: 100%;*/ } -table.log td { +.box table td { border-top: 1px solid #eee; padding: 4px 12px; } -table.log th { +.box table th { padding: 4px 12px; border-top: 1px solid #eee; font-weight: normal; text-align: left; } +.top { vertical-align: top; } +.center { text-align: center !important; } +.left { float: left !important; } +.right { float: right !important; } +.aright { text-align: right !important; } + .pagination { margin: 18px 0px; text-align: right; } -.left { float: left !important; } -.right { float: right !important; } - .fieldWithErrors input, .fieldWithErrors textarea { border: 2px solid #c00; } @@ -795,6 +751,13 @@ table.log th { #wiki_text h3 { font-size: 12px; } #wiki_text h4, #wiki_text h5, #wiki_text h6 { font-size: 11px; } +.box h3. { + margin-bottom: -9px; + margin-top: 18px; + padding-top: 9px; + font-weight: normal; +} + .content ol li { background-image: none; padding: 0px; @@ -803,3 +766,24 @@ table.log th { ul ul, ul ol, ol ul, ol ol { margin: 0px; } + +li p, td p { + margin-top: 0px; +} + +.dashboard td:first-child { + padding-left: 27px; +} + +.dashboard table tr td { + padding-right: 9px; +} + +.dashboard .box ul { + margin-bottom: 0px; +} + + +xbody { background-image: url(<%= App.base_path %>/prototype/line.png); background-repeat: repeat; } +xhtml * { background-color: transparent !important; } + diff --git a/app/views/users/dashboard.html.erb b/app/views/users/dashboard.html.erb deleted file mode 100644 index c11200d..0000000 --- a/app/views/users/dashboard.html.erb +++ /dev/null @@ -1,49 +0,0 @@ -<% last_event = nil %> - -

Dashboard

-

Bem vindo, <%= h(@current_user.display_name) %>

- - -
-

Notícias recentes

-<% @news.each do |n| %> -
-

<%= n.timestamp.strftime("%d de %B") %>

-

<%= link_to h(n.course.full_name) , course_url(n.course) %> › - <%= link_to h(n.title), course_news_url(n.course, n) %>

-
-<% end %> -
- - -
-

Próximos eventos

- - <% @events.each do |event| %> - <% if last_event != event.date %> - <% if last_event %>
<% end %> -
<%= event.date.strftime("%d de %B") %>
-
" if !@events.empty? %> - - - - -
-

Disciplinas Matriculadas

- -
- -

<%#= link_to 'Descadastrar usuário', :action => 'destroy'%>

diff --git a/app/views/widgets/calendario.html.erb b/app/views/widgets/calendario.html.erb index 640ba84..6fab461 100644 --- a/app/views/widgets/calendario.html.erb +++ b/app/views/widgets/calendario.html.erb @@ -21,7 +21,7 @@ cell_text = d.mday cell_attrs = {:class => 'day'} @events.each do |e| - if e.date == d + if e.time == d cell_attrs[:onclick] = "show_events('#{d.to_s}')" cell_attrs[:class] = 'specialDay' cell_text = link_to d.mday, "#" @@ -35,8 +35,8 @@