name: forms
icon: timesheet
label: Form
hidden: true
enable_dataloader: false
fields:
  name:
    type: text
    label: Name
    required: true
    searchable: true
    readonly: true
    name: name
  state:
    type: select
    label: State
    options:
      - label: Enabled
        value: enabled
      - label: Disabled
        value: disabled
    readonly: true
    name: state
    filterable: true
  description:
    type: textarea
    label: Description
    is_wide: true
    name: description
  category:
    type: lookup
    label: Category
    reference_to: categories
    readonly: true
    name: category
    filterable: true
  is_valid:
    type: boolean
    label: Valid
    readonly: true
    name: is_valid
  help_text:
    type: text
    label: help text
    readonly: true
    name: help_text
  error_message:
    type: text
    label: error message
    readonly: true
    name: error_message
  instance_style:
    type: select
    label: Instance Style
    options:
      - label: Table
        value: table
      - label: Default
        value: default
    name: instance_style
    filterable: true
  historys:
    label: historys
    blackbox: true
    omit: true
    hidden: true
    name: historys
  approve_on_create:
    label: Approve on Create
    type: boolean
    name: approve_on_create
  approve_on_modify:
    label: Approve on Modify
    type: boolean
    name: approve_on_modify
  approve_on_delete:
    type: boolean
    label: Approve on Delete
    name: approve_on_delete
  enable_workflow:
    type: boolean
    label: Enable Workflow
    name: enable_workflow
  enable_view_others:
    type: boolean
    label: Enable View Others
    name: enable_view_others
  current:
    label: current
    type: object
    is_wide: true
    # readonly: true
    blackbox: true
    name: current
  current.form_script:
    label: Form Script
    type: code
    language: javascript
    readonly: true
    name: current.form_script
  current.name_forumla:
    label: Name Forumla
    type: code
    readonly: true
    name: current.name_forumla
  current.fields:
    label: Fields
    type: table
    is_wide: true
    # readonly: true
    name: current.fields
    amis: 
      inlineEditMode: false
      addable: false
      # 强制规范组件的mode，否则在combo组件下显示异常
      mode: normal
      enableTree: true
      columns: ["code", "name", "type", "is_required", "is_wide", "is_list_display", "is_searchable", "is_multiselect"]
  current.fields.$.code:
    label: Code
    type: text
    readonly: true
    name: current.fields.$.code
  current.fields.$.name:
    label: Name
    type: text
    readonly: true
    name: current.fields.$.name
  current.fields.$.type:
    label: Type
    type: select
    options:
      - label: Checkbox
        value: checkbox
      - label: DateTime
        value: dateTime
      - label: Date
        value: date
      - label: Time
        value: time
      - label: Email
        value: email
      - label: Group
        value: group
      - label: Input
        value: input
      - label: MultiSelect
        value: multiSelect
      - label: Number
        value: number
      - label: Password
        value: password
      - label: Radio
        value: radio
      - label: Section
        value: section
      - label: Select
        value: select
      - label: Table
        value: table
      - label: URL
        value: url
      - label: User
        value: user
      - label: Geolocation
        value: geolocation
      - label: Image
        value: image
      - label: File
        value: file
      - label: Lookup
        value: lookup
    readonly: true
    name: current.fields.$.type
    filterable: true
  current.fields.$.is_required:
    label: Required
    type: boolean
    # readonly: true
    name: current.fields.$.is_required
  current.fields.$.is_wide:
    label: Wide
    type: boolean
    # readonly: true
    name: current.fields.$.is_wide
  current.fields.$.is_list_display:
    label: Display in List
    type: boolean
    # readonly: true
    name: current.fields.$.is_list_display
  current.fields.$.is_searchable:
    label: Searchable
    type: boolean
    # readonly: true
    name: current.fields.$.is_searchable
  current.fields.$.is_multiselect:
    label: Multiselect
    type: boolean
    # readonly: true
    name: current.fields.$.is_multiselect
  current.fields.$.visibleOn:
    label: visible On
    type: code
    # readonly: true
    is_wide: true
    name: current.fields.$.visibleOn
    amis:
      visibleOn: ${!!_master.record.object_name}
  # company_id:
  #   required: false
  #   omit: false
  #   hidden: false
list_views:
  all:
    label: All Forms
    filter_scope: space
    filters:
      - - is_deleted
        - =
        - false
    columns:
      - name
      - category
      - modified
      - modified_by
      - auto_remind
      - state
actions:
  standard_new:
    visible: false
    'on': list
  standard_edit:
    visible: false
    'on': record
  standard_delete:
    visible: false
    'on': record_more
  designForm:
    label: Form Designer
    visible: !<tag:yaml.org,2002:js/function> |-
      function (object_name, record_id, record_permissions) {
              return true;
            }
    'on': record
    todo: !<tag:yaml.org,2002:js/function> |-
      function (object_name, record_id, fields) {
              return WorkflowCore.openFormDesign(Steedos.locale(), Steedos.spaceId(), this.record._id, Creator.getUserCompanyId());
            }
permission_set:
  user:
    allowCreate: false
    allowDelete: false
    allowEdit: false
    allowRead: true
    modifyAllRecords: false
    viewAllRecords: false
  admin:
    allowCreate: false
    allowDelete: false
    allowEdit: true
    allowRead: true
    modifyAllRecords: true
    viewAllRecords: true
  workflow_admin:
    allowCreate: false
    allowDelete: false
    allowEdit: true
    allowRead: true
    modifyAllRecords: false
    viewAllRecords: false
    modifyCompanyRecords: true
    viewCompanyRecords: true
    disabled_list_views: []
    disabled_actions: []
    unreadable_fields: []
    uneditable_fields: []
    unrelated_objects: []
