Skip to content

Commit

Permalink
Switch to use the ParameterTable.Mode enum everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
james-strauss-uwa committed Jul 15, 2024
1 parent 3f8baee commit 4b1b7e2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class Eagle {
translator : ko.Observable<Translator>;
undo : ko.Observable<Undo>;
parameterTable : ko.Observable<ParameterTable>;
parameterTableMode : ko.Observable<ParameterTable.Mode>;

globalOffsetX : ko.Observable<number>;
globalOffsetY : ko.Observable<number>;
Expand All @@ -111,7 +112,6 @@ export class Eagle {
graphErrors : ko.ObservableArray<Errors.Issue>;
loadingWarnings : ko.ObservableArray<Errors.Issue>;
loadingErrors : ko.ObservableArray<Errors.Issue>;
parameterTableMode : ko.Observable<ParameterTable.Mode>;
showTableModal : ko.Observable<boolean>;
currentFileInfo : ko.Observable<FileInfo>;
currentFileInfoTitle : ko.Observable<string>;
Expand Down
12 changes: 8 additions & 4 deletions src/ParameterTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,24 @@ export class ParameterTable {

getTableFields : ko.PureComputed<Field[]> = ko.pureComputed(() => {
const eagle: Eagle = Eagle.getInstance();

switch (eagle.parameterTableMode()){

case ParameterTable.Mode.Unknown:
return [];

case ParameterTable.Mode.GraphConfig:
return eagle.selectedNode().getFields();

case ParameterTable.Mode.NodeFields:
return eagle.selectedNode()?.getFields();

case ParameterTable.Mode.GraphConfig:
const config: GraphConfig = eagle.graphConfig();
const lg: LogicalGraph = eagle.logicalGraph();
const displayedFields: Field[] = [];

if (!config){
return [];
}

for (const [nodeId, node] of config.getNodes()){
const lgNode = lg.findNodeById(nodeId);

Expand Down
10 changes: 5 additions & 5 deletions src/RightClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,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="eagle.openParamsTableModal('keyParametersTableModal', 'normal');">Graph Attributes Table</a>`)
$('#customContextMenu').append(`<a class='rightClickPerpetual' onclick="eagle.openParamsTableModal(ParameterTable.Mode.GraphConfig, '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 @@ -571,8 +571,8 @@ export class RightClick {
Eagle.selectedRightClickLocation(Eagle.FileType.Graph)

$('#customContextMenu').append(RightClick.getNodeDescriptionDropdown())
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(`inspectorTableModal`,`rightClick`)">Inspector Table</a>')
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(`keyParametersTableModal`,`rightClick`)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(ParameterTable.Mode.NodeFields,`rightClick`)">Inspector Table</a>')
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(ParameterTable.Mode.GraphConfig,`rightClick`)">Open Fields Table</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 @@ -581,8 +581,8 @@ export class RightClick {

}else if(passedObjectClass === 'rightClick_graphNode'){
$('#customContextMenu').append(RightClick.getNodeDescriptionDropdown())
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(`inspectorTableModal`,`rightClick`)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(`keyParametersTableModal`,`rightClick`)">Graph Attributes</a>')
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(ParameterTable.Mode.NodeFields,`rightClick`)">Open Fields Table</a>')
$('#customContextMenu').append('<a onclick="eagle.openParamsTableModal(ParameterTable.Mode.GraphConfig,`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
12 changes: 6 additions & 6 deletions templates/modals/parameter_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<div class="modal-content">
<!-- ko if: showTableModal() -->
<div class="modal-header" data-bind="click: function(){ParameterTable.resetSelection()}">
<!-- ko if: tableModalType() === 'keyParametersTableModal' -->
<!-- ko if: parameterTableMode() === ParameterTable.Mode.GraphConfig -->
<h5 class="modal-title" id="parameterTableModalTitle">Key Graph Attributes</h5>
<!-- /ko -->
<!-- ko if: tableModalType() === 'inspectorTableModal' -->
<!-- ko if: parameterTableMode() === ParameterTable.Mode.NodeFields -->
<h5 class="modal-title" id="parameterTableModalTitle">Fields Table: <span data-bind="html: selectedNode().getName()"></span></h5>
<!-- ko if: selectedNode() != null -->
<!-- ko if: selectedNode().isLocked() -->
Expand Down Expand Up @@ -56,7 +56,7 @@ <h5 class="modal-title" id="parameterTableModalTitle">Fields Table: <span data-b
<!-- ko if: ParameterTable.getActiveColumnVisibility().keyAttribute() -->
<th id="parameter_table_isKeyAttribute" data-bind="eagleTooltip:'Toggle Field Key attribute state'" data-bs-placement="top"></th>
<!-- /ko -->
<!-- ko if: $root.tableModalType() === 'keyParametersTableModal'-->
<!-- ko if: $root.parameterTableMode() === ParameterTable.Mode.GraphConfig -->
<th id="parameter_table_node_name" data-bind="eagleTooltip:`This Parameter's Parent Node Name`" data-bs-placement="top">
Node Name
<div data-bind="css: {resizer: $root.parameterTable().setUpColumnResizer('parameter_table_node_name') === true}"></div>
Expand Down Expand Up @@ -127,7 +127,7 @@ <h5 class="modal-title" id="parameterTableModalTitle">Fields Table: <span data-b
<!-- kept for now as we will need the space for the row drag handle -->
</td>
<!-- /ko -->
<!-- ko if: $root.tableModalType() === 'keyParametersTableModal' -->
<!-- ko if: $root.parameterTableMode() === ParameterTable.Mode.GraphConfig -->
<td class='columnCell column_NodeName'>
<input class="tableParameter" type="string" data-bind="value: $root.logicalGraph().findNodeByKey(nodeKey()).getName(), disabled: true">
</td>
Expand Down Expand Up @@ -357,10 +357,10 @@ <h5 class="modal-title" id="parameterTableModalTitle">Fields Table: <span data-b
</table>
</div>
<div class="modal-footer" data-bind="click: ParameterTable.resetSelection">
<!-- ko if: selectedNode() != null && tableModalType() === 'inspectorTableModal' -->
<!-- ko if: selectedNode() != null && parameterTableMode() === ParameterTable.Mode.NodeFields -->
<button type="button" class="btn btn-primary" id="parameterTableModalAddParameterButton" data-bind="click: $root.addEmptyTableRow, clickBubble:false, disabled: selectedNode().isLocked()" ><span id="parameterTableModalAddParameter">Add Parameter</span></button>
<!-- /ko -->
<!-- ko if: selectedNode() != null && selectedNode().getCategory() === 'Docker' -->
<!-- ko if: selectedNode() != null && selectedNode().getCategory() === Category.Docker -->
<button id="tableOpenDocker" class="btn btn-primary float-left" data-bind="click: ParameterTable.initiateBrowseDocker, clickBubble: false, eagleTooltip: `Browse images on dockerhub`" data-bs-toggle="tooltip" data-html="true" data-bs-placement="right" data-bs-original-title="">
Browse DockerHub
</button>
Expand Down
2 changes: 1 addition & 1 deletion templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<button id="openGraphModelDataModal" class="btn btn-outline-secondary navbar-btn" type="button" data-bs-placement="bottom" data-bind="click: function(){Utils.showModelDataModal('Graph Info', $root.logicalGraph().fileInfo());}, eagleTooltip: 'Show Graph Info'">
<i class="material-icons md-18">info</i>
</button>
<button id="openKeyParameterTable" class="btn btn-outline-secondary navbar-btn" type="button" data-bs-placement="bottom" data-bind="click: function(){eagle.openParamsTableModal('keyParametersTableModal', 'normal')}, eagleTooltip: `Configure Key Graph Attributes ` + Utils.getKeyboardShortcutTextByKey('open_key_parameter_table_modal', true)">
<button id="openKeyParameterTable" class="btn btn-outline-secondary navbar-btn" type="button" data-bs-placement="bottom" data-bind="click: function(){eagle.openParamsTableModal(ParameterTable.Mode.GraphConfig, 'normal')}, eagleTooltip: `Configure Key Graph Attributes ` + Utils.getKeyboardShortcutTextByKey('open_key_parameter_table_modal', true)">
<i class="md-18 icon-keyAttrTable"></i>
</button>
<button id="copyGraphUrl" class="btn btn-outline-secondary navbar-btn" type="button" data-bs-placement="bottom" data-bind="click: copyGraphUrl, eagleTooltip: 'Copy Graph Url'" >
Expand Down

0 comments on commit 4b1b7e2

Please sign in to comment.