# key: It represents the id of the table
# string, required
# allows letters, numbers and underscores only (should start with a letter)
key: approvedCandidates

# type: Should be "table" for tables
# required, string
type: table

# name: Describes the name of the table in plural form
# string, required
name: Candidates

# itemName: Describes the name of an item (singular)
# string, required
itemName: Candidate

# summary: Describes how to display a summary of an item
# object, required
summary:

  # describes the first line (title) of the item. It can contain variables that references the fields of the table
  # string, required
  title: "{{id}} - {{firstName}} {{lastName}}"

  # describes the second line (subtitle) of the item. It can contain variables that references the fields of the table.
  # string, optional
  subtitle: "{{email}}"

# fields: describes the fields of this table
# object, required
fields:

  # field. Defines a field, probably should be handled in its own schema
  # the field name should allow only letters, numbers and underscore, and always start with a letter, and be no larger than 50 chars.
  firstName:

    # type: Describes the field type. Possible options are documented here:
    # https://docs.google.com/spreadsheets/d/19rrs2h1sQV4R87j3Q6eGup11KQE1d5N89-1cFlSz4v0/edit?userstoinvite=cjarrin@devsu.com&ts=5d4464ff&actionButton=1#gid=1274754179
    # string, required
    type: signature

    # label: Should be a string
    # string, required
    label: First Name

    # required: Determines if this field is required or not. Default false.
    # boolean, optional
    required: true

    # description: Displayed to the user as additional information for helping them to understand the purpose of the field
    # string, optional
    description: It is the first name of the candidate
    readOnly: false

  middleName:
    type: relationship
    label: RelationShip
    required: true
    description: Example
    table: Recruiters

  lastName:
    type: text
    label: Last Name
    required: true
    readOnly: false

  email:
    type: text
    label: Short Description
    required: true
    readOnly: false

  salary:
    type: money
    label: Salary
    required: false
    readOnly: false

  username:
    type: user
    label: Username
    required: true
    description: Simple example
    readOnly: false

  identificationDocumentType:
    type: select
    label: Document Type
    required: false
    readOnly: false
    options:

      # each option is a key:value pair
      # both the key and the value can be anything
      passport: Passport
      driversLicense: Driver's License
      other: Other

  identificationNumber:
    type: text
    label: Document Number
    required: false
    readOnly: false

# form: Describes how the form for this table should be rendered.
# optional. It should be validated against the form schema
form:
  rows:
    - _title: Personal Information
    - [firstName, middleName, lastName]
    - email
    - [identificationDocumentType, identificationNumber]
    - _title: Other Information
    - salary

# stages: Describe the stages that an item can go through
# object, optional. If it does not have stages, it means that this type of item does not have stages.
stages:

  # stage key: Identifies the stage.
  # string, only letters, numbers and underscore, should start with a letter.
  new:
    # name: Defines the name of the stage
    # string, required
    name: New

    # description
    # string, optional
    description: It is a new candidate, hasn't gone through any tests

  inProcess:
    name: In Process
    description: It has entered the process, but no outcome yet defined

  approved:
    name: Approved
    description: Candidate has been approved

    # done: Determines if it is on a "final" state
    # boolean, optional. Default false
    done: true

    # successful: Determines if the outcome can be considered successful.
    # boolean, optional.
    successful: true

  rejected:
    name: Rejected
    description: Candidate has been rejected definitively
    done: true
    successful: false

  shortTermPool:
    name: Short Term Pool
    description: Candidate is not a fit now, but probably in the near future
    # parked: Determines if the item is on a "parked" state. (not done, but not active neither)
    # boolean, optional. Default false
    parked: true

  longTermPool:
    name: Long Term Pool
    description: Candidate is not a fit now, and doesn't seem to be a fit in the near future
    parked: true

# initialStage: Which of the stages should be considered by default when creating an item.
# optional. It depends on stages.
initialStage: new

# permissions: Defines the permissions for this table. Probably it should be moved to its own schema.
# object, optional
permissions:

  # each permission name must correspond to a valid role
  # TODO: is it possible using JSON Schema to validate against the roles defined in the app?
  # it might reference to a role in the same app (e.g. "recruitment"), or a role in another app
  # (e.g. "anotherApp.anotherRole") or a role defined in the commons folder (e.g. "commons.employee")
  recruiter:

    # create: Determines if the user can create an item in this table
    # optional, it can be:
    # - a boolean (true or false)
    # - an array, which contains the fields that can be entered when creating an item.
    #   - * means all fields
    #   - ! prefix means to exclude that field
    #   - otherwise, it should be a valid field name to be included
    create: true

    # delete: Determines if the user can delete an item.
    # optional, it can be:
    # - a boolean (true or false)
    # - an object with any of these properties:
    #   - own: can delete only items created by them
    #   - assigned: can delete only items related to cases assigned to them
    #   - any: can delete any items. It is the same as "delete: true"
    delete:
      own: true
      assigned: true
      any: false

    # view: Determines if the user can view items.
    # optional, it can be:
    # - a boolean (true or false)
    # - an array of fields (e.g. ["*", "!salary"] means all fields except salary)
    # - an object, with properties "own", "assigned" or "any" such object might be:
    #   - a boolean (true or false), which means access to all fields
    #   - an array with the name of the fields
    #     - * means all fields
    #     - ! prefix means to exclude that field
    #     - otherwise, it should be a valid field name to be included
    view: true

    # edit: Determines which fields are editable by the user.
    # optional, it follows the same rules as view
    edit: ['*', '!address']
  employee:
    create: false
    delete:
      own: true
    view:
      own: ['*', '!salary']
    edit:
      own: [firstName, lastName, email]

# testData: It is sample data that might be useful for testing the table
# object, optional
testData:

  # keys can be anything
  first:

    # we have key/value pairs for each key
    firstName: Juan
    lastName: Perez
    email: juanperez@gmail.com
    identificationDocumentType: cedula
    identificationNumber: 1712345678

  2:
    firstName: Pedro
    lastName: Perez
    email: pedroperez@gmail.com


# data: It defines data that should be automatically created or updated in the app when it's published.
# it follows the same structure as "testData"
data:
    1:
      firstName: Juan
      lastName: Perez
      email: juanperez@gmail.com
      identificationDocumentType: cedula
      identificationNumber: 1712345678
