Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dpinney/omf
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinney committed Oct 16, 2024
2 parents 2243552 + ee1055f commit dea81fd
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 433 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ omf/solvers/reopt_jl/testFiles/REoptInputs.json
omf/solvers/reopt_jl/reopt_jl.so
omf/solvers/reopt_jl/julia-1.9.4/*
instantiated.txt
omf/solvers/protsetopt/testFiles/
omf/solvers/protsetopt/testFiles/
.vite/
3 changes: 2 additions & 1 deletion omf/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ def map_omd(omd_path, output_dir, open_browser=False, showAddNewObjectsButton=Tr
'''
Create an HTML page of the GeoJSON circuit editor without Flask
'''

# - Load feeder data
with open(omd_path) as f:
omd = json.load(f)
Expand All @@ -670,6 +669,8 @@ def map_omd(omd_path, output_dir, open_browser=False, showAddNewObjectsButton=Tr
# - Load JavaScript
main_js_filepath = (pathlib.Path(omf.omfDir).resolve(True) / 'static' / 'geoJsonMap' / 'v3' / 'main.js').resolve(True)
all_js_filepaths = list((pathlib.Path(omf.omfDir).resolve(True) / 'static' / 'geoJsonMap').glob('**/*.js'))
# - Filter out .test.js files
all_js_filepaths = list(filter(lambda p: not str(p).endswith('.test.js'), all_js_filepaths))
all_js_filepaths.remove(main_js_filepath)
all_js_filepaths.append(main_js_filepath)
all_js_file_content = []
Expand Down
36 changes: 24 additions & 12 deletions omf/static/geoJsonMap/v3/featureController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,36 @@ class FeatureController { // implements ControllerInterface
* @returns {undefined}
*/
addObservables(observables) {
observables.forEach(ob => {
const key = (this.observableGraph.getMaxKey() + 1).toString();
ob.setProperty('treeKey', key, 'meta');
this.observableGraph.insertObservable(ob);
if (!ob.isConfigurationObject()) {
LeafletLayer.createAndGroupLayer(ob, this);
for (const observable of observables) {
const treeKey = (this.observableGraph.getMaxKey() + 1).toString();
observable.setProperty('treeKey', treeKey, 'meta');
// - When a component is added, the easiest way to ensure a unique, descriptive name is to use its treeKey. Since the treeKey must be set
// here, it also makes sense to set the name here, even, potentially, for mass add
// - All components have a name due to line 1327 of geo.py
if (observable.hasProperty('name')) {
let name = observable.getProperty('name');
let key = treeKey;
while (this.observableGraph.getObservables(ob => ob.hasProperty('name') && ob.getProperty('name') === name).length > 0) {
name = `${name}_${key}`;
key += 1;
}
observable.setProperty('name', name);
}
this.observableGraph.insertObservable(observable);
if (!observable.isConfigurationObject()) {
LeafletLayer.createAndGroupLayer(observable, this);
}
if (ob.isLine()) {
ob.getObservers().filter(ob => ob instanceof LeafletLayer)[0].getLayer().bringToBack();
if (observable.isLine()) {
observable.getObservers().filter(ob => ob instanceof LeafletLayer)[0].getLayer().bringToBack();
}
if (ob.isChild()) {
const parentKey = this.observableGraph.getKey(ob.getProperty('parent'), ob.getProperty('treeKey', 'meta'));
const parentChildLineFeature = this.observableGraph.getParentChildLineFeature(parentKey, key);
if (observable.isChild()) {
const parentKey = this.observableGraph.getKey(observable.getProperty('parent'), observable.getProperty('treeKey', 'meta'));
const parentChildLineFeature = this.observableGraph.getParentChildLineFeature(parentKey, treeKey);
this.observableGraph.insertObservable(parentChildLineFeature);
LeafletLayer.createAndGroupLayer(parentChildLineFeature, this);
parentChildLineFeature.getObservers().filter(ob => ob instanceof LeafletLayer)[0].getLayer().bringToBack();
}
});
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion omf/static/geoJsonMap/v3/featureDropdownDiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class FeatureDropdownDiv {
const outerFunc = function(div) {
if (div.lastChild.classList.contains('-expanded')) {
div.firstChild.getElementsByClassName('icon')[0].classList.add('-rotated');
that.#featureEditModal = new FeatureEditModal([that.#observable], that.#controller);
that.#featureEditModal = new FeatureEditModal(that.#observable, that.#controller);
div.lastChild.append(that.#featureEditModal.getDOMElement());
} else {
div.firstChild.getElementsByClassName('icon')[0].classList.remove('-rotated');
Expand Down
Loading

0 comments on commit dea81fd

Please sign in to comment.