-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
135 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="form-group"> | ||
<label>{{this.args.element.label}}</label> | ||
{{#each this.args.element.options as |option|}} | ||
<div class="radio-option"> | ||
<input | ||
type="radio" | ||
id={{option.value}} | ||
name={{this.args.element.id}} | ||
value={{option.value}} | ||
{{on "change" this.updateSelection}} | ||
checked={{eq this.args.element.value option.value}} | ||
> | ||
<label for={{option.value}}>{{option.label}}</label> | ||
</div> | ||
{{/each}} | ||
</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,15 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class RadioButtonComponent extends Component { | ||
@action | ||
updateSelection(event) { | ||
// Проверим, что event и event.target существуют | ||
if (event && event.target) { | ||
const selectedValue = event.target.value; // Получаем значение из event | ||
this.args.updateValue(selectedValue); // Передаём выбранное значение | ||
} else { | ||
console.error('Event or event.target is undefined'); | ||
} | ||
} | ||
} |
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,5 +1,5 @@ | ||
<div class="step-bar"> | ||
<div class="step" style="width: {{this.progress}}%;"> | ||
{{this.currentStep}} of {{this.totalSteps}} Steps | ||
Step {{this.args.currentStep}} of {{this.args.totalSteps}} | ||
</div> | ||
</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 |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class StepBarComponent extends Component { | ||
@tracked currentStep = 1; | ||
@tracked totalSteps = 5; | ||
|
||
get progress() { | ||
return (this.currentStep / this.totalSteps) * 100; | ||
return (this.args.currentStep / this.args.totalSteps) * 100; | ||
} | ||
} |
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
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,26 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'survey-builder/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | radio-button', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`<RadioButton />`); | ||
|
||
assert.dom().hasText(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
<RadioButton> | ||
template block text | ||
</RadioButton> | ||
`); | ||
|
||
assert.dom().hasText('template block text'); | ||
}); | ||
}); |