removing culture cell data on import

This commit is contained in:
annapanni 2022-04-27 15:46:46 +02:00
parent 98cbcd1ff0
commit d4ca17b3a2

View file

@ -417,16 +417,7 @@ function editCultures() {
tip(`Names for ${cBurgs.length} burgs are regenerated`, false, "success"); tip(`Names for ${cBurgs.length} burgs are regenerated`, false, "success");
} }
function cultureRemove() { function removeCultureModel(culture) {
if (customization === 4) return;
const culture = +this.parentNode.dataset.id;
alertMessage.innerHTML = "Are you sure you want to remove the culture? <br>This action cannot be reverted";
$("#alert").dialog({
resizable: false,
title: "Remove culture",
buttons: {
Remove: function () {
cults.select("#culture" + culture).remove(); cults.select("#culture" + culture).remove();
debug.select("#cultureCenter" + culture).remove(); debug.select("#cultureCenter" + culture).remove();
@ -444,6 +435,19 @@ function editCultures() {
if (c.origin === culture) c.origin = origin; if (c.origin === culture) c.origin = origin;
}); });
refreshCulturesEditor(); refreshCulturesEditor();
}
function cultureRemove() {
if (customization === 4) return;
const culture = +this.parentNode.dataset.id;
alertMessage.innerHTML = "Are you sure you want to remove the culture? <br>This action cannot be reverted";
$("#alert").dialog({
resizable: false,
title: "Remove culture",
buttons: {
Remove: function () {
removeCultureModel(culture);
$(this).dialog("close"); $(this).dialog("close");
}, },
Cancel: function () { Cancel: function () {
@ -930,9 +934,7 @@ function editCultures() {
current.base = nameBaseIndex === -1 ? 0 : nameBaseIndex; current.base = nameBaseIndex === -1 ? 0 : nameBaseIndex;
} }
const validId = cultures.filter(c => !c.removed).map(c => c.i); cultures.filter(c => c.removed).forEach(c => removeCultureModel(c.i))
cultures.forEach(item => (item.origin = validId.includes(item.origin) ? item.origin : 0));
cultures[0].origin = null;
drawCultures(); drawCultures();
refreshCulturesEditor(); refreshCulturesEditor();