-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
19 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export {default as CurrencyTemplate} from "./currency.mjs"; | ||
export {default as SourceField} from "./source-field.mjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { SchemaField, StringField } = foundry.data.fields; | ||
|
||
/** | ||
* Data fields that stores information on the adventure or sourcebook where this document originated. | ||
* | ||
* @property {string} book Book/publication where the item originated. | ||
* @property {string} page Page or section where the item can be found. | ||
* @property {string} custom Fully custom source label. | ||
* @property {string} uuid Upstream source of this data if it originated in another compendium. | ||
* @property {string} license Type of license that covers this item. | ||
*/ | ||
export default class SourceTemplate extends SchemaField { | ||
constructor(fields={}, options={}) { | ||
super({ | ||
book: new StringField(), | ||
page: new StringField(), | ||
custom: new StringField(), | ||
uuid: new StringField(), // TODO: Convert to UUIDField with v12 | ||
license: new StringField(), | ||
...fields | ||
}, { label: "DND5E.Source", ...options }); | ||
} | ||
|
||
/* -------------------------------------------- */ | ||
|
||
initialize(value, model, options={}) { | ||
const obj = super.initialize(value, model, options); | ||
|
||
Object.defineProperty(obj, "label", { | ||
get() { | ||
if ( this.custom ) return this.custom; | ||
// TODO: Improve this logic | ||
return this.book ? this.page ? `${this.book} ${this.page}` : this.book : ""; | ||
}, | ||
enumerable: false | ||
}); | ||
Object.defineProperty(obj, "toString", { | ||
value: () => { | ||
foundry.utils.logCompatibilityWarning("Source has been converted to an object, the label can now be accessed " | ||
+ "using the `source#label` property.", { since: "DnD5e 2.4", until: "DnD5e 2.6" }); | ||
return obj.label; | ||
}, | ||
enumerable: false | ||
}); | ||
|
||
return obj; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -510,7 +510,7 @@ | |
"chat": "", | ||
"unidentified": "" | ||
}, | ||
"source": "" | ||
"source": {} | ||
}, | ||
"physicalItem": { | ||
"quantity": 1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters