import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'
import EditIcon from '../../components/Icons/EditIcon'
import DesignIcon from '../../components/Icons/DesignIcon'
import DocumentTemplateIcon from '../../components/Icons/DocumentTemplateIcon'

export const DocumentTemplate = {
  name: 'documentTemplate',
  label: 'Document Template',
  prefix: 'DTP',
  icon: DocumentTemplateIcon,
  actions: [
    {
      name: 'design',
      label: 'Design',
      row: true,
      icon: DesignIcon,
      url: (_id) =>
        `/dashboard/management/documenttemplates/design?documentTemplateId=${_id}`
    },
    {
      name: 'info',
      label: 'Info',
      default: true,
      row: true,
      icon: InfoCircleIcon,
      url: (_id) =>
        `/dashboard/management/documenttemplates/info?documentTemplateId=${_id}`
    },

    {
      name: 'reload',
      label: 'Reload',
      icon: ReloadIcon,
      url: (_id) =>
        `/dashboard/management/documenttemplates/info?documentTemplateId=${_id}&action=reload`
    },
    {
      name: 'edit',
      label: 'Edit',
      row: true,
      icon: EditIcon,
      url: (_id) =>
        `/dashboard/management/documenttemplates/info?documentTemplateId=${_id}&action=edit`
    }
  ],
  columns: [
    'name',
    '_id',
    'active',
    'global',
    'objectType',
    'tags',
    'parent',
    'parent._id',
    'documentSize',
    'documentSize._id',
    'createdAt',
    'updatedAt'
  ],
  filters: ['name', '_id', 'active', 'tags', 'objectType'],
  group: ['documentSize', 'tags'],
  sorters: [
    'name',
    'parent',
    'documentSize',
    'createdAt',
    'updatedAt',
    'active',
    'global',
    'objectType'
  ],
  properties: [
    {
      name: '_id',
      label: 'ID',
      type: 'id',
      objectType: 'documentTemplate',
      showCopy: true
    },
    {
      name: 'createdAt',
      label: 'Created At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'name',
      label: 'Name',
      required: true,
      type: 'text',
      columnWidth: 200,
      columnFixed: 'left'
    },
    {
      name: 'updatedAt',
      label: 'Updated At',
      type: 'dateTime',
      readOnly: true
    },
    {
      name: 'objectType',
      label: 'Object Type',
      required: true,
      type: 'objectType',
      empty: (documentTemplate) => {
        return documentTemplate.global
      }
    },
    {
      name: 'active',
      label: 'Active',
      required: true,
      type: 'bool',
      columnWidth: 150
    },
    {
      name: 'tags',
      label: 'Tags',
      required: false,
      type: 'tags'
    },
    {
      name: 'global',
      label: 'Global',
      required: true,
      type: 'bool',
      columnWidth: 150
    },
    {
      name: 'documentSize',
      label: 'Document Size',
      required: true,
      type: 'object',
      objectType: 'documentSize'
    },
    {
      name: 'documentSize._id',
      label: 'Document Size ID',
      type: 'id',
      objectType: 'documentSize',
      showCopy: true,
      showHyperlink: true
    },
    {
      name: 'parent',
      label: 'Parent',
      required: false,
      type: 'object',
      masterFilter: { global: true, active: true },
      objectType: 'documentTemplate',
      empty: (documentTemplate) => {
        return documentTemplate.global
      }
    },
    {
      name: 'parent._id',
      label: 'Parent ID',
      required: false,
      type: 'id',
      showHyperlink: true,
      objectType: 'documentTemplate',
      empty: (documentTemplate) => {
        return documentTemplate.global
      }
    },
    {
      name: 'documentPrinters',
      label: 'Document Printers',
      required: false,
      type: 'objectList',
      objectType: 'documentPrinter'
    },
    {
      name: 'content',
      label: 'Content',
      required: false,
      type: 'codeBlock',
      language: 'ejs'
    },
    {
      name: 'testObject',
      label: 'Test Object',
      required: false,
      type: 'codeBlock',
      language: 'json'
    }
  ]
}
