Finish removing the Range bucket type that was accidentally still able to be created
This commit is contained in:
parent
3fc8b654c7
commit
8f993adb47
6 changed files with 34 additions and 52 deletions
|
|
@ -75,7 +75,7 @@ export class TableCreator extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
if (this._name.startsWith(`Dice`)) {
|
||||
ctx.createButtonDisabled = !this._name.match(diceNamespacePattern);
|
||||
ctx.typeDisabled = true;
|
||||
ctx.type = BucketTypes.RANGE;
|
||||
ctx.type = BucketTypes.NUMBER;
|
||||
this.#diceNamespaceAlert ??= ui.notifications.info(
|
||||
`Tables in the "Dice" namespace must be formatted as "Dice/dX" where X is the number of sides on the die and are restricted to be ranges 1 to X.`,
|
||||
{ permanent: true },
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ Hooks.on(`init`, () => {
|
|||
manager: TableManager,
|
||||
};
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
CONFIG.stats.db = MemoryDatabase;
|
||||
};
|
||||
// if (import.meta.env.DEV) {
|
||||
// CONFIG.stats.db = MemoryDatabase;
|
||||
// };
|
||||
|
||||
game.modules.get(__ID__).api = api;
|
||||
if (game.settings.get(__ID__, `globalAPI`)) {
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ Hooks.on(`ready`, () => {
|
|||
);
|
||||
|
||||
// Fire and forget
|
||||
CONFIG.stats.db.migrateData(notif)
|
||||
CONFIG.stats.db.migrateData(lastVersion, notif)
|
||||
.then(() => {
|
||||
game.settings.set(__ID__, `lastVersion`, __VERSION__);
|
||||
setTimeout(() => ui.notifications.remove(notif), 500);
|
||||
setTimeout(() => ui.notifications.remove(notif), 5_000);
|
||||
});
|
||||
} else {
|
||||
ui.notifications.error(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ const { StringField, NumberField } = foundry.data.fields;
|
|||
export const BucketTypes = {
|
||||
STRING: `string`,
|
||||
NUMBER: `number`,
|
||||
RANGE: `range`,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Default Subtables:
|
|||
tables that are parents to other tables.
|
||||
*/
|
||||
|
||||
const { deleteProperty, diffObject, expandObject, mergeObject } = foundry.utils;
|
||||
const { deleteProperty, diffObject, expandObject, isNewerVersion, mergeObject } = foundry.utils;
|
||||
|
||||
/**
|
||||
* The generic Database implementation, any subclasses should implement all of
|
||||
|
|
@ -275,7 +275,11 @@ export class Database {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
static requiresMigrationFrom(lastVersion) {
|
||||
return foundry.utils.isNewerVersion(__VERSION__, lastVersion);
|
||||
Logger.table({
|
||||
lastVersion,
|
||||
newer: isNewerVersion(__VERSION__, lastVersion),
|
||||
});
|
||||
return isNewerVersion(__VERSION__, lastVersion);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -289,7 +293,28 @@ export class Database {
|
|||
* @param {Notification} notif The progress bar notification used for
|
||||
* user feedback while performing migrations.
|
||||
*/
|
||||
static async migrateData(lastVersion, notif) {};
|
||||
static async migrateData(lastVersion, notif) {
|
||||
const totalSteps = 1;
|
||||
Logger.debug(lastVersion);
|
||||
|
||||
/*
|
||||
This migration is for going up to 1.0.3, getting rid of any tables that have
|
||||
a bucket type of range, since those were not supported within the initial
|
||||
release, but could still accidentally be created by users.
|
||||
*/
|
||||
if (isNewerVersion(`1.0.3`, lastVersion)) {
|
||||
Logger.log(`Migrating up to the v1.0.3 data structure`);
|
||||
const tables = game.settings.get(__ID__, `tables`);
|
||||
for (const table of Object.values(tables)) {
|
||||
if (table.buckets.type !== `range`) { continue };
|
||||
table.buckets.type = BucketTypes.NUMBER;
|
||||
table.buckets.showEmptyBuckets = true;
|
||||
};
|
||||
await game.settings.set(__ID__, `tables`, tables);
|
||||
notif.update({ pct: notif.pct + (1 / totalSteps) });
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<div class="input-group">
|
||||
<label for="{{meta.idp}}-min">
|
||||
Minimum
|
||||
</label>
|
||||
<input
|
||||
id="{{meta.idp}}-min"
|
||||
type="number"
|
||||
name="buckets.min"
|
||||
value="{{ buckets.min }}"
|
||||
required
|
||||
{{disabled buckets.locked}}
|
||||
>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="{{meta.idp}}-max">
|
||||
Maximum
|
||||
</label>
|
||||
<input
|
||||
id="{{meta.idp}}-max"
|
||||
type="number"
|
||||
name="buckets.max"
|
||||
value="{{ buckets.max }}"
|
||||
required
|
||||
{{disabled buckets.locked}}
|
||||
>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="{{meta.idp}}-step">
|
||||
Step
|
||||
</label>
|
||||
<input
|
||||
id="{{meta.idp}}-step"
|
||||
type="number"
|
||||
name="buckets.step"
|
||||
value="{{ buckets.step }}"
|
||||
required
|
||||
{{disabled buckets.locked}}
|
||||
>
|
||||
<p class="hint">
|
||||
The size of the step between values within the range.
|
||||
</p>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue