- {{#each @model.posts as |post|}}
+ {{#each @model.postsPaged as |post|}}
{{#unless post.isDeleted}}
{{forum/forum-post
post
@@ -19,10 +19,10 @@
{{#if currentPageIsLastPage}}
- {{#unless @model.thread.isOpen}}
+ {{#unless @model.isOpen}}
Dit topic is gesloten!
- {{#if (can 'create post for forum/thread' @model.thread)}}
+ {{#if (can 'create post for forum/thread' @model)}}
Jij kunt echter nog wel reageren omdat je moderatierechten hebt.
{{else}}
Je kunt niet meer reageren.
@@ -30,14 +30,14 @@
{{/unless}}
- {{#if (can 'create post for forum/thread' @model.thread)}}
+ {{#if (can 'create post for forum/thread' @model)}}
Reageren
@@ -47,5 +47,5 @@
{{/if}}
-
+
\ No newline at end of file
diff --git a/app/utils/model-save.js b/app/utils/model-save.js
index 1330c1b14..96ba2590a 100644
--- a/app/utils/model-save.js
+++ b/app/utils/model-save.js
@@ -26,8 +26,9 @@ export default class ModelSaveUtil {
}
}
- redirectSuccess(model) {
- const targetModel = this.entity?.successTransitionModel ?? model;
+ redirectSuccess() {
+ const targetModel = this.entity?.successTransitionModel;
+ console.log(targetModel)
if (!isNone(this.entity?.successTransitionTarget)) {
this.transition(this.entity.successTransitionTarget, targetModel?.id);
}
@@ -35,19 +36,20 @@ export default class ModelSaveUtil {
redirectCancel() {
const targetModel = this.entity?.cancelTransitionModel;
+ console.log(targetModel)
if (!isNone(this.entity?.cancelTransitionTarget)) {
this.transition(this.entity.cancelTransitionTarget, targetModel?.id);
}
}
- onSuccess(model) {
+ onSuccess() {
// Show notice
this.sendSuccess();
if (this.entity?.onSuccess) {
- this.entity.onSuccess(model);
+ this.entity.onSuccess();
} else {
// Redirect
- this.redirectSuccess(model);
+ this.redirectSuccess();
}
}
From ab44d8040821cd2172420f89c09fa47235225388 Mon Sep 17 00:00:00 2001
From: matteo
Date: Fri, 30 Sep 2022 15:47:00 +0200
Subject: [PATCH 21/40] more changes
---
app/controllers/application/destroy.js | 5 ++-
.../category/threads/thread/posts/edit.js | 3 +-
.../category/threads/thread/posts/index.js | 25 +++++++-------
app/controllers/forum/categories/new.js | 2 +-
app/controllers/groups/edit.js | 5 +--
app/controllers/mail-aliases/destroy.js | 1 +
app/controllers/mail-aliases/edit.js | 34 ++++++++-----------
app/utils/model-save.js | 12 ++++---
8 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/app/controllers/application/destroy.js b/app/controllers/application/destroy.js
index f0ff994a6..85d6d543b 100644
--- a/app/controllers/application/destroy.js
+++ b/app/controllers/application/destroy.js
@@ -15,9 +15,8 @@ export default class DestroyController extends EditController {
}
onError(error) {
- // todo: somehow incorporate the error into the message maybe? could be useful if users can show us the error message
- this.errorMessage = 'Er ging iets fout bij het verwijderen.';
- this.errorMessage += error;
+ // todo: somehow incorporate the error into the message in a more robust manner?
+ this.errorMessage = `Er ging iets fout bij het verwijderen: ${error}`;
}
transition() {
diff --git a/app/controllers/forum/categories/category/threads/thread/posts/edit.js b/app/controllers/forum/categories/category/threads/thread/posts/edit.js
index 7fe03cfbc..ff97f6fe8 100644
--- a/app/controllers/forum/categories/category/threads/thread/posts/edit.js
+++ b/app/controllers/forum/categories/category/threads/thread/posts/edit.js
@@ -3,7 +3,6 @@ import EditController from 'amber-ui/controllers/application/edit';
export default class EditPostController extends EditController {
successMessage = 'Forumbericht aangepast!';
successTransitionTarget = 'forum.categories.category.threads.thread';
-
- successTransitionModel = null;
+ successTransitionModel = this.model?.thread;
}
diff --git a/app/controllers/forum/categories/category/threads/thread/posts/index.js b/app/controllers/forum/categories/category/threads/thread/posts/index.js
index 30fd8416f..94b96c444 100644
--- a/app/controllers/forum/categories/category/threads/thread/posts/index.js
+++ b/app/controllers/forum/categories/category/threads/thread/posts/index.js
@@ -37,31 +37,30 @@ export default class PostsIndexController extends Controller {
this.postsPaged = await this.store.queryPaged('forum/post', params);
}
+ scrollToNewForumPost() {
+ document
+ .getElementById('newForumPostCard')
+ .scrollIntoView({behavior: 'smooth', block: 'center'});
+ }
+
@action
async newPostCreated() {
await this.model.posts.reload();
}
@action
- addQuote(q) {
+ async addQuote(q) {
this.set('newContent', `${this.newContent}${q} \n\n`);
- function scrollToNewForumPost() {
- document
- .getElementById('newForumPostCard')
- .scrollIntoView({behavior: 'smooth', block: 'center'});
- }
-
if (!this.currentPageIsLastPage) {
- this.transitionToRoute({
+ await this.transitionToRoute({
queryParams: {page: this.postsPaged.meta.totalPages},
- }).then(() => {
- next(() => {
- scrollToNewForumPost();
- });
+ })
+ next(() => {
+ this.scrollToNewForumPost();
});
} else {
- scrollToNewForumPost();
+ this.scrollToNewForumPost();
}
}
diff --git a/app/controllers/forum/categories/new.js b/app/controllers/forum/categories/new.js
index 429e0cd72..5c4601343 100644
--- a/app/controllers/forum/categories/new.js
+++ b/app/controllers/forum/categories/new.js
@@ -3,6 +3,6 @@ import NewController from 'amber-ui/controllers/application/new';
export default class NewCategoryController extends NewController {
successMessage = 'Categorie toegevoegd!';
successTransitionTarget = 'forum.categories';
- successTransitionTarget = null;
+ successTransitionModel = null;
cancelTransitionTarget = 'forum.categories';
}
diff --git a/app/controllers/groups/edit.js b/app/controllers/groups/edit.js
index c4dfff166..ab2967341 100644
--- a/app/controllers/groups/edit.js
+++ b/app/controllers/groups/edit.js
@@ -1,4 +1,3 @@
-// eslint-disable-next-line ember/no-computed-properties-in-native-classes
import { action } from '@ember/object';
import { A } from '@ember/array';
import { GroupKinds } from 'amber-ui/constants';
@@ -46,6 +45,7 @@ export default class EditGroupController extends EditController {
async submit() {
// todo: take a good look at this method, and see if its can be simplified to conform more to the
// EditController + model-save-utils pattern
+ // Especially the error handling has to be cleaned up heavily. It's hard to read and understand what's going on
const membershipErrors = A();
if (this.model !== undefined) {
@@ -76,12 +76,13 @@ export default class EditGroupController extends EditController {
},
''
);
+
this.errorMessage = `Er ${prefix} ${failedMembershipSavings} ${suffix} niet juist opgeslagen: \n ${membershipErrorText}`;
} else {
this.modelSaveUtil.onSuccess();
}
} catch (error) {
- this.errorMessage = error.message;
+ this.modelSaveUtil.onError(error);
}
}
}
diff --git a/app/controllers/mail-aliases/destroy.js b/app/controllers/mail-aliases/destroy.js
index bb9c7c3f7..496180efc 100644
--- a/app/controllers/mail-aliases/destroy.js
+++ b/app/controllers/mail-aliases/destroy.js
@@ -2,4 +2,5 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class MailAliasDestroyController extends DestroyController {
successTransitionTarget = 'mail-aliases.index';
+ // cancelTransitionTarget = 'mail-aliases.index';
}
diff --git a/app/controllers/mail-aliases/edit.js b/app/controllers/mail-aliases/edit.js
index 4671084a9..2ba315499 100644
--- a/app/controllers/mail-aliases/edit.js
+++ b/app/controllers/mail-aliases/edit.js
@@ -1,9 +1,5 @@
-// eslint-disable-next-line ember/no-computed-properties-in-native-classes
-import { equal, reads } from '@ember/object/computed';
import EditController from 'amber-ui/controllers/application/edit';
import { MailAliasModerationTypes } from 'amber-ui/constants';
-// eslint-disable-next-line ember/no-computed-properties-in-native-classes
-import { computed } from '@ember/object';
export default class EditMailAliasController extends EditController {
successTransitionTarget = 'mail-aliases.show';
@@ -15,27 +11,27 @@ export default class EditMailAliasController extends EditController {
};
}
- @equal('model.moderationType', 'open')
- moderationTypeOpen;
+ get moderationTypeOpen() {
+ return this.model.moderationsType === 'open';
+ }
- @computed('store', function () {
+ get groups() {
return this.store.findAll('group');
- })
- groups;
+ }
- @computed('store', function () {
+ get users() {
return this.store.findAll('user');
- })
- users;
+ }
- @reads('model.user.id')
- anyUser;
+ get anyUser() {
+ return this.model.user.id;
+ }
- @reads('model.group.id')
- anyGroup;
+ get anyGroup() {
+ return this.model.group.id;
+ }
- @computed('_mailAliasModerationTypes', function () {
+ get mailAliasModerationTypes() {
return MailAliasModerationTypes.map(this._mailAliasModerationTypes);
- })
- mailAliasModerationTypes;
+ }
}
diff --git a/app/utils/model-save.js b/app/utils/model-save.js
index 96ba2590a..483c59750 100644
--- a/app/utils/model-save.js
+++ b/app/utils/model-save.js
@@ -28,7 +28,6 @@ export default class ModelSaveUtil {
redirectSuccess() {
const targetModel = this.entity?.successTransitionModel;
- console.log(targetModel)
if (!isNone(this.entity?.successTransitionTarget)) {
this.transition(this.entity.successTransitionTarget, targetModel?.id);
}
@@ -36,7 +35,6 @@ export default class ModelSaveUtil {
redirectCancel() {
const targetModel = this.entity?.cancelTransitionModel;
- console.log(targetModel)
if (!isNone(this.entity?.cancelTransitionTarget)) {
this.transition(this.entity.cancelTransitionTarget, targetModel?.id);
}
@@ -66,9 +64,13 @@ export default class ModelSaveUtil {
if (this.entity?.onError) {
this.entity.onError(error);
} else {
- this.entity.errorMessage = error.errors
- .map((err) => err.detail)
- .join(', ');
+ if (error.errors) {
+ this.entity.errorMessage = error.errors
+ .map((err) => err.detail)
+ .join(', ');
+ } else {
+ this.entity.errorMessage = String(error)
+ }
}
}
From fa693ba5d3f6bbfa6240bcc4b96333180a3e0fca Mon Sep 17 00:00:00 2001
From: matteo
Date: Fri, 30 Sep 2022 15:47:15 +0200
Subject: [PATCH 22/40] more changes
---
app/controllers/mail-aliases/destroy.js | 2 +-
app/templates/mail-aliases/destroy.hbs | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/app/controllers/mail-aliases/destroy.js b/app/controllers/mail-aliases/destroy.js
index 496180efc..38369008b 100644
--- a/app/controllers/mail-aliases/destroy.js
+++ b/app/controllers/mail-aliases/destroy.js
@@ -2,5 +2,5 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class MailAliasDestroyController extends DestroyController {
successTransitionTarget = 'mail-aliases.index';
- // cancelTransitionTarget = 'mail-aliases.index';
+ cancelTransitionTarget = 'mail-aliases.show';
}
diff --git a/app/templates/mail-aliases/destroy.hbs b/app/templates/mail-aliases/destroy.hbs
index f2dcb507d..4dee4946c 100644
--- a/app/templates/mail-aliases/destroy.hbs
+++ b/app/templates/mail-aliases/destroy.hbs
@@ -1,9 +1,7 @@
Weet je zeker dat je dit mail-alias ({{@model.email}}) wil verwijderen?
Ja
-
- Nee
-
+Nee
{{#if errorMessage}}
{{this.errorMessage}}
From 54813ae0d970f6e22172358dccf178fa944fa0d6 Mon Sep 17 00:00:00 2001
From: matteo
Date: Fri, 30 Sep 2022 15:50:39 +0200
Subject: [PATCH 23/40] typo
---
app/controllers/mail-aliases/edit.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/mail-aliases/edit.js b/app/controllers/mail-aliases/edit.js
index 2ba315499..78e580040 100644
--- a/app/controllers/mail-aliases/edit.js
+++ b/app/controllers/mail-aliases/edit.js
@@ -12,7 +12,7 @@ export default class EditMailAliasController extends EditController {
}
get moderationTypeOpen() {
- return this.model.moderationsType === 'open';
+ return this.model.moderationType === 'open';
}
get groups() {
From f1c07274189fb8a6117344c40e0a3420430f9907 Mon Sep 17 00:00:00 2001
From: matteo
Date: Fri, 30 Sep 2022 16:16:00 +0200
Subject: [PATCH 24/40] better handling of transitions in destroycontrollers
---
app/controllers/application/destroy.js | 8 +++++++-
app/controllers/mail-moderations/accept.js | 2 +-
app/controllers/mail-moderations/destroy.js | 4 +++-
app/controllers/mail-moderations/reject.js | 2 +-
app/controllers/oauth/authorize.js | 2 +-
app/controllers/photo-albums/new.js | 1 -
app/controllers/photo-albums/photo-album/destroy.js | 1 +
app/controllers/photo-albums/photo-album/edit.js | 2 ++
.../photo-albums/photo-album/photos/destroy.js | 1 +
app/templates/photo-albums/photo-album/destroy.hbs | 8 +-------
app/utils/model-save.js | 3 ++-
11 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/app/controllers/application/destroy.js b/app/controllers/application/destroy.js
index 85d6d543b..0633171b9 100644
--- a/app/controllers/application/destroy.js
+++ b/app/controllers/application/destroy.js
@@ -8,6 +8,7 @@ export default class DestroyController extends EditController {
@tracked successTransitionModel = null;
@tracked cancelTransitionTarget = null;
@tracked cancelTransitionModel = this.model;
+ @tracked destroyed = false;
@action
destroyModel() {
@@ -20,7 +21,12 @@ export default class DestroyController extends EditController {
}
transition() {
- this.replaceRoute(...arguments);
+ // todo: this does not quite work everywhere, because navigating back after the transition
+ if (this.destroyed) {
+ this.replaceRoute(...arguments);
+ } else {
+ this.transitionToRoute(...arguments);
+ }
}
submit = undefined;
diff --git a/app/controllers/mail-moderations/accept.js b/app/controllers/mail-moderations/accept.js
index 630aba196..fdb64e93b 100644
--- a/app/controllers/mail-moderations/accept.js
+++ b/app/controllers/mail-moderations/accept.js
@@ -1,7 +1,7 @@
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { isInvalidResponse } from 'ember-fetch/errors';
-
+// todo: octane
export default Controller.extend({
fetch: service(),
errorMessage: null,
diff --git a/app/controllers/mail-moderations/destroy.js b/app/controllers/mail-moderations/destroy.js
index f3086446d..158f24fd3 100644
--- a/app/controllers/mail-moderations/destroy.js
+++ b/app/controllers/mail-moderations/destroy.js
@@ -1,6 +1,8 @@
import DestroyController from 'amber-ui/controllers/application/destroy';
export default class MailModerationDestroyController extends DestroyController {
+ successMessage = 'Mail is genegeerd.';
+ cancelMessage = 'Wijzigingen geannuleerd.'
successTransitionTarget = 'mail-moderations.index';
- successMessage = 'Mail is genegeerd';
+ cancelTransitionTarget = 'mail-moderations.show';
}
diff --git a/app/controllers/mail-moderations/reject.js b/app/controllers/mail-moderations/reject.js
index 4156d0c5c..db1c47ca7 100644
--- a/app/controllers/mail-moderations/reject.js
+++ b/app/controllers/mail-moderations/reject.js
@@ -1,7 +1,7 @@
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { isInvalidResponse } from 'ember-fetch/errors';
-
+// todo: octane
export default Controller.extend({
fetch: service(),
errorMessage: null,
diff --git a/app/controllers/oauth/authorize.js b/app/controllers/oauth/authorize.js
index 27973b007..5213a5496 100644
--- a/app/controllers/oauth/authorize.js
+++ b/app/controllers/oauth/authorize.js
@@ -1,6 +1,6 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
-
+// todo: octane
export default Controller.extend({
fetch: service(),
clientName: null,
diff --git a/app/controllers/photo-albums/new.js b/app/controllers/photo-albums/new.js
index c16c1994e..83e86b7c3 100644
--- a/app/controllers/photo-albums/new.js
+++ b/app/controllers/photo-albums/new.js
@@ -1,5 +1,4 @@
import NewController from 'amber-ui/controllers/application/new';
-// eslint-disable-next-line ember/no-computed-properties-in-native-classes
import { inject as service } from '@ember/service';
export default class NewPhotoAlbumController extends NewController {
diff --git a/app/controllers/photo-albums/photo-album/destroy.js b/app/controllers/photo-albums/photo-album/destroy.js
index bc230e475..859f22900 100644
--- a/app/controllers/photo-albums/photo-album/destroy.js
+++ b/app/controllers/photo-albums/photo-album/destroy.js
@@ -2,4 +2,5 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class PhotoAlbumDestroyController extends DestroyController {
successTransitionTarget = 'photo-albums.index';
+ cancelTransitionTarget = 'photo-albums.photo-album.show';
}
diff --git a/app/controllers/photo-albums/photo-album/edit.js b/app/controllers/photo-albums/photo-album/edit.js
index 8170fd416..d5ca94c15 100644
--- a/app/controllers/photo-albums/photo-album/edit.js
+++ b/app/controllers/photo-albums/photo-album/edit.js
@@ -1,6 +1,8 @@
import { inject as service } from '@ember/service';
import NewPhotoAlbumController from '../new';
+// todo: it would follow the pattern more if we let the NewPhotoAlbumController extend the EditPhotoAlbumController,
+// instead of vice versa
export default class EditPhotoAlbumController extends NewPhotoAlbumController {
successMessage = "Wijzigen en/of foto's toevoegen gelukt!";
cancelMessage = "Wijzigen en/of foto's toevoegen geannuleerd.";
diff --git a/app/controllers/photo-albums/photo-album/photos/destroy.js b/app/controllers/photo-albums/photo-album/photos/destroy.js
index 62e1828bc..855425c3e 100644
--- a/app/controllers/photo-albums/photo-album/photos/destroy.js
+++ b/app/controllers/photo-albums/photo-album/photos/destroy.js
@@ -2,4 +2,5 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class PhotoAlbumPhotoDestroyController extends DestroyController {
successTransitionTarget = 'photo-albums.photo-album.photos.index';
+ cancelTransitionTarget = 'photo-albums.photo-album.photos.show';
}
diff --git a/app/templates/photo-albums/photo-album/destroy.hbs b/app/templates/photo-albums/photo-album/destroy.hbs
index bb11a0c13..72e87470d 100644
--- a/app/templates/photo-albums/photo-album/destroy.hbs
+++ b/app/templates/photo-albums/photo-album/destroy.hbs
@@ -14,12 +14,6 @@
Verwijderen
-
- Annuleren
-
+ Annuleren
\ No newline at end of file
diff --git a/app/utils/model-save.js b/app/utils/model-save.js
index 483c59750..205bbf91e 100644
--- a/app/utils/model-save.js
+++ b/app/utils/model-save.js
@@ -104,7 +104,8 @@ export default class ModelSaveUtil {
model
.destroyRecord()
.then(() => {
- this.onSuccess(null);
+ this.entity.destroyed = true;
+ this.onSuccess();
})
.catch((error) => {
this.onError(error);
From 3a164840a037ec24f675f274a9f54ce72b2725d5 Mon Sep 17 00:00:00 2001
From: matteo
Date: Fri, 30 Sep 2022 16:59:22 +0200
Subject: [PATCH 25/40] I think I have had all new edit and destroy controllers
---
app/controllers/polls/destroy.js | 2 ++
app/controllers/sog/name-trainer.js | 2 +-
app/controllers/static-pages/destroy.js | 1 +
app/controllers/users/activate-account.js | 2 +-
app/controllers/users/destroy.js | 1 +
app/controllers/users/resend-activation.js | 2 +-
app/templates/static-pages/destroy.hbs | 4 +---
app/templates/users/destroy.hbs | 4 +---
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/controllers/polls/destroy.js b/app/controllers/polls/destroy.js
index ed496383a..185fc2534 100644
--- a/app/controllers/polls/destroy.js
+++ b/app/controllers/polls/destroy.js
@@ -2,5 +2,7 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class PollDestroyController extends DestroyController {
successMessage = 'Poll verwijderd!';
+ cancelMessage = 'Poll verwijderen geannuleerd.';
successTransitionTarget = 'polls.index';
+ cancelTransitionTarget = 'polls.show';
}
diff --git a/app/controllers/sog/name-trainer.js b/app/controllers/sog/name-trainer.js
index 11ffc4b62..5aa4f5955 100644
--- a/app/controllers/sog/name-trainer.js
+++ b/app/controllers/sog/name-trainer.js
@@ -1,7 +1,7 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { run } from '@ember/runloop';
-
+// todo: octane
export default Controller.extend({
queryParams: ['groupId', 'difficulty'],
groupId: null,
diff --git a/app/controllers/static-pages/destroy.js b/app/controllers/static-pages/destroy.js
index 0ee21c8a6..00adb245e 100644
--- a/app/controllers/static-pages/destroy.js
+++ b/app/controllers/static-pages/destroy.js
@@ -2,4 +2,5 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class StaticPageDestroyController extends DestroyController {
successTransitionTarget = 'static-pages.index';
+ cancelTransitionTarget = 'static-pages.show';
}
diff --git a/app/controllers/users/activate-account.js b/app/controllers/users/activate-account.js
index 9d7ade848..544eb83da 100644
--- a/app/controllers/users/activate-account.js
+++ b/app/controllers/users/activate-account.js
@@ -4,7 +4,7 @@ import { computed } from '@ember/object';
import { run } from '@ember/runloop';
import { isNone } from '@ember/utils';
import { isNotFoundResponse } from 'ember-fetch/errors';
-
+// todo: octane
export default Controller.extend({
fetch: service(),
diff --git a/app/controllers/users/destroy.js b/app/controllers/users/destroy.js
index c99f535c9..90f64de3d 100644
--- a/app/controllers/users/destroy.js
+++ b/app/controllers/users/destroy.js
@@ -2,4 +2,5 @@ import DestroyController from 'amber-ui/controllers/application/destroy';
export default class UserDestroyController extends DestroyController {
successTransitionTarget = 'users.index';
+ cancelTransitionTarget = 'users.show';
}
diff --git a/app/controllers/users/resend-activation.js b/app/controllers/users/resend-activation.js
index 2a81598e6..f04410a54 100644
--- a/app/controllers/users/resend-activation.js
+++ b/app/controllers/users/resend-activation.js
@@ -1,7 +1,7 @@
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { isNotFoundResponse } from 'ember-fetch/errors';
-
+// todo: octane
export default Controller.extend({
fetch: service(),
actions: {
diff --git a/app/templates/static-pages/destroy.hbs b/app/templates/static-pages/destroy.hbs
index e12d17057..6120d52b0 100644
--- a/app/templates/static-pages/destroy.hbs
+++ b/app/templates/static-pages/destroy.hbs
@@ -1,9 +1,7 @@
Weet je zeker dat je deze informatie pagina wilt verwijderen?