Skip to content

Commit

Permalink
i removed the parametertable.mode variable and am instead using the s…
Browse files Browse the repository at this point in the history
…etting for the bottom window mode.
  • Loading branch information
M-Wicenec committed Nov 1, 2024
1 parent 594ebb8 commit f282072
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 115 deletions.
3 changes: 3 additions & 0 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,9 @@ export class Eagle {
// open the graph configurations table
GraphConfigurationsTable.openModal();

this.undo().pushSnapshot(this, "New graph configuration added");
this.logicalGraph().fileInfo().modified = true;

//focus on and select the name field of the newly added config in the configurations table, ready to rename. this requires a little wait, to allow the ui to update
setTimeout(() => {
$('#graphConfigurationsTableWrapper .activeConfig .column-name input').focus().select()
Expand Down
2 changes: 1 addition & 1 deletion src/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export class Field {
}

//check if the node name matches, but only if using the key parameter table modal
if(ParameterTable.mode() === ParameterTable.Mode.GraphConfig){
if(Setting.findValue(Setting.BOTTOM_WINDOW_MODE) === Eagle.BottomWindowMode.GraphConfigAttributesTable){
if(Eagle.getInstance().logicalGraph().findNodeById(that.nodeId()).getName().toLowerCase().indexOf(term) >= 0){
result = true
}
Expand Down
4 changes: 2 additions & 2 deletions src/KeyboardShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ export class KeyboardShortcut {
new KeyboardShortcut("open_settings", "Open setting", [new Key("o")], "keydown", true, false, ['menu','options'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.smartToggleModal('settingsModal');}),
new KeyboardShortcut("open_help", "Open Online Documentation", [new Key("h")], "keydown", true, false, ['read me','guide','documentation'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.onlineDocs();}),
new KeyboardShortcut("open_keyboard_shortcut_modal", "Open Keyboard Shortcut Modal", [new Key("k")], "keydown", true, false, ['shortcuts'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.smartToggleModal('shortcutsModal')}),
new KeyboardShortcut("open_parameter_table", "Open Parameter Table Modal", [new Key("t")], "keydown", true, false, ['fields','field','node','table'], KeyboardShortcut.true, KeyboardShortcut.notInStudentMode, KeyboardShortcut.notInStudentMode, (eagle): void => {ParameterTable.openModal(ParameterTable.Mode.NodeFields, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("open_graph_attributes_configuration_table", "Open Graph Attributes Configuration Table Modal", [new Key("t", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['fields','field','node','graph','table','favourites'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {ParameterTable.openModal(ParameterTable.Mode.GraphConfig, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("open_parameter_table", "Open Parameter Table Modal", [new Key("t")], "keydown", true, false, ['fields','field','node','table'], KeyboardShortcut.true, KeyboardShortcut.notInStudentMode, KeyboardShortcut.notInStudentMode, (eagle): void => {ParameterTable.openModal(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("open_graph_attributes_configuration_table", "Open Graph Attributes Configuration Table Modal", [new Key("t", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['fields','field','node','graph','table','favourites'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {ParameterTable.openModal(Eagle.BottomWindowMode.GraphConfigAttributesTable, ParameterTable.SelectType.Normal);}),
new KeyboardShortcut("undo", "Undo", [new Key("z")], "keydown", true, false, ['back','history'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.undo().prevSnapshot(eagle)}),
new KeyboardShortcut("redo", "Redo", [new Key("z", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['forward','history'], KeyboardShortcut.true, KeyboardShortcut.true, KeyboardShortcut.true, (eagle): void => {eagle.undo().nextSnapshot(eagle)}),
new KeyboardShortcut("check_graph", "Check Graph", [new Key("!", KeyboardShortcut.Modifier.Shift)], "keydown", true, false, ['error','errors','fix'], KeyboardShortcut.true, KeyboardShortcut.allowGraphEditing, KeyboardShortcut.allowGraphEditing, (eagle): void => {eagle.showGraphErrors();}),
Expand Down
4 changes: 0 additions & 4 deletions src/Modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ export class Modals {
$('#editFieldModalAffirmativeButton').trigger("focus");
});

$('#editFieldModal').on('hidden.bs.modal', function(){
ParameterTable.openModal(ParameterTable.Mode.NodeFields, ParameterTable.SelectType.Normal)
});

// #editEdgeModal - requestUserEditEdge()
$('#editEdgeModalAffirmativeButton').on('click', function(){
$('#editEdgeModal').data('completed', true);
Expand Down
111 changes: 50 additions & 61 deletions src/ParameterTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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
static selection : ko.Observable<string | null>; // cell in the parameter table that is currently selected
Expand All @@ -31,7 +30,6 @@ export class ParameterTable {
static tableHeaderW : any;

static init(){
ParameterTable.mode = ko.observable(ParameterTable.Mode.GraphConfig);

ParameterTable.selectionParent = ko.observable(null);
ParameterTable.selectionParentIndex = ko.observable(-1);
Expand All @@ -58,16 +56,12 @@ export class ParameterTable {
return columnVisibilities
}

static inMode = (mode: ParameterTable.Mode): boolean => {
return mode === ParameterTable.mode();
}

static formatTableInspectorSelection = () : string => {
if (ParameterTable.selection() === null){
return "";
}

if (ParameterTable.mode() === ParameterTable.Mode.NodeFields){
if (Setting.findValue(Setting.BOTTOM_WINDOW_MODE) === Eagle.BottomWindowMode.ParameterTable){
return ParameterTable.selectionParent().getDisplayText() + " - " + ParameterTable.selectionName();
} else {
return "Unknown";
Expand All @@ -79,7 +73,7 @@ export class ParameterTable {
return "";
}

if (ParameterTable.mode() === ParameterTable.Mode.NodeFields){
if (Setting.findValue(Setting.BOTTOM_WINDOW_MODE) === Eagle.BottomWindowMode.ParameterTable){
return ParameterTable.selection();
} else {
return "Unknown";
Expand Down Expand Up @@ -162,11 +156,11 @@ export class ParameterTable {
static getTableFields : ko.PureComputed<Field[]> = ko.pureComputed(() => {
const eagle: Eagle = Eagle.getInstance();

switch (ParameterTable.mode()){
case ParameterTable.Mode.NodeFields:
switch (Setting.findValue(Setting.BOTTOM_WINDOW_MODE)){
case Eagle.BottomWindowMode.ParameterTable:
return eagle.selectedNode()?.getFields();

case ParameterTable.Mode.GraphConfig:
case Eagle.BottomWindowMode.GraphConfigAttributesTable:
const lg: LogicalGraph = eagle.logicalGraph();
const config: GraphConfig = lg.getActiveGraphConfig();
const displayedFields: Field[] = [];
Expand Down Expand Up @@ -196,6 +190,10 @@ export class ParameterTable {
}

return displayedFields;

default:
console.warn('could not return field because the bottom window node is set to: ' + Setting.findValue(Setting.BOTTOM_WINDOW_MODE))
return null
}
}, this);

Expand Down Expand Up @@ -365,49 +363,51 @@ export class ParameterTable {
// if so, proceed as normal
// if not, then we need to clone the current active graph config and modify the clone

// if (graphConfig.getIsModified()){
if (graphConfig){
if (add){
graphConfig.addField(currentField);
} else {
graphConfig.removeField(currentField);
}
// } else {
// Utils.requestUserString("New Configuration", "Enter a name for the new configuration", Utils.generateGraphConfigName(graphConfig), false, (completed : boolean, userString : string) : void => {
// ParameterTable.openModal(ParameterTable.mode(), ParameterTable.SelectType.Normal);

// if (!completed){
// return;
// }
// if (userString === ""){
// Utils.showNotification("Invalid name", "Please enter a name for the new object", "danger");
// return;
// }

// // clone config
// graphConfig = graphConfig.clone();
// graphConfig.setId(Utils.generateGraphConfigId());

// // set name and set modified flag
// graphConfig.setName(userString);
// graphConfig.setIsModified(true);
// graphConfig.setIsFavorite(false);

// // add/remove the field that was requested in the first place
// if (add){
// graphConfig.addField(currentField);
// } else {
// graphConfig.removeField(currentField);
// }

// // make this config the active config
// Eagle.getInstance().logicalGraph().setActiveGraphConfig(graphConfig);
// });
// }
} else {
Utils.requestUserString("New Configuration", "Enter a name for the new configuration", Utils.generateGraphConfigName(graphConfig), false, (completed : boolean, userString : string) : void => {
ParameterTable.openModal(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.Normal);

if (!completed){
return;
}
if (userString === ""){
Utils.showNotification("Invalid name", "Please enter a name for the new object", "danger");
return;
}

// clone config
graphConfig = graphConfig.clone();
graphConfig.setId(Utils.generateGraphConfigId());

// set name and set modified flag
graphConfig.setName(userString);

// add/remove the field that was requested in the first place
if (add){
graphConfig.addField(currentField);
} else {
graphConfig.removeField(currentField);
}

// make this config the active config
Eagle.getInstance().logicalGraph().setActiveGraphConfig(graphConfig.getId());

//set the graph as modified and take an undo snapshot
Eagle.getInstance().undo().pushSnapshot(Eagle.getInstance(), "Added field " + currentField.getDisplayText() + ' to config ' + graphConfig.getName());
Eagle.getInstance().logicalGraph().fileInfo().modified = true;
});
}
}

static requestEditConfig(config: GraphConfig): void {
GraphConfigurationsTable.closeModal();
ParameterTable.openModal(ParameterTable.Mode.GraphConfig, ParameterTable.SelectType.Normal);
ParameterTable.openModal(Eagle.BottomWindowMode.GraphConfigAttributesTable, ParameterTable.SelectType.Normal);
}

static requestEditDescriptionInModal(currentField:Field) : void {
Expand Down Expand Up @@ -512,7 +512,7 @@ export class ParameterTable {
upresizer.on('mousedown', mouseDownHandler);
}

static openModal = (mode: ParameterTable.Mode, selectType: ParameterTable.SelectType) : void => {
static openModal = (mode: Eagle.BottomWindowMode, selectType: ParameterTable.SelectType) : void => {
const eagle: Eagle = Eagle.getInstance();

// eagle.showEagleIsLoading()
Expand All @@ -528,26 +528,15 @@ export class ParameterTable {
}
}

if(mode === ParameterTable.Mode.NodeFields){
Setting.find(Setting.BOTTOM_WINDOW_MODE).setValue(Eagle.BottomWindowMode.ParameterTable)
}else{
Setting.find(Setting.BOTTOM_WINDOW_MODE).setValue(Eagle.BottomWindowMode.GraphConfigAttributesTable)
}
Setting.find(Setting.BOTTOM_WINDOW_MODE).setValue(mode)

if(selectType === ParameterTable.SelectType.RightClick){
eagle.setSelection(Eagle.selectedRightClickObject(), Eagle.selectedRightClickLocation())

RightClick.closeCustomContextMenu(true);

setTimeout(function() {
ParameterTable.mode(mode);
// $('#parameterTableModal').modal("show");
}, 30);
}else{
ParameterTable.mode(mode);
// $('#parameterTableModal').modal("show");
}
// ParameterTable.showTableModal(true)

//open the bottom window
SideWindow.setShown('bottom',true)
},5)
}
Expand All @@ -558,7 +547,7 @@ export class ParameterTable {

eagle.setSelection(node, Eagle.FileType.Graph)

ParameterTable.openModal(ParameterTable.Mode.NodeFields, ParameterTable.SelectType.Normal);
ParameterTable.openModal(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.Normal);

setTimeout(function(){
$('#tableRow_'+field.getId()).addClass('highlighted')
Expand Down
12 changes: 6 additions & 6 deletions src/RightClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class RightClick {

$('#customContextMenu').append('<h5 class="rightClickDropdownDividerTitle" tabindex="-1">Graph Options</h5>')
$('#customContextMenu').append(`<a class='rightClickPerpetual' onclick="Utils.showModelDataModal('Graph Info', eagle.logicalGraph().fileInfo());">Show Graph Info</a>`)
$('#customContextMenu').append(`<a class='rightClickPerpetual' onclick="ParameterTable.openModal(ParameterTable.Mode.GraphConfig, ParameterTable.SelectType.Normal);">Graph Attributes Table</a>`)
$('#customContextMenu').append(`<a class='rightClickPerpetual' onclick="ParameterTable.openModal(Eagle.BottomWindowMode.GraphConfigAttributesTable, ParameterTable.SelectType.Normal);">Graph Attributes Table</a>`)
$('#customContextMenu').append(`<a class='rightClickPerpetual' onclick="eagle.copyGraphUrl();">Copy Graph URL</a>`)
}else if(passedObjectClass === 'edgeDropCreate'){
if(Setting.findValue(Setting.ALLOW_GRAPH_EDITING)){
Expand Down Expand Up @@ -625,16 +625,16 @@ export class RightClick {

if(Setting.findValue(Setting.ALLOW_PALETTE_EDITING)){
$('#customContextMenu').append(RightClick.getNodeDescriptionDropdown())
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(ParameterTable.Mode.NodeFields, ParameterTable.SelectType.RightClick)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.RightClick)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick=eagle.deleteSelection(true,false,false)>Delete</a>')
$('#customContextMenu').append('<a onclick=eagle.addSelectedNodesToPalette("contextMenuRequest")>Add to another palette</a>')
}
}else if(passedObjectClass === 'rightClick_hierarchyNode'){
Eagle.selectedRightClickLocation(Eagle.FileType.Graph)

$('#customContextMenu').append(RightClick.getNodeDescriptionDropdown())
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(ParameterTable.Mode.NodeFields, ParameterTable.SelectType.RightClick)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(ParameterTable.Mode.GraphConfig, ParameterTable.SelectType.RightClick)">Graph Attributes</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.RightClick)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(Eagle.BottomWindowMode.GraphConfigAttributesTable, ParameterTable.SelectType.RightClick)">Graph Attributes</a>')
$('#customContextMenu').append('<a onclick=eagle.deleteSelection(true,false,false)>Delete</a>')
if(Setting.findValue(Setting.ALLOW_PALETTE_EDITING)){
$('#customContextMenu').append('<a onclick=eagle.addSelectedNodesToPalette("contextMenuRequest")>Add to palette</a>')
Expand All @@ -643,8 +643,8 @@ export class RightClick {

}else if(passedObjectClass === 'rightClick_graphNode'){
$('#customContextMenu').append(RightClick.getNodeDescriptionDropdown())
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(ParameterTable.Mode.NodeFields, ParameterTable.SelectType.RightClick)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(ParameterTable.Mode.GraphConfig, ParameterTable.SelectType.RightClick)">Graph Attributes</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(Eagle.BottomWindowMode.ParameterTable, ParameterTable.SelectType.RightClick)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="ParameterTable.openModal(Eagle.BottomWindowMode.GraphConfigAttributesTable, ParameterTable.SelectType.RightClick)">Graph Attributes</a>')
$('#customContextMenu').append('<a onclick=eagle.deleteSelection(true,false,false)>Delete</a>')
if (data.isConstruct()){
$('#customContextMenu').append('<a onclick=eagle.deleteSelection(true,false,true)>Delete All</a>')
Expand Down
Loading

0 comments on commit f282072

Please sign in to comment.