mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 07:37:10 +00:00
Refactor error view and make loot table default
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
import { AbstractView, Path, locale, DataModel } from "minecraft-schemas";
|
||||
import { IView, locale, DataModel, ModelListener } from "minecraft-schemas";
|
||||
import { Errors } from "minecraft-schemas/lib/model/Errors";
|
||||
|
||||
export class ErrorsView extends AbstractView {
|
||||
export class ErrorsView implements ModelListener, IView {
|
||||
model: DataModel
|
||||
target: HTMLElement
|
||||
|
||||
constructor(model: DataModel, target: HTMLElement) {
|
||||
super(model)
|
||||
this.model = model
|
||||
this.target = target
|
||||
}
|
||||
|
||||
render(): void {
|
||||
this.target.style.display = this.model.errors.count() > 0 ? 'flex' : 'none'
|
||||
setModel(newModel: DataModel) {
|
||||
this.model.removeListener(this)
|
||||
this.model = newModel
|
||||
this.model.addListener(this)
|
||||
}
|
||||
|
||||
errors(errors: Errors): void {
|
||||
this.target.style.display = errors.count() > 0 ? 'flex' : 'none'
|
||||
|
||||
const errors = this.model.errors.get(new Path())
|
||||
this.target.children[0].innerHTML = errors.map(err =>
|
||||
this.target.children[0].innerHTML = errors.getAll().map(err =>
|
||||
`<div class="error">
|
||||
<svg class="error-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="18" height="18"><path fill-rule="evenodd" d="M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM0 8a8 8 0 1116 0A8 8 0 010 8zm9 3a1 1 0 11-2 0 1 1 0 012 0zm-.25-6.25a.75.75 0 00-1.5 0v3.5a.75.75 0 001.5 0v-3.5z"></path></svg>
|
||||
<span class="error-path">${err.path.toString()}</span>
|
||||
|
||||
@@ -99,6 +99,9 @@ Promise.all([
|
||||
const treeControlsRedo = document.getElementById('tree-controls-redo')!
|
||||
|
||||
let selected = modelFromPath(location.pathname)
|
||||
if (selected.length === 0) {
|
||||
selected = 'loot-table'
|
||||
}
|
||||
|
||||
const models: { [key: string]: DataModel } = {
|
||||
'loot-table': new DataModel(LootTableSchema),
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
<link rel="stylesheet" href="./styles/global.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user