Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the template required when creating an agendapoint #247

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/components/document-creator.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"document-creator/form"
title=this.title
invalidTitle=this.invalidTitle
invalidTemplate=this.invalidTemplate
updateTitle=this.updateTitle
selectedTemplate=this.template
options=this.templateOptions
Expand Down
12 changes: 11 additions & 1 deletion app/components/document-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class DocumentCreatorComponent extends Component {
@tracked template;
@tracked templateOptions = [];
@tracked invalidTitle;
@tracked invalidTemplate;
@tracked errorSaving;

@service store;
Expand Down Expand Up @@ -45,6 +46,7 @@ export default class DocumentCreatorComponent extends Component {
@action
onSelectTemplate(template) {
this.template = template;
this.validateTemplate();
}

get isSaving() {
Expand All @@ -59,9 +61,17 @@ export default class DocumentCreatorComponent extends Component {
}
}

validateTemplate() {
if (this.template) {
this.invalidTemplate = false;
} else {
this.invalidTemplate = true;
}
}
validateForm() {
this.validateTitle();
return !this.invalidTitle;
this.validateTemplate();
return !this.invalidTemplate && !this.invalidTitle;
}

@action
Expand Down
4 changes: 2 additions & 2 deletions app/components/document-creator/form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</div>
<div>
{{#let (unique-id) as |id|}}
<AuLabel for={{id}}>
<AuLabel @error={{@invalidTemplate}} for={{id}}>
{{t "documentCreator.template"}}
</AuLabel>
<PowerSelect

class={{if @invalidTemplate "u-c-input au-c-input--error"}}
@options={{@options}}
@selected={{@selectedTemplate}}
@onChange={{@onSelectTemplate}}
Expand Down