Class: Trello::CustomField

Inherits:
BasicData show all
Defined in:
lib/trello/custom_field.rb

Overview

A Custom Field can be activated on a board. Values are stored at the card level.

Instance Attribute Summary collapse

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicData

#==, #attributes, client, #collection_path, create, #element_name, #element_path, #hash, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attrs, #save, save, schema, #schema, #update!, #update_fields

Methods included from JsonUtils

included

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#checkbox_optionsArray<Hash>

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#enable_display_on_card=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#field_groupString (readonly)

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#idString (readonly)

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#model_idString

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#model_typeString

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#nameString

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#positionFloat

Returns:

  • (Float)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

#typeString

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/trello/custom_field.rb', line 22

class CustomField < BasicData

  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true
    attribute :field_group, readonly: true, remote_key: 'fieldGroup'

    # Writable
    attribute :name
    attribute :position, remote_key: 'pos'
    attribute :enable_display_on_card, remote_key: 'cardFront', class_name: 'CustomFieldDisplay'

    # Writable but for create only
    attribute :model_id, remote_key: 'idModel', create_only: true
    attribute :model_type, remote_key: 'modelType', create_only: true
    attribute :type, create_only: true
    attribute :checkbox_options, remote_key: 'options', create_only: true
  end

  validates_presence_of :id, :model_id, :model_type, :name, :type, :position

  class << self
    # Find a custom field by its id.
    def find(id, params = {})
      client.find('customFields', id, params)
    end
  end

  def collection_name
    'customFields'
  end

  # References Board where this custom field is located
  # Currently, model_type will always be "board" at the customFields endpoint
  one :board, path: :boards, using: :model_id

  # If type == 'list'
  many :custom_field_options, path: 'options'

  # Delete this custom field
  # Also deletes all associated values across all cards
  def delete
    client.delete("/customFields/#{id}")
  end

  # If type == 'list', create a new option and add to this Custom Field
  def create_new_option(value)
    payload = { value: value }
    client.post("/customFields/#{id}/options", payload)
  end

  # Will also clear it from individual cards that have this option selected
  def delete_option(option_id)
    client.delete("/customFields/#{id}/options/#{option_id}")
  end
end

Class Method Details

.find(id, params = {}) ⇒ Object

Find a custom field by its id.



45
46
47
# File 'lib/trello/custom_field.rb', line 45

def find(id, params = {})
  client.find('customFields', id, params)
end

Instance Method Details

#collection_nameObject



50
51
52
# File 'lib/trello/custom_field.rb', line 50

def collection_name
  'customFields'
end

#create_new_option(value) ⇒ Object

If type == ‘list’, create a new option and add to this Custom Field



68
69
70
71
# File 'lib/trello/custom_field.rb', line 68

def create_new_option(value)
  payload = { value: value }
  client.post("/customFields/#{id}/options", payload)
end

#deleteObject

Delete this custom field Also deletes all associated values across all cards



63
64
65
# File 'lib/trello/custom_field.rb', line 63

def delete
  client.delete("/customFields/#{id}")
end

#delete_option(option_id) ⇒ Object

Will also clear it from individual cards that have this option selected



74
75
76
# File 'lib/trello/custom_field.rb', line 74

def delete_option(option_id)
  client.delete("/customFields/#{id}/options/#{option_id}")
end