Skip to content

Commit 96c6c4d

Browse files
committed
fix issue in list view
1 parent eabc205 commit 96c6c4d

7 files changed

Lines changed: 58 additions & 33 deletions

File tree

documentation/components/ListExpensesComponent.html

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ <h3>HostListeners</h3> <table class="table table-sm table-bordered">
519519

520520
<tr>
521521
<td class="col-md-4">
522-
<div class="io-line">Defined in <a href="" data-line="357"
523-
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:357</a></div>
522+
<div class="io-line">Defined in <a href="" data-line="358"
523+
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:358</a></div>
524524
</td>
525525
</tr>
526526

@@ -705,8 +705,8 @@ <h3 id="methods">
705705

706706
<tr>
707707
<td class="col-md-4">
708-
<div class="io-line">Defined in <a href="" data-line="345"
709-
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:345</a></div>
708+
<div class="io-line">Defined in <a href="" data-line="346"
709+
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:346</a></div>
710710
</td>
711711
</tr>
712712

@@ -783,8 +783,8 @@ <h3 id="methods">
783783

784784
<tr>
785785
<td class="col-md-4">
786-
<div class="io-line">Defined in <a href="" data-line="305"
787-
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:305</a></div>
786+
<div class="io-line">Defined in <a href="" data-line="306"
787+
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:306</a></div>
788788
</td>
789789
</tr>
790790

@@ -1109,8 +1109,8 @@ <h3 id="methods">
11091109

11101110
<tr>
11111111
<td class="col-md-4">
1112-
<div class="io-line">Defined in <a href="" data-line="357"
1113-
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:357</a></div>
1112+
<div class="io-line">Defined in <a href="" data-line="358"
1113+
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:358</a></div>
11141114
</td>
11151115
</tr>
11161116

@@ -1273,8 +1273,8 @@ <h3 id="methods">
12731273

12741274
<tr>
12751275
<td class="col-md-4">
1276-
<div class="io-line">Defined in <a href="" data-line="333"
1277-
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:333</a></div>
1276+
<div class="io-line">Defined in <a href="" data-line="334"
1277+
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:334</a></div>
12781278
</td>
12791279
</tr>
12801280

@@ -1421,8 +1421,8 @@ <h3 id="methods">
14211421

14221422
<tr>
14231423
<td class="col-md-4">
1424-
<div class="io-line">Defined in <a href="" data-line="318"
1425-
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:318</a></div>
1424+
<div class="io-line">Defined in <a href="" data-line="319"
1425+
class="link-to-prism">src/app/features/list-expenses/list-expenses.component.ts:319</a></div>
14261426
</td>
14271427
</tr>
14281428

@@ -2614,7 +2614,8 @@ <h3 id="inputs">
26142614
this.expenseService.update(expense_id, newData);
26152615
this.toastService.show(&#x27;Expense updated successfully&#x27;, &#x27;success&#x27;);
26162616
this.isEditOpen &#x3D; false;
2617-
this.searchData(this.searchQuery);
2617+
this.expenses &#x3D; this.expenses.map(item &#x3D;&gt; item.expense_id &#x3D;&#x3D;&#x3D; expense_id ? { ...item, ...newData } : item);
2618+
this.expenses &#x3D; this.expenses.map(item &#x3D;&gt; ({ ...item, amount: Math.round(item.amount * 100) / 100 }));
26182619
}
26192620

26202621
/**
@@ -2626,7 +2627,7 @@ <h3 id="inputs">
26262627
this.expenseService.delete(id);
26272628
this.toastService.show(&quot;Expense deleted successfully&quot;, &#x27;success&#x27;);
26282629
this.closeModal();
2629-
this.searchData(this.searchQuery);
2630+
this.expenses &#x3D; this.expenses.filter(item &#x3D;&gt; item.expense_id !&#x3D;&#x3D; id);
26302631
}
26312632
}
26322633

@@ -2636,7 +2637,7 @@ <h3 id="inputs">
26362637
*/
26372638
searchData(query: string): void {
26382639
this.expenses &#x3D; this.expenseService.getAll();
2639-
if(query.length &#x3D;&#x3D;&#x3D; 0) {
2640+
if (query.length &#x3D;&#x3D;&#x3D; 0) {
26402641
return;
26412642
}
26422643
this.expenses &#x3D; this.expenses.filter(ex &#x3D;&gt; {

documentation/injectables/ConfigService.html

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ <h3 id="methods">
249249

250250
<tr>
251251
<td class="col-md-4">
252-
<div class="io-line">Defined in <a href="" data-line="40"
253-
class="link-to-prism">src/app/service/util/config/config.service.ts:40</a></div>
252+
<div class="io-line">Defined in <a href="" data-line="42"
253+
class="link-to-prism">src/app/service/util/config/config.service.ts:42</a></div>
254254
</td>
255255
</tr>
256256

@@ -261,7 +261,10 @@ <h3 id="methods">
261261
<ul>
262262
<li><code>&quot;local&quot;</code><code>http://localhost:8000</code></li>
263263
<li><code>&quot;live&quot;</code><code>https://exwiseapi.onrender.com</code></li>
264-
<li>Any other value defaults to <code>&quot;local&quot;</code></li>
264+
<li>Any other value → Determines based on current window location.</li>
265+
<li>If the URL contains <code>&quot;localhost&quot;</code>, returns <code>http://localhost:8000</code>.</li>
266+
<li>If the URL contains <code>&quot;exwiseapi&quot;</code>, returns <code>https://exwiseapi.onrender.com</code>.</li>
267+
<li>Defaults to <code>http://localhost:8000</code> if none of the above conditions are met.</li>
265268
</ul>
266269
</div>
267270

@@ -297,8 +300,8 @@ <h3 id="methods">
297300

298301
<tr>
299302
<td class="col-md-4">
300-
<div class="io-line">Defined in <a href="" data-line="57"
301-
class="link-to-prism">src/app/service/util/config/config.service.ts:57</a></div>
303+
<div class="io-line">Defined in <a href="" data-line="65"
304+
class="link-to-prism">src/app/service/util/config/config.service.ts:65</a></div>
302305
</td>
303306
</tr>
304307

@@ -450,8 +453,10 @@ <h3 id="inputs">
450453
*
451454
* - &#x60;&quot;local&quot;&#x60; → &#x60;http://localhost:8000&#x60;
452455
* - &#x60;&quot;live&quot;&#x60; → &#x60;https://exwiseapi.onrender.com&#x60;
453-
* - Any other value defaults to &#x60;&quot;local&quot;&#x60;
454-
*
456+
* - Any other value → Determines based on current window location.
457+
* - If the URL contains &#x60;&quot;localhost&quot;&#x60;, returns &#x60;http://localhost:8000&#x60;.
458+
* - If the URL contains &#x60;&quot;exwiseapi&quot;&#x60;, returns &#x60;https://exwiseapi.onrender.com&#x60;.
459+
* - Defaults to &#x60;http://localhost:8000&#x60; if none of the above conditions are met.
455460
* @returns {string} The API base URL for the current environment.
456461
*/
457462
getapiUrl(): string {
@@ -462,6 +467,12 @@ <h3 id="inputs">
462467
return &quot;https://exwiseapi.onrender.com&quot;;
463468
}
464469
else {
470+
if (window.location.href.includes(&quot;localhost&quot;)) {
471+
return &quot;http://localhost:8000&quot;;
472+
}
473+
else if (window.location.href.includes(&quot;exwiseapi&quot;)) {
474+
return &quot;https://exwiseapi.onrender.com&quot;;
475+
}
465476
return &quot;http://localhost:8000&quot;;
466477
}
467478
}

documentation/js/search/search_index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/miscellaneous/variables.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,11 @@ <h3></h3> <table class="table table-sm table-bordered">
644644

645645
/**
646646
* Current environment type.
647-
* Possible values: &#x27;local&#x27;, &#x27;live&#x27;
647+
* - &#x27;local&#x27; for local development (uses localhost API endpoint)
648+
* - &#x27;live&#x27; for production (uses production API endpoint)
649+
* - leave empty for automatic detection based on current window location
648650
*/
649-
developmentEnvironment: &#x27;live&#x27;, // Change to &#x27;live&#x27; for production or &#x27;local&#x27; for local development
651+
developmentEnvironment: &#x27;&#x27;, // Change to &#x27;live&#x27; for production or &#x27;local&#x27; for local development
650652

651653
/**
652654
* Application version.

src/app/features/list-expenses/list-expenses.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ export class ListExpensesComponent implements OnInit {
295295
this.expenseService.update(expense_id, newData);
296296
this.toastService.show('Expense updated successfully', 'success');
297297
this.isEditOpen = false;
298-
this.searchData(this.searchQuery);
298+
this.expenses = this.expenses.map(item => item.expense_id === expense_id ? { ...item, ...newData } : item);
299+
this.expenses = this.expenses.map(item => ({ ...item, amount: Math.round(item.amount * 100) / 100 }));
299300
}
300301

301302
/**
@@ -307,7 +308,7 @@ export class ListExpensesComponent implements OnInit {
307308
this.expenseService.delete(id);
308309
this.toastService.show("Expense deleted successfully", 'success');
309310
this.closeModal();
310-
this.searchData(this.searchQuery);
311+
this.expenses = this.expenses.filter(item => item.expense_id !== id);
311312
}
312313
}
313314

@@ -317,7 +318,7 @@ export class ListExpensesComponent implements OnInit {
317318
*/
318319
searchData(query: string): void {
319320
this.expenses = this.expenseService.getAll();
320-
if(query.length === 0) {
321+
if (query.length === 0) {
321322
return;
322323
}
323324
this.expenses = this.expenses.filter(ex => {

src/app/service/util/config/config.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ export class ConfigService {
3333
*
3434
* - `"local"` → `http://localhost:8000`
3535
* - `"live"` → `https://exwiseapi.onrender.com`
36-
* - Any other value defaults to `"local"`
37-
*
36+
* - Any other value → Determines based on current window location.
37+
* - If the URL contains `"localhost"`, returns `http://localhost:8000`.
38+
* - If the URL contains `"exwiseapi"`, returns `https://exwiseapi.onrender.com`.
39+
* - Defaults to `http://localhost:8000` if none of the above conditions are met.
3840
* @returns {string} The API base URL for the current environment.
3941
*/
4042
getapiUrl(): string {
@@ -45,6 +47,12 @@ export class ConfigService {
4547
return "https://exwiseapi.onrender.com";
4648
}
4749
else {
50+
if (window.location.href.includes("localhost")) {
51+
return "http://localhost:8000";
52+
}
53+
else if (window.location.href.includes("exwiseapi")) {
54+
return "https://exwiseapi.onrender.com";
55+
}
4856
return "http://localhost:8000";
4957
}
5058
}

src/environments/environments.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ export const environment = {
2020

2121
/**
2222
* Current environment type.
23-
* Possible values: 'local', 'live'
23+
* - 'local' for local development (uses localhost API endpoint)
24+
* - 'live' for production (uses production API endpoint)
25+
* - leave empty for automatic detection based on current window location
2426
*/
25-
developmentEnvironment: 'live', // Change to 'live' for production or 'local' for local development
27+
developmentEnvironment: '', // Change to 'live' for production or 'local' for local development
2628

2729
/**
2830
* Application version.

0 commit comments

Comments
 (0)