mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-04-30 02:31:41 -04:00
Merge branch '3-fix-add-remove-attr' into 'master'
3: Fix issue with adding and removing attributes Closes #3 See merge request foundrynet/worldbuilding!6
This commit is contained in:
commit
ef009146f2
2 changed files with 16 additions and 4 deletions
|
@ -82,9 +82,15 @@ export class SimpleActorSheet extends ActorSheet {
|
|||
|
||||
// Add new attribute
|
||||
if ( action === "create" ) {
|
||||
const nk = Object.keys(attrs).length + 1;
|
||||
const objKeys = Object.keys(attrs);
|
||||
let nk = Object.keys(attrs).length + 1;
|
||||
let newValue = `attr${nk}`;
|
||||
let newKey = document.createElement("div");
|
||||
newKey.innerHTML = `<input type="text" name="data.attributes.attr${nk}.key" value="attr${nk}"/>`;
|
||||
while ( objKeys.includes(newValue) ) {
|
||||
++nk;
|
||||
newValue = `attr${nk}`;
|
||||
};
|
||||
newKey.innerHTML = `<input type="text" name="data.attributes.attr${nk}.key" value="${newValue}"/>`;
|
||||
newKey = newKey.children[0];
|
||||
form.appendChild(newKey);
|
||||
await this._onSubmit(event);
|
||||
|
|
|
@ -67,9 +67,15 @@ export class SimpleItemSheet extends ItemSheet {
|
|||
|
||||
// Add new attribute
|
||||
if ( action === "create" ) {
|
||||
const nk = Object.keys(attrs).length + 1;
|
||||
const objKeys = Object.keys(attrs);
|
||||
let nk = Object.keys(attrs).length + 1;
|
||||
let newValue = `attr${nk}`;
|
||||
let newKey = document.createElement("div");
|
||||
newKey.innerHTML = `<input type="text" name="data.attributes.attr${nk}.key" value="attr${nk}"/>`;
|
||||
while ( objKeys.includes(newValue) ) {
|
||||
++nk;
|
||||
newValue = `attr${nk}`;
|
||||
}
|
||||
newKey.innerHTML = `<input type="text" name="data.attributes.attr${nk}.key" value="${newValue}"/>`;
|
||||
newKey = newKey.children[0];
|
||||
form.appendChild(newKey);
|
||||
await this._onSubmit(event);
|
||||
|
|
Loading…
Add table
Reference in a new issue