Skip to content

Commit

Permalink
feat(form-builder): highlight the slug of the question that is curren…
Browse files Browse the repository at this point in the history
…tly being edited in bold (#2700)
  • Loading branch information
StephanH90 authored Apr 23, 2024
1 parent 3694054 commit 81d14db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
<a
data-test-edit-question
href="#"
class="uk-width-auto uk-margin-small-right uk-text-bold"
class={{if
this.isActive
"uk-width-auto uk-margin-small-right uk-text-bold"
"uk-width-auto uk-margin-small-right"
}}
{{on "click" (fn this.editQuestion @question)}}
>
{{@question.slug}}
Expand All @@ -51,7 +55,11 @@
</a>
{{else}}
<span
class="uk-width-auto uk-margin-small-right uk-text-bold"
class={{if
this.isActive
"uk-width-auto uk-margin-small-right uk-text-bold"
"uk-width-auto uk-margin-small-right"
}}
>{{@question.slug}}</span>
{{/if}}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { action } from "@ember/object";
import { guidFor } from "@ember/object/internals";
import { service } from "@ember/service";
import Component from "@glimmer/component";
import jexl from "jexl";

import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";

export default class CfbFormEditorQuestionListItem extends Component {
@service router;

get elementId() {
return guidFor(this);
}
Expand Down Expand Up @@ -48,6 +51,14 @@ export default class CfbFormEditorQuestionListItem extends Component {
);
}

get isActive() {
// we can't access this.router.applicationRouter.currentRoute.queryParams
// because it is non-reactive
return this.router.currentURL?.endsWith(
`/questions/${this.args.question.slug}`,
);
}

@action
editQuestion(question, e) {
e.preventDefault();
Expand Down

0 comments on commit 81d14db

Please sign in to comment.