From 50575ffd687ceaf067076bf3b531861362c8c967 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Wed, 5 Jan 2022 00:13:08 +0100 Subject: [PATCH] feat: flatten and reorder after all --- src/models/abstractModel.ts | 9 +++---- src/models/caldavToken.js | 15 ----------- src/models/caldavToken.ts | 14 ++++++++++ src/views/user/settings/Caldav.vue | 42 +++++++++++------------------- 4 files changed, 32 insertions(+), 48 deletions(-) delete mode 100644 src/models/caldavToken.js create mode 100644 src/models/caldavToken.ts diff --git a/src/models/abstractModel.ts b/src/models/abstractModel.ts index 202ccde9..fbf074e2 100644 --- a/src/models/abstractModel.ts +++ b/src/models/abstractModel.ts @@ -5,15 +5,13 @@ export default class AbstractModel { /** * The max right the user has on this object, as returned by the x-max-right header from the api. - * @type {number|null} */ - maxRight = null + maxRight: number | null = null /** * The abstract constructor takes an object and merges its data with the default data of this model. - * @param data */ - constructor(data) { + constructor(data : Object = {}) { data = objectToCamelCase(data) // Put all data in our model while overriding those with a value of null or undefined with their defaults @@ -26,9 +24,8 @@ export default class AbstractModel { /** * Default attributes that define the "empty" state. - * @return {{}} */ - defaults() { + defaults(): Object { return {} } } \ No newline at end of file diff --git a/src/models/caldavToken.js b/src/models/caldavToken.js deleted file mode 100644 index 2d7a4ebd..00000000 --- a/src/models/caldavToken.js +++ /dev/null @@ -1,15 +0,0 @@ -import AbstractModel from './abstractModel' - -export default class CaldavTokenModel extends AbstractModel { - constructor(data) { - super(data) - this.created = new Date(this.created) - } - - defaults() { - return { - id: 0, - created: null, - } - } -} \ No newline at end of file diff --git a/src/models/caldavToken.ts b/src/models/caldavToken.ts new file mode 100644 index 00000000..9ecf2232 --- /dev/null +++ b/src/models/caldavToken.ts @@ -0,0 +1,14 @@ +import AbstractModel from './abstractModel' + +export default class CaldavTokenModel extends AbstractModel { + id = 0 + created : undefined | Date = undefined + + constructor(data? : Object) { + super(data) + + if (this.created) { + this.created = new Date(this.created) + } + } +} \ No newline at end of file diff --git a/src/views/user/settings/Caldav.vue b/src/views/user/settings/Caldav.vue index 6c663d8a..ec68c8a4 100644 --- a/src/views/user/settings/Caldav.vue +++ b/src/views/user/settings/Caldav.vue @@ -67,7 +67,7 @@