Skip to content

Commit

Permalink
fix(LimitTrailFields): 🐛 New fields were being limited by default
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jan 29, 2022
1 parent d6afee9 commit 2de4170
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/Components/Checkboxes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
let selected = settings[settingName];
let toNone = selected.length === 0 ? false : true;
$: toNone = selected.length === 0 ? false : true;
async function save() {
Expand Down
36 changes: 34 additions & 2 deletions src/Components/UserHierarchies.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { hierToStr } from "../Utils/HierUtils";
export let plugin: BCPlugin;
const { settings } = plugin;
let currHiers = [...plugin.settings.userHiers];
async function update(currHiers: UserHier[]) {
Expand Down Expand Up @@ -80,7 +81,24 @@
<button
aria-label="Remove Hierarchy"
on:click={async () => {
currHiers.splice(i, 1);
const oldHier = currHiers.splice(i, 1)[0];
oldHier.up.forEach((upField) => {
const index = settings.limitTrailCheckboxes.indexOf(upField);
if (index > -1) settings.limitTrailCheckboxes.splice(index, 1);
});

DIRECTIONS.forEach((dir) => {
oldHier[dir].forEach((field) => {
const indexI = settings.limitJumpToFirstFields.indexOf(field);
if (indexI > -1)
settings.limitJumpToFirstFields.splice(indexI, 1);

const indexJ = settings.limitWriteBCCheckboxes.indexOf(field);
if (indexJ > -1)
settings.limitJumpToFirstFields.splice(indexJ, 1);
});
});

currHiers = currHiers;
await update(currHiers);
}}
Expand All @@ -101,8 +119,22 @@
value={hier[dir]?.join(", ") ?? ""}
on:change={async (e) => {
const { value } = e.target;
currHiers[i][dir] = splitAndTrim(value);
const splits = splitAndTrim(value);
currHiers[i][dir] = splits;
await update(currHiers);

splits.forEach((split) => {
if (
dir === "up" &&
!settings.limitTrailCheckboxes.includes(split)
)
settings.limitTrailCheckboxes.push(split);
if (!settings.limitJumpToFirstFields.includes(split))
settings.limitJumpToFirstFields.push(split);
if (!settings.limitWriteBCCheckboxes.includes(split))
settings.limitWriteBCCheckboxes.push(split);
});
await plugin.saveSettings();
}}
/>
</div>
Expand Down

0 comments on commit 2de4170

Please sign in to comment.