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

Refactor: {{action}} helper usage #635

Open
wants to merge 50 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2313978
todos
DrumsnChocolate May 18, 2022
77c57cf
add checks for overrides of ModelSaveUtils, using the entity property…
DrumsnChocolate May 18, 2022
1d5bcbe
Merge branch 'master' into refactor/edit_destroy_controllers
DrumsnChocolate Aug 30, 2022
b7c24ac
Merge branch 'staging' into refactor/edit_destroy_controllers
DrumsnChocolate Aug 30, 2022
bc89493
got the activity destroy controller working properly, it seems :)
DrumsnChocolate Aug 30, 2022
50bfe4f
article comments now properly redirect. Took me a while to figure out…
DrumsnChocolate Aug 30, 2022
2aca33a
this is starting to look like something. not perfect, but it works fo…
DrumsnChocolate Aug 30, 2022
c4bfc9c
this should comprise the last of controllers that extend DestroyContr…
DrumsnChocolate Aug 30, 2022
a7237d6
debit collection show is currently broken, do not understand why. get…
DrumsnChocolate Aug 30, 2022
03adffb
starting to get a grip on how ember works, I think
DrumsnChocolate Sep 1, 2022
f5c771f
more progress, now also added cancel action to editcontroller, and re…
DrumsnChocolate Sep 3, 2022
cca8442
refactoring all usages of "Annuleren" LinkTo elements into buttons th…
DrumsnChocolate Sep 3, 2022
5393cfa
jslint
DrumsnChocolate Sep 3, 2022
2dd9e23
FINALLY figured out how to do a union of ObjectProxies
DrumsnChocolate Sep 3, 2022
8c407d5
moved thread save logic to model
DrumsnChocolate Sep 3, 2022
29e8f50
more stuff
DrumsnChocolate Sep 3, 2022
7c16a8f
fix debit collection controllers
DrumsnChocolate Sep 6, 2022
581e29d
going through the controllers alphabetically, decided to add some met…
DrumsnChocolate Sep 6, 2022
9e8dd3a
idk, changes from last time I worked on this
DrumsnChocolate Sep 19, 2022
56acba6
Merge branch 'staging' into refactor/edit_destroy_controllers
DrumsnChocolate Sep 19, 2022
b825372
fix js lint
DrumsnChocolate Sep 19, 2022
7aa8b6d
fix template lint
DrumsnChocolate Sep 19, 2022
115e24f
Merge branch 'master' into refactor/edit_destroy_controllers
DrumsnChocolate Sep 29, 2022
3d7a48e
I found a way to keep the model just the model, while also querying p…
DrumsnChocolate Sep 29, 2022
ab44d80
more changes
DrumsnChocolate Sep 30, 2022
fa693ba
more changes
DrumsnChocolate Sep 30, 2022
54813ae
typo
DrumsnChocolate Sep 30, 2022
f1c0727
better handling of transitions in destroycontrollers
DrumsnChocolate Sep 30, 2022
3a16484
I think I have had all new edit and destroy controllers
DrumsnChocolate Sep 30, 2022
e9d58e2
js lint fixes
DrumsnChocolate Sep 30, 2022
2e15f06
Merge branch 'staging' into refactor/edit_destroy_controllers
DrumsnChocolate Oct 23, 2022
f00b5d0
remove comment
DrumsnChocolate Oct 23, 2022
3ebeb38
start of refactoring action helper usage
DrumsnChocolate Oct 23, 2022
7e1342b
Merge branch 'staging' into refactor/action_helper_usage
DrumsnChocolate Dec 21, 2022
27a553a
Merge branch 'staging' into refactor/action_helper_usage
DrumsnChocolate Jan 15, 2023
9983ee3
remove preventdefaults
DrumsnChocolate Jan 27, 2023
5e081eb
Merge branch 'staging' into refactor/action_helper_usage
DrumsnChocolate May 7, 2023
f28249f
Merge branch 'staging' into refactor/action_helper_usage
DrumsnChocolate Nov 3, 2024
9380381
rewrite board room presence in octane
DrumsnChocolate Nov 3, 2024
1d3650b
use @action syntax on newPresence, and move permission check to template
DrumsnChocolate Nov 3, 2024
95344b9
use on, fn
DrumsnChocolate Nov 3, 2024
2d9f7a0
modal, sidebar
DrumsnChocolate Nov 3, 2024
3bb722a
rewrite privacy-modal to octane (afaik)
DrumsnChocolate Nov 3, 2024
a3d32a1
remove unused import
DrumsnChocolate Nov 3, 2024
2ea0d64
action helper in public-activity-card-small
DrumsnChocolate Nov 3, 2024
a90eb41
write open and closed question components in octane
DrumsnChocolate Nov 3, 2024
c64f6c4
fix lint
DrumsnChocolate Nov 3, 2024
8e9cde7
Merge branch 'staging' into refactor/action_helper_usage
DrumsnChocolate Nov 4, 2024
4f53b89
fix broken submit based on #896
DrumsnChocolate Nov 5, 2024
45d3aac
fix poll form
DrumsnChocolate Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/components/basic-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class='btn-close'
data-bs-dismiss='modal'
aria-label='Close'
{{action @closeModal}}
{{on 'click' @closeModal}}
type='button'
></button>
{{/if}}
Expand All @@ -24,14 +24,14 @@
<button
type='button'
class='btn btn-secondary {{if @submitDisabled "disabled"}}'
{{action @onSubmit}}
{{on 'click' @onSubmit}}
disabled={{@submitDisabled}}
>
{{@submitText}}
</button>
{{/if}}
{{#if @closeModal}}
<button type='button' class='btn btn-default' {{action @closeModal}}>
<button type='button' class='btn btn-default' {{on 'click' @closeModal}}>
Annuleren
</button>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion app/components/cards/public-activity-card-small.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
itemscope
itemtype='https://schema.org/Event'
class='card-body p-0'
{{action action}}
{{on 'click' @action}}
>
<div class='d-flex' data-test-public-activity-card>
<div
Expand Down
51 changes: 25 additions & 26 deletions app/components/form/closed-question.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{#unless question.form.hasResponses}}
<div class='float-md-end mb-3'>
<FaIcon @icon='xmark' {{on 'click' (action 'deleteQuestion')}} />
<FaIcon @icon='xmark' {{on 'click' this.deleteQuestion}} />
</div>
{{/unless}}

Expand All @@ -13,8 +13,8 @@
aria-label='Vraag'
name='question'
placeholder='Vraag'
@value={{question.question}}
disabled={{question.form.hasResponses}}
@value={{@question.question}}
disabled={{@question.form.hasResponses}}
/>
</div>

Expand All @@ -25,11 +25,10 @@
<label class='visually-hidden form-label'>Vraagtype</label>
<Input::SelectInput
@class='form-select w-auto'
@required={{required}}
@options={{questionTypeOptions}}
@placeholder={{Vraagtype}}
@value={{question.fieldType}}
@disabled={{question.form.hasResponses}}
@options={{this.questionTypeOptions}}
@placeholder="vraagtype"
@value={{@question.fieldType}}
@disabled={{@question.form.hasResponses}}
/>
</div>

Expand All @@ -38,22 +37,22 @@
class='form-check-input'
@type='checkbox'
name='required'
@checked={{question.required}}
disabled={{question.form.hasResponses}}
id="question-{{question.position}}-required-check"
@checked={{@question.required}}
disabled={{@question.form.hasResponses}}
id="question-{{@question.position}}-required-check"
/>
<label class='form-check-label' for="question-{{question.position}}-required-check">Verplicht</label>
<label class='form-check-label' for="question-{{@question.position}}-required-check">Verplicht</label>
</div>
</div>
</div>

{{#unless question.form.hasResponses}}
{{#unless @question.form.hasResponses}}
<div class='col-md-7 col-sm-12'>
<div class='float-md-end'>
<button
type='button'
class='btn btn-default'
{{action 'moveQuestionUp'}}
{{on 'click' this.moveQuestionUp}}
>
<FaIcon @icon='arrow-up' />
Omhoog
Expand All @@ -62,7 +61,7 @@
<button
type='button'
class='btn btn-default'
{{action 'moveQuestionDown'}}
{{on 'click' this.moveQuestionDown}}
>
<FaIcon @icon='arrow-down' />
Omlaag
Expand All @@ -72,14 +71,14 @@
{{/unless}}
</div>

{{#each question.sortedOptions as |opt|}}
{{#each @question.sortedOptions as |opt|}}
{{#unless opt.isDeleted}}
<div class='d-flex mb-3'>
<span class='input-group-addon d-flex justify-content-center align-items-center me-3'>
<input id="question-{{question.position}}-option-{{opt.position}}-check" class="form-check-input" type={{question.fieldType}} disabled={{true}} />
<label for="question-{{question.position}}-option-{{opt.position}}-required-check"/>
<input id="question-{{@question.position}}-option-{{opt.position}}-check" class="form-check-input" type={{@question.fieldType}} disabled={{true}} />
<label for="question-{{@question.position}}-option-{{opt.position}}-required-check"/>
</span>

<div class='input-group'>
<Input
@type='text'
Expand All @@ -88,28 +87,28 @@
name='option'
placeholder='Optie'
@value={{opt.option}}
disabled={{question.form.hasResponses}}
disabled={{@question.form.hasResponses}}
/>

{{#unless question.form.hasResponses}}
{{#unless @question.form.hasResponses}}
<button
type='button'
class='btn btn-default'
{{action 'moveOptionUp' opt}}
{{on 'click' (fn this.moveOptionUp opt)}}
>
<FaIcon @icon='arrow-up' />
</button>
<button
type='button'
class='btn btn-default'
{{action 'moveOptionDown' opt}}
{{on 'click' (fn this.moveOptionDown opt)}}
>
<FaIcon @icon='arrow-down' />
</button>
<button
type='button'
class='btn btn-default'
{{action 'deleteOption' opt}}
{{on 'click' (fn this.deleteOption opt)}}
>
<FaIcon @icon='trash' />
</button>
Expand All @@ -119,8 +118,8 @@
{{/unless}}
{{/each}}

{{#unless question.form.hasResponses}}
<button type='button' class='btn btn-default mb-3' {{action 'addOption'}}>
{{#unless @question.form.hasResponses}}
<button type='button' class='btn btn-default mb-3' {{on 'click' this.addOption}}>
Optie toevoegen
</button>
{{/unless}}
77 changes: 39 additions & 38 deletions app/components/form/closed-question.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
import { ClosedQuestionTypes } from 'amber-ui/constants';
import { inject as service } from '@ember/service';
import OpenQuestionComponent from './open-question';
import { action } from '@ember/object';

export default OpenQuestionComponent.extend({
store: service(),
questionTypes: ClosedQuestionTypes,
init() {
this._super();
},
actions: {
addOption() {
const position =
this.question.get('sortedOptions.lastObject.position') + 1 || 0;
this.store.createRecord('form/closed-question-option', {
question: this.question,
position,
});
},
deleteOption(option) {
option.deleteRecord();
},
moveOptionUp(option) {
const index = this.question.get('sortedOptions').indexOf(option);
if (index > 0) {
const previousOption = this.question
.get('sortedOptions')
.objectAt(index - 1);
this.send('switchPositions', option, previousOption);
}
},
moveOptionDown(option) {
const index = this.question.get('sortedOptions').indexOf(option);
if (index < this.question.get('sortedOptions.length') - 1) {
const nextOption = this.question
.get('sortedOptions')
.objectAt(index + 1);
this.send('switchPositions', option, nextOption);
}
},
},
});
export default class ClosedQuestionComponent extends OpenQuestionComponent {
@service store;
questionTypes = ClosedQuestionTypes;
@action
addOption() {

Check warning on line 10 in app/components/form/closed-question.js

View check run for this annotation

Codecov / codecov/patch

app/components/form/closed-question.js#L10

Added line #L10 was not covered by tests
const position =
this.question.get('sortedOptions.lastObject.position') + 1 || 0;
this.store.createRecord('form/closed-question-option', {
question: this.question,
position,

Check warning on line 15 in app/components/form/closed-question.js

View check run for this annotation

Codecov / codecov/patch

app/components/form/closed-question.js#L14-L15

Added lines #L14 - L15 were not covered by tests
});
}

@action
deleteOption(option) {
option.deleteRecord();
}

Check warning on line 23 in app/components/form/closed-question.js

View check run for this annotation

Codecov / codecov/patch

app/components/form/closed-question.js#L23

Added line #L23 was not covered by tests
@action
moveOptionUp(option) {
const index = this.question.get('sortedOptions').indexOf(option);
if (index > 0) {
const previousOption = this.question
.get('sortedOptions')
.objectAt(index - 1);

Check warning on line 30 in app/components/form/closed-question.js

View check run for this annotation

Codecov / codecov/patch

app/components/form/closed-question.js#L28-L30

Added lines #L28 - L30 were not covered by tests
this.switchPositions(option, previousOption);
}
}

Check warning on line 33 in app/components/form/closed-question.js

View check run for this annotation

Codecov / codecov/patch

app/components/form/closed-question.js#L33

Added line #L33 was not covered by tests

@action
moveOptionDown(option) {
const index = this.question.get('sortedOptions').indexOf(option);
if (index < this.question.get('sortedOptions.length') - 1) {
const nextOption = this.question.get('sortedOptions').objectAt(index + 1);
this.switchPositions(option, nextOption);
}
}

Check warning on line 42 in app/components/form/closed-question.js

View check run for this annotation

Codecov / codecov/patch

app/components/form/closed-question.js#L39-L42

Added lines #L39 - L42 were not covered by tests
}
4 changes: 2 additions & 2 deletions app/components/form/form-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<div class='card'>
<div class='card-body create-new-question'>
{{#if question.isOpenQuestion}}
{{form/open-question question form=model}}
<Form::OpenQuestion @question={{question}} @form={{model}}/>
{{else}}
{{form/closed-question question form=model}}
<Form::ClosedQuestion @question={{question}} @form={{model}}/>
{{/if}}
</div>
</div>
Expand Down
31 changes: 15 additions & 16 deletions app/components/form/open-question.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<span class='fw-bold mb-3'>Open vraag</span>

{{#unless question.form.hasResponses}}
{{#unless @question.form.hasResponses}}
<div class='float-md-end mb-3'>
<FaIcon @icon='xmark' {{on 'click' (action 'deleteQuestion')}} />
<FaIcon @icon='xmark' {{on 'click' this.deleteQuestion}} />
</div>
{{/unless}}

Expand All @@ -13,8 +13,8 @@
aria-label='Vraag'
name='question'
placeholder='Vraag'
@value={{question.question}}
disabled={{question.form.hasResponses}}
@value={{@question.question}}
disabled={{@question.form.hasResponses}}
/>
</div>

Expand All @@ -25,11 +25,10 @@
<label class='visually-hidden form-label'>Vraagtype</label>
<Input::SelectInput
@class='form-select'
@required={{required}}
@options={{questionTypeOptions}}
@placeholder={{Vraagtype}}
@value={{question.fieldType}}
@disabled={{question.form.hasResponses}}
@options={{this.questionTypeOptions}}
@placeholder="vraagtype"
@value={{@question.fieldType}}
@disabled={{@question.form.hasResponses}}
/>
</div>

Expand All @@ -38,22 +37,22 @@
class='form-check-input'
@type='checkbox'
name='required'
@checked={{question.required}}
disabled={{question.form.hasResponses}}
id="question-{{question.position}}-required-check"
@checked={{@question.required}}
disabled={{@question.form.hasResponses}}
id="question-{{@question.position}}-required-check"
/>
<label class='form-check-label' for="question-{{question.position}}-required-check">Verplicht</label>
<label class='form-check-label' for="question-{{@question.position}}-required-check">Verplicht</label>
</div>
</div>
</div>

{{#unless question.form.hasResponses}}
{{#unless @question.form.hasResponses}}
<div class='col-md-7 col-sm-12'>
<div class='float-md-end'>
<button
type='button'
class='btn btn-default'
{{action 'moveQuestionUp'}}
{{on 'click' this.moveQuestionUp}}
>
<FaIcon @icon='arrow-up' />
Omhoog
Expand All @@ -62,7 +61,7 @@
<button
type='button'
class='btn btn-default'
{{action 'moveQuestionDown'}}
{{on 'click' this.moveQuestionDown}}
>
<FaIcon @icon='arrow-down' />
Omlaag
Expand Down
Loading
Loading