Class: Redmine::FieldFormat::UserFormat
- Inherits:
-
RecordList
- Object
- Base
- List
- RecordList
- Redmine::FieldFormat::UserFormat
- Defined in:
- lib/redmine/field_format.rb
Instance Method Summary collapse
- #before_custom_field_save(custom_field) ⇒ Object
- #possible_values_options(custom_field, object = nil) ⇒ Object
- #possible_values_records(custom_field, object = nil) ⇒ Object
- #query_filter_values(custom_field, query) ⇒ Object
- #value_from_keyword(custom_field, keyword, object) ⇒ Object
Methods inherited from RecordList
#cast_single_value, #group_statement, #join_for_order_statement, #order_statement, #possible_custom_value_options, #reset_target_class, #target_class, #validate_custom_value
Methods inherited from List
#bulk_edit_tag, #edit_tag, #query_filter_options
Methods inherited from Base
#after_save_custom_value, #bulk_edit_tag, #cast_custom_value, #cast_single_value, #cast_value, #edit_tag, field_attributes, #formatted_custom_value, #formatted_value, #group_statement, #join_for_order_statement, #label, #name, #order_statement, #possible_custom_value_options, #query_filter_options, #set_custom_field_value, #target_class, #validate_custom_field, #validate_custom_value, #validate_single_value
Methods included from Helpers::URL
#uri_with_link_safe_scheme?, #uri_with_safe_scheme?
Methods included from I18n
#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages
Instance Method Details
#before_custom_field_save(custom_field) ⇒ Object
894 895 896 897 898 899 |
# File 'lib/redmine/field_format.rb', line 894 def before_custom_field_save(custom_field) super if custom_field.user_role.is_a?(Array) custom_field.user_role.map!(&:to_s).reject!(&:blank?) end end |
#possible_values_options(custom_field, object = nil) ⇒ Object
860 861 862 863 864 865 |
# File 'lib/redmine/field_format.rb', line 860 def (custom_field, object=nil) users = possible_values_records(custom_field, object) = users.map {|u| [u.name, u.id.to_s]} = [["<< #{l(:label_me)} >>", User.current.id]] + if users.include?(User.current) end |
#possible_values_records(custom_field, object = nil) ⇒ Object
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
# File 'lib/redmine/field_format.rb', line 867 def possible_values_records(custom_field, object=nil) if object.is_a?(Array) projects = object.map {|o| o.respond_to?(:project) ? o.project : nil}.compact.uniq projects.map {|project| possible_values_records(custom_field, project)}.reduce(:&) || [] elsif object.respond_to?(:project) && object.project scope = object.project.users if custom_field.user_role.is_a?(Array) role_ids = custom_field.user_role.map(&:to_s).reject(&:blank?).map(&:to_i) if role_ids.any? scope = scope.where("#{Member.table_name}.id IN (SELECT DISTINCT member_id FROM" \ " #{MemberRole.table_name} WHERE role_id IN (?))", role_ids) end end scope.sorted else [] end end |
#query_filter_values(custom_field, query) ⇒ Object
901 902 903 |
# File 'lib/redmine/field_format.rb', line 901 def query_filter_values(custom_field, query) query. end |
#value_from_keyword(custom_field, keyword, object) ⇒ Object
887 888 889 890 891 892 |
# File 'lib/redmine/field_format.rb', line 887 def value_from_keyword(custom_field, keyword, object) users = possible_values_records(custom_field, object).to_a parse_keyword(custom_field, keyword) do |k| Principal.detect_by_keyword(users, k).try(:id) end end |