Skip to content

Commit

Permalink
adjested code to suit james change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Nov 4, 2024
1 parent b37ef30 commit c40f2ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/GraphConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class GraphConfigNode {
static fromJson(data: any, errorsWarnings: Errors.ErrorsWarnings): GraphConfigNode {
const result = new GraphConfigNode();

if (data.fields !== 'undefined'){
if (data.fields !== undefined){
for (const fieldId in data.fields){
const fieldData = data.fields[fieldId];
const newField: GraphConfigField = GraphConfigField.fromJson(fieldData, errorsWarnings);
Expand Down
34 changes: 15 additions & 19 deletions src/LogicalGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,14 @@ export class LogicalGraph {
getGraphConfigs = (): GraphConfig[] => {
return this.graphConfigs();
}

getGraphConfigById = (requestedConifgId:GraphConfig.Id): GraphConfig => {
const graphConfigs = this.getGraphConfigs()
let requestedGraphConfig : GraphConfig = null

for(let i = 0 ; i < graphConfigs.length ; i++){
if(graphConfigs[i].getId() === requestedConifgId){
requestedGraphConfig = graphConfigs[i]

getGraphConfigById = (id: GraphConfig.Id): GraphConfig => {
for(let i = 0 ; i < this.graphConfigs().length ; i++){
if(this.graphConfigs()[i].getId() === id){
return this.graphConfigs()[i]
}
}

return requestedGraphConfig
return null
}

addGraphConfig = (config: GraphConfig): void => {
Expand All @@ -367,17 +363,17 @@ export class LogicalGraph {
clone.setId(Utils.generateGraphConfigId());
clone.setName(Utils.generateGraphConfigName(clone));

// duplicate, set active and graph as modified
this.addGraphConfig(clone)
this.setActiveGraphConfig(clone.getId())
this.fileInfo().modified = true;
// duplicate, set active and graph as modified
this.addGraphConfig(clone)
this.setActiveGraphConfig(clone.getId())
this.fileInfo().modified = true;

Utils.showNotification("Duplicated Config", "as '" + clone.getName() + "' and set to active config", "success");
Utils.showNotification("Duplicated Config", "as '" + clone.getName() + "' and set to active config", "success");

//focus on and select the name field of the newly duplicated config, ready to rename. this requires a little wait, to allow the ui to update
setTimeout(() => {
$('#graphConfigurationsTableWrapper .activeConfig .column-name input').focus().select()
}, 100);
//focus on and select the name field of the newly duplicated config, ready to rename. this requires a little wait, to allow the ui to update
setTimeout(() => {
$('#graphConfigurationsTableWrapper .activeConfig .column-name input').focus().select()
}, 100);

Eagle.getInstance().undo().pushSnapshot(Eagle.getInstance(), "Duplicated a graph config" + clone.getName());
}
Expand Down

0 comments on commit c40f2ce

Please sign in to comment.