-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor create/meta controller to component (#814)
- Loading branch information
Showing
5 changed files
with
93 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<div class="cr-form-wrapper box"> | ||
<BsForm | ||
@formLayout="horizontal" | ||
@model={{@formData}} | ||
@onInvalid={{(scroll-first-invalid-element-into-view-port)}} | ||
@onSubmit={{this.submit}} | ||
novalidate | ||
as |form| | ||
> | ||
<form.element | ||
@controlType="text" | ||
@label={{t "create.meta.input.title.label"}} | ||
@property="title" | ||
class="title" | ||
data-test-form-element="title" | ||
as |el| | ||
> | ||
<el.control | ||
placeholder={{t "create.meta.input.title.placeholder"}} | ||
{{autofocus}} | ||
/> | ||
</form.element> | ||
<form.element | ||
@controlType="textarea" | ||
@label={{t "create.meta.input.description.label"}} | ||
@property="description" | ||
class="description" | ||
data-test-form-element="description" | ||
as |el| | ||
> | ||
<el.control | ||
placeholder={{t "create.meta.input.description.placeholder"}} | ||
/> | ||
</form.element> | ||
|
||
<div class="row cr-steps-bottom-nav"> | ||
<div class="col-6 col-md-8 order-12"> | ||
<NextButton /> | ||
</div> | ||
<div class="col-6 col-md-4 order-1 text-right"> | ||
<BackButton @onClick={{this.previousPage}} /> | ||
</div> | ||
</div> | ||
</BsForm> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
import { registerDestructor } from '@ember/destroyable'; | ||
import type RouterService from '@ember/routing/router-service'; | ||
import type { CreateMetaRouteModel } from '../routes/create/meta'; | ||
|
||
export interface CreateMetaSignature { | ||
Args: { | ||
formData: CreateMetaRouteModel['formData']; | ||
poll: CreateMetaRouteModel['poll']; | ||
}; | ||
} | ||
|
||
export default class CreateMetaComponent extends Component<CreateMetaSignature> { | ||
@service declare router: RouterService; | ||
|
||
@action | ||
previousPage() { | ||
this.router.transitionTo('create.index'); | ||
} | ||
|
||
@action | ||
submit() { | ||
this.router.transitionTo('create.options'); | ||
} | ||
|
||
constructor(owner: unknown, args: CreateMetaSignature['Args']) { | ||
super(owner, args); | ||
|
||
registerDestructor(this, () => { | ||
const { poll, formData } = this.args; | ||
|
||
poll.title = formData.title; | ||
poll.description = formData.description; | ||
}); | ||
} | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
CreateMeta: typeof CreateMetaComponent; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1 @@ | ||
<div class="cr-form-wrapper box"> | ||
<BsForm | ||
@formLayout="horizontal" | ||
@model={{@model.formData}} | ||
@onInvalid={{(scroll-first-invalid-element-into-view-port)}} | ||
@onSubmit={{this.submit}} | ||
novalidate | ||
as |form| | ||
> | ||
<form.element | ||
@controlType="text" | ||
@label={{t "create.meta.input.title.label"}} | ||
@property="title" | ||
class="title" | ||
data-test-form-element="title" | ||
as |el| | ||
> | ||
<el.control | ||
placeholder={{t "create.meta.input.title.placeholder"}} | ||
{{autofocus}} | ||
/> | ||
</form.element> | ||
<form.element | ||
@controlType="textarea" | ||
@label={{t "create.meta.input.description.label"}} | ||
@property="description" | ||
class="description" | ||
data-test-form-element="description" | ||
as |el| | ||
> | ||
<el.control | ||
placeholder={{t "create.meta.input.description.placeholder"}} | ||
/> | ||
</form.element> | ||
|
||
<div class="row cr-steps-bottom-nav"> | ||
<div class="col-6 col-md-8 order-12"> | ||
<NextButton /> | ||
</div> | ||
<div class="col-6 col-md-4 order-1 text-right"> | ||
<BackButton @onClick={{this.previousPage}} /> | ||
</div> | ||
</div> | ||
</BsForm> | ||
</div> | ||
<CreateMeta @formData={{@model.formData}} @poll={{@model.poll}} /> |