-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ admin: Improve algo config page organisation
- Loading branch information
1 parent
089a2b9
commit c42c72e
Showing
5 changed files
with
171 additions
and
165 deletions.
There are no files selected for viewing
158 changes: 0 additions & 158 deletions
158
admin/app/components/administration/certification/flash-algorithm-configuration.gjs
This file was deleted.
Oops, something went wrong.
97 changes: 97 additions & 0 deletions
97
admin/app/components/administration/certification/flash-algorithm-configuration/form.gjs
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,97 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixCheckbox from '@1024pix/pix-ui/components/pix-checkbox'; | ||
import PixInput from '@1024pix/pix-ui/components/pix-input'; | ||
import { on } from '@ember/modifier'; | ||
import { t } from 'ember-intl'; | ||
|
||
<template> | ||
<form class="flash-algorithm-configuration-form"> | ||
<PixInput | ||
{{on "input" @updateNumberValues}} | ||
@id="maximumAssessmentLength" | ||
@value={{@form.maximumAssessmentLength}} | ||
type="number" | ||
min="0" | ||
> | ||
<:label>{{t | ||
"pages.administration.certification.flash-algorithm-configuration.form.maximumAssessmentLength" | ||
}}</:label> | ||
</PixInput> | ||
|
||
<PixInput {{on "input" @updateNumberValues}} @id="warmUpLength" @value={{@form.warmUpLength}} type="number" min="0"> | ||
<:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.warmUpLength"}}</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
{{on "input" @updateNumberValues}} | ||
@id="challengesBetweenSameCompetence" | ||
@value={{@form.challengesBetweenSameCompetence}} | ||
type="number" | ||
min="0" | ||
> | ||
<:label>{{t | ||
"pages.administration.certification.flash-algorithm-configuration.form.challengesBetweenSameCompetence" | ||
}}</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
{{on "input" @updateNumberValues}} | ||
@id="variationPercent" | ||
@value={{@form.variationPercent}} | ||
type="number" | ||
min="0" | ||
> | ||
<:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.variationPercent"}}</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
{{on "input" @updateNumberValues}} | ||
@id="variationPercentUntil" | ||
@value={{@form.variationPercentUntil}} | ||
type="number" | ||
min="0" | ||
> | ||
<:label>{{t | ||
"pages.administration.certification.flash-algorithm-configuration.form.variationPercentUntil" | ||
}}</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
{{on "input" @updateNumberValues}} | ||
@id="doubleMeasuresUntil" | ||
@value={{@form.doubleMeasuresUntil}} | ||
type="number" | ||
min="0" | ||
> | ||
<:label>{{t "pages.administration.certification.flash-algorithm-configuration.form.doubleMeasuresUntil"}}</:label> | ||
</PixInput> | ||
|
||
<PixCheckbox | ||
{{on "input" @updateCheckboxValues}} | ||
@id="limitToOneQuestionPerTube" | ||
@value={{@form.limitToOneQuestionPerTube}} | ||
checked={{@form.limitToOneQuestionPerTube}} | ||
> | ||
<:label>{{t | ||
"pages.administration.certification.flash-algorithm-configuration.form.limitToOneQuestionPerTube" | ||
}}</:label> | ||
</PixCheckbox> | ||
|
||
<PixCheckbox | ||
{{on "input" @updateCheckboxValues}} | ||
@id="enablePassageByAllCompetences" | ||
@value={{@form.enablePassageByAllCompetences}} | ||
checked={{@form.enablePassageByAllCompetences}} | ||
> | ||
<:label>{{t | ||
"pages.administration.certification.flash-algorithm-configuration.form.enablePassageByAllCompetences" | ||
}}</:label> | ||
</PixCheckbox> | ||
|
||
<PixButton | ||
class="scoring-simulator__form-button" | ||
@type="submit" | ||
@triggerAction={{@onCreateFlashAlgorithmConfiguration}} | ||
>{{t "common.actions.save"}}</PixButton> | ||
</form> | ||
</template> |
62 changes: 62 additions & 0 deletions
62
admin/app/components/administration/certification/flash-algorithm-configuration/index.gjs
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,62 @@ | ||
import PixBlock from '@1024pix/pix-ui/components/pix-block'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { t } from 'ember-intl'; | ||
|
||
import Form from './form'; | ||
|
||
export default class FlashAlgorithmConfiguration extends Component { | ||
@service store; | ||
@service notifications; | ||
@tracked form = { | ||
maximumAssessmentLength: this.args.model.maximumAssessmentLength, | ||
warmUpLength: this.args.model.warmUpLength, | ||
challengesBetweenSameCompetence: this.args.model.challengesBetweenSameCompetence, | ||
variationPercent: this.args.model.variationPercent, | ||
variationPercentUntil: this.args.model.variationPercentUntil, | ||
doubleMeasuresUntil: this.args.model.doubleMeasuresUntil, | ||
limitToOneQuestionPerTube: this.args.model.limitToOneQuestionPerTube, | ||
enablePassageByAllCompetences: this.args.model.enablePassageByAllCompetences, | ||
}; | ||
|
||
@action | ||
async onCreateFlashAlgorithmConfiguration(event) { | ||
event.preventDefault(); | ||
const adapter = this.store.adapterFor('flash-algorithm-configuration'); | ||
try { | ||
await adapter.createRecord(this.form); | ||
this.notifications.success('La configuration a été créée'); | ||
} catch (errorResponse) { | ||
this.notifications.error("La configuration n'a pu être créée"); | ||
} | ||
} | ||
|
||
@action | ||
updateNumberValues(event) { | ||
this.form = { ...this.form, [event.target.id]: event.target.value }; | ||
} | ||
|
||
@action | ||
updateCheckboxValues(event) { | ||
this.form = { ...this.form, [event.target.id]: event.target.checked }; | ||
} | ||
|
||
<template> | ||
<PixBlock class="page-section"> | ||
|
||
<h2 class="page-section__title"> | ||
{{t "pages.administration.certification.flash-algorithm-configuration.title"}} | ||
</h2> | ||
|
||
<Form | ||
@form={{this.form}} | ||
@updateNumberValues={{this.updateNumberValues}} | ||
@updateCheckboxValues={{this.updateCheckboxValues}} | ||
@onCreateFlashAlgorithmConfiguration={{this.onCreateFlashAlgorithmConfiguration}} | ||
/> | ||
|
||
</PixBlock> | ||
</template> | ||
} |
11 changes: 11 additions & 0 deletions
11
admin/app/components/administration/certification/index.gjs