fix(reference-viewer): add markForCheck, improve Chancee quantity visibility per group#3669
Conversation
…ibility per group
| expect(component['referenceLootRows']![0].Chance).toBe('45.00' as unknown as number); // 90 / 2 | ||
| expect(component['referenceLootRows']![1].Chance).toBe('50.00' as unknown as number); // 100 / 2 | ||
| // Group 2 | ||
| expect(component['referenceLootRows']![2].Chance).toBe('25.00' as unknown as number); // 75 / 3 |
There was a problem hiding this comment.
Instead of using the divded value, use the value
so instead of
expect(component['referenceLootRows']![0].Chance).toBe('45.00' as unknown as number); // 90 / 2
use
expect(component['referenceLootRows']![0].Chance).toBe(90); and same for others [1, 2, 3, 4]
|
|
||
| const component = host.child(); | ||
| expect(component['referenceLootRows']![0].Chance).toBe(100); // GroupId 0, unchanged | ||
| expect(component['referenceLootRows']![1].Chance).toBe('40.00' as unknown as number); // 80 / 2 |
There was a problem hiding this comment.
Here also
expect(component['referenceLootRows']![1].Chance).toBe(80);
| fixture.detectChanges(); | ||
|
|
||
| const component = host.child(); | ||
| // 100 / 3 = 33.33 |
There was a problem hiding this comment.
While here for the nitpick since we are fixing this after 33.33 "(only whenchance is 0)"
| this.referenceLootRows = result.map((row) => { | ||
| let Chance = row.Chance; | ||
|
|
||
| if (row.GroupId !== 0) { |
There was a problem hiding this comment.
row.GroupId !== 0 && row.Chance === 0
if the chance is 0 it fallsbacks to 100 divided by groupcount
|
|
||
| if (row.GroupId !== 0) { | ||
| const groupCount = result.filter((r) => r.GroupId === row.GroupId).length; | ||
| Chance = (row.Chance === 0 ? 100 / groupCount : row.Chance / groupCount).toFixed(2) as unknown as number; |
There was a problem hiding this comment.
Chance = (100 / groupCount).toFixed(2) as unknown as number;
closes #3618