Skip to content

Commit

Permalink
fix(frontend/statistics): race condition causing initial filters to b…
Browse files Browse the repository at this point in the history
…e blank
  • Loading branch information
c0rydoras committed Feb 26, 2025
1 parent 8ecdc69 commit 707f6b2
Showing 1 changed file with 156 additions and 154 deletions.
310 changes: 156 additions & 154 deletions frontend/app/statistics/template.hbs
Original file line number Diff line number Diff line change
@@ -1,162 +1,164 @@
<PagePermission>
<h1 class="mb-6">Statistics</h1>

<TaskSelection
@history={{false}}
@archived={{true}}
@on-set-customer={{fn this.setModelFilter "customer"}}
@on-set-project={{fn this.setModelFilter "project"}}
@on-set-task={{fn this.setModelFilter "task"}}
@initial={{hash
customer=this.selectedCustomer
project=this.selectedProject
task=this.selectedTask
}}
as |t|
>
<FilterSidebar
@appliedCount={{this.appliedFilters.length}}
@onReset={{queue t.clear this.reset}}
as |fs|
{{#unless this.prefetchData.isRunning}}
<TaskSelection
@history={{false}}
@archived={{true}}
@on-set-customer={{fn this.setModelFilter "customer"}}
@on-set-project={{fn this.setModelFilter "project"}}
@on-set-task={{fn this.setModelFilter "task"}}
@initial={{hash
customer=this.selectedCustomer
project=this.selectedProject
task=this.selectedTask
}}
as |t|
>
<fs.group @label="Task" @expanded={{true}}>
<fs.filter @label="Customer" data-test-filter-customer>
<t.customer />
</fs.filter>
<fs.filter @label="Project" data-test-filter-project>
<t.project />
</fs.filter>
<fs.filter @label="Task" data-test-filter-task>
<t.task />
</fs.filter>
</fs.group>
<fs.group @label="Responsibility">
<fs.filter @label="User" data-test-filter-user>
<UserSelection
@user={{this.selectedUser}}
@onChange={{fn this.setModelFilter "user"}}
as |u|
>
<u.user />
</UserSelection>
</fs.filter>
<fs.filter @label="Reviewer" data-test-filter-reviewer>
<UserSelection
@user={{this.selectedReviewer}}
@onChange={{fn this.setModelFilter "reviewer"}}
@queryOptions={{hash is_reviewer=1}}
as |u|
>
<u.user @placeholder="Select reviewer..." />
</UserSelection>
</fs.filter>
</fs.group>
<fs.group @label="Finances">
<fs.filter
data-test-filter-billing-type
@label="Billing type"
@type="select"
@selected={{this.billingType}}
@valuePath="id"
@labelPath="name"
@prompt="All billing types"
@options={{this.billingTypes}}
@onChange={{fn (mut this.billingType)}}
/>
<fs.filter
data-test-filter-cost-center
@label="Cost center"
@type="select"
@selected={{this.costCenter}}
@valuePath="id"
@labelPath="name"
@prompt="All cost centers"
@options={{this.costCenters}}
@onChange={{fn (mut this.costCenter)}}
/>
</fs.group>
<fs.group @label="Time range">
<fs.filter
data-test-filter-from-date
@type="date"
@label="From"
@selected={{moment this.fromDate}}
@onChange={{fn this.updateParam "fromDate"}}
/>
<fs.filter
data-test-filter-to-date
@type="date"
@label="To"
@selected={{moment this.toDate}}
@onChange={{fn this.updateParam "toDate"}}
/>
<DateButtons
class="mt-2"
@onUpdateFromDate={{fn this.updateParam "fromDate"}}
@onUpdateToDate={{fn this.updateParam "toDate"}}
/>
</fs.group>
<fs.group @label="State">
<fs.filter
data-test-filter-review
@label="Review"
@type="button"
@selected={{this.review}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Needed" value="1")
(hash label="Not needed" value="0")
}}
@onChange={{fn this.updateParam "review"}}
/>
<fs.filter
data-test-filter-not-billable
@label="Billability"
@type="button"
@selected={{this.notBillable}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Billable" value="0")
(hash label="Not billable" value="1")
}}
@onChange={{fn this.updateParam "notBillable"}}
/>
<FilterSidebar
@appliedCount={{this.appliedFilters.length}}
@onReset={{queue t.clear this.reset}}
as |fs|
>
<fs.group @label="Task" @expanded={{true}}>
<fs.filter @label="Customer" data-test-filter-customer>
<t.customer />
</fs.filter>
<fs.filter @label="Project" data-test-filter-project>
<t.project />
</fs.filter>
<fs.filter @label="Task" data-test-filter-task>
<t.task />
</fs.filter>
</fs.group>
<fs.group @label="Responsibility">
<fs.filter @label="User" data-test-filter-user>
<UserSelection
@user={{this.selectedUser}}
@onChange={{fn this.setModelFilter "user"}}
as |u|
>
<u.user />
</UserSelection>
</fs.filter>
<fs.filter @label="Reviewer" data-test-filter-reviewer>
<UserSelection
@user={{this.selectedReviewer}}
@onChange={{fn this.setModelFilter "reviewer"}}
@queryOptions={{hash is_reviewer=1}}
as |u|
>
<u.user @placeholder="Select reviewer..." />
</UserSelection>
</fs.filter>
</fs.group>
<fs.group @label="Finances">
<fs.filter
data-test-filter-billing-type
@label="Billing type"
@type="select"
@selected={{this.billingType}}
@valuePath="id"
@labelPath="name"
@prompt="All billing types"
@options={{this.billingTypes}}
@onChange={{fn (mut this.billingType)}}
/>
<fs.filter
data-test-filter-cost-center
@label="Cost center"
@type="select"
@selected={{this.costCenter}}
@valuePath="id"
@labelPath="name"
@prompt="All cost centers"
@options={{this.costCenters}}
@onChange={{fn (mut this.costCenter)}}
/>
</fs.group>
<fs.group @label="Time range">
<fs.filter
data-test-filter-from-date
@type="date"
@label="From"
@selected={{moment this.fromDate}}
@onChange={{fn this.updateParam "fromDate"}}
/>
<fs.filter
data-test-filter-to-date
@type="date"
@label="To"
@selected={{moment this.toDate}}
@onChange={{fn this.updateParam "toDate"}}
/>
<DateButtons
class="mt-2"
@onUpdateFromDate={{fn this.updateParam "fromDate"}}
@onUpdateToDate={{fn this.updateParam "toDate"}}
/>
</fs.group>
<fs.group @label="State">
<fs.filter
data-test-filter-review
@label="Review"
@type="button"
@selected={{this.review}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Needed" value="1")
(hash label="Not needed" value="0")
}}
@onChange={{fn this.updateParam "review"}}
/>
<fs.filter
data-test-filter-not-billable
@label="Billability"
@type="button"
@selected={{this.notBillable}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Billable" value="0")
(hash label="Not billable" value="1")
}}
@onChange={{fn this.updateParam "notBillable"}}
/>

<fs.filter
data-test-filter-verified
@type="button"
@label="Verified"
@selected={{this.verified}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Verified" value="1")
(hash label="Not verified" value="0")
}}
@onChange={{fn this.updateParam "verified"}}
/>
<fs.filter
data-test-filter-billed
@label="Billed"
@type="button"
@selected={{this.billed}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Billed" value="1")
(hash label="Not Billed" value="0")
}}
@onChange={{fn this.updateParam "billed"}}
/>
</fs.group>
</FilterSidebar>
</TaskSelection>
<fs.filter
data-test-filter-verified
@type="button"
@label="Verified"
@selected={{this.verified}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Verified" value="1")
(hash label="Not verified" value="0")
}}
@onChange={{fn this.updateParam "verified"}}
/>
<fs.filter
data-test-filter-billed
@label="Billed"
@type="button"
@selected={{this.billed}}
@valuePath="value"
@labelPath="label"
@options={{array
(hash label="All" value="")
(hash label="Billed" value="1")
(hash label="Not Billed" value="0")
}}
@onChange={{fn this.updateParam "billed"}}
/>
</fs.group>
</FilterSidebar>
</TaskSelection>
{{/unless}}

<nav class="max-sm:border-y max-sm:shadow-sm">
<NavTabs class="hidden sm:flex">
Expand Down

0 comments on commit 707f6b2

Please sign in to comment.