Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 81 - Manager able to add LeaveTime #86

Merged
merged 14 commits into from
Apr 7, 2017
Merged
2 changes: 1 addition & 1 deletion app/controllers/backend/leave_times_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def collection_scope

def resource_params
params.require(:leave_time).permit(
:user_id, :leave_type, :quota, :effective_date, :expiration_date, :usable_hours, :used_hours
:user_id, :leave_type, :quota, :effective_date, :expiration_date, :usable_hours, :used_hours, :remark
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def no_data_alert(message = t('warnings.no_data'))
end

def status_select_option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#87 中,對於 enum select options 的生成。

([:all] + LeaveApplication.statuses.keys).map { |type| [I18n.t("simple_form.options.leave_application.status.#{type}"), type] }.to_h
([:all] + LeaveApplication.statuses.keys).map { |type| [LeaveApplication.human_enum_value(:status, type), type] }.to_h
end

def specific_year
Expand Down
1 change: 1 addition & 0 deletions app/models/leave_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class LeaveTime < ApplicationRecord
end
LEAVE_POOLS_TYPES = LEAVE_POOLS_CONFIG.keys
LEAVE_POOLS_TYPES_SYM = DataHelper.each_to_sym LEAVE_POOLS_TYPES
enum leave_type: Hash[Settings.leave_types.keys.map do |type| [type, type] end]
LEAVE_POOLS_ALLOW_PRE_CREATION =
Settings.leave_pools_misc.allow_pre_creation
LEAVE_POOLS_AUTO_CREATION =
Expand Down
3 changes: 2 additions & 1 deletion app/views/backend/leave_times/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

= simple_form_for [:backend, current_object] do |f|
= f.association :user, required: true
= f.input :leave_type, required: true, collection: LeaveTime::LEAVE_POOLS_TYPES_SYM
= f.input :leave_type, required: true, collection: LeaveTime.enum_attributes_for_select(:leave_types)
= f.input :quota
= f.input :effective_date, date_time_picker_hash(:start, current_object[:effective_date])
= f.input :expiration_date, date_time_picker_hash(:end, current_object[:expiration_date])
= f.input :remark, as: :text
- unless current_object.new_record?
= f.input :usable_hours
= f.input :used_hours
Expand Down
1 change: 1 addition & 0 deletions app/views/shared/_navigation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
%ul.dropdown-menu
%li= link_to t("title.backend/users.index"), backend_users_path
%li= link_to t("title.backend/users.new"), new_backend_user_path
%li= link_to t("title.backend/leave_times.new"), new_backend_leave_time_path
%li= link_to t("title.backend/leave_applications.index"),
backend_leave_applications_path(status: :pending)
%li= link_to t("title.backend/monthly_leave_times.index"),
Expand Down
2 changes: 2 additions & 0 deletions config/application.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ defaults: &defaults
creation: none
maternity:
creation: none
bonus:
creation: none

leave_pools:
remote:
Expand Down
33 changes: 27 additions & 6 deletions config/locales/meta_data.zh_TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ zh-TW:
activerecord:
attributes:
user:
name: "姓名"
login_name: "帳號"
name: "員工姓名"
login_name: "員工帳號"
email: "電子郵件"
role: "身份"
roles:
Expand All @@ -21,17 +21,37 @@ zh-TW:
join_date: "到職日期"
leave_date: "離職日期"
leave_time:
leave_types:
remote: '在家上班'
late: '遲到'
absent: '曠職'
annual: '特休'
personal: '事假'
sick: '病假'
bereavement: '喪假'
official: '公假'
marriage: '婚假'
maternity: '產假'
funeral: '喪假'
bonus: '補休'
user: "員工"
name: "擁有者"
leave_type: "假別"
quota: "時數"
quota: "額度"
used_hours: "已用時數"
used_hours_if_allow: "已用時數"
usable_hours: "可用時數"
usable_hours_if_allow: "可用時數"
effective_date: '有效時間'
expiration_date: '失效時間'
remark: '備註'
leave_application:
statuses:
approved: '核准'
rejected: '駁回'
pending: '待審'
canceled: '取消'
all: '全部'
user: "員工"
start_time: "開始時間"
end_time: "結束時間"
Expand Down Expand Up @@ -100,10 +120,11 @@ zh-TW:
index: "員工休假狀況"
backend/leave_times:
index: "員工休假扣打"
new: "新增休假扣打"
new: "新增員工休假"
edit: "修改"
delete: "刪除"
change_type: "切換休假種類至"
remark: "備註"
leave_applications:
index: "查看歷年假單"
show: "檢視"
Expand Down Expand Up @@ -147,8 +168,8 @@ zh-TW:
index: "%{year} 年 %{month} 月 員工休假狀況"
backend/leave_times:
index: "員工休假扣打"
new: "新增休假扣打"
edit: "修改休假扣打"
new: "新增員工休假"
edit: "修改員工休假"
tools: "工具"

success:
Expand Down
10 changes: 2 additions & 8 deletions config/locales/simple_form.zh_TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ zh-TW:
annual: '特休'
bonus: '補休'
personal: '事假'
sick: '病假' # 之後要改全薪/半薪病假
sick_1: '病假'
sick_2: '半薪病假'
official: '公假'
marriage: '婚假'
maternity: '產假'
funeral: '喪假'
bereavement: '喪假'
absent: '曠職'
leave_application:
leave_type:
Expand All @@ -36,10 +37,3 @@ zh-TW:
maternity: '產假'
funeral: '喪假'
bonus: '補休'

status:
approved: '核准'
rejected: '駁回'
pending: '待審'
canceled: '取消'
all: '全部'
1 change: 1 addition & 0 deletions spec/factories/leave_times.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
quota 0
used_hours 0
usable_hours 0
remark "Test string"

Settings.leave_application_types.keys.each do |type|
trait type.to_sym do
Expand Down