From f8265ce3a8ffb3f6b2ae972efa848f7d79142da0 Mon Sep 17 00:00:00 2001 From: steeven Date: Sun, 7 Apr 2024 20:01:07 +0200 Subject: [PATCH] =?UTF-8?q?un=20pas=20en=20avant.=20j'acc=C3=A8de=20aux=20?= =?UTF-8?q?settings=20dans=20le=20modale,=20mais=20pas=20aux=20bons...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/main.ts b/main.ts index eb4b1c2..0a2301f 100644 --- a/main.ts +++ b/main.ts @@ -43,8 +43,6 @@ export default class budgetPlugin extends Plugin { settings: BudgetSettings; async onload() { - ///// starting the app - // addRibbon icon await this.loadSettings(); const ribbonIconEl = this.addRibbonIcon( @@ -71,7 +69,7 @@ export default class budgetPlugin extends Plugin { console.log("Debug: trigger new expense modal from ribbon"); } ); - // Adds a setting tag so the user ca configure the aspects of the plugin + // Adds a setting tag so the user can configure the aspects of the plugin this.addSettingTab(new ExpenseSettingTab(this.app, this)); } @@ -91,6 +89,7 @@ export default class budgetPlugin extends Plugin { } export class ExpenseModal extends Modal { + settings = DEFAULT_SETTINGS; expenseAmount: string = "120"; expenseCategory: string; expenseValue: string = "basics"; @@ -115,8 +114,22 @@ export class ExpenseModal extends Modal { this.onSubmit = onSubmit; } + // j'accède aux settings ok, mais pas les bons... ici ce sont les DEFAULT_SETTINGS et je veux les modifés ! + async loadData(): Promise { + await this.loadSettings(); + } + + async loadSettings(): Promise { + this.settings = Object.assign( + {}, + this.expenseCategory, + await this.loadData() + ); + } + onOpen() { const { contentEl } = this; + console.log(this.settings.expenseCategories); contentEl.createEl("h1", { text: "Enter new Expense" }); new Setting(contentEl).setName("Amount").addText((text) => @@ -125,14 +138,6 @@ export class ExpenseModal extends Modal { }) ); - async function fetchData() { - const response = await fetch("data.json"); - const data = await response.json(); - console.log(data); - } - - fetchData(); - /* move this to the setting const category = [ { categoryId: 1, categoryName: "Eat", categoryIcon: "carrot" },