Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of git@github.com:Smudge/newstc

  • Loading branch information...
commit 5dc8a2d59cdfa63b325abfb8c6b22ca37c106f69 2 parents 4e6cc6b + 3ee302d
Ryan Laughlin authored July 02, 2009
2  app/controllers/application_controller.rb
@@ -47,7 +47,7 @@ def current_user
47 47
   # current_department is suitable to those methods that skip_before_filter load_department
48 48
   def current_department
49 49
     if params[:department_id] or session[:department_id]
50  
-      @department ||= Department.find(params[:department_id] || session[:department_id])
  50
+        @department ||= Department.find(params[:department_id] || session[:department_id])
51 51
     elsif current_user and current_user.departments
52 52
       @department = current_user.user_config.default_dept ? Department.find(current_user.user_config.default_dept) : current_user.departments[0]
53 53
     elsif current_user and current_user.is_superuser?
13  app/controllers/notices_controller.rb
... ...
@@ -1,5 +1,6 @@
1 1
 class NoticesController < ApplicationController
2  
-
  2
+  layout "application"
  3
+#  layout "new_notice", :only  => :new
3 4
   before_filter :fetch_loc_groups
4 5
 
5 6
   def index
@@ -16,6 +17,7 @@ def show
16 17
 
17 18
   def new
18 19
     @notice = Notice.new
  20
+    render :action => "new", :layout => 'new_notice'
19 21
   end
20 22
 
21 23
   def edit
@@ -23,15 +25,16 @@ def edit
23 25
   end
24 26
 
25 27
   def create
  28
+    params.to_yaml
26 29
     @notice = Notice.new(params[:notice])
27  
-    @notice.is_sticky = true unless current_user.is_admin_of?(@department)
  30
+    @notice.is_sticky = true unless current_user.is_admin_of?(current_department)
28 31
     @notice.author = current_user
29 32
     @notice.department = @department
30 33
     @notice.start_time = Time.now if @notice.is_sticky
31 34
     @notice.end_time = nil if params[:indefinite] || @notice.is_sticky
32 35
     if @notice.save
33 36
       set_sources
34  
-      if @notice.save
  37
+      if @notice.saveNo
35 38
         flash[:notice] = 'Notice was successfully created.'
36 39
         redirect_to @notice
37 40
       else
@@ -74,7 +77,7 @@ def destroy
74 77
     end
75 78
   end
76 79
 
77  
-    protected
  80
+  protected
78 81
 
79 82
   def fetch_loc_groups
80 83
     @loc_groups = @department.loc_groups.all
@@ -90,7 +93,7 @@ def set_sources(update = false)
90 93
     end
91 94
     @notice.user_sources << @department if params[:department_wide_viewers] && !@notice.is_sticky
92 95
     @notice.location_sources = [] if update
93  
-    @notice.location_sources << @department if params[:department_wide_locations] && current_user.is_admin_of?(@department)
  96
+    @notice.departments << @department if params[:department_wide_locations] && current_user.is_admin_of?(@department)
94 97
     if params[:for_locations]
95 98
       params[:for_locations].each do |loc|
96 99
         @notice.location_sources << Location.find_by_id(loc)
2  app/helpers/application_helper.rb
@@ -19,7 +19,7 @@ def early_late_info(start)
19 19
 
20 20
   def return_to_shift_report_if_needed
21 21
     if current_user.current_shift
22  
-      link_to "Return to your current report", {:controller => "report", :action => "index"}
  22
+      link_to "Return to your current report", {:controller => "report", :action => "index"} + concat("<br/>")
23 23
     end
24 24
   end
25 25
 
24  app/helpers/notices_helper.rb
... ...
@@ -1,16 +1,20 @@
1 1
 module NoticesHelper
2  
-  def show_notice_archive
3  
-    if params[:show_inactive].nil?
4  
-      link_to "Show Inactive Notices", :show_inactive => true
  2
+
  3
+  def locations_check(location)
  4
+    @notice.departments.locations.include?(location) or current_user.current_shift.location == location or @notice.locations.include?(location) or loc_group.locations.include?(location)
  5
+  end
  6
+
  7
+  def loc_group_check(loc_group)
  8
+    if @notice.departments.empty?
  9
+      @notice.loc_groups.include?(loc_group)
5 10
     else
6  
-      link_to "Hide Inactive Notices", notices_path
7  
-      unless Notice.inactive.empty?
8  
-        concat('<fieldset class ="index">')
9  
-          concat('<legend>Inactive Notices</legend>')
10  
-          render(:partial => 'notice', :collection => Notice.inactive)
11  
-        concat("<fieldset>")
12  
-      end
  11
+      @notice.departments.loc_groups.include?(loc_group)
13 12
     end
14 13
   end
  14
+
  15
+  def dept_check
  16
+    @notice.departments.include?(current_department)
  17
+  end
  18
+
15 19
 end
16 20
 
2  app/models/location.rb
@@ -27,7 +27,7 @@ def locations
27 27
     [self]
28 28
   end
29 29
 
30  
-  def notices
  30
+  def find_notices
31 31
     Notice.active.select {|n| n.display_locations.include?(self)}
32 32
   end
33 33
 
5  app/models/user.rb
@@ -104,8 +104,8 @@ def can_signup?(loc_group)
104 104
   end
105 105
 
106 106
   # check for admin permission given a dept, location group, or location
107  
-  def is_admin_of?(thing)
108  
-    self.is_superuser? || (permission_list.include?(thing.admin_permission) && self.is_active?(thing))
  107
+  def is_admin_of?(dept)
  108
+    self.is_superuser? || (permission_list.include?(dept.admin_permission) && self.is_active?(dept))
109 109
   end
110 110
 
111 111
   # see list of superusers defined in config/initializers/superuser_list.rb
@@ -174,3 +174,4 @@ def create_user_config
174 174
     UserConfig.new({:user_id => self.id}).save
175 175
   end
176 176
 end
  177
+
1  app/views/dashboard/index.html.erb
@@ -11,7 +11,6 @@
11 11
 <fieldset class = "index">
12 12
   <legend>Current shifts</legend>
13 13
   <%= return_to_shift_report_if_needed %>
14  
-  <br/>
15 14
   <% if current_user.punch_clock %>
16 15
     <%= link_to "Clock out?", current_user.punch_clock,
17 16
                                                   :confirm => "Are you sure",
3  app/views/layouts/application.html.erb
@@ -11,7 +11,7 @@
11 11
         <h4 id="subtitle"><%=h yield(:subtitle) %></h4>
12 12
       <%- end -%>
13 13
       <!-- Main Content -->
14  
-      <%= yield(:body) || yield %>     
  14
+      <%= yield(:body) || yield %>
15 15
       </div>
16 16
       <div id="pageAnchor">
17 17
         <a href="#top_of_page">
@@ -29,3 +29,4 @@
29 29
     <div id="pageboxBottom"/> <!-- do not remove this -->
30 30
   </body>
31 31
 </html>
  32
+
2  app/views/layouts/include/_nav.html.erb
@@ -6,7 +6,7 @@
6 6
     <li class="<%= tab('departments') %>"><%= link_to "Departments", departments_path %></li>
7 7
   <% end -%>
8 8
   <% if !current_user.new_record? && !current_department.new_record? %>
9  
-    <% if (current_user.is_admin_of?(current_department)) -%>
  9
+    <% if (current_user.is_admin_of?(@department)) -%>
10 10
       <li class="<%= tab('users') %>"><%= link_to "Users", department_users_path(current_department) %></li>
11 11
     <% end -%>
12 12
     <% if current_user.departments.include?(current_department) || current_user.is_superuser? %>
19  app/views/notices/_form.html.erb
... ...
@@ -1,7 +1,4 @@
1  
-<% javascript 'jrails', 'jquery', 'jquery-ui', 'jquery.tokeninput', 'thickbox-compressed'  %>
2  
-<% stylesheet 'tokeninput-facebook' %>
3  
-
4  
-<fieldset>
  1
+<fieldset class = "index">
5 2
 <% form_for(@notice) do |f| %>
6 3
   <%= f.error_messages %>
7 4
   <% if current_user.is_admin_of?(@department) %>
@@ -32,15 +29,15 @@
32 29
   <%= tokenized_users_autocomplete(@notice, "user_sources", "for_users") %>
33 30
   <p>
34 31
     For locations: <br />
35  
-    <% if current_user.is_admin_of?(@department) %>
36  
-      <%= check_box_tag :department_wide_locations %><%= @department.name %> (all locations)<br />
  32
+    <% if current_user.is_admin_of?(current_department) %>
  33
+      <%= check_box_tag :department_wide_locations, 1, dept_check, :disabled => dept_check %><%= current_department.name %> (all locations)<br />
37 34
     <% end %>
38 35
     <% for loc_group in @loc_groups do %>
39 36
       &nbsp;&nbsp;&nbsp;
40  
-      <%= check_box_tag "for_location_groups[]", loc_group.id, false, :disabled => false %><%= loc_group.name %>:
  37
+      <%= check_box_tag "for_location_groups[]", loc_group.id, loc_group_check(loc_group), :disabled => loc_group_check(loc_group)%><%= loc_group.name %>:
41 38
       <% for location in loc_group.locations do %>
42 39
         <% if current_user.current_shift %>
43  
-          <%= check_box_tag "for_locations[]", location.id, current_user.current_shift.location == location, :disabled => false %>
  40
+          <%= check_box_tag "for_locations[]", location.id, locations_check(location), :disabled => locations_check(location) %>
44 41
         <% else %>
45 42
           <%= check_box_tag "for_locations[]", location.id, false, :disabled => false %>
46 43
         <% end %>
@@ -54,14 +51,10 @@
54 51
 </fieldset>
55 52
 
56 53
 <p>
57  
-  <%= f.submit 'Create/Update' %>
  54
+  <%= f.submit 'Save',:onclick => 'self.parent.tb_remove()' %>
58 55
 </p>
59 56
 
60 57
 <% end %>
61  
-<!--
62  
- document.observe('dom:loaded',function(){ $('checkbox_div').hide(); });
63  
-    document.observe('dom:loaded',function(){ $('pref_link').show(); });
64  
--->
65 58
 
66 59
 <script type="text/javascript" charset="utf-8">
67 60
     $(document).ready(function(){$("#advanced").hide();})
24  app/views/notices/index.html.erb
... ...
@@ -1,8 +1,13 @@
1 1
 <% stylesheet 'thickbox' %>
2 2
 <% javascript 'jrails', 'jquery', 'jquery-ui', 'thickbox-compressed' %>
3 3
 
4  
-<h1 id="page_title"><%=h "Notices - " %><font size = -2><%= link_to 'Post a new notice', new_notice_path, :class => "thickbox" %></font></h1>
5  
-
  4
+<h1 id="page_title">
  5
+  Notices -
  6
+  <font size = -2>
  7
+    <%= link_to 'Post a new notice', {:action => 'new', :TB_iframe => true}, :class => "thickbox" %>
  8
+  </font>
  9
+</h1>
  10
+<div id = "for_you">
6 11
 <% unless current_user.notices.empty? %>
7 12
   <fieldset class ="index">
8 13
     <legend>For you</legend>
@@ -10,19 +15,24 @@
10 15
   </fieldset>
11 16
   <br />
12 17
 <% end %>
13  
-
14  
-
15  
-<% @department.locations.each do |loc| %>
16  
-  <% unless loc.notices.empty? %>
  18
+</div>
  19
+<div id = "location_notices">
  20
+<% current_department.locations.each do |loc| %>
  21
+  <% unless loc.find_notices.empty? %>
17 22
   <fieldset class ="index">
18 23
     <legend><%= loc.name %></legend>
19  
-    <%= render :partial => 'notice', :collection => loc.notices %>
  24
+    <%= render :partial => 'notice', :collection => loc.find_notices%>
20 25
   </fieldset>
21 26
   <br/>
22 27
   <% end %>
23 28
 <% end %>
  29
+</div>
24 30
 
25 31
 <% if current_user.is_admin_of?(@department) %>
26 32
   <%= link_to 'Notice archive', 'notices/archive' %>
27 33
 <% end %>
  34
+<script type="text/javascript" charset="utf-8">
  35
+    page.replace_html("for_you", :partial => "for_you" );
  36
+    page.replace_html("location_notices", :partial => "notice", :collection => "loc.notices" );
  37
+</script>
28 38
 
11  app/views/notices/show.html.erb
@@ -32,10 +32,17 @@
32 32
   <b>People who see this:</b> <br />
33 33
   <%= (@notice.viewers.collect {|v| v.name}).join("<br />")%>
34 34
 </p>
35  
-
  35
+<p>
  36
+  <b>Display in these departments:</b> <br />
  37
+  <%= (@notice.departments.collect {|d| d.name}).join("<br />") %>
  38
+</p>
  39
+<p>
  40
+  <b>Display in these location groups:</b> <br />
  41
+  <%= (@notice.loc_groups.collect {|lg| lg.name}).join("<br />") %>
  42
+</p>
36 43
 <p>
37 44
   <b>Display in these locations:</b> <br />
38  
-  <%= (@notice.display_locations.collect {|v| v.name}).join("<br />") %>
  45
+  <%= (@notice.display_locations.collect {|l| l.name}).join("<br />") %>
39 46
 </p>
40 47
 
41 48
 
1  public/stylesheets/notice.css
... ...
@@ -1,6 +1,7 @@
1 1
 fieldset.index {
2 2
   width: 75%;
3 3
   padding: 5px;
  4
+  background-color:#DDDDFF
4 5
 }
5 6
 
6 7
 fieldset.sticky {

0 notes on commit 5dc8a2d

Please sign in to comment.
Something went wrong with that request. Please try again.