From c9f22a2a1da63048cf6dbe57cc57634530ffb557 Mon Sep 17 00:00:00 2001 From: Wilco Date: Wed, 2 Nov 2022 21:45:04 +0100 Subject: [PATCH 1/5] Add support for more spreadsheet formats (#640) --- app/controllers/debit/collections/new.js | 10 ++++++++-- app/controllers/users/batch/new.js | 10 ++++++++-- app/templates/users/batch/new.hbs | 2 +- public/files/user_import_example.csv | 4 ---- public/files/user_import_example.ods | Bin 0 -> 11887 bytes 5 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 public/files/user_import_example.csv create mode 100644 public/files/user_import_example.ods diff --git a/app/controllers/debit/collections/new.js b/app/controllers/debit/collections/new.js index 3864b36f6..1d2132fed 100644 --- a/app/controllers/debit/collections/new.js +++ b/app/controllers/debit/collections/new.js @@ -11,8 +11,14 @@ export default class DebitCollectionNewController extends EditController { return null; } - validMimetypes = 'text/csv'; - validExtensions = EmberArray.apply(['csv']); + validMimetypes = EmberArray.apply([ + 'text/csv', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.ms-excel.sheet.macroenabled.12', + ]); + + validExtensions = EmberArray.apply(['csv', 'ods', 'xlsx', 'xlsm']); @action fileLoaded(file) { const collection = this.model; diff --git a/app/controllers/users/batch/new.js b/app/controllers/users/batch/new.js index d3a32db56..44924968b 100644 --- a/app/controllers/users/batch/new.js +++ b/app/controllers/users/batch/new.js @@ -22,8 +22,14 @@ export default class NewUserBatchController extends NewController { @tracked importErrors = A(); @tracked properties = A(); - validMimetypes = 'text/csv'; - validExtensions = EmberArray.apply(['csv']); + validMimetypes = EmberArray.apply([ + 'text/csv', + 'application/vnd.oasis.opendocument.spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.ms-excel.sheet.macroenabled.12', + ]); + + validExtensions = EmberArray.apply(['csv', 'ods', 'xlsx', 'xlsm']); get groups() { return this.store.findAll('group'); diff --git a/app/templates/users/batch/new.hbs b/app/templ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N**J3Rv*d8xzHnYj(3`qs~AvA)RWU_wnD zzW=N;UB&C6uj(s{w+yS9oE=pp=Kd^}(0p4><}qQtp5-$t!!oe5l9NST&9<}kJ&OV> z9z=^cY|BPKx6 zn$PM$$Ue`VCJlx4)kv!QTgBC@&&C$%<$i}wAWO=}C1*~0B(zPtXRQ~adp=59vG?Ug zi9SIwj6FtQ;~vZQNL*g*PaE8&n*!fm-LTwpp6KsVPO@R2GWmzg0GwZ^mj6KcBTRo?J?_@!AM)z?FIH(KS%g~_3;=+3`vcxC KI)^lOPyYv=wEK1d literal 0 HcmV?d00001 From 04db56bd91ad1807690be1048ba17f5654746ca8 Mon Sep 17 00:00:00 2001 From: Wilco Date: Thu, 17 Nov 2022 13:05:12 +0100 Subject: [PATCH 2/5] Fix ember-moment config (#654) --- config/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environment.js b/config/environment.js index 165240d42..cdae2b993 100644 --- a/config/environment.js +++ b/config/environment.js @@ -32,7 +32,7 @@ module.exports = function (environment) { hostname: '/api/v1', }, - moment: { + 'ember-moment': { allowEmpty: true, }, From 4da97611ffeebb46a01e3c7da5d798a5050dbc45 Mon Sep 17 00:00:00 2001 From: Ellen-Wittingen <101463776+Ellen-Wittingen@users.noreply.github.com> Date: Sat, 19 Nov 2022 23:45:15 +0100 Subject: [PATCH 3/5] Fix new forum post content resetting (#567) Co-authored-by: matteo Co-authored-by: Matteo Bronkhorst <32799956+DrumsnChocolate@users.noreply.github.com> --- app/components/forum/forum-post-new.hbs | 2 +- app/components/forum/forum-post-new.js | 16 ++++++++++---- .../category/threads/thread/posts/index.js | 21 +++++++++++++++---- .../category/threads/thread/posts/index.js | 7 +++++++ .../category/threads/thread/posts/index.hbs | 5 +++-- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/app/components/forum/forum-post-new.hbs b/app/components/forum/forum-post-new.hbs index ea0113d9b..cf036133c 100644 --- a/app/components/forum/forum-post-new.hbs +++ b/app/components/forum/forum-post-new.hbs @@ -1,5 +1,5 @@

- +

From 894d9e2cc29a3ac1eabb8bd052d85e53d190230c Mon Sep 17 00:00:00 2001 From: Matteo Bronkhorst <32799956+DrumsnChocolate@users.noreply.github.com> Date: Sun, 20 Nov 2022 21:35:00 +0100 Subject: [PATCH 5/5] Refactor: remaining controllers to octane (#656) --- app/components/photo-comments/comments.js | 2 +- app/components/users/privacy-settings.js | 2 +- app/controllers/activities/generate-alias.js | 47 ++-- app/controllers/activities/print-enrolled.js | 118 +++++----- app/controllers/activities/show.js | 19 +- app/controllers/application.js | 9 +- app/controllers/articles/show.js | 48 ++-- app/controllers/debit/collections/show.js | 67 +++--- app/controllers/error.js | 51 ++--- app/controllers/mail-moderations/accept.js | 40 ++-- app/controllers/mail-moderations/reject.js | 43 ++-- app/controllers/oauth/authorize.js | 78 +++---- .../photo-albums/photo-album/photos/show.js | 36 +-- app/controllers/photo-comments/index.js | 2 +- app/controllers/polls/show.js | 2 +- app/controllers/sog/name-trainer.js | 209 ++++++++++-------- app/controllers/users/activate-account.js | 89 ++++---- app/controllers/users/forgot-password.js | 42 ++-- app/controllers/users/resend-activation.js | 39 ++-- app/controllers/users/webdav.js | 43 ++-- app/models/debit/collection.js | 4 +- app/routes/application/application.js | 1 - app/templates/activities/generate-alias.hbs | 8 +- app/templates/activities/print-enrolled.hbs | 50 ++--- app/templates/activities/show.hbs | 21 +- app/templates/articles/show.hbs | 10 +- app/templates/debit/collections/show.hbs | 2 +- app/templates/error.hbs | 8 +- app/templates/mail-moderations/accept.hbs | 4 +- app/templates/mail-moderations/reject.hbs | 4 +- app/templates/oauth/authorize.hbs | 6 +- .../photo-albums/photo-album/photos/show.hbs | 4 +- app/templates/sog/name-trainer.hbs | 73 +++--- app/templates/users/activate-account.hbs | 16 +- app/templates/users/forgot-password.hbs | 6 +- app/templates/users/resend-activation.hbs | 2 +- app/templates/users/webdav.hbs | 4 +- 37 files changed, 622 insertions(+), 587 deletions(-) diff --git a/app/components/photo-comments/comments.js b/app/components/photo-comments/comments.js index eca7754c9..253344704 100644 --- a/app/components/photo-comments/comments.js +++ b/app/components/photo-comments/comments.js @@ -5,7 +5,7 @@ import { action } from '@ember/object'; export default class Comments extends Component { @service store; - @service('flash-notice') flashNotice; + @service flashNotice; @tracked content = null; diff --git a/app/components/users/privacy-settings.js b/app/components/users/privacy-settings.js index f306541eb..33a98f282 100644 --- a/app/components/users/privacy-settings.js +++ b/app/components/users/privacy-settings.js @@ -9,7 +9,7 @@ import { isPresent } from '@ember/utils'; import { tracked } from '@glimmer/tracking'; export default class PrivacySettingsComponent extends Component { - @service('flash-notice') flashNotice; + @service flashNotice; @service session; @tracked errorMessage = null; diff --git a/app/controllers/activities/generate-alias.js b/app/controllers/activities/generate-alias.js index 7c340fb65..e4ce8dd5c 100644 --- a/app/controllers/activities/generate-alias.js +++ b/app/controllers/activities/generate-alias.js @@ -1,28 +1,27 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; import { isInvalidResponse } from 'ember-fetch/errors'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; -export default Controller.extend({ - fetch: service(), - errorMessage: null, - actions: { - async generateAlias() { - this.set('errorMessage', null); - const response = await this.fetch.post( - `/activities/${this.model.id}/generate_alias` - ); - - if (response.ok) { - const json = await response.json(); - this.set('alias', json.data.alias); - this.set('expires_at', json.data.expires_at); - } else if (isInvalidResponse(response)) { - const json = await response.json(); - this.set( - 'errorMessage', - json.errors ? json.errors[0].detail : response - ); - } - }, - }, -}); +export default class GenerateAliasController extends Controller { + @service fetch; + @tracked errorMessage = null; + @tracked alias; + @tracked expiresAt; + @action + async generateAlias() { + this.errorMessage = null; + const response = await this.fetch.post( + `/activities/${this.model.id}/generate_alias` + ); + if (response.ok) { + const json = await response.json(); + this.alias = json.data.alias; + this.expiresAt = json.data.expires_at; + } else if (isInvalidResponse(response)) { + const json = await response.json(); + this.errorMessage = json.errors ? json.errors[0].detail : response; + } + } +} diff --git a/app/controllers/activities/print-enrolled.js b/app/controllers/activities/print-enrolled.js index 25e65e708..8c6de9e5a 100644 --- a/app/controllers/activities/print-enrolled.js +++ b/app/controllers/activities/print-enrolled.js @@ -1,54 +1,66 @@ import Controller from '@ember/controller'; -import { sort } from '@ember/object/computed'; - -export default Controller.extend({ - showAllergyInfo: true, - showCheckbox: true, - currentTab: 'form', // Possible options: [ form, consumptionList ] - options: ['Bier', 'Fris'], - newOption: '', - additionalEmptyRows: 5, - showRobertHofstra: true, - - sortedString: Object.freeze(['userFullName']), - sortedResponses: sort('model.form.responses', 'sortedString'), - - actions: { - print() { - const { title } = this.model; - const popup = window.open('', 'PRINT', 'height=400,width=600'); - - popup.document.write( - `Inschrijflijst ${title}` - ); - popup.document.write(''); - popup.document.write( - '' - ); - popup.document.write( - '' - ); - popup.document.write(document.getElementById('printarea').innerHTML); - popup.document.write(''); - popup.document.close(); // Necessary for IE >= 10 - popup.focus(); // Necessary for IE >= 10*/ - }, - selectForm() { - this.set('currentTab', 'form'); - }, - selectConsumptionList() { - this.set('currentTab', 'consumptionList'); - }, - removeOption(index) { - this.options.removeAt(index, 1); - }, - addOption() { - const option = this.newOption; - this.options.pushObject(option); - this.set('newOption', ''); - }, - reorderItems(itemModels) { - this.set('options', itemModels); - }, - }, -}); +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; + +const tabs = ['form', 'consumptionList']; +const formTab = tabs[0]; +const consumptionListTab = tabs[1]; + +export default class PrintEnrolledController extends Controller { + @tracked showAllergyInfo = true; + @tracked showCheckbox = true; + @tracked currentTab = formTab; + @tracked options = ['Bier', 'Fris']; + @tracked newOption = ''; + @tracked showRobertHofstra = true; + additionalEmptyRows = 5; + + get sortedResponses() { + return this.model.form.get('responses').sortBy('userFullName'); + } + + @action + print() { + const { title } = this.model; + const popup = window.open('', 'PRINT', 'height=400,width=600'); + + popup.document.write(`Inschrijflijst ${title}`); + popup.document.write(''); + popup.document.write( + '' + ); + popup.document.write( + '' + ); + popup.document.write(document.getElementById('printarea').innerHTML); + popup.document.write(''); + popup.document.close(); // Necessary for IE >= 10 + popup.focus(); // Necessary for IE >= 10*/ + } + + @action + selectForm() { + this.currentTab = formTab; + } + + @action + selectConsumptionList() { + this.currentTab = consumptionListTab; + } + + @action + removeOption(index) { + this.options.removeAt(index, 1); + } + + @action + addOption() { + this.options.pushObject(this.newOption); + this.newOption = ''; + } + + @action + reorderItems(itemModels) { + this.options = itemModels; + } +} diff --git a/app/controllers/activities/show.js b/app/controllers/activities/show.js index 05097857f..50eb03058 100644 --- a/app/controllers/activities/show.js +++ b/app/controllers/activities/show.js @@ -1,16 +1,11 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; -import { computed } from '@ember/object'; import { isNone } from '@ember/utils'; -export default Controller.extend({ - flashNotice: service('flash-notice'), - canSubmitResponse: computed( - 'model.form', - 'model.form.currentUserCanRespond', - function () { - const { form } = this.model; - return !isNone(form) && form.get('currentUserCanRespond'); - } - ), -}); +export default class ShowActivityController extends Controller { + @service flashNotice; + get canSubmitResponse() { + const { form } = this.model; + return !isNone(form) && form.get('currentUserCanRespond'); + } +} diff --git a/app/controllers/application.js b/app/controllers/application.js index 9f28d3646..46162b04c 100644 --- a/app/controllers/application.js +++ b/app/controllers/application.js @@ -1,7 +1,8 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; -export default Controller.extend({ - session: service(), - layoutManager: service('layout-manager'), -}); +export default class ApplicationController extends Controller { + @service session; + + @service layoutManager; +} diff --git a/app/controllers/articles/show.js b/app/controllers/articles/show.js index b442554cb..f585df384 100644 --- a/app/controllers/articles/show.js +++ b/app/controllers/articles/show.js @@ -1,26 +1,28 @@ import { inject as service } from '@ember/service'; -import { sort } from '@ember/object/computed'; import Controller from '@ember/controller'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; -export default Controller.extend({ - session: service(), - flashNotice: service('flash-notice'), - newArticleComment: '', - articleCommentSorting: ['createdAt'], - sortedArticleComments: sort('model.comments', 'articleCommentSorting'), - actions: { - submitArticleComment() { - if (this.newArticleComment.trim().length > 0) { - const articleComment = this.store.createRecord('articleComment', { - content: this.newArticleComment, - article: this.model, - user: this.session.get('currentUser'), - }); - articleComment.save().then(() => { - this.flashNotice.sendSuccess('Reactie opgeslagen!'); - }); - this.set('newArticleComment', ''); - } - }, - }, -}); +export default class ShowArticleController extends Controller { + @service session; + @service flashNotice; + @tracked newArticleComment = ''; + get sortedArticleComments() { + return this.model.comments.sortBy('createdAt'); + } + + @action + submitArticleComment() { + if (this.newArticleComment.trim().length > 0) { + const articleComment = this.store.createRecord('articleComment', { + content: this.newArticleComment, + article: this.model, + user: this.session.get('currentUser'), + }); + articleComment.save().then(() => { + this.flashNotice.sendSuccess('Reactie opgeslagen!'); + }); + this.newArticleComment = ''; + } + } +} diff --git a/app/controllers/debit/collections/show.js b/app/controllers/debit/collections/show.js index 05d49dcae..45504cf44 100644 --- a/app/controllers/debit/collections/show.js +++ b/app/controllers/debit/collections/show.js @@ -1,43 +1,28 @@ import Controller from '@ember/controller'; -import EmberObject, { computed } from '@ember/object'; -export default Controller.extend({ - groupedTransactions: computed( - 'model.transactions.length', - 'model.transactions.@each.user', - function () { - const transactions = []; - - this.model.transactions.forEach((transaction) => { - let transactionsGroupedByUser = transactions.findBy( - 'userId', - transaction.get('user.id') - ); - - if (!transactionsGroupedByUser) { - transactions.pushObject( - EmberObject.create({ - userId: transaction.get('user.id'), - user: transaction.get('user'), - transactions: [], - totalTransactionAmount: 0, - }) - ); - } - - transactionsGroupedByUser = transactions.findBy( - 'userId', - transaction.get('user.id') - ); - transactionsGroupedByUser.transactions.pushObject(transaction); - transactionsGroupedByUser.totalTransactionAmount += - transaction.get('amount'); - }); - transactions.forEach((transactionsGroupedByUser) => { - transactionsGroupedByUser.totalTransactionAmount = - transactionsGroupedByUser.totalTransactionAmount.toFixed(2); - }); - return transactions; - } - ), -}); +export default class DebitCollectionShowController extends Controller { + get groupedTransactions() { + const transactions = []; + this.model.transactions.forEach((transaction) => { + const user = transaction.get('user'); + let transactionGroup = transactions.find( + (transactionGroup) => transactionGroup.user === user + ); + if (!transactionGroup) { + transactionGroup = { + user: transaction.get('user'), + transactions: [], + totalTransactionAmount: 0, + }; + transactions.push(transactionGroup); + } + transactionGroup.transactions.push(transaction); + transactionGroup.totalTransactionAmount += transaction.get('amount'); + }); + transactions.forEach((transactionGroup) => { + transactionGroup.totalTransactionAmount = + transactionGroup.totalTransactionAmount.toFixed(2); + }); + return transactions; + } +} diff --git a/app/controllers/error.js b/app/controllers/error.js index 7ee2d790e..c56bbfbbd 100644 --- a/app/controllers/error.js +++ b/app/controllers/error.js @@ -1,28 +1,32 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; -import { computed } from '@ember/object'; import { run } from '@ember/runloop'; -export default Controller.extend({ - flashNotice: service('flash-notice'), - showNotFound: computed( - 'model.{isAdapterError,isAuthorizationError}', - 'status', - function () { - return ( - this.model.isAuthorizationError || - (this.model.isAdapterError && ['403', '404'].includes(this.status)) - ); - } - ), - showStatic: computed('status', function () { +export default class ErrorController extends Controller { + @service flashNotice; + + constructor() { + super(); + run.scheduleOnce('afterRender', this, this.checkBackend); + } + + get showNotFound() { + return ( + this.model.isAuthorizationError || + (this.model.isAdapterError && ['403', '404'].includes(this.status)) + ); + } + + get showStatic() { return ['502', '503'].includes(this.status); - }), - status: computed('model.errors.firstObject.status', function () { + } + + get status() { const status = this.model.errors?.firstObject.status; return status ? String(status) : status; - }), - message: computed('status', function () { + } + + get message() { switch (this.status) { case '400': // Bad Request return 'Er is iets mis met de request. Geef de ICT-commissie even de tijd om dit op te lossen.'; @@ -49,11 +53,8 @@ export default Controller.extend({ default: return 'Er is iets mis gegaan. Probeer het later opnieuw.'; } - }), - init() { - this._super(); - run.scheduleOnce('afterRender', this, this.checkBackend); - }, + } + checkBackend() { if (this.showStatic) { this.flashNotice.sendWarning( @@ -61,5 +62,5 @@ export default Controller.extend({ true ); } - }, -}); + } +} diff --git a/app/controllers/mail-moderations/accept.js b/app/controllers/mail-moderations/accept.js index fdb64e93b..549797c1b 100644 --- a/app/controllers/mail-moderations/accept.js +++ b/app/controllers/mail-moderations/accept.js @@ -1,24 +1,24 @@ 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, - actions: { - async submit() { - this.set('errorMessage', null); - const response = await this.fetch.post( - `/stored_mails/${this.model.id}/accept` - ); +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; - if (response.ok) { - this.model.unloadRecord(); - this.transitionToRoute('mail-moderations.index'); - } else if (isInvalidResponse(response)) { - const json = await response.json(); - this.set('errorMessage', json.errors[0].detail); - } - }, - }, -}); +export default class AcceptController extends Controller { + @service fetch; + @tracked errorMessage = null; + @action + async submit() { + this.errorMessage = null; + const response = await this.fetch.post( + `/stored_mails/${this.model.id}/accept` + ); + if (response.ok) { + this.model.unloadRecord(); + this.transitionToRoute('mail-moderations.index'); + } else if (isInvalidResponse(response)) { + const json = await response.json(); + this.errorMessage = json.errors[0].detail; + } + } +} diff --git a/app/controllers/mail-moderations/reject.js b/app/controllers/mail-moderations/reject.js index db1c47ca7..61474c6c3 100644 --- a/app/controllers/mail-moderations/reject.js +++ b/app/controllers/mail-moderations/reject.js @@ -1,24 +1,27 @@ 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, - actions: { - async submit() { - this.set('errorMessage', null); - const response = await this.fetch.post( - `/stored_mails/${this.model.id}/reject` - ); +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; - if (response.ok) { - this.model.unloadRecord(); - this.transitionToRoute('mail-moderations.index'); - } else if (isInvalidResponse(response)) { - const json = await response.json(); - this.set('errorMessage', json.error); - } - }, - }, -}); +export default class RejectController extends Controller { + @service fetch; + @service flashNotice; + @tracked errorMessage = null; + @action + async submit() { + this.errorMessage = null; + const response = await this.fetch.post( + `/stored_mails/${this.model.id}/reject` + ); + + if (response.ok) { + this.flashNotice.sendSuccess('Mail moderatie afgewezen!'); + this.model.unloadRecord(); + this.transitionToRoute('mail-moderations.index'); + } else if (isInvalidResponse(response)) { + const json = await response.json(); + this.errorMessage = json.error; + } + } +} diff --git a/app/controllers/oauth/authorize.js b/app/controllers/oauth/authorize.js index 5213a5496..5381742ce 100644 --- a/app/controllers/oauth/authorize.js +++ b/app/controllers/oauth/authorize.js @@ -1,42 +1,44 @@ import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; -// todo: octane -export default Controller.extend({ - fetch: service(), - clientName: null, +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; - queryParams: ['client_id', 'redirect_uri', 'response_type', 'state', 'scope'], +export default class AuthorizeController extends Controller { + @service fetch; + @tracked clientName = null; + queryParams = [ + 'client_id', + 'redirect_uri', + 'response_type', + 'state', + 'scope', + ]; - actions: { - authorize() { - this.fetch - .fetch('/oauth/authorize', { - /* eslint-disable camelcase */ - body: JSON.stringify({ - client_id: this.client_id, - redirect_uri: this.redirect_uri, - response_type: this.response_type, - state: this.state, - scope: this.scope, - }), - /* eslint-enable camelcase */ - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - }) - .then((response) => { - response.json().then((json) => { - if (json.error) { - this.set('errorMessage', json.error_description); - } else if (json.redirect_uri) { - location.href = json.redirect_uri; - } else { - this.set('errorMessage', 'Unknown error'); - } - }); - }); - }, - }, -}); + @action + async authorize() { + const response = await this.fetch.fetch('/oauth/authorize', { + /* eslint-disable camelcase */ + body: JSON.stringify({ + client_id: this.client_id, + redirect_uri: this.redirect_uri, + response_type: this.response_type, + state: this.state, + scope: this.scope, + }), + /* eslint-enable camelcase */ + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + }); + const json = await response.json(); + if (json.error) { + this.errorMessage = json.error_description; + } else if (json.redirect_uri) { + location.href = json.redirect_uri; + } else { + this.errorMessage = 'Unknown error'; + } + } +} diff --git a/app/controllers/photo-albums/photo-album/photos/show.js b/app/controllers/photo-albums/photo-album/photos/show.js index e02d4b74f..e1a335732 100644 --- a/app/controllers/photo-albums/photo-album/photos/show.js +++ b/app/controllers/photo-albums/photo-album/photos/show.js @@ -1,8 +1,25 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; +import { action } from '@ember/object'; + +export default class PhotoShowController extends Controller { + @service session; + + @action + goToPreviousPhoto() { + return this.advanceToPhoto(-1); + } + + @action + goToNextPhoto() { + return this.advanceToPhoto(1); + } + + @action + onSwipe(direction) { + return this.advanceToPhoto(-direction); + } -export default Controller.extend({ - session: service(), advanceToPhoto(delta) { const photos = this.model.photoAlbum.get('sortedPhotos'); const length = photos.get('length'); @@ -12,16 +29,5 @@ export default Controller.extend({ 'photo-albums.photo-album.photos.show', photos.objectAt(index) ); - }, - actions: { - goToPreviousPhoto() { - return this.advanceToPhoto(-1); - }, - goToNextPhoto() { - return this.advanceToPhoto(1); - }, - onSwipe(direction) { - return this.advanceToPhoto(-direction); - }, - }, -}); + } +} diff --git a/app/controllers/photo-comments/index.js b/app/controllers/photo-comments/index.js index cb73e9cfe..bedf0c36a 100644 --- a/app/controllers/photo-comments/index.js +++ b/app/controllers/photo-comments/index.js @@ -4,7 +4,7 @@ import { inject as service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; export default class PhotoCommentsIndexController extends FilterableAndSortableController { - @service('flash-notice') flashNotice; + @service flashNotice; @tracked sortedAscending = false; @tracked sortedAttribute = 'updated_at'; diff --git a/app/controllers/polls/show.js b/app/controllers/polls/show.js index 53421d7df..02bca8dde 100644 --- a/app/controllers/polls/show.js +++ b/app/controllers/polls/show.js @@ -8,7 +8,7 @@ import { isNone } from '@ember/utils'; import { tracked } from '@glimmer/tracking'; export default class PollsShowController extends Controller { - @service('flash-notice') flashNotice; + @service flashNotice; @service store; @tracked errorMessage = null; diff --git a/app/controllers/sog/name-trainer.js b/app/controllers/sog/name-trainer.js index 5aa4f5955..29124a490 100644 --- a/app/controllers/sog/name-trainer.js +++ b/app/controllers/sog/name-trainer.js @@ -1,12 +1,15 @@ import Controller from '@ember/controller'; -import { computed } from '@ember/object'; +import { inject as service } from '@ember/service'; import { run } from '@ember/runloop'; -// todo: octane -export default Controller.extend({ - queryParams: ['groupId', 'difficulty'], - groupId: null, - difficulty: 1, - difficultyOptions: [ +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + +export default class NameTrainerController extends Controller { + @service store; + queryParams = ['groupId', 'difficulty']; + @tracked groupId = null; + @tracked difficulty = 1; + difficultyOptions = [ { value: 1, label: 'Makkelijk', @@ -19,41 +22,56 @@ export default Controller.extend({ value: 3, label: 'Moeilijk', }, - ], - currentQuestionIndex: 1, - success: 0, - questions: [], - textInput: '', - started: false, - finished: false, - answered: false, - users: computed('group.name', 'store', function () { - return this.store.query('user', { - filter: { group: this.group.get('name') }, - }); - }), - group: computed('groupId', 'store', function () { - if (!this.groupId) { - return; + ]; + + @tracked currentQuestionIndex = 1; + @tracked success = 0; + @tracked questions = []; + @tracked textInput = ''; + @tracked started = false; + @tracked finished = false; + @tracked answered = false; + @tracked errorMessage; + + get users() { + return this.getUsers(); + } + + async getUsers() { + const group = await this.group; + if (!group) { + return []; } + const memberships = await group.get('memberships'); + return await Promise.all(memberships.mapBy('user')); + } + get group() { + if (!this.groupId) { + return null; + } return this.store.find('group', this.groupId); - }), - humanizedDifficulty: computed('difficulty', 'difficultyOptions', function () { + } + + get humanizedDifficulty() { return this.difficultyOptions.find( (option) => option.value === this.difficulty ).label; - }), - progressBarStyle: computed('progress', function () { + } + + get progressBarStyle() { return `width: ${this.progress}%`; - }), - currentQuestion: computed('currentQuestionIndex', 'questions', function () { + } + + get currentQuestion() { return this.questions.objectAt(this.currentQuestionIndex - 1); - }), - progress: computed('currentQuestionIndex', 'questions.length', function () { + } + + get progress() { return (this.currentQuestionIndex / this.questions.length) * 100; - }), - inputClass: computed('answered', 'currentQuestion.success', function () { + } + + get inputClass() { if (this.answered) { if (this.currentQuestion.success) { return 'form-control is-valid'; @@ -61,53 +79,65 @@ export default Controller.extend({ return 'form-control is-invalid'; } } - return 'form-control'; - }), - grade: computed('questions.length', 'success', function () { + } + + get grade() { return 1 + Math.round((90 / this.questions.length) * this.success) / 10; - }), - actions: { - setGroupId(model) { - this.set('groupId', model.id); - }, - startTrainer() { - this.users.then((users) => { - this.generateQuestions(users.filter((user) => user.avatarThumbUrl)); - this.set('started', true); - this.set('finished', false); - this.set('currentQuestionIndex', 1); - this.set('success', 0); - }); - }, - stopTrainer() { - this.set('started', false); - this.set('finished', false); - }, - chooseOption(option) { - if (!this.answered) { - let { currentQuestion } = this; - currentQuestion.answer = option; - currentQuestion.success = option === currentQuestion.question; - if (currentQuestion.success) { - this.incrementProperty('success'); - } - - this.goToNextQuestion(); - } - }, - checkAnswer() { + } + + @action + setGroupId(model) { + this.groupId = model.id; + } + + @action + async startTrainer() { + const users = await this.users; + const usersWithAvatar = users.filter((user) => user.avatarThumbUrl); + if (!usersWithAvatar.length) { + this.errorMessage = + 'Namen trainen wordt een beetje onmogelijk, want niemand in deze groep heeft een profielfoto.'; + return; + } + this.generateQuestions(usersWithAvatar); + this.started = true; + this.finished = false; + this.currentQuestionIndex = 1; + this.success = 0; + } + + @action + stopTrainer() { + this.started = false; + this.finished = false; + } + + @action + chooseOption(option) { + if (!this.answered) { let { currentQuestion } = this; - currentQuestion.answer = this.textInput; - currentQuestion.success = - currentQuestion.answer === currentQuestion.question.get('fullName'); + currentQuestion.answer = option; + currentQuestion.success = option === currentQuestion.question; if (currentQuestion.success) { - this.incrementProperty('success'); + this.success++; } - this.goToNextQuestion(); - }, - }, + } + } + + @action + checkAnswer() { + let { currentQuestion } = this; + currentQuestion.answer = this.textInput; + currentQuestion.success = + currentQuestion.answer === currentQuestion.question.get('fullName'); + if (currentQuestion.success) { + this.success++; + } + this.goToNextQuestion(); + } + generateQuestions(people) { let shuffledPeople = this.shuffleArray(people); let questions = shuffledPeople.map((person) => ({ @@ -116,34 +146,37 @@ export default Controller.extend({ answer: null, success: null, })); - this.set('questions', questions); - }, + this.questions = questions; + } + generateOptions(items, item) { let shuffledItems = this.shuffleArray(items); shuffledItems.splice(shuffledItems.indexOf(item), 1); let options = shuffledItems.slice(0, 4); options[Math.floor(Math.random() * options.length)] = item; return options; - }, + } + shuffleArray(array) { return array .map((a) => ({ sort: Math.random(), value: a })) .sort((a, b) => a.sort - b.sort) .map((a) => a.value); - }, + } + goToNextQuestion() { - this.set('answered', true); + this.answered = true; let _this = this; run.later(function () { - if (_this.get('currentQuestionIndex') < _this.get('questions.length')) { - _this.set('answered', false); - _this.incrementProperty('currentQuestionIndex'); - _this.set('textInput', ''); + if (_this.currentQuestionIndex < _this.questions.length) { + _this.answered = false; + _this.currentQuestionIndex++; + _this.textInput = ''; } else { - _this.set('answered', false); - _this.set('finished', true); - _this.set('started', false); + _this.answered = false; + _this.finished = true; + _this.started = false; } }, 2000); - }, -}); + } +} diff --git a/app/controllers/users/activate-account.js b/app/controllers/users/activate-account.js index 544eb83da..adf37b45e 100644 --- a/app/controllers/users/activate-account.js +++ b/app/controllers/users/activate-account.js @@ -1,25 +1,28 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; -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(), +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; - isSaveButtonDisabled: computed( - 'password.length', - 'passwordConfirmation', - function () { - return ( - isNone(this.password) || - this.password.length < 12 || - this.password !== this.passwordConfirmation - ); - } - ), - infoMessage: computed('password.length', 'passwordConfirmation', function () { +export default class ActivateAccountController extends Controller { + @service fetch; + queryParams = ['activation_token']; + @tracked password; + @tracked passwordConfirmation; + @tracked successMessage; + @tracked errorMessage; + + get isSaveButtonDisabled() { + return ( + isNone(this.password) || + this.password.length < 12 || + this.password !== this.passwordConfirmation + ); + } + + get infoMessage() { if (isNone(this.password)) { return 'Voer een wachtwoord in van minimaal 12 tekens.'; } else if (this.password.length < 12) { @@ -30,35 +33,31 @@ export default Controller.extend({ ) { return 'De 2 wachtwoorden komen niet overeen.'; } - return false; - }), + } - queryParams: ['activation_token'], - - actions: { - async resetPassword() { - const response = await this.fetch.post( - `/users/${this.model.id}/activate_account`, - { - body: { - password: this.password, - passwordConfirmation: this.passwordConfirmation, - activationToken: this.activation_token, - }, - } - ); - - if (response.ok) { - this.set('successMessage', 'Wachtwoord is aangepast'); - run.later(() => { - this.transitionToRoute('login'); - }, 2000); - } else if (isNotFoundResponse(response)) { - this.set('errorMessage', 'Token niet geldig, vraag een nieuwe aan'); - } else { - this.set('errorMessage', 'Er ging iets mis...'); + @action + async resetPassword() { + const response = await this.fetch.post( + `/users/${this.model.id}/activate_account`, + { + body: { + password: this.password, + passwordConfirmation: this.passwordConfirmation, + activationToken: this.activation_token, + }, } - }, - }, -}); + ); + + if (response.ok) { + this.successMessage = 'Wachtwoord is aangepast'; + run.later(() => { + this.transitionToRoute('login'); + }, 2000); + } else if (isNotFoundResponse(response)) { + this.errorMessage = 'Token niet geldig, vraag een nieuwe aan'; + } else { + this.errorMessage = 'Er ging iets mis...'; + } + } +} diff --git a/app/controllers/users/forgot-password.js b/app/controllers/users/forgot-password.js index a911e445d..266bd3449 100644 --- a/app/controllers/users/forgot-password.js +++ b/app/controllers/users/forgot-password.js @@ -1,26 +1,24 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; -export default Controller.extend({ - fetch: service(), +export default class ForgotPasswordController extends Controller { + @service fetch; + queryParams = ['email']; + @tracked email = null; + @tracked successMessage; + @tracked errorMessage; + @action + async forgotPassword() { + const response = await this.fetch.post('/users/reset_password', { + body: { email: this.email }, + }); - queryParams: ['email'], - email: null, - - actions: { - async forgotPassword() { - const response = await this.fetch.post('/users/reset_password', { - body: { email: this.email }, - }); - - if (response.ok) { - this.set( - 'successMessage', - 'Je ontvangt een e-mail met verdere instructies' - ); - } else { - this.set('errorMessage', 'Er ging iets mis, probeer het nog een keer'); - } - }, - }, -}); + if (response.ok) { + this.successMessage = 'Je ontvangt een e-mail met verdere instructies'; + } else { + this.errorMessage = 'Er ging iets mis, probeer het nog een keer'; + } + } +} diff --git a/app/controllers/users/resend-activation.js b/app/controllers/users/resend-activation.js index f04410a54..66aa33360 100644 --- a/app/controllers/users/resend-activation.js +++ b/app/controllers/users/resend-activation.js @@ -1,23 +1,24 @@ 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: { - async resendActivation() { - this.set('errorMessage', null); - const response = await this.fetch.post( - `/users/${this.model.id}/resend_activation_mail` - ); +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; - if (response.ok) { - this.transitionToRoute('users.show', this.model); - } else if (isNotFoundResponse) { - this.set('errorMessage', 'Deze gebruiker is al geactiveerd!'); - } else { - this.set('errorMessage', 'Er is wat fout gegaan.'); - } - }, - }, -}); +export default class ResendActivationController extends Controller { + @service fetch; + @tracked errorMessage; + @action + async resendActivation() { + this.errorMessage = null; + const response = await this.fetch.post( + `/users/${this.model.id}/resend_activation_mail` + ); + if (response.ok) { + this.transitionToRoute('users.show', this.model); + } else if (isNotFoundResponse(response)) { + this.errorMessage = 'Deze gebruiker is al geactiveerd!'; + } else { + this.errorMessage = 'Er is wat fout gegaan.'; + } + } +} diff --git a/app/controllers/users/webdav.js b/app/controllers/users/webdav.js index 3f49ef15e..76c45232f 100644 --- a/app/controllers/users/webdav.js +++ b/app/controllers/users/webdav.js @@ -1,30 +1,25 @@ import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; -import { computed } from '@ember/object'; +import { action } from '@ember/object'; -export default Controller.extend({ - session: service(), - fetch: service(), - webDavEnabled: computed('session.currentUser.webdavSecretKey', function () { +export default class WebdavController extends Controller { + @service session; + @service fetch; + get webDavEnabled() { return this.session.currentUser.webdavSecretKey !== null; - }), - webDavURL: computed( - 'session.currentUser.webdavSecretKey', - 'session.currentUser.id', - function () { - return `${window.location.origin}/webdav/${this.session.currentUser.id}/${this.session.currentUser.webdavSecretKey}/contacts`; - } - ), + } - actions: { - generateWebdavSecret() { - let user = this.session.currentUser; + get webDavURL() { + return `${window.location.origin}/webdav/${this.session.currentUser.id}/${this.session.currentUser.webdavSecretKey}/contacts`; + } - return this.fetch - .fetch(`/users/${user.id}/activate_webdav`, { method: 'POST' }) - .then(function () { - user.reload(); - }); - }, - }, -}); + @action + async generateWebdavSecret() { + let user = this.session.currentUser; + + await this.fetch.fetch(`/users/${user.id}/activate_webdav`, { + method: 'POST', + }); + user.reload(); + } +} diff --git a/app/models/debit/collection.js b/app/models/debit/collection.js index 463eac4ed..88d1bfce5 100644 --- a/app/models/debit/collection.js +++ b/app/models/debit/collection.js @@ -26,7 +26,9 @@ export default class Collection extends Model { }); if (failedTransactions) { const prefix = failedTransactions > 1 ? 'zijn' : 'is'; - throw `Er ${prefix} ${failedTransactions} transacties niet juist opgeslagen`; + throw new Error( + `Er ${prefix} ${failedTransactions} transacties niet juist opgeslagen` + ); } } } diff --git a/app/routes/application/application.js b/app/routes/application/application.js index 399a33741..7ab64e637 100644 --- a/app/routes/application/application.js +++ b/app/routes/application/application.js @@ -1,6 +1,5 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; -import Error from '@ember/error'; export class ApplicationRoute extends Route { @service session; diff --git a/app/templates/activities/generate-alias.hbs b/app/templates/activities/generate-alias.hbs index 2a28a1c89..ca453dd43 100644 --- a/app/templates/activities/generate-alias.hbs +++ b/app/templates/activities/generate-alias.hbs @@ -1,13 +1,13 @@
- {{#if alias}} + {{#if this.alias}}

Je mailalias is aangemaakt!

Je kunt alle ingeschrevenen mailen via - {{alias}}.
+ {{this.alias}}.
Dit alias verloopt op - {{moment-format expires_at 'DD-MM-YYYY [om] HH:mm'}}. + {{moment-format this.expiresAt 'DD-MM-YYYY [om] HH:mm'}}.

{{else}}

@@ -21,7 +21,7 @@ {{/if}}

- {{#unless alias}} + {{#unless this.alias}}
Annuleren @@ -153,24 +154,23 @@
- {{#if (eq currentTab 'form')}} + {{#if (eq this.currentTab 'form')}}
Inschrijvingen voor {{@model.title}}
- {{form/responses-table - @model.form - sortedResponses - showAllergyInfo=showAllergyInfo - showCheckbox=showCheckbox + + {{else if (eq this.currentTab 'consumptionList')}}
Streeplijst voor {{@model.title}}
{{/if}}
diff --git a/app/templates/activities/show.hbs b/app/templates/activities/show.hbs index 7d8e5eab6..36b55dea3 100644 --- a/app/templates/activities/show.hbs +++ b/app/templates/activities/show.hbs @@ -1,25 +1,24 @@ - -{{cards/activity-card @model.activity moreInfo=true}} + {{#if @model.form}} {{#if (can 'create form/responses')}} {{#if @model.currentUserResponse.completed}} - {{form/response/response-completed-alert @model.form}} - {{else if canSubmitResponse}} - {{form/response/response-card - @model.form - @model.currentUserResponse - data-test-form-response-card=@model.form.id - }} + + {{else if this.canSubmitResponse}} + {{else}} - {{form/response/form-closed-alert @model.form}} + {{/if}} {{/if}} {{#if (can 'show form/responses')}} - {{form/responses-table-card @model.form}} + {{/if}} {{/if}} \ No newline at end of file diff --git a/app/templates/articles/show.hbs b/app/templates/articles/show.hbs index c591fbf3a..623e9a602 100644 --- a/app/templates/articles/show.hbs +++ b/app/templates/articles/show.hbs @@ -2,9 +2,9 @@ -{{cards/article-card model}} + -{{#if (can 'show article comments of article' model)}} +{{#if (can 'show article comments of article' @model)}}
{{capitalize (t 'model.articleComment.name.other')}}
@@ -13,10 +13,10 @@
- {{#each sortedArticleComments as |comment|}} + {{#each this.sortedArticleComments as |comment|}} {{#unless comment.isDeleted}}
- {{user-comment comment}} +
{{/unless}} {{/each}} @@ -33,7 +33,7 @@ {{/if}}
- {{#each groupedTransactions as |transactionGroup|}} + {{#each this.groupedTransactions as |transactionGroup|}}
{{transactionGroup.user.fullName}}
diff --git a/app/templates/error.hbs b/app/templates/error.hbs index 0d357f6a4..70ae04c50 100644 --- a/app/templates/error.hbs +++ b/app/templates/error.hbs @@ -1,7 +1,7 @@ -{{#if showNotFound}} +{{#if this.showNotFound}} {{else}} - {{#if showStatic}} + {{#if this.showStatic}} {{else}}
@@ -12,7 +12,7 @@

- {{message}} + {{this.message}}

Herladen
@@ -23,7 +23,7 @@

- {{model}} + {{@model}}


diff --git a/app/templates/mail-moderations/accept.hbs b/app/templates/mail-moderations/accept.hbs index d4a6c4ac1..ee67246f2 100644 --- a/app/templates/mail-moderations/accept.hbs +++ b/app/templates/mail-moderations/accept.hbs @@ -6,13 +6,13 @@ Nee -{{#if errorMessage}} +{{#if this.errorMessage}} diff --git a/app/templates/mail-moderations/reject.hbs b/app/templates/mail-moderations/reject.hbs index 0de4d1c5e..ec4e02de8 100644 --- a/app/templates/mail-moderations/reject.hbs +++ b/app/templates/mail-moderations/reject.hbs @@ -4,12 +4,12 @@ Nee -{{#if errorMessage}} +{{#if this.errorMessage}}
{{this.errorMessage}}
{{/if}} \ No newline at end of file diff --git a/app/templates/oauth/authorize.hbs b/app/templates/oauth/authorize.hbs index cff04c262..73d002dba 100644 --- a/app/templates/oauth/authorize.hbs +++ b/app/templates/oauth/authorize.hbs @@ -7,14 +7,14 @@
- {{#if clientName}} + {{#if this.clientName}}

Door op "Inloggen" te klikken log je met je C.S.V. Alpha account in bij de volgende applicatie:

    -
  • {{clientName}}
  • +
  • {{this.clientName}}

Deze applicatie krijgt daarmee nu en in de toekomst toegang tot @@ -22,7 +22,7 @@ adres en in welke groepen je zit.

- {{#if errorMessage}} + {{#if this.errorMessage}}