modaq
Version:
Quiz Bowl Reader using TypeScript, React, and MobX
104 lines • 4.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomizeGameFormatState = void 0;
const mobx_1 = require("mobx");
require("./IGameFormat");
class CustomizeGameFormatState {
constructor(existingGameFormat) {
Object.defineProperty(this, "gameFormat", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
// Based on the UI, we have to store powerMarkers/powerValues separately. This is a bit of a leaky abstraction
// (state shouldn't know about the view), which we should try to fix
Object.defineProperty(this, "powerMarkers", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "powerValues", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "pronunicationGuideMarkers", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "powerMarkerErrorMessage", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "powerValuesErrorMessage", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "pronunciationGuideMarkersErrorMessage", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
mobx_1.makeAutoObservable(this);
this.gameFormat = Object.assign({}, existingGameFormat);
this.powerMarkers = this.gameFormat.powers.map((power) => power.marker);
this.powerMarkerErrorMessage = undefined;
this.powerValues = this.gameFormat.powers.map((power) => power.points).join(",");
this.powerValuesErrorMessage = undefined;
this.pronunicationGuideMarkers = this.gameFormat.pronunciationGuideMarkers;
this.pronunciationGuideMarkersErrorMessage = undefined;
}
clearPowerErrorMessages() {
this.powerMarkerErrorMessage = undefined;
this.powerValuesErrorMessage = undefined;
}
clearPronunciationGuideMarkersErrorMessage() {
this.pronunciationGuideMarkersErrorMessage = undefined;
}
setPowerMarkers(powerMarkers) {
// Clear the error message if we have a new value
this.powerMarkers = powerMarkers;
this.powerMarkerErrorMessage = undefined;
}
setPowerMarkerErrorMessage(message) {
this.powerMarkerErrorMessage = message;
}
setPowerValues(powerValues) {
// Clear the error message if we have a new value
this.powerValues = powerValues;
this.powerValuesErrorMessage = undefined;
}
setPowerValuesErrorMessage(message) {
this.powerValuesErrorMessage = message;
}
setPronunciationGuideMarkers(pronunciationGuideMarkers) {
this.pronunicationGuideMarkers = pronunciationGuideMarkers;
this.clearPronunciationGuideMarkersErrorMessage();
}
setPronunciationGuideMarkersErrorMessage(message) {
this.pronunciationGuideMarkersErrorMessage = message;
}
updateGameFormat(gameFormatUpdate) {
this.gameFormat = Object.assign(Object.assign({}, this.gameFormat), gameFormatUpdate);
if (gameFormatUpdate.powers != undefined) {
this.setPowerValues(this.gameFormat.powers.map((power) => power.points).join(","));
this.setPowerMarkers(this.gameFormat.powers.map((power) => power.marker));
}
if (gameFormatUpdate.pronunciationGuideMarkers != undefined) {
this.pronunciationGuideMarkersErrorMessage = undefined;
this.pronunicationGuideMarkers = this.gameFormat.pronunciationGuideMarkers;
}
}
}
exports.CustomizeGameFormatState = CustomizeGameFormatState;
//# sourceMappingURL=CustomizeGameFormatDialogState.js.map