name: cfs_files_filerecord
label: Attachment Version
table_name: 'cfs.files.filerecord'
icon: drafts
enable_search: true
enable_api: true
hidden: true
fields:
  original:
    label: Original
    type: object
    blackbox: true
    readonly: true
  "original.name":
    label: Name
    type: text
    readonly: true
    # is_name: true
  "original.size":
    label: Size
    type: number
    readonly: true
  metadata:
    label: Metadata
    type: object
    blackbox: true
  "metadata.owner":
    label: Owner
    type: lookup
    reference_to: users
    hidden: true #前端显示成id了，直接隐藏
  "metadata.owner_name":
    label: Owner Name
    type: text
    readonly: true
    # visible_on: "{{global.mode ==='read' ? true : false}}"
  "metadata.parent":
    label: Parent 
    type: master_detail
    reference_to: cms_files
    visible_on: "{{false}}"
  uploadedAt: 
    label: Upload Time
    type: "datetime"
  created_by:
    hidden: true
  modified_by:
    hidden: true
list_views:
  all:
    columns: 
      - "original.name"
      - "metadata.owner_name"
      - "uploadedAt"
      - "original.size"
    filter_scope: space
permission_set:
  user:
    allowCreate: false
    allowDelete: true
    allowEdit: false
    allowRead: true
    modifyAllRecords: false
    viewAllRecords: true 
  admin:
    allowCreate: false
    allowDelete: true
    allowEdit: true
    allowRead: true
    modifyAllRecords: true
    viewAllRecords: true 
  customer:
    allowCreate: false
    allowDelete: true
    allowEdit: false
    allowRead: true
    modifyAllRecords: false
    viewAllRecords: true

actions:
  standard_edit:
    label: Edit
    sort: 0
    visible: false
    'on': record_only_more
  download:
    label: Download
    visible: true
    on: record
    todo: !<tag:yaml.org,2002:js/function> |-
      function (object_name, record_id) {
        var file, fileId, filename, length, ref, ref1, rev, url;
        file = this.record;
        if(!file){
          return false;
        }
        fileId = record_id;
        if (fileId) {
          window.location = Steedos.absoluteUrl("/api/v6/files/download/cfs.files.filerecord/" + fileId + "/" + file.name);
        }
      }
