/* Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ import LogViewAdapter from './LogViewAdapter'; class ApproveModuleAdapter extends LogViewAdapter { cancelRequest(id) { const object = {}; object.id = id; const reqJson = JSON.stringify(object); const callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'cancelSuccessCallBack'; callBackData.callBackFail = 'cancelFailCallBack'; this.customAction('cancel', `modules=${this.modulePathName}`, reqJson, callBackData); } // eslint-disable-next-line no-unused-vars cancelSuccessCallBack(callBackData) { this.showMessage('Successful', `${this.itemName} cancellation request sent`); this.get([]); } cancelFailCallBack(callBackData) { this.showMessage(`Error Occurred while cancelling ${this.itemName}`, callBackData); } getActionButtonsHtml(id, data) { const editButton = ''; const deleteButton = ''; const requestCancellationButton = ``; const viewLogsButton = ''; let html = '
_edit__logs__delete_
'; html = html.replace('_logs_', viewLogsButton); if (this.showDelete) { if (data[7] === 'Approved') { html = html.replace('_delete_', requestCancellationButton); } else if (data[7] === 'Pending' || this.user.user_level === 'Admin') { html = html.replace('_delete_', deleteButton); } else { html = html.replace('_delete_', ''); } } else { html = html.replace('_delete_', ''); } if (this.showEdit) { html = html.replace('_edit_', editButton); } else { html = html.replace('_edit_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); return html; } } export default ApproveModuleAdapter;