diff --git a/src/facilities/toyShop/toyShop.js b/src/facilities/toyShop/toyShop.js index fed9a8adafc859b91460825a2d436a1a2f0387af..12e69fc3758c61bb46566a5f7a1d8dcec536662e 100644 --- a/src/facilities/toyShop/toyShop.js +++ b/src/facilities/toyShop/toyShop.js @@ -40,9 +40,6 @@ App.UI.toyShop = function() { let linkArray; App.UI.DOM.appendNewElement("h2", el, "Buttplugs"); el.append(create()); - if (V.customItem.buttPlugs.size > 0) { - //el.append(reviewDesigns()); - } return el; function create() { @@ -54,10 +51,14 @@ App.UI.toyShop = function() { length(), apply(), ); + if (V.customItem.buttPlugs.size > 0) { + el.append(reviewDesigns()); + } return el; } function reviewDesigns() { - const el = new DocumentFragment(); + const el = document.createElement("p"); + App.UI.DOM.appendNewElement("h3", el, "Tweak existing design"); const choice = App.UI.DOM.appendNewElement("div", el, ` Choose an existing design to edit `); const select = App.UI.DOM.appendNewElement("select", choice); for (const [key, values] of V.customItem.buttPlugs) { @@ -67,23 +68,38 @@ App.UI.toyShop = function() { select.onchange = () => { const O = select.options[select.selectedIndex]; selectedPlug = O.value; + buttPlugName = selectedPlug; + buttPlugData = V.customItem.buttPlugs.get(selectedPlug); refresh(); }; - buttPlugName = selectedPlug; - buttPlugData = V.customItem.buttPlugs.get(selectedPlug); el.append( - desc(), - titleLocked(), + descLocked(), + title(), width(), length(), - apply(), ); + const build = App.UI.DOM.appendNewElement("div", el, `Send updated design to production and make sure all appropriate slaves are updated `); + const linkArray = []; + linkArray.push( + App.UI.DOM.link( + "Update the mold", + () => { buildPlug(); } + ) + ); + + linkArray.push( + App.UI.DOM.link( + `Recall "${buttPlugName}"`, + () => { deletePlug(); } + ) + ); + build.append(App.UI.DOM.generateLinksStrip(linkArray)); return el; - function titleLocked() { + function descLocked() { // Title - return App.UI.DOM.makeElement("div", `Title has already been selected for this model`); + return App.UI.DOM.makeElement("div", `Description has already been selected for this model: "${buttPlugName}"`); } } @@ -198,7 +214,13 @@ App.UI.toyShop = function() { function deletePlug() { - + V.customItem.buttPlugs.delete(buttPlugName); + for (const slave of V.slaves) { + if (slave.buttplug === buttPlugName) { + slave.buttplug = "none"; + } + } + refresh(); } }