Skip to content

Commit

Permalink
refactor: edit and destroy controllers to octane style (#556)
Browse files Browse the repository at this point in the history
Co-authored-by: Guido de Jong <[email protected]>
Co-authored-by: guidojw <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 29, 2022
1 parent 3296286 commit c40be53
Show file tree
Hide file tree
Showing 137 changed files with 1,136 additions and 863 deletions.
8 changes: 4 additions & 4 deletions app/components/forms/activity-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@
@errors={{@combinedErrors}}
@errorMessage={{@errorMessage}}
>
<LinkTo
@route='activities.show'
@model={{@model.id}}
<button
{{action @onCancel}}
type="button"
class='btn btn-default'
>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/article-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
<LinkTo @route='index' class='btn btn-default'>Annuleren</LinkTo>
<button {{action @onCancel}} type="button" class='btn btn-default'>Annuleren</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
20 changes: 7 additions & 13 deletions app/components/forms/book-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,13 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
{{#if @model.isNew}}
<LinkTo @route='books.index' class='btn btn-default'>
Annuleren
</LinkTo>
{{else}}
<LinkTo
@route='books.show'
@model={{@model.id}}
class='btn btn-default'
>
Annuleren
</LinkTo>
{{/if}}
<button
{{action @onCancel}}
type="button"
class='btn btn-default'
>
Annuleren
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
12 changes: 3 additions & 9 deletions app/components/forms/category-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
{{#if @model.isNew}}
<LinkTo @route='forum.categories' class='btn btn-default'>
Annuleren
</LinkTo>
{{else}}
<LinkTo @route='forum.categories.category' class='btn btn-default'>
Annuleren
</LinkTo>
{{/if}}
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/group-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
<LinkTo @route='groups.index' class='btn btn-default'>Annuleren</LinkTo>
<button {{action @onCancel}} type="button" class='btn btn-default'>Annuleren</button>
</ModelForm::FormActions>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/mail-alias-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
<LinkTo @route='mail-aliases.index' class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/mandate-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
</div>

<ModelForm::FormActions @model={{@model}} @errorMessage={{@errorMessage}}>
<LinkTo @route='debit.mandates.index' class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/photo-album-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
<LinkTo @route='photo-albums.index' class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/components/forms/poll-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
@errors={{@combinedErrors}}
@errorMessage={{@errorMessage}}
>
<LinkTo
@route='polls.show'
@model={{@model.id}}
<button
{{action @onCancel}}
type="button"
class='btn btn-default'
>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/components/forms/post-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
<LinkTo
@route='forum.categories.category.threads.thread.show'
@model={{@model.thread}}
<button
{{action @onCancel}}
type="button"
class='btn btn-default'
>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/static-page-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
</div>

<ModelForm::FormActions @model={{@model}} @errorMessage={{@errorMessage}}>
<LinkTo @route='static-pages.index' class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
33 changes: 12 additions & 21 deletions app/components/forms/thread-form.hbs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<div class='card'>
<div class='card-header'>
<h5>{{if @model.thread.isNew 'Topic aanmaken' 'Topic wijzigen'}}</h5>
<h5>{{if @model.isNew 'Topic aanmaken' 'Topic wijzigen'}}</h5>
</div>
<div class='card-body'>
<form {{action @onSubmit on='submit'}}>
<ModelForm::TextInput
@model={{@model.thread}}
@model={{@model}}
@property='title'
@label='Titel'
@required={{true}}
/>

{{#if @model.post}}
{{#if @model.isNew }}
<label for='forumpost-message'>Bericht *</label>
<MdEditor
@content={{@model.post.message}}
@content={{@model.firstPost.message}}
@textareaId='forumpost-message'
/>
{{else}}
{{#if (can 'edit forum/threads')}}
<ModelForm::CheckboxInput
@model={{@model.thread}}
@model={{@model}}
@property='isOpen'
@label='Open voor reacties'
/>
Expand All @@ -31,22 +31,13 @@
@errors={{@model.errors}}
@errorMessage={{@errorMessage}}
>
{{#if @model.thread.isNew}}
<LinkTo
@route='forum.categories.category.threads'
class='btn btn-default'
>
Annuleren
</LinkTo>
{{else}}
<LinkTo
@route='forum.categories.category.threads.thread'
@model={{@model.thread}}
class='btn btn-default'
>
Annuleren
</LinkTo>
{{/if}}
<button
{{action @onCancel}}
type="button"
class='btn btn-default'
>
Annuleren
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/transaction-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
</div>

<ModelForm::FormActions @model={{@model}} @errorMessage={{@errorMessage}}>
<LinkTo @route='debit.collections' class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/user-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
@errorMessage={{@errorMessage}}
@inputLayout='vertical'
>
<LinkTo @route='users.show' @model={{@model.id}} class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
</form>
18 changes: 8 additions & 10 deletions app/components/forum/forum-post-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ import { inject as service } from '@ember/service';
import Component from '@ember/component';
import { action } from '@ember/object';

// todo: incorporate the model-save-util into components?
export default class ForumPostNewComponent extends Component {
@service store;
@service('flash-notice') flashNotice;
@service flashNotice;

@action
save() {
async save() {
let { content, thread } = this;

this.store
await this.store
.createRecord('forum/post', {
message: content,
thread,
})
.save()
.then(() => {
this.flashNotice.sendSuccess('Forumbericht toegevoegd!');
this.set('content', '');
this.onSubmit();
});
.save();
this.flashNotice.sendSuccess('Forumbericht toegevoegd!');
this.set('content', '');
this.onSubmit();
}

@action
Expand Down
6 changes: 3 additions & 3 deletions app/components/users/privacy-settings.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h5>Privacyinstellingen</h5>
<form class='form' {{action 'submit' on='submit'}}>
<form class='form' {{action @onSubmit on='submit'}}>
{{#if isOwnUser}}
<div class='form-group row'>
<label class='col-sm-6 col-form-label form-control-label'>
Expand Down Expand Up @@ -105,9 +105,9 @@
@errorMessage={{this.errorMessage}}
@inputLayout='vertical'
>
<LinkTo @route='users.show' @model={{model.id}} class='btn btn-default'>
<button {{action @onCancel}} type="button" class='btn btn-default'>
Annuleren
</LinkTo>
</button>
</ModelForm::FormActions>
{{/if}}
</form>
11 changes: 4 additions & 7 deletions app/components/users/privacy-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
} from 'amber-ui/constants';
import Component from '@glimmer/component';
import ModelSaveUtil from 'amber-ui/utils/model-save';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { isPresent } from '@ember/utils';
import { tracked } from '@glimmer/tracking';
Expand All @@ -17,7 +16,10 @@ export default class PrivacySettingsComponent extends Component {

successMessage = 'Privacyinstellingen gewijzigd!';
successTransitionTarget = null;
successTransitionModel = null;
get successTransitionModel() {
return null;
}

formActionsVisible = true;

constructor() {
Expand Down Expand Up @@ -48,9 +50,4 @@ export default class PrivacySettingsComponent extends Component {
this.args.model.allowTomatoSharing
);
}

@action
submit() {
this.modelSaveUtil.saveModel(this.args.model);
}
}
7 changes: 4 additions & 3 deletions app/controllers/activities/destroy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DestroyController from 'amber-ui/controllers/application/destroy';

export default DestroyController.extend({
successTransitionTarget: 'activities.index',
});
export default class ActivityDestroyController extends DestroyController {
successTransitionTarget = 'activities.index';
cancelTransitionTarget = 'activities.show';
}
Loading

0 comments on commit c40be53

Please sign in to comment.