Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed undo and redo while opening file from imports and gallery #521

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import * as actions from '../../../redux/actions/actions'
import ComponentParameters from './ComponentParametersData'
var graph
var undoManager
export { undoManager };

let fileOpenedSuccessfully = false;

export function setFileOpenedStatus(status) {
fileOpenedSuccessfully = status;
}

export function getFileOpenedStatus() {
return fileOpenedSuccessfully;
}

const {
mxPrintPreview,
Expand Down Expand Up @@ -65,6 +76,11 @@ const checkWireChange = (changes) => {

// UNDO
export function Undo() {
if (fileOpenedSuccessfully) {
undoManager.clear(); // Clear the undoManager
fileOpenedSuccessfully = false;
}
// undoManager.clear()
if (undoManager.indexOfNextAdd === 0) {
// Nothing to undo
return
Expand Down Expand Up @@ -1061,6 +1077,7 @@ export function renderGalleryXML(xml) {
graph.removeCells(graph.getChildVertices(graph.getDefaultParent()))
graph.view.refresh()
var xmlDoc = mxUtils.parseXml(xml)
setFileOpenedStatus(true);
parseXmlToGraph(xmlDoc, graph)
}
// Certain Variables need to be Defined before Saving the Circuit, XML Wire Connections does that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import queryString from 'query-string'
import { RotateLeft } from '@material-ui/icons'
import AddPhotoAlternateIcon from '@material-ui/icons/AddPhotoAlternate'
import { fetchRole } from '../../redux/actions/authActions'
import { setFileOpenedStatus } from './Helper/ToolbarTools';

import {
NetlistModal,
Expand Down Expand Up @@ -630,6 +631,7 @@ export default function SchematicToolbar ({
setMessage('Unsupported file error !')
handleSnacClick()
} else {
setFileOpenedStatus(true); // Set flag to indicate successful file opening
dispatch(openLocalSch(obj))
}
}
Expand Down