Hello and Happy New Year! This year we’re heading to continue improving our existing products with interesting updates, in parallel with turning some new ideas into great new features and/or new products.
As a start, we chose to develop a small new JavaScript/TypeScript sample app for DlhSoft Gantt Chart Hyper Library to show developers how they can add Undo and Redo commands in their JavaScript-targeting apps and automatically updating Gantt Chart items and the user interface of the component when such commands are executed.
However, we found it would be more useful for everybody if we extracted the Undo stack recording and execution into a separate small library that we could offer as open source for everyone to be able to update and extend for their own purposes, as needed, even when not using DlhSoft components. Eventually, here is the Undo stack repository on GitHub!
Internally, we used Bridge.net the first time to write the internal logic code of the UndoStack component in C#, and have it immediately available in JavaScript too (for our original purpose). While this process involved working around some issues that Bridge has with dates, times, and time spans and we eventually decided to use integral types instead, the output of using that package is really nice: we could then easily generate two NuGet packages, one for .NET and one for JavaScript, having the logic actually in a single source code base using a single programming language (C#)! This is the first time we didn’t need to duplicate business logic originally written in one language (C#) to another (JavaScript/TypeScript).
Finally, here is the Undo-Redo sample app for GanttChartView JavaScript component, in full source code (available in TypeScript on top of UndoStack definitions, or in generated JavaScript). Enjoy!
> While this process involved working around some issues that Bridge has with dates, times, and time spans and we eventually decided to use integral types instead.
The Bridge team would be interested in your feedback regarding these issues. Some Type improvements are being included with the next release of Bridge, so the Type issues noted here may have been fixed. But it would be great to get your feedback to ensure what you require is added to the next release of Bridge.
Thank you for your comment and GitHub pull request regarding the badge. We are sure that eventually the DateTime/TimeSpan issues would be resolved.
Actually the issue in our case was just that if we tried to call minus operator between DateTime values in C#, thus generating a TimeSpan, the JavaScript code resulted in not working as expected. To resolve this we used dateTime.Ticks / 10000 to convert dates to numbers first.
If you want, you can try changing ActionRecord class to use DateTime instead of int (for WhenWasDone property) and update the code for UndoStack to work with DateTime and TimeSpan values instead of int values, and see how it works in the JavaScript demo.
https://github.com/DlhSoftTeam/UndoStack/blob/master/UndoManagement/DlhSoft.UndoManagementLibrary/UndoStack.cs