diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js index a6461e52dfd4deb0697689f4097df9887296ad61..94958c03337bc4f29abfcd6399a538157865987b 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js @@ -2183,14 +2183,10 @@ export class SchedulingSetCreate extends Component { * Read Data from clipboard */ async readClipBoard(){ - try{ - const queryOpts = { name: 'clipboard-read', allowWithoutGesture: true }; - // await navigator.permissions.query(queryOpts); - let data = await navigator.clipboard.readText(); - return data; - }catch(err){ - console.log("Error",err); - } + const queryOpts = { name: 'clipboard-read', allowWithoutGesture: true }; + // await navigator.permissions.query(queryOpts); + let data = await navigator.clipboard.readText(); + return data; } /** @@ -2253,52 +2249,26 @@ export class SchedulingSetCreate extends Component { this.growl.show({severity: 'error', summary: 'Warning', detail: 'Unable to copy the data to clipboard'}); } } - - /* if (navigator.userAgent.indexOf('Firefox')>=0) { - if (navigator.appVersion.indexOf("Win") != -1) { - const queryOpts = { name: 'clipboard-write', allowWithoutGesture: true }; - await navigator.permissions.query(queryOpts); - await navigator.clipboard.writeText(clipboardData); - } else { - const elem = document.createElement('textarea'); - elem.value = clipboardData; - document.body.appendChild(elem); - elem.select(); - document.execCommand('copy'); - document.body.removeChild(elem); - } - } else { - const elem = document.createElement('textarea'); - elem.value = clipboardData; - document.body.appendChild(elem); - elem.select(); - document.execCommand('copy'); - document.body.removeChild(elem); - // await navigator.clipboard.writeText(clipboardData); - } */ - const headerText = (this.state.copyHeader) ?'with Header' : ''; this.growl.show({severity: 'success', summary: '', detail: selectedRows.length+' row(s) copied to clipboard '+headerText }); } + /** * Copy data to/from clipboard * @param {*} e */ async clipboardEvent(e){ var key = e.which || e.keyCode; - var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false); - if ( key === 67 && ctrl ) { - //Ctrl+C + var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17 || key === 91) ? true : false); + if ( key === 67 && ctrl ) { //Ctrl+C this.copyToClipboard(); } - else if ( key === 86 && ctrl ) { // Ctrl+V - // If browser is Firefox, show the dialog to paste clipboard content and - if (navigator.appVersion.indexOf("Win") != -1 && navigator.userAgent.indexOf('Firefox')<0) { + else if ( key === 86 && ctrl ) { // Ctrl+V + try{ + var clipText = await this.readClipBoard(); + await this.setState({clipText: clipText}); this.copyFromClipboard(); - } else { - this.setState({ - confirmDialogVisible: true, - }); + }catch(error) { this.callBackFunction = this.copyFromClipboard; this.onCancel = () => { this.setState({confirmDialogVisible: false, clipText: ''}); @@ -2315,30 +2285,8 @@ export class SchedulingSetCreate extends Component { this.dialogContent = this.pasteTextField; this.actions = [{id: "ok_btn", title: "Ok", callback: this.copyFromClipboard}, {id: "cancel_btn", title: "Cancel", callback: this.onCancel}]; + this.setState({confirmDialogVisible: true}); } - /* if (navigator.userAgent.indexOf('Firefox')>=0) { - this.setState({ - confirmDialogVisible: true, - }); - this.callBackFunction = this.copyFromClipboard; - this.onCancel = () => { - this.setState({confirmDialogVisible: false, clipText: ''}); - this.actions = null; - }; - this.onClose = () => { - this.setState({confirmDialogVisible: false, clipText: ''}); - this.actions = null; - }; - this.showIcon = false; - this.dialogType = "confirmation"; - this.dialogHeader = "Paste Copied Data"; - this.dialogMsg = "Paste copied content in the field and click Ok to paste to the selected row(s)"; - this.dialogContent = this.pasteTextField; - this.actions = [{id: "ok_btn", title: "Ok", callback: this.copyFromClipboard}, - {id: "cancel_btn", title: "Cancel", callback: this.onCancel}] - } else { - this.copyFromClipboard(); - }*/ } } @@ -2351,8 +2299,6 @@ export class SchedulingSetCreate extends Component { onChange={e => this.setState({clipText: e.target.value})}></textarea>; } - - /** * Function to copy the data from clipboard */ @@ -2362,7 +2308,7 @@ export class SchedulingSetCreate extends Component { this.tmpRowData = this.state.rowData; let dataRowCount = this.state.totalCount; //Read Clipboard Data - let clipboardData = this.state.clipText?this.state.clipText:await this.readClipBoard(); + let clipboardData = this.state.clipText?this.state.clipText:null;//await this.readClipBoard(); let selectedRowIndex = 0; if (selectedRows){ await selectedRows.map(selectedRow =>{