Project

General

Profile

Defect #19271 ยป field_format.rb.patch

@ 3.0-stable - Sebastian Paluch, 2015-05-15 20:27

View differences:

lib/redmine/field_format.rb (working copy)
122 122
        possible_values_options(custom_value.custom_field, custom_value.customized)
123 123
      end
124 124

  
125
      def possible_values_options(custom_field, object=nil)
125
      def possible_values_options(custom_field, object=nil, options={})
126 126
        []
127 127
      end
128 128

  
......
464 464
      end
465 465

  
466 466
      def query_filter_options(custom_field, query)
467
        {:type => :list_optional, :values => possible_values_options(custom_field, query.project)}
467
        {:type => :list_optional, :values => possible_values_options(custom_field, query.project,{:query_filter => true})}
468 468
      end
469 469

  
470 470
      protected
......
528 528
        options
529 529
      end
530 530

  
531
      def possible_values_options(custom_field, object=nil)
531
      def possible_values_options(custom_field, object=nil, options={})
532 532
        custom_field.possible_values
533 533
      end
534 534

  
......
567 567
        value == '1' ? true : false
568 568
      end
569 569

  
570
      def possible_values_options(custom_field, object=nil)
570
      def possible_values_options(custom_field, object=nil, options={})
571 571
        [[::I18n.t(:general_text_Yes), '1'], [::I18n.t(:general_text_No), '0']]
572 572
      end
573 573

  
......
658 658
      self.form_partial = 'custom_fields/formats/user'
659 659
      field_attributes :user_role
660 660

  
661
      def possible_values_options(custom_field, object=nil)
661
      def possible_values_options(custom_field, object=nil, options={})
662 662
        if object.is_a?(Array)
663 663
          projects = object.map {|o| o.respond_to?(:project) ? o.project : nil}.compact.uniq
664
          projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
664
          projects.map {|project| possible_values_options(custom_field, project, options)}.reduce(:&) || []
665 665
        elsif object.respond_to?(:project) && object.project
666 666
          scope = object.project.users
667 667
          if custom_field.user_role.is_a?(Array)
......
689 689
      self.form_partial = 'custom_fields/formats/version'
690 690
      field_attributes :version_status
691 691

  
692
      def possible_values_options(custom_field, object=nil)
692
      def possible_values_options(custom_field, object=nil, options={})
693 693
        if object.is_a?(Array)
694 694
          projects = object.map {|o| o.respond_to?(:project) ? o.project : nil}.compact.uniq
695
          projects.map {|project| possible_values_options(custom_field, project)}.reduce(:&) || []
695
          projects.map {|project| possible_values_options(custom_field, project, options)}.reduce(:&) || []
696 696
        elsif object.respond_to?(:project) && object.project
697 697
          scope = object.project.shared_versions
698
          if custom_field.version_status.is_a?(Array)
698
          if !(options[:query_filter] || false) && custom_field.version_status.is_a?(Array)
699 699
            statuses = custom_field.version_status.map(&:to_s).reject(&:blank?)
700 700
            if statuses.any?
701 701
              scope = scope.where(:status => statuses.map(&:to_s))
    (1-1/1)