Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 5 commits
  • 11 files changed
  • 0 comments
  • 1 contributor
8 app/models/refinery/reports/department.rb
@@ -14,6 +14,14 @@ class Department < Refinery::Core::BaseModel
14 14 acts_as_indexed :fields => [:name]
15 15
16 16 validates :name, presence: true, uniqueness: true
  17 +
  18 + def self.intern
  19 + where(intern: true)
  20 + end
  21 +
  22 + def self.extern
  23 + where(intern: false)
  24 + end
17 25 end
18 26 end
19 27 end
12 app/models/refinery/reports/person.rb
@@ -15,6 +15,18 @@ class Person < Refinery::Core::BaseModel
15 15 def self.grouped
16 16 all.group_by{|x| x.department.name}
17 17 end
  18 +
  19 + def to_s
  20 + "#{position} #{name} #{info.present? ? "(#{info})" : ""}"
  21 + end
  22 +
  23 + def checkbox_title
  24 + "person_ids #{id}"
  25 + end
  26 +
  27 + def checkbox_name
  28 + "report[person_ids][]"
  29 + end
18 30 end
19 31 end
20 32 end
11 app/models/refinery/reports/report.rb
... ... @@ -1,4 +1,5 @@
1 1 require_relative '../../../../lib/models/type.rb'
  2 +require_relative '../../../../lib/models/usable.rb'
2 3
3 4 module Refinery
4 5 module Reports
@@ -61,6 +62,16 @@ def person_ids=(person_ids)
61 62 def person_ids
62 63 resources.select{|r| r.usable.is_a?(Person)}.map(&:id)
63 64 end
  65 +
  66 + def intern_resources
  67 + intern_ids = Department.intern.map(&:id)
  68 + resources.select{|r| intern_ids.include?(r.usable.department_id)}.group_by{|r| r.usable.department.name}
  69 + end
  70 +
  71 + def extern_resources
  72 + extern_ids = Department.extern.map(&:id)
  73 + resources.select{|r| extern_ids.include?(r.usable.department_id)}.group_by{|r| r.usable.department.name}
  74 + end
64 75 end
65 76 end
66 77 end
12 app/models/refinery/reports/vehicle.rb
@@ -15,6 +15,18 @@ class Vehicle < Refinery::Core::BaseModel
15 15 def self.grouped
16 16 all.group_by{|x| x.department.name}
17 17 end
  18 +
  19 + def to_s
  20 + "#{name} #{short_name.present? ? "(#{short_name})" : ""}"
  21 + end
  22 +
  23 + def checkbox_title
  24 + "vehicle_ids_#{id}"
  25 + end
  26 +
  27 + def checkbox_name
  28 + "report[vehicle_ids][]"
  29 + end
18 30 end
19 31 end
20 32 end
14 app/views/refinery/reports/admin/reports/_actions.html.erb
@@ -12,18 +12,4 @@
12 12 <%= link_to t('refinery.reports.admin.departments.records.title'),
13 13 refinery.reports_admin_departments_path, method: :get %>
14 14 </li>
15   -<% if !searching? && ::Refinery::Reports::Admin::ReportsController.sortable? && ::Refinery::Reports::Report.any? %>
16   - <li>
17   - <%= link_to t('.reorder', :what => "Reports"),
18   - refinery.reports_admin_reports_path,
19   - :id => "reorder_action",
20   - :class => "reorder_icon" %>
21   -
22   - <%= link_to t('.reorder_done', :what => "Reports"),
23   - refinery.reports_admin_reports_path,
24   - :id => "reorder_action_done",
25   - :style => "display: none;",
26   - :class => "reorder_icon" %>
27   - </li>
28   -<% end %>
29 15 </ul>
37 app/views/refinery/reports/admin/reports/_form.html.erb
@@ -11,7 +11,7 @@
11 11
12 12 <div class='field'>
13 13 <%= f.label :typ %>
14   - <%= f.select(:typ, Type::TYPES, {}) %>
  14 + <%= f.select(:typ, ::Type::TYPES, {}) %>
15 15 </div>
16 16
17 17 <div class='field'>
@@ -46,32 +46,35 @@
46 46 <%= f.hidden_field :coordinates %>
47 47
48 48 <div class='field'>
49   - <%= f.label :chief -%>
50   - <%= f.text_field :chief -%>
51   -
  49 + <%= f.label :chief %>
  50 + <%= f.text_field :chief %>
52 51 </div>
53 52
  53 + <%= hidden_field_tag 'report[vehicle_ids][]' %>
  54 + <%= hidden_field_tag 'report[person_ids][]' %>
  55 +
54 56 <div class='field'>
55   - <% ::Refinery::Reports::Vehicle.grouped.each do |department, vehicles| %>
56   - <p>
  57 + <% Usable.all['intern'].each do |department, usables| %>
  58 + <p>
57 59 <h3><%= department %></h3>
58   - <% vehicles.each do |vehicle| %>
59   - <%= check_box_tag "vehicle_ids_#{vehicle.id}", vehicle.id,
60   - @report.resources.map(&:usable).include?(vehicle), name: 'report[vehicle_ids][]' %><%= vehicle.name %><br>
  60 + <% usables.each do |usable| %>
  61 + <%= check_box_tag usable.checkbox_title, usable.id,
  62 + @report.resources.map(&:usable).include?(usable), name: usable.checkbox_name %><%= usable %><br>
61 63 <% end %>
62   - </p>
63   - <% end %>
64   - <%= hidden_field_tag 'report[vehicle_ids][]' %>
65   - <% ::Refinery::Reports::Person.grouped.each do |department, persons| %>
  64 + </p>
  65 + <% end %>
  66 + </div>
  67 +
  68 + <div class='field'>
  69 + <% Usable.all['extern'].each do |department, usables| %>
66 70 <p>
67 71 <h3><%= department %></h3>
68   - <% persons.each do |person| %>
69   - <%= check_box_tag "person_ids_#{person.id}", person.id,
70   - @report.resources.map(&:usable).include?(person), name: 'report[person_ids][]' %><%= person.name %><br>
  72 + <% usables.each do |usable| %>
  73 + <%= check_box_tag usable.checkbox_title, usable.id,
  74 + @report.resources.map(&:usable).include?(usable), name: usable.checkbox_name %><%= usable %><br>
71 75 <% end %>
72 76 </p>
73 77 <% end %>
74   - <%= hidden_field_tag 'report[person_ids][]' %>
75 78 </div>
76 79
77 80 <div class='field'>
2  app/views/refinery/reports/admin/reports/_sortable_list.html.erb
... ... @@ -1,5 +1,3 @@
1 1 <ul id='sortable_list'>
2 2 <%= render :partial => 'report', :collection => @reports %>
3 3 </ul>
4   -<%= render '/refinery/admin/sortable_list',
5   - :continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true %>
175 app/views/refinery/reports/reports/show.html.erb
... ... @@ -1,69 +1,124 @@
  1 +<% content_for :javascripts do %>
  2 +<script src="https://maps.googleapis.com/maps/api/js?keyAIzaSyAn0P5CUJVzdB7fOEYAt6Sz1gEkUtB_leg&sensor=false"
  3 + type="text/javascript"></script>
  4 +<%= javascript_include_tag 'gmap3.min' %>
  5 +<script type="text/javascript">
  6 +$(function(){
  7 + function check_coordinates_given(){
  8 + var hash = {};
  9 + if($('#report_coordinates').text() != ''){
  10 + hash = {
  11 + latLng: $('#report_coordinates').text().replace(/[\(\)]/g, '').split(','),
  12 + visible: true,
  13 + id: 'location'
  14 + };
  15 + }
  16 + return hash;
  17 + }
  18 +
  19 + $("#map_canvas").gmap3({
  20 + map:{
  21 + options:{
  22 + center:[50.975242, 9.323609],
  23 + zoom:12,
  24 + mapTypeId: google.maps.MapTypeId.ROADMAP,
  25 + mapTypeControl: true,
  26 + mapTypeControlOptions: {
  27 + style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
  28 + },
  29 + navigationControl: true
  30 + }
  31 + },
  32 + marker:{
  33 + values:[
  34 + check_coordinates_given()
  35 + ]
  36 + }
  37 + });
  38 +});
  39 +
  40 +</script>
  41 +
  42 +<% end %>
  43 +
1 44 <% content_for :body_content_title do %>
2 45 <%= @report.keyword %>
3 46 <% end %>
4 47
5 48 <% content_for :body do %>
6   - <section>
7   - <h1>Keyword</h1>
8   - <p>
9   - <%=raw @report.keyword %>
10   - </p>
11   - </section>
12   - <section>
13   - <h1>Location</h1>
14   - <p>
15   - <%=raw @report.location %>
16   - </p>
17   - </section>
18   - <section>
19   - <h1>Started At</h1>
20   - <p>
21   - <%=raw @report.started_at %>
22   - </p>
23   - </section>
24   - <section>
25   - <h1>Ended At</h1>
26   - <p>
27   - <%=raw @report.ended_at %>
28   - </p>
29   - </section>
30   - <section>
31   - <h1>Is Running</h1>
32   - <p>
33   - <%=raw @report.is_running %>
34   - </p>
35   - </section>
36   - <section>
37   - <h1>Chief</h1>
38   - <p>
39   - <%=raw @report.chief %>
40   - </p>
41   - </section>
42   - <section>
43   - <h1>Report</h1>
44   - <p>
45   - <%=raw @report.report %>
46   - </p>
47   - </section>
48   - <section>
49   - <h1>Author</h1>
50   - <p>
51   - <%=raw @report.author %>
52   - </p>
53   - </section>
54   -<% end %>
55   -
56   -<% content_for :side_body do %>
57   - <aside>
58   - <h2><%= t('.other') %></h2>
59   - <ul id="reports">
60   - <% @reports.each do |report| %>
61   - <li>
62   - <%= link_to report.keyword, refinery.reports_report_path(report) %>
63   - </li>
  49 + <table>
  50 + <thead>
  51 + </thead>
  52 + <tbody>
  53 + <tr>
  54 + <td><b><%= label_tag :keyword, @report.class.human_attribute_name(:keyword) %></b>:</td>
  55 + <td><b><%= @report.keyword %></b></td>
  56 + </tr>
  57 + <tr>
  58 + <td><b><%= label_tag :typ, @report.class.human_attribute_name(:typ) %>:</b></td>
  59 + <td><%= @report.typ %></td>
  60 + </tr>
  61 + <tr>
  62 + <td><b><%= label_tag :location, @report.class.human_attribute_name(:location) %>:</b></td>
  63 + <td><%= @report.location %></td>
  64 + </tr>
  65 + <tr>
  66 + <td><b><%= label_tag :started_at, @report.class.human_attribute_name(:started_at) %></b>:</td>
  67 + <td><%= @report.started_at.strftime("%d.%m.%Y %H:%M") %></td>
  68 + </tr>
  69 + <tr>
  70 + <td><b><%= label_tag :ended_at, @report.class.human_attribute_name(:ended_at) %></b>:</td>
  71 + <td><%= @report.is_running? ? @report.class.human_attribute_name(:is_running) : @report.ended_at.strftime("%d.%m.%Y %H:%M") %></td>
  72 + </tr>
  73 + <tr>
  74 + <td><b><%= label_tag :chief, @report.class.human_attribute_name(:chief) %></b>:</td>
  75 + <td><%= @report.chief %></td>
  76 + </tr>
  77 + </tbody>
  78 + </table>
  79 + <div id="report_coordinates" style="display: none;"><%= @report.coordinates %></div>
  80 + <% if @report.coordinates.present? %>
  81 + <div id="map_canvas"></div>
  82 + <% end %>
  83 + <div id="intern_box">
  84 + <% @report.intern_resources.each do |key, val| %>
  85 + <b><%= key %></b>
  86 + <ul>
  87 + <% val.each do |resource| %>
  88 + <li><%= resource.usable %></li>
  89 + <% end %>
  90 + </ul>
  91 + <% end %>
  92 + </div>
  93 + <div id="extern_box">
  94 + <% @report.extern_resources.each do |key, val| %>
  95 + <b><%= key %></b>
  96 + <ul>
  97 + <% val.each do |resource| %>
  98 + <li><%= resource.usable %></li>
  99 + <% end %>
  100 + </ul>
  101 + <% end %>
  102 + </div>
  103 + <% if @report.report.present? %>
  104 + <div id="report">
  105 + <h4><%= label_tag :report, @report.class.human_attribute_name(:report) %>:</h4>
  106 + <%= @report.report %>
  107 + <% if @report.author.present? %>
  108 + <p>
  109 + <b><%= label_tag :author, @report.class.human_attribute_name(:author) %></b>: <%= @report.author %>
  110 + </p>
  111 + <% end %>
  112 + </div>
  113 + <% end %>
  114 + <% if @report.links.any? %>
  115 + <div id="links">
  116 + <h4><%= label_tag :links, @report.class.human_attribute_name(:links) %>:</h4>
  117 + <% @report.links.each do |link| %>
  118 + <%= link_to link.title, link.url %><br>
64 119 <% end %>
65   - </ul>
66   - </aside>
  120 + </div>
  121 + <% end %>
67 122 <% end %>
68 123
69 124 <%= render '/refinery/content_page' %>
4 config/locales/de.yml
@@ -66,7 +66,9 @@ de:
66 66 chief: Einsatzleiter
67 67 report: Einsatzbericht
68 68 author: Verfasser
69   - refinery/reports/department:
  69 + links: Weitere Berichte und Bilder
  70 + typ: Einsatzart
  71 + refinery/reports/vehicle:
70 72 short_name: Kurzbezeichnung
71 73 time:
72 74 formats:
2  config/locales/en.yml
@@ -54,3 +54,5 @@ en:
54 54 chief: Chief
55 55 report: Report
56 56 author: Author
  57 + links: Further Links and Images
  58 + typ: Type
12 lib/models/usable.rb
... ... @@ -0,0 +1,12 @@
  1 +class Usable
  2 +
  3 + attr_accessor :usables
  4 +
  5 + def self.all
  6 + return @usables unless @usables.nil?
  7 + combined = Refinery::Reports::Vehicle.all + Refinery::Reports::Person.all
  8 + hsh = combined.group_by{|u| u.department.intern? ? 'intern' : 'extern'}
  9 + @usables = hsh.each{|k,v| hsh[k] = v.group_by{|r| r.department.name}}
  10 + @usables
  11 + end
  12 +end

No commit comments for this range

Something went wrong with that request. Please try again.