diff --git a/SAS/TMSS/frontend/tmss_webapp/src/layout/components/CustomDialog.js b/SAS/TMSS/frontend/tmss_webapp/src/layout/components/CustomDialog.js index 36fdcb1febdf2569f4944e362bfb076c043ffa43..c8b2fc0f1307fb23cf51dbe4829d42abecbd4015 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/layout/components/CustomDialog.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/layout/components/CustomDialog.js @@ -23,7 +23,8 @@ export class CustomDialog extends Component { // const isError = this.props.type.toLowerCase()==='error'; let iconClass = isConfirm?"pi-question-circle pi-warning":(isWarning?"pi-info-circle pi-warning": (isSuccess?"pi-check-circle pi-success":"pi-times-circle pi-danger")); return ( - <div className={`custom-dlg p-grid`} data-testid="confirm_dialog"> + <div className={`custom-dlg p-grid`} data-testid="confirm_dialog" + style={{opacity: (this.props.opacity===undefined || this.props.opacity===null)?1:this.props.opacity}}> <Dialog header={this.props.header} visible={this.props.visible} style={{width: this.props.width?this.props.width:'25vw'}} inputId="confirm_dialog" modal={true} onHide={this.props.onClose} 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..95fda18c6276c0680563bfc3935994401069220f 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 @@ -167,7 +167,8 @@ export class SchedulingSetCreate extends Component { this.agSUWithDefaultValue = {'id': 0, 'suname': '', 'sudesc': ''}; this.emptyAGSU = {}; this.priorityQueuelist = []; - + this.intervelTrigger = null; + this.onProjectChange = this.onProjectChange.bind(this); this.setSchedulingSetParams = this.setSchedulingSetParams.bind(this); this.onStrategyChange = this.onStrategyChange.bind(this); @@ -200,6 +201,7 @@ export class SchedulingSetCreate extends Component { this.applyChanges = this.applyChanges.bind(this); this.getSchedulingDialogContent = this.getSchedulingDialogContent.bind(this); this.setSUSet = this.setSUSet.bind(this); + this.copyClipText = this.copyClipText.bind(this); this.formRules = { // Form validation rules project: {required: true, message: "Select project to get Scheduling Sets"}, @@ -2183,14 +2185,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 +2251,27 @@ 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 ( ctrl && (key === 67 || key === 45) ) { //Ctrl+C(Windows & linux) or Cmd+C(Mac) or Ctrl+Insert(windows & linux) 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 ( (ctrl && key === 86) || (e.shiftKey && key === 45) ) { // Ctrl+V(windows & linux) or Cmd+V or Shift+Insert(windows & linux) + try { + var clipText = await this.readClipBoard(); + await this.setState({clipText: clipText}); this.copyFromClipboard(); - } else { - this.setState({ - confirmDialogVisible: true, - }); + } catch(error) { + //this.setState({disabled: 'none'}) this.callBackFunction = this.copyFromClipboard; this.onCancel = () => { this.setState({confirmDialogVisible: false, clipText: ''}); @@ -2313,32 +2286,15 @@ export class SchedulingSetCreate extends Component { 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}, + this.actions = [ + {id: "ok_btn", title: "Ok", callback: this.copyFromClipboard}, {id: "cancel_btn", title: "Cancel", callback: this.onCancel}]; + await this.setState({confirmDialogVisible: true}); + if(document.getElementById("clipTextField")) { + document.getElementById("clipTextField").focus(); + } + setTimeout(this.copyFromClipboard, 1); } - /* 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(); - }*/ } } @@ -2347,22 +2303,25 @@ export class SchedulingSetCreate extends Component { * @returns Component */ pasteTextField() { - return <textarea value={this.state.clipText} style={{width: '100%'}} autoFocus - onChange={e => this.setState({clipText: e.target.value})}></textarea>; + return <textarea id="clipTextField" value={this.state.clipText} style={{width: '100%'}} autoFocus + onChange={(e) => {this.copyClipText(e)}} placeholder="Paste your text here..." />; } - + copyClipText(e){ + this.setState({clipText: e.target.value}) + } /** * Function to copy the data from clipboard */ async copyFromClipboard(){ try { + //this.setState({}) var selectedRows = this.state.gridApi.getSelectedNodes(); 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 =>{ @@ -2833,7 +2792,9 @@ export class SchedulingSetCreate extends Component { } <CustomDialog type={this.dialogType} visible={this.state.confirmDialogVisible} width={this.dialogWidth} height={this.dialogHeight} header={this.dialogHeader} message={this.dialogMsg} - content={this.dialogContent} onClose={this.onClose} onCancel={this.onCancel} onSubmit={this.callBackFunction} + opacity={this.dialogHeader.startsWith("Paste")?0:1} + content={this.dialogContent} onClose={this.onClose} + onCancel={this.onCancel} onSubmit={this.callBackFunction} showIcon={this.showIcon} actions={this.actions}> </CustomDialog> <CustomPageSpinner visible={this.state.showSpinner} />