bookyt_projects 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  class ActivitiesController < AuthorizedController
2
2
  belongs_to :project, :optional => true
3
3
 
4
+ has_scope :by_date
5
+
4
6
  def new
5
7
  # Allow callers specifying defaults
6
8
  if params[:activity]
@@ -0,0 +1,22 @@
1
+ class BatchActivitiesController < ApplicationController
2
+ def new
3
+ # Allow callers specifying defaults
4
+ @date = params[:date] || Date.today
5
+
6
+ # TODO: only employees currently working for tenant
7
+ people = current_tenant.company.employees
8
+
9
+ @activities = people.map{|person|
10
+ person.activities.build(:project => person.latest_project)
11
+ }
12
+ end
13
+
14
+ def create
15
+ date = Date.parse(params[:batch_activities][:date])
16
+ @activites = params[:activities].collect{|activity_params|
17
+ Activity.create(activity_params.merge(:date => date, :minutes => "0"))
18
+ }
19
+
20
+ redirect_to activities_path(:by_date => date.to_s(:db))
21
+ end
22
+ end
@@ -5,9 +5,12 @@ class Activity < ActiveRecord::Base
5
5
  validates :project, :presence => true, :allow_blank => false
6
6
  validates :person, :presence => true, :allow_blank => false
7
7
 
8
- attr_accessor :minutes, :hours
9
-
8
+ # Scopes
9
+ scope :by_date, lambda {|value| where(:date => value)}
10
+
10
11
  # Duration
12
+ attr_accessor :minutes, :hours
13
+
11
14
  validates_date :date, :allow_nil => false, :allow_blank => false
12
15
  validates :duration_from, :presence => true, :unless => :hours_minutes
13
16
  validates :duration_to, :presence => true, :unless => :hours_minutes
@@ -5,5 +5,11 @@ module BookytProjects
5
5
  included do
6
6
  has_many :activities, :foreign_key => :person_id
7
7
  end
8
+
9
+ module InstanceMethods
10
+ def latest_project
11
+ activities.order(:duration_to).last.try(:project)
12
+ end
13
+ end
8
14
  end
9
15
  end
@@ -2,13 +2,16 @@
2
2
  = f.inputs do
3
3
  = f.input :project, :as => :combobox
4
4
  = f.input :person, :as => :combobox
5
+
5
6
  = f.inputs do
6
7
  = f.input :date, :as => :date_field, :required => true
7
8
  = f.input :duration_from, :as => :hour_field
8
9
  = f.input :duration_to, :as => :hour_field
9
10
  = f.input :hours
10
11
  = f.input :minutes
12
+
11
13
  = f.inputs do
12
14
  = f.input :comment
15
+
13
16
  = f.buttons do
14
17
  = f.commit_button
@@ -0,0 +1,25 @@
1
+ = semantic_form_for :batch_activities, :url => batch_activities_path do |f|
2
+ = f.inputs do
3
+ = f.input :date, :as => :date_field, :label => t('attributes.date'), :input_html => {:value => @date}
4
+
5
+ = f.inputs do
6
+ %table{:style => 'width: 100%'}
7
+ %thead
8
+ %th= t_attr :person, Activity
9
+ %th= t_attr :project, Activity
10
+ %th{:style => 'width: 5em'}= t_attr :duration, Activity
11
+ %th= t_attr :comment, Activity
12
+
13
+ %tbody
14
+ - for activity in @activities
15
+ %tr
16
+ = fields_for 'activities[]', activity do |a|
17
+ %td
18
+ = link_to activity.person, activity.person
19
+ = a.hidden_field :person_id
20
+ %td= a.select :project_id, Project.all.map{|project| [project.to_s, project.id]}, {:prompt => t_select_prompt(Project)}
21
+ %td= a.text_field :hours
22
+ %td= a.text_field :comment
23
+
24
+ = f.buttons do
25
+ = f.commit_button
@@ -0,0 +1,3 @@
1
+ %h2= t_title
2
+
3
+ = render 'form'
@@ -1,20 +1,10 @@
1
- - @attributes ||= collection.first.attribute_names - ['id', 'created_at', 'updated_at']
2
1
  %table.list{:class => "#{collection.first.class.to_s.downcase.pluralize} collection"}
3
2
  %thead
4
3
  %tr
5
- - @attributes.each do |field|
6
- %th= t_attr field, collection.first.class
4
+ %th= t_attr :name
5
+ %th= t_attr :client
6
+ %th= t_attr :duration
7
7
  %th.action-links
8
8
 
9
- - @attributes = @attributes - ['name', 'client_id', 'project_state_id']
10
9
  %tbody
11
- - collection.each do |r|
12
- %tr
13
- %td= link_to r.name, r, {'data-href-container' => 'tr'}
14
- - @attributes.each do |field|
15
- %td= r.send(field) if r.respond_to?(field)
16
- %td= r.client
17
- %td= r.project_state
18
- %td.action-links
19
- = list_link_for(:edit, r)
20
- = list_link_for(:delete, r)
10
+ =render collection
@@ -0,0 +1,7 @@
1
+ %tr
2
+ %td= link_to project.name, project, {'data-href-container' => 'tr'}
3
+ %td= project.client
4
+ %td= [project.duration_from, project.duration_to].compact.join(' - ')
5
+ %td.action-links
6
+ = list_link_for(:edit, project)
7
+ = list_link_for(:delete, project)
@@ -5,12 +5,12 @@
5
5
 
6
6
  %table.list
7
7
  %tr
8
- %th Datum
8
+ %th= t_attr :date, Activity
9
9
  %th Wochentag
10
- %th.number Soll-Stunden
11
- %th.number Stunden
12
- %th.number Über-/Unterzeit
13
- %th.number Saldo
10
+ %th.number= t_attr :hours_due, Activity
11
+ %th.number= t_attr :hours_worked, Activity
12
+ %th.number= t_attr :overtime, Activity
13
+ %th.number= t_attr :overall_overtime, Activity
14
14
 
15
15
  - overall_overtime = 0
16
16
  - @work_days.each do |day|
@@ -5,6 +5,7 @@ de:
5
5
  project_state: Projektstatus
6
6
  activity: Aktivität
7
7
  timesheet: Stundenrapport
8
+ batch_activity: Tagesrapport
8
9
  attributes:
9
10
  project:
10
11
  name: Bezeichnung
@@ -30,10 +31,17 @@ de:
30
31
  project_id: Projekt
31
32
  comment: Kommentar
32
33
  time: Zeitraum
34
+ hours_due: Soll-Stunden
35
+ hours_worked: Arbeitsstunden
36
+ overtime: Über-/Unterzeit
37
+ overall_overtime: Saldo
33
38
 
34
39
  bookyt:
35
40
  projects:
36
41
  minutes: "%{duration} Minuten"
42
+ main_navigation:
43
+ salaries: Löhne
44
+ projects: Projekte
37
45
 
38
46
  # Titles
39
47
  timesheets:
data/config/routes.rb CHANGED
@@ -4,6 +4,7 @@ Rails.application.routes.draw do
4
4
  end
5
5
  resources :project_states
6
6
  resources :activities
7
+ resources :batch_activities
7
8
 
8
9
  resources :employees do
9
10
  resources :timesheets
@@ -1,12 +1,12 @@
1
1
  module BookytProjects
2
2
  module Navigation
3
3
  def setup_bookyt_projects(navigation)
4
- navigation.item :projects, t_model(Project), projects_path, :if => Proc.new { user_signed_in? } do |projects|
4
+ navigation.item :projects, t('bookyt.main_navigation.projects'), projects_path, :if => Proc.new { user_signed_in? } do |projects|
5
+ projects.item :capture_hours, t('activities.new.title'), new_batch_activity_path
5
6
  projects.item :project_index, t_title(:index, Project), projects_path, :highlights_on => /\/(projects|activities)($|\/[0-9]*($|\/.*))/
6
7
  projects.item :new_project, t_title(:new, Project), new_project_path
7
8
  projects.item :project_states, t_model(ProjectState), project_states_path, :highlights_on => /\/project_states($|\/([0-9]*|new)($|\/.*))/
8
9
  end
9
- navigation.item :capture_hours, t('activities.new.title'), new_activity_path, :if => Proc.new { user_signed_in? }
10
10
  end
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.11.1'
2
+ VERSION = '0.11.2'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookyt_projects
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 1
10
- version: 0.11.1
9
+ - 2
10
+ version: 0.11.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Simecek (CyT)
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-11 00:00:00 Z
19
+ date: 2012-01-13 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails
@@ -104,6 +104,7 @@ extra_rdoc_files:
104
104
  files:
105
105
  - app/assets/stylesheets/bookyt_projects.sass
106
106
  - app/controllers/activities_controller.rb
107
+ - app/controllers/batch_activities_controller.rb
107
108
  - app/controllers/project_states_controller.rb
108
109
  - app/controllers/projects_controller.rb
109
110
  - app/controllers/timesheets_controller.rb
@@ -115,14 +116,17 @@ files:
115
116
  - app/views/activities/_activity.html.haml
116
117
  - app/views/activities/_form.html.haml
117
118
  - app/views/activities/_list.html.haml
119
+ - app/views/batch_activities/_form.html.haml
120
+ - app/views/batch_activities/new.html.haml
118
121
  - app/views/project_states/_form.html.haml
119
122
  - app/views/projects/_form.html.haml
120
123
  - app/views/projects/_list.html.haml
124
+ - app/views/projects/_project.html.haml
121
125
  - app/views/projects/_show.html.haml
122
126
  - app/views/timesheets/index.html.haml
123
127
  - config/application.rb
124
128
  - config/boot.rb
125
- - config/locales/de.yml
129
+ - config/locales/bookyt_projects.de.yml
126
130
  - config/routes.rb
127
131
  - db/migrate/20110909075128_create_project_states.rb
128
132
  - db/migrate/20110909075220_create_projects.rb
@@ -164,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
168
  requirements: []
165
169
 
166
170
  rubyforge_project:
167
- rubygems_version: 1.8.11
171
+ rubygems_version: 1.8.12
168
172
  signing_key:
169
173
  specification_version: 3
170
174
  summary: Project management plugin for bookyt