2023-11-09 13:29:01 +00:00
|
|
|
nopaque.resource_displays.ResourceDisplay = class ResourceDisplay {
|
2023-10-10 09:06:44 +00:00
|
|
|
static htmlClass;
|
|
|
|
|
|
|
|
constructor(displayElement) {
|
|
|
|
this.displayElement = displayElement;
|
|
|
|
this.userId = this.displayElement.dataset.userId;
|
|
|
|
this.isInitialized = false;
|
2024-12-03 14:59:08 +00:00
|
|
|
if (this.userId === undefined) {return;}
|
2024-12-05 13:26:05 +00:00
|
|
|
app.userHub.addEventListener('patch', (event) => {
|
2024-12-03 14:59:08 +00:00
|
|
|
if (this.isInitialized) {this.onPatch(event.detail);}
|
|
|
|
});
|
2024-12-05 13:26:05 +00:00
|
|
|
app.userHub.get(this.userId).then((user) => {
|
2024-12-03 14:59:08 +00:00
|
|
|
this.init(user);
|
|
|
|
this.isInitialized = true;
|
|
|
|
});
|
2023-10-10 09:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
init(user) {throw 'Not implemented';}
|
|
|
|
|
|
|
|
onPatch(patch) {throw 'Not implemented';}
|
|
|
|
|
|
|
|
setElement(element, value) {
|
|
|
|
switch (element.tagName) {
|
|
|
|
case 'INPUT': {
|
|
|
|
element.value = value;
|
|
|
|
M.updateTextFields();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
element.innerText = value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setElements(elements, value) {
|
|
|
|
for (let element of elements) {
|
|
|
|
this.setElement(element, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|