Add personnel number field

This commit is contained in:
Alexandr Antonov 2024-02-20 15:55:13 +03:00
parent 4f86f36b3e
commit 839aedd663
10 changed files with 38 additions and 13 deletions

View File

@ -61,7 +61,7 @@ class DayoffQuery < Query
add_available_filter 'phone', type: :string, name: l(:label_people_phone)
add_available_filter 'skype', type: :string, name: l(:label_people_skype)
add_available_filter 'twitter', type: :string, name: l(:label_people_twitter)
add_available_filter 'facebook', type: :string, name: l(:label_people_facebook)
add_available_filter 'personnel_number', type: :string, name: l(:label_people_facebook)
add_available_filter 'linkedin', type: :string, name: l(:label_people_linkedin)
add_available_filter 'job_title', type: :string, name: l(:label_people_job_title)
@ -154,7 +154,7 @@ class DayoffQuery < Query
define_sql_methods_for(User, :firstname, :lastname)
define_sql_methods_for(PeopleInformation, :middlename, :gender, :address,
:phone, :skype, :twitter, :facebook, :linkedin, :job_title, :manager_id)
:phone, :skype, :twitter, :personnel_number, :linkedin, :job_title, :manager_id)
def sql_for_mail_field(field, operator, value)
sql_for_field(field, operator, value, EmailAddress.table_name, :address)

View File

@ -30,7 +30,7 @@ class PeopleInformation < ApplicationRecord
validates :workday_length, numericality: { allow_nil: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 24 }
safe_attributes 'phone', 'address', 'skype', 'birthday', 'job_title', 'company', 'middlename', 'gender', 'twitter',
'facebook', 'linkedin', 'department_id', 'background', 'appearance_date', 'is_system', 'manager_id'
'personnel_number', 'linkedin', 'department_id', 'background', 'appearance_date', 'is_system', 'manager_id'
safe_attributes 'workday_length'
def start_date

View File

@ -39,7 +39,7 @@ class PeopleQuery < Query
QueryColumn.new(:phone, :sortable => "#{PeopleInformation.table_name}.phone", :caption => :label_people_phone),
QueryColumn.new(:skype, :sortable => "#{PeopleInformation.table_name}.skype", :caption => :label_people_skype ),
QueryColumn.new(:twitter, :sortable => "#{PeopleInformation.table_name}.twitter", :caption => :label_people_twitter),
QueryColumn.new(:facebook, :sortable => "#{PeopleInformation.table_name}.facebook", :caption => :label_people_facebook),
QueryColumn.new(:personnel_number, :sortable => "#{PeopleInformation.table_name}.personnel_number", :caption => :label_people_facebook),
QueryColumn.new(:linkedin, :sortable => "#{PeopleInformation.table_name}.linkedin", :caption => :label_people_linkedin),
QueryColumn.new(:birthday, :sortable => "#{PeopleInformation.table_name}.birthday", :caption => :label_people_birthday),
QueryColumn.new(:job_title, :sortable => "#{PeopleInformation.table_name}.job_title", :groupable => "#{PeopleInformation.table_name}.job_title", :caption => :label_people_job_title),
@ -132,7 +132,7 @@ class PeopleQuery < Query
add_available_filter 'phone', :type => :string, :order => 6, :name => l(:label_people_phone)
add_available_filter 'skype', :type => :string, :order => 7, :name => l(:label_people_skype)
add_available_filter 'twitter', :type => :string, :order => 8, :name => l(:label_people_twitter)
add_available_filter 'facebook', :type => :string, :order => 9, :name => l(:label_people_facebook)
add_available_filter 'personnel_number', :type => :string, :order => 9, :name => l(:label_people_facebook)
add_available_filter 'linkedin', :type => :string, :order => 10, :name => l(:label_people_linkedin)
add_available_filter 'birthday', :type => :date_past, :order => 11, :name => l(:label_people_birthday)
add_available_filter 'job_title', :type => :string, :order => 12, :name => l(:label_people_job_title)
@ -247,7 +247,7 @@ class PeopleQuery < Query
end
[
:phone, :address, :skype, :birthday, :job_title, :company, :middlename, :gender, :twitter,
:facebook, :linkedin, :background, :appearance_date, :workday_length
:personnel_number, :linkedin, :background, :appearance_date, :workday_length
].each do |f|
define_method("sql_for_#{f}_field") do |field, operator, value|
'(' + sql_for_field(field, operator, value, PeopleInformation.table_name, f) + ')'

View File

@ -32,7 +32,7 @@ class Person < User
has_one :information, :class_name => 'PeopleInformation', :foreign_key => :user_id, :dependent => :destroy
delegate :phone, :address, :skype, :birthday, :job_title, :company, :middlename, :gender, :twitter,
:facebook, :linkedin, :department_id, :background, :appearance_date, :is_system, :manager_id,
:personnel_number, :linkedin, :department_id, :background, :appearance_date, :is_system, :manager_id,
:to => :information, :allow_nil => true
acts_as_customizable

View File

@ -58,10 +58,10 @@
<td class="twitter icon icon-twitter"><%= link_to @person.twitter, "http://twitter.com/" + @person.twitter %></td>
</tr>
<% end %>
<% unless @person.facebook.blank? %>
<% unless @person.personnel_number.blank? %>
<tr>
<th class = "facebook"><%= l(:label_people_facebook) %>:</th>
<td class="facebook icon icon-facebook"><%= link_to @person.facebook.gsub(/^.*facebook.com\//, ''), "http://facebook.com/#{@person.facebook}" %></td>
<th class = "personnel_number"><%= l(:label_people_facebook) %>:</th>
<td class="personnel_number"><%= @person.personnel_number %></td>
</tr>
<% end %>
<% unless @person.linkedin.blank? %>

View File

@ -61,7 +61,7 @@
<!--
<p><%= information.text_field :skype, :label => l(:label_people_skype) -%></p>
<p><%= information.text_field :facebook, :label => l(:label_people_facebook) + ' ID'-%></p>
<p><%= information.text_field :personnel_number, :label => l(:label_people_facebook) -%></p>
<p><%= information.text_field :twitter, :label => l(:label_people_twitter) -%></p>
<p><%= information.text_field :linkedin, :label => l(:label_people_linkedin) + ' ID' -%></p>
-->

View File

@ -2,6 +2,7 @@ api.person do
api.id @person.id
api.login @person.login
api.email @person.email
api.personnel_number @person.personnel_number
api.firstname @person.firstname
api.middlename @person.middlename
api.lastname @person.lastname

View File

@ -22,7 +22,7 @@ en:
label_people_phone_plural: Phones
label_people_skype: Skype
label_people_twitter: Twitter
label_people_facebook: Facebook
label_people_facebook: Personnel number
label_people_linkedin: LinkedIn
label_people_workday_length: Workday length
label_people_middlename: Middle name

View File

@ -22,7 +22,7 @@ ru:
label_people_phone_plural: Телефоны
label_people_skype: Skype
label_people_twitter: Twitter
label_people_facebook: Facebook
label_people_facebook: Табельный номер
label_people_linkedin: LinkedIn
label_people_workday_length: Продолжительность рабочего дня
label_people_middlename: Отчество

View File

@ -0,0 +1,24 @@
# This file is a part of Redmine People (redmine_people) plugin,
# humanr resources management plugin for Redmine
#
# Copyright (C) 2011-2022 RedmineUP
# http://www.redmineup.com/
#
# redmine_people is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_people is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_people. If not, see <http://www.gnu.org/licenses/>.
class ChangeFacebookToPersonnelNumber < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
rename_column :people_information, :facebook, :personnel_number
end
end