Skip to content

Commit

Permalink
Moved showTableModal observable from Eagle to ParameterTable. Cleaned…
Browse files Browse the repository at this point in the history
… up some other spaghetti functions
  • Loading branch information
james-strauss-uwa committed Aug 14, 2024
1 parent 9aa1139 commit 2a3126f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export class Eagle {
graphErrors : ko.ObservableArray<Errors.Issue>;
loadingWarnings : ko.ObservableArray<Errors.Issue>;
loadingErrors : ko.ObservableArray<Errors.Issue>;
showTableModal : ko.Observable<boolean>;
currentFileInfo : ko.Observable<FileInfo>;
currentFileInfoTitle : ko.Observable<string>;
hierarchyMode : ko.Observable<boolean>; //we need this to be able to keep the right window in the hierarchy tab if the user is actively using it, but otherwise always switch the right window to the inspector.
Expand Down Expand Up @@ -201,7 +200,6 @@ export class Eagle {
this.loadingWarnings = ko.observableArray([]);
this.loadingErrors = ko.observableArray([]);

this.showTableModal = ko.observable(false)
this.currentFileInfo = ko.observable(null);
this.currentFileInfoTitle = ko.observable("");
this.hierarchyMode = ko.observable(false)
Expand Down
2 changes: 1 addition & 1 deletion src/GraphConfigurationsTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class GraphConfigurationsTable {
}
}

Utils.showOpenGraphConfigurationsTableModal();
$('#graphConfigurationsTableModal').modal("show");

GraphConfigurationsTable.showTableModal(true)

Expand Down
6 changes: 1 addition & 5 deletions src/KeyboardShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ export class KeyboardShortcut {
return Setting.findValue(Setting.ALLOW_GRAPH_EDITING);
}

static showTableModal(eagle: Eagle) : boolean {
return eagle.showTableModal()
}

static graphNotEmpty(eagle: Eagle) : boolean {
if (eagle.logicalGraph() === null){
return false;
Expand Down Expand Up @@ -233,7 +229,7 @@ export class KeyboardShortcut {
new KeyboardShortcut("select_all_in_graph", "Select all in graph", ["a"], "keydown", KeyboardShortcut.Modifier.Ctrl, KeyboardShortcut.true, [''], KeyboardShortcut.true, KeyboardShortcut.graphNotEmpty, (eagle): void => { eagle.selectAllInGraph(); }),
new KeyboardShortcut("select_none_in_graph", "Select none in graph", ["Escape"], "keydown", KeyboardShortcut.Modifier.None, KeyboardShortcut.true, ['deselect'], KeyboardShortcut.true, KeyboardShortcut.somethingIsSelected, (eagle): void => { eagle.selectNoneInGraph(); }),
new KeyboardShortcut("fix_all", "Fix all errors in graph", ["f"], "keydown", KeyboardShortcut.Modifier.None, KeyboardShortcut.true, [''], KeyboardShortcut.allowGraphEditing, KeyboardShortcut.allowGraphEditing, (eagle): void => { Errors.fixAll(); }),
new KeyboardShortcut("table_move_down", "Table move down one cell", ["Enter"], "keydown", KeyboardShortcut.Modifier.Input, KeyboardShortcut.true, ['controls'], KeyboardShortcut.false, KeyboardShortcut.showTableModal, (eagle): void => { ParameterTable.tableEnterShortcut(currentEvent);}),
new KeyboardShortcut("table_move_down", "Table move down one cell", ["Enter"], "keydown", KeyboardShortcut.Modifier.Input, KeyboardShortcut.true, ['controls'], KeyboardShortcut.false, ParameterTable.showTableModal, (eagle): void => { ParameterTable.tableEnterShortcut(currentEvent);}),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class Modals {
});

$('#parameterTableModal').on('hidden.bs.modal', function(){
eagle.showTableModal(false)
ParameterTable.showTableModal(false)
eagle.checkGraph();
});

Expand Down
14 changes: 9 additions & 5 deletions src/ParameterTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { GraphConfig, GraphConfigField } from "./GraphConfig";

export class ParameterTable {

static showTableModal : ko.Observable<boolean> = ko.observable(false);

static mode: ko.Observable<ParameterTable.Mode>;
static selectionParent : ko.Observable<Field | null>; // row in the parameter table that is currently selected
static selectionParentIndex : ko.Observable<number> // id of the selected field
Expand Down Expand Up @@ -481,7 +483,7 @@ export class ParameterTable {
if($('.modal.show').attr('id')==='parameterTableModal'){
// TODO: use closeModal here!
$('#parameterTableModal').modal('hide')
eagle.showTableModal(false)
ParameterTable.showTableModal(false)
}else{
return
}
Expand All @@ -492,17 +494,19 @@ export class ParameterTable {
RightClick.closeCustomContextMenu(true);

setTimeout(function() {
Utils.showOpenParamsTableModal(mode);
ParameterTable.mode(mode);
$('#parameterTableModal').modal("show");
}, 30);
}else{
if (mode=== ParameterTable.Mode.NodeFields && !eagle.selectedNode()){
eagle.hideEagleIsLoading()
Utils.showNotification("Error", "No Node Is Selected", "warning");
}else{
Utils.showOpenParamsTableModal(mode);
ParameterTable.mode(mode);
$('#parameterTableModal').modal("show");
}
}
eagle.showTableModal(true)
ParameterTable.showTableModal(true)

},5)
}
Expand All @@ -522,7 +526,7 @@ export class ParameterTable {

static closeModal = (): void => {
$('#parameterTableModal').modal('hide')
Eagle.getInstance().showTableModal(false)
ParameterTable.showTableModal(false)
}

static addEmptyTableRow = () : void => {
Expand Down
2 changes: 2 additions & 0 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ export class Utils {
$('#settingsModal').modal("hide");
}

/*
static showOpenParamsTableModal(mode: ParameterTable.Mode) : void {
ParameterTable.mode(mode);
$('#parameterTableModal').modal("show");
Expand All @@ -772,6 +773,7 @@ export class Utils {
static showOpenGraphConfigurationsTableModal() : void {
$('#graphConfigurationsTableModal').modal("show");
}
*/

static showShortcutsModal() : void {
$('#shortcutsModal').modal("show");
Expand Down
2 changes: 1 addition & 1 deletion templates/modals/parameter_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal fade" id="parameterTableModal" tabindex="-1" role="dialog" aria-labelledby="parameterTableModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<!-- ko if: showTableModal() -->
<!-- ko if: ParameterTable.showTableModal() -->
<div class="modal-header" data-bind="click: function(){ParameterTable.resetSelection()}">
<!-- ko if: ParameterTable.inMode(ParameterTable.Mode.GraphConfig) -->
<h5 class="modal-title" id="parameterTableModalTitle">
Expand Down

0 comments on commit 2a3126f

Please sign in to comment.