Fixed UI tree element not expanding/collapsing

Fixed error message when loading a mesh with an empty filepath
This commit is contained in:
Lucas Dower 2023-01-15 18:50:35 +00:00
parent 8b0ce63afc
commit eda39d771b
No known key found for this signature in database
GPG Key ID: B3EE6B8499593605
4 changed files with 16 additions and 4 deletions

View File

@ -276,8 +276,6 @@ export class ObjImporter extends IImporter {
]; ];
override parseFile(filePath: string) { override parseFile(filePath: string) {
ASSERT(path.isAbsolute(filePath), `ObjImporter: ${filePath} not absolute`);
this._objPath = path.parse(filePath); this._objPath = path.parse(filePath);
this._parseOBJ(filePath); this._parseOBJ(filePath);
@ -302,8 +300,11 @@ export class ObjImporter extends IImporter {
} }
private _parseOBJ(path: string) { private _parseOBJ(path: string) {
if (path === '') {
throw new AppError(`No filepath given`);
}
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
throw new AppError(`Could not find ${path}`); throw new AppError(`Could not find '${path}'`);
} }
const fileContents = fs.readFileSync(path, 'utf8'); const fileContents = fs.readFileSync(path, 'utf8');
if (fileContents.includes('<27>')) { if (fileContents.includes('<27>')) {

View File

@ -9,7 +9,7 @@ export class FileInputElement extends ConfigUIElement<string, HTMLDivElement> {
private _hovering: boolean; private _hovering: boolean;
public constructor() { public constructor() {
super(); super('');
this._fileExtensions = []; this._fileExtensions = [];
this._loadedFilePath = ''; this._loadedFilePath = '';
this._hovering = false; this._hovering = false;

View File

@ -60,6 +60,7 @@ export class OutputElement {
ASSERT(element !== null); ASSERT(element !== null);
element.innerHTML = this._message.toString(); element.innerHTML = this._message.toString();
this._message.postBuild();
} }
public setStyle(style: OutputStyle) { public setStyle(style: OutputStyle) {

View File

@ -74,6 +74,16 @@ export class UITreeBuilder implements IUIOutputElement {
this._postBuildDelegates.forEach((delegate) => { this._postBuildDelegates.forEach((delegate) => {
delegate(); delegate();
}); });
const toggler = document.getElementsByClassName('caret') as HTMLCollectionOf<HTMLElement>;
for (let i = 0; i < toggler.length; i++) {
const temp = toggler[i];
temp.onclick = () => {
temp.parentElement?.querySelector('.nested')?.classList.toggle('active');
temp.classList.toggle('caret-down');
};
}
} }
public buildHTML(): string { public buildHTML(): string {