Project

General

Profile

Feature #9664 ยป redmine-customfields-rest.patch

Vincent Caron, 2013-09-24 14:25

View differences:

app/controllers/custom_fields_controller.rb (working copy)
21 21
  before_filter :require_admin
22 22
  before_filter :build_new_custom_field, :only => [:new, :create]
23 23
  before_filter :find_custom_field, :only => [:edit, :update, :destroy]
24
  accept_api_auth :index
24 25

  
25 26
  def index
26 27
    @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
27 28
    @tab = params[:tab] || 'IssueCustomField'
29

  
30
    respond_to do |format|
31
      format.html { render :layout => 'base' }
32
      format.api { @count = CustomField.all.count }
33
    end
28 34
  end
29 35

  
30 36
  def new
app/views/custom_fields/index.api.rsb (revision 0)
1
api.array :custom_fields, api_meta(:total_count => @count, :offset => 0, :limit => @count) do
2
  @custom_fields_by_type.each do |type, fields|
3
    fields.each do |field|
4
      api.custom_field do
5
        api.id                field.id
6
        api.name              field.name
7
        api.type              type
8
        api.format            field.field_format
9
        api.required          field.is_required?
10
        api.searchable        field.searchable
11
        api.multiple_values   field.multiple?
12
        api.array :possible_values do
13
          field.possible_values.each do |v|
14
            api.value v
15
          end
16
        end
17
        api.default_value    field.default_value
18
      end
19
    end
20
  end
21
end
    (1-1/1)