mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-10 10:25:36 +01:00
29 lines
754 B
JavaScript
29 lines
754 B
JavaScript
import {LoadTemplate} from './utils'
|
|
import {BindArray} from './bind'
|
|
|
|
export function SolidList(app) {
|
|
this.app = app;
|
|
app.bus.subscribe('solid-list', (data) => this.onChange(data));
|
|
this.dom = $(LoadTemplate('solid-list')({}));
|
|
BindArray(this.dom, []);
|
|
}
|
|
|
|
SolidList.prototype.onChange = function(data) {
|
|
let domData = data.solids.map(s => ({id: s.id}));
|
|
domData.forEach(s => {
|
|
let toRefresh = data.needRefresh.find(nr => nr.id == s.id);
|
|
if (toRefresh) {
|
|
Object.assign(s, this.getFullInfo(toRefresh));
|
|
}
|
|
});
|
|
BindArray(this.dom, domData);
|
|
};
|
|
|
|
SolidList.prototype.getFullInfo = function(solid) {
|
|
return {
|
|
id: solid.id,
|
|
type: solid.tCadType,
|
|
sketches: this.app.findSketches(solid).map(id => ({id}))
|
|
};
|
|
};
|
|
|