Skip to content

Commit

Permalink
Merge pull request #1452 from StochSS/hotfix-spatial-model-presentations
Browse files Browse the repository at this point in the history
HOTFIX: Spatial Model Presentations
  • Loading branch information
briandrawert authored May 1, 2023
2 parents 34c2c29 + b048c14 commit aaa75eb
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 202 deletions.
2 changes: 1 addition & 1 deletion client/domain-view/templates/actionsView.pug
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ div#domain-actions-editor.card

a.nav-link.tab(data-hook="actions-view-tab" data-toggle="tab" href="#view-actions") View

button.btn.btn-outline-collapse.inline(data-toggle="collapse" data-target="#collapse-actions" data-hook="collapse") +
button.btn.btn-outline-collapse.inline(data-toggle="collapse" data-target="#collapse-actions" data-hook="collapse-actions") +

div.card-body

Expand Down
2 changes: 1 addition & 1 deletion client/domain-view/templates/shapesView.pug
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ div#domain-geometries-editor.card

a.nav-link.tab(data-hook="shapes-view-tab" data-toggle="tab" href="#view-shapes") View

button.btn.btn-outline-collapse.inline(data-toggle="collapse" data-target="#collapse-shapes" data-hook="collapse") +
button.btn.btn-outline-collapse.inline(data-toggle="collapse" data-target="#collapse-shapes" data-hook="collapse-shapes") +

div.card-body
p.mb-0
Expand Down
2 changes: 1 addition & 1 deletion client/domain-view/templates/transformationsView.pug
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ div#domain-transformation-editor.card

a.nav-link.tab(data-hook="transformations-view-tab" data-toggle="tab" href="#view-transformations") View

button.btn.btn-outline-collapse.inline(data-toggle="collapse" data-target="#collapse-transformations" data-hook="collapse") +
button.btn.btn-outline-collapse.inline(data-toggle="collapse" data-target="#collapse-transformations" data-hook="collapse-transformations") +

div.card-body

Expand Down
2 changes: 1 addition & 1 deletion client/domain-view/views/actions-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let template = require('../templates/actionsView.pug');
module.exports = View.extend({
template: template,
events: {
'click [data-hook=collapse]' : 'changeCollapseButtonText',
'click [data-hook=collapse-actions]' : 'changeCollapseButtonText',
'click [data-hook=fill-action]' : 'addAction',
'click [data-hook=set-action]' : 'addAction',
'click [data-hook=remove-action]' : 'addAction',
Expand Down
2 changes: 1 addition & 1 deletion client/domain-view/views/shapes-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let template = require('../templates/shapesView.pug');
module.exports = View.extend({
template: template,
events: {
'click [data-hook=collapse]' : 'changeCollapseButtonText',
'click [data-hook=collapse-shapes]' : 'changeCollapseButtonText',
'click [data-hook=cartesian-lattice]' : 'addShape',
'click [data-hook=spherical-lattice]' : 'addShape',
'click [data-hook=cylindrical-lattice]' : 'addShape'
Expand Down
2 changes: 1 addition & 1 deletion client/domain-view/views/transformations-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let template = require('../templates/transformationsView.pug');
module.exports = View.extend({
template: template,
events: {
'click [data-hook=collapse]' : 'changeCollapseButtonText',
'click [data-hook=collapse-transformations]' : 'changeCollapseButtonText',
'click [data-hook=translate-transformation]' : 'addTransformation',
'click [data-hook=rotate-transformation]' : 'addTransformation',
'click [data-hook=reflect-transformation]' : 'addTransformation',
Expand Down
25 changes: 14 additions & 11 deletions client/domain-view/views/types-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ module.exports = View.extend({
changeCollapseButtonText: function (e) {
app.changeCollapseButtonText(this, e);
},
getParticleCounts: function (particles) {
let particleCounts = {};
particles.forEach((particle) => {
if(particleCounts[particle.type]) {
particleCounts[particle.type] += 1;
}else{
particleCounts[particle.type] = 1;
}
});
this.collection.forEach((type) => {
type.numParticles = particleCounts[type.typeID] ? particleCounts[type.typeID] : 0;
});
},
handleAddDomainType: function () {
let name = this.collection.addType();
this.collection.parent.trigger('update-particle-type-options', {currName: name});
Expand Down Expand Up @@ -135,17 +148,7 @@ module.exports = View.extend({
});
},
updateParticleCounts: function (particles) {
let particleCounts = {};
particles.forEach((particle) => {
if(particleCounts[particle.type]) {
particleCounts[particle.type] += 1;
}else{
particleCounts[particle.type] = 1;
}
});
this.collection.forEach((type) => {
type.numParticles = particleCounts[type.typeID] ? particleCounts[type.typeID] : 0;
});
this.getParticleCounts(particles);
$(this.queryByHook('unassigned-type-count')).text(this.collection.models[0].numParticles);
this.renderEditTypeView();
this.renderViewTypeView();
Expand Down
12 changes: 12 additions & 0 deletions client/pages/model-presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,22 @@ let ModelPresentationPage = PageView.extend({
let endpoint = `api/file/json-data?file=${this.model.directory}&owner=${owner}`;
app.getXHR(endpoint, {
success: (err, response, body) => {
let particles = body.model.domain.particles
this.model.set(body.model);
if(this.model.is_spatial && Object.keys(body.model.domain).includes("particles")) {
let particles = new Particles(body.model.domain.particles);
this.model.domain.particles = particles;
this.model.domain.actions.forEach((action) => {
action.filename = action.filename.split('/').pop();
action.subdomainFile = action.subdomainFile.split('/').pop();
});
this.model.domain.x_lim = body.domainLimits[0];
this.model.domain.y_lim = body.domainLimits[1];
this.model.domain.z_lim = body.domainLimits[2];
let particleCounts = {};
this.model.domain.types.forEach((type) => { particleCounts[type.typeID] = 0; });
particles.forEach((particle) => { particleCounts[particle.type] += 1; });
this.model.domain.types.forEach((type) => { type.numParticles = particleCounts[type.typeID]; });
}
let domainPlot = Boolean(body.domainPlot) ? body.domainPlot : null;
this.renderSubviews(false, domainPlot);
Expand Down
Loading

0 comments on commit aaa75eb

Please sign in to comment.