/* Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ import AdapterBase from '../../../api/AdapterBase'; /** * DocumentAdapter */ class DocumentAdapter extends AdapterBase { getDataMapping() { return [ 'id', 'name', 'details', ]; } getHeaders() { return [ { sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Details' }, ]; } getFormFields() { return [ ['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }], ['expire_notification', { label: 'Notify Expiry', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], ['expire_notification_month', { label: 'Notify Expiry Before One Month', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], ['expire_notification_week', { label: 'Notify Expiry Before One Week', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], ['expire_notification_day', { label: 'Notify Expiry Before One Day', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], // [ "sign", {"label":"Require Signature","type":"select","source":[["Yes","Yes"],["No","No"]]}], // [ "sign_label", {"label":"Signature Description","type":"textarea","validation":"none"}], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ]; } getHelpLink() { return 'https://icehrm.gitbook.io/icehrm/training-and-reviews/document-management'; } } /** * CompanyDocumentAdapter */ class CompanyDocumentAdapter extends AdapterBase { getDataMapping() { return [ 'id', 'name', 'details', 'status', ]; } getHeaders() { return [ { sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Details' }, { sTitle: 'Status' }, ]; } getFormFields() { return [ ['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], ['attachment', { label: 'Attachment', type: 'fileupload' }], [ 'share_departments', { label: 'Share Departments', type: 'select2multi', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], help: 'This document will be visible to employees from selected department. If no department is selected only Admin users can see this', }, ], [ 'share_employees', { label: 'Share Employees', type: 'select2multi', 'allow-null': true, 'null-label': 'All Employees', 'remote-source': ['Employee', 'id', 'first_name+last_name'], validation: 'none', help: 'Instead of sharing with all the employees in a department, you can share it only with specific employees', }, ], ]; } } /** * EmployeeDocumentAdapter */ class EmployeeDocumentAdapter extends AdapterBase { getDataMapping() { return [ 'id', 'employee', 'document', 'details', 'date_added', 'status', 'attachment', ]; } getHeaders() { return [ { sTitle: 'ID', bVisible: false }, { sTitle: 'Employee' }, { sTitle: 'Document' }, { sTitle: 'Details' }, { sTitle: 'Date Added' }, { sTitle: 'Status' }, { sTitle: 'Attachment', bVisible: false }, ]; } getFormFields() { return [ ['id', { label: 'ID', type: 'hidden' }], ['employee', { label: 'Employee', type: 'select2', sort: 'none', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], }], ['document', { label: 'Document', type: 'select2', 'remote-source': ['Document', 'id', 'name'] }], ['date_added', { label: 'Date Added', type: 'date', validation: '' }], ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ['attachment', { label: 'Attachment', type: 'fileupload', validation: '' }], ]; } getFilters() { return [ ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], ]; } getActionButtonsHtml(id, data) { let html = '
'
+ '
'
+ '
'
+ '