Skip to content

Commit 3380eb1

Browse files
committed
fix(frontend/magic-link-modal): consistent flag behaviour
before this, flags such as `notBillable` or `review` would behave as such: - not in the url by default - `?<flag>=true` when toggled - `?<flag>=false` when toggled again with this fix, flags are only ever included in the url when they're enabled
1 parent 48cf979 commit 3380eb1

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

ember/frontend/app/components/magic-link-modal.gjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import FaIcon from "@fortawesome/ember-fontawesome/components/fa-icon";
66
import Component from "@glimmer/component";
77
import { tracked } from "@glimmer/tracking";
88
import pick from "@nullvoxpopuli/ember-composable-helpers/helpers/pick";
9-
import toggle from "@nullvoxpopuli/ember-composable-helpers/helpers/toggle";
109
import { not } from "ember-truth-helpers";
1110
import { ReportDurationpicker } from "ui-core/components/ui-durationpicker";
1211

@@ -27,8 +26,13 @@ export default class MagicLinkModal extends Component {
2726
@service notify;
2827

2928
@action
30-
onSetTask(task) {
31-
this.task = task;
29+
toggleFlag(flag) {
30+
// the url should not include flags that aren't set
31+
// "toggling" a flag adds `?<flag>=true` to the url
32+
// "toggling" it again should remove it from the url
33+
// rather than e.g. changing it to `?<flag>=false`
34+
const value = this[flag];
35+
this[flag] = value ? undefined : true;
3236
}
3337

3438
get magicLinkString() {
@@ -70,9 +74,8 @@ export default class MagicLinkModal extends Component {
7074
</modal.header>
7175
<modal.body class="grid gap-2" data-test-task-selector>
7276
<TaskSelection
73-
@disabled={{false}}
7477
@task={{this.task}}
75-
@on-set-task={{this.onSetTask}}
78+
@on-set-task={{fn (mut this.task)}}
7679
as |t|
7780
>
7881
<t.customer @dropdownClass="z-[60]" />
@@ -102,7 +105,7 @@ export default class MagicLinkModal extends Component {
102105
class="margin-small-right form-control flex-shrink"
103106
data-test-magic-link-review
104107
@hint="Needs review"
105-
@onToggle={{toggle "review" this}}
108+
@onToggle={{fn this.toggleFlag "review"}}
106109
@value={{this.review}}
107110
>
108111
<span class="fa-layers fa-fw">
@@ -118,7 +121,7 @@ export default class MagicLinkModal extends Component {
118121
class="form-control flex-shrink"
119122
data-test-magic-link-not-billable
120123
@hint="Not billable"
121-
@onToggle={{toggle "notBillable" this}}
124+
@onToggle={{fn this.toggleFlag "notBillable"}}
122125
@value={{this.notBillable}}
123126
>
124127
<span class="fa-layers fa-fw">

0 commit comments

Comments
 (0)