Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
james-strauss-uwa committed Oct 13, 2023
1 parent fe26bd5 commit 7697cd2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
33 changes: 33 additions & 0 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4565,6 +4565,39 @@ export class Eagle {
}
});
}

findPaletteContainingNode = (nodeId: string): Palette => {
for (const palette of this.palettes()){
for (const node of palette.getNodes()){
if (node.getId() === nodeId){
return palette;
}
}
}

return null;
}

// when a field value is modified in the parameter table, we need to flag the containing palette or logical graph as modified
onFieldValueChanged = () : void => {
const eagle = Eagle.getInstance();

switch (Eagle.selectedLocation()){
case Eagle.FileType.Palette:
const paletteNode: Node | Edge = eagle.selectedObjects()[0];
console.assert(paletteNode instanceof Node)

const containingPalette: Palette = eagle.findPaletteContainingNode(paletteNode.getId());

containingPalette.fileInfo().modified = true;
break;
case Eagle.FileType.Graph:
eagle.logicalGraph().fileInfo().modified = true;
break;
}

eagle.selectedObjects.valueHasMutated();
}
}

export namespace Eagle
Expand Down
6 changes: 6 additions & 0 deletions src/ParameterTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ export class ParameterTable {
}
}

fieldValueChanged = (field: Field) : void => {
console.log("fieldValueChanged", field.getNodeKey());

// TODO: put code here instead of eagle?
}

static select = (selection:string, selectionName:string, readOnlyState:boolean, selectionParent:Field, selectionIndex:number) : void => {
ParameterTable.selectionName(selectionName);
ParameterTable.selectionParent(selectionParent);
Expand Down
16 changes: 8 additions & 8 deletions templates/modals/parameter_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ <h5 class="modal-title" id="parameterTableModalTitle">Fields Table: <span data-b
<!-- ko if: ParameterTable.getActiveColumnVisibility().value() -->
<!-- ko if: $data.getHtmlInputType() === 'number' || $data.getHtmlInputType() === 'text' || $data.getHtmlInputType() === 'password' -->
<!-- ko if: $data.getType() === 'Integer' -->
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }"><input class="tableParameter" min="0" step="1" onfocus="this.previousValue = this.value" onkeydown="this.previousValue = this.value" oninput="validity.valid || (value = this.previousValue)" data-bind="checked: valIsTrue($data.value()), disabled: $root.getCurrentParamValueReadonly($data), valueUpdate: ['afterkeydown', 'input'], value: value, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$root.selectedObjects.valueHasMutated()}, keyup: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}}"></td>
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }"><input class="tableParameter" min="0" step="1" onfocus="this.previousValue = this.value" onkeydown="this.previousValue = this.value" oninput="validity.valid || (value = this.previousValue)" data-bind="checked: valIsTrue($data.value()), disabled: $root.getCurrentParamValueReadonly($data), valueUpdate: ['afterkeydown', 'input'], value: value, attr:{type: $data.getHtmlInputType()}, event: {change: $root.onFieldValueChanged, keyup: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}}"></td>
<!-- /ko -->
<!-- ko ifnot: $data.getType() === 'Integer' -->
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }"><input class="tableParameter inputNoArrows tableFieldStringValueInput" data-bind="checked: valIsTrue($data.value()), disabled: $root.getCurrentParamValueReadonly($data), valueUpdate: ['afterkeydown', 'input'], value: value, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$root.selectedObjects.valueHasMutated()}, keyup: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}}"></td>
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }"><input class="tableParameter inputNoArrows tableFieldStringValueInput" data-bind="checked: valIsTrue($data.value()), disabled: $root.getCurrentParamValueReadonly($data), valueUpdate: ['afterkeydown', 'input'], value: value, attr:{type: $data.getHtmlInputType()}, event: {change: $root.onFieldValueChanged, keyup: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.value(), 'value', $root.getCurrentParamValueReadonly($data), $data, $index())}}"></td>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $data.getHtmlInputType() === 'checkbox' -->
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }"><input class="tableParameter" tabindex='-1' data-bind="checked: valIsTrue($data.value()), disabled: $root.getCurrentParamValueReadonly($data), valueUpdate: ['afterkeydown', 'input'], value: value, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$data.toggle(); $root.selectedObjects.valueHasMutated();}}"></td>
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }"><input class="tableParameter" tabindex='-1' data-bind="checked: valIsTrue($data.value()), disabled: $root.getCurrentParamValueReadonly($data), valueUpdate: ['afterkeydown', 'input'], value: value, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$data.toggle(); eagle.onFieldValueChanged();}}"></td>
<!-- /ko -->
<!-- ko if: $data.getHtmlInputType() === 'select' -->
<td class='columnCell column_Value' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'value' }">
<select aria-label="Label" aria-describedby="group-addon" data-bs-placement="bottom" data-bind="disabled: $root.getCurrentParamValueReadonly($data), event: {change: function(){$root.selectedObjects.valueHasMutated();}}, options: $data.options, value: $data.value">
<select aria-label="Label" aria-describedby="group-addon" data-bs-placement="bottom" data-bind="disabled: $root.getCurrentParamValueReadonly($data), event: {change: $root.onFieldValueChanged}, options: $data.options, value: $data.value">
<!-- options are added dynamically -->
</select>
</td>
Expand All @@ -162,21 +162,21 @@ <h5 class="modal-title" id="parameterTableModalTitle">Fields Table: <span data-b
<!-- ko if: ParameterTable.getActiveColumnVisibility().defaultValue() -->
<!-- ko if: $data.getHtmlInputType() === 'number' || $data.getHtmlInputType() === 'text' || $data.getHtmlInputType() === 'password' -->
<!-- ko if: $data.getType() === 'Integer' -->
<td class='columnCell column_DefaultValue' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'defaultValue' }"><input class="tableParameter" min="0" step="1" onfocus="this.previousValue = this.value" onkeydown="this.previousValue = this.value" oninput="validity.valid || (value = this.previousValue)" data-bind="checked: valIsTrue($data.defaultValue()), disabled: $root.parameterTable().getNodeLockedState($data), valueUpdate: ['afterkeydown', 'input'], value: defaultValue, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$root.selectedObjects.valueHasMutated()}, keyup: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}}"></td>
<td class='columnCell column_DefaultValue' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'defaultValue' }"><input class="tableParameter" min="0" step="1" onfocus="this.previousValue = this.value" onkeydown="this.previousValue = this.value" oninput="validity.valid || (value = this.previousValue)" data-bind="checked: valIsTrue($data.defaultValue()), disabled: $root.parameterTable().getNodeLockedState($data), valueUpdate: ['afterkeydown', 'input'], value: defaultValue, attr:{type: $data.getHtmlInputType()}, event: {change: $root.onFieldValueChanged, keyup: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}}"></td>
<!-- /ko -->
<!-- ko ifnot: $data.getType() === 'Integer' -->
<td class='columnCell column_DefaultValue' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'defaultValue' }"><input class="tableParameter inputNoArrows" data-bind="checked: valIsTrue($data.defaultValue()), disabled: $root.parameterTable().getNodeLockedState($data), valueUpdate: ['afterkeydown', 'input'], value: defaultValue, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$root.selectedObjects.valueHasMutated()}, keyup: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}}"></td>
<td class='columnCell column_DefaultValue' data-bind=" css: { selectedTableParameter: ParameterTable.selection() != null && $data == ParameterTable.selectionParent() && ParameterTable.selectionName() == 'defaultValue' }"><input class="tableParameter inputNoArrows" data-bind="checked: valIsTrue($data.defaultValue()), disabled: $root.parameterTable().getNodeLockedState($data), valueUpdate: ['afterkeydown', 'input'], value: defaultValue, attr:{type: $data.getHtmlInputType()}, event: {change: $root.onFieldValueChanged, keyup: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}, click: function(event, data){ParameterTable.select($data.defaultValue(), 'defaultValue', $root.parameterTable().getNodeLockedState($data), $data, $index())}}"></td>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: $data.getHtmlInputType() === 'checkbox' -->
<td class='columnCell column_DefaultValue'><input class="tableParameter" tabindex='-1' onclick="$(this).val(this.checked ? true : false)" data-bind="checked: valIsTrue($data.defaultValue()), disabled: $root.parameterTable().getNodeLockedState($data), valueUpdate: ['afterkeydown', 'input'], value: defaultValue, attr:{type: $data.getHtmlInputType()}, event: {change: function(){$root.selectedObjects.valueHasMutated();}}"></td>
<td class='columnCell column_DefaultValue'><input class="tableParameter" tabindex='-1' onclick="$(this).val(this.checked ? true : false)" data-bind="checked: valIsTrue($data.defaultValue()), disabled: $root.parameterTable().getNodeLockedState($data), valueUpdate: ['afterkeydown', 'input'], value: defaultValue, attr:{type: $data.getHtmlInputType()}, event: {change: $root.onFieldValueChanged}"></td>
<!-- /ko -->

<!-- selection input -->
<!-- ko if: $data.getHtmlInputType() === 'select' -->
<td class='columnCell column_DefaultValue'>
<!-- ko ifnot: Setting.findValue(Setting.ALLOW_COMPONENT_EDITING) -->
<select aria-label="Label" aria-describedby="group-addon" data-bs-placement="bottom" data-bind="disabled: $root.parameterTable().getNodeLockedState($data), event: {change: function(){$root.selectedObjects.valueHasMutated();}}, options: $data.options, value: $data.defaultValue">
<select aria-label="Label" aria-describedby="group-addon" data-bs-placement="bottom" data-bind="disabled: $root.parameterTable().getNodeLockedState($data), event: {change: $root.onFieldValueChanged}, options: $data.options, value: $data.defaultValue">
<!-- options are added dynamically -->
</select>
<!-- /ko -->
Expand Down

0 comments on commit 7697cd2

Please sign in to comment.