From a7ec8f8aa15525ff9b17480b5dedf24c304d3fab Mon Sep 17 00:00:00 2001 From: _Bastler Date: Wed, 6 Oct 2021 11:13:46 +0200 Subject: [PATCH] user settings --- src/app/pages/settings/settings.page.html | 72 ++++++++++------ src/app/pages/settings/settings.page.scss | 19 +++- src/app/pages/settings/settings.page.ts | 23 +++++ src/app/pages/submission/submission.page.html | 86 ++++++++++--------- src/app/pages/submission/submission.page.scss | 17 ++++ src/app/pages/user/user.page.html | 4 + src/styles.scss | 5 -- 7 files changed, 151 insertions(+), 75 deletions(-) diff --git a/src/app/pages/settings/settings.page.html b/src/app/pages/settings/settings.page.html index 3ba2b6f..88ddb6a 100644 --- a/src/app/pages/settings/settings.page.html +++ b/src/app/pages/settings/settings.page.html @@ -1,28 +1,44 @@ -
- - - - - - - - - {{'settings.email.error' | i18n}} - - - - - - {{'settings.about.error' | i18n}} - - - - - - {{'settings.success' | i18n}} - - - -
\ No newline at end of file +
+
+ + + {{user.username}} + + + + {{'settings.email.error' | i18n}} + + + + + + {{'settings.about.error' | i18n}} + + + +

{{'settings.pagesettings' | i18n}}

+ + + + + {{'settings.gravity.hint' | i18n}} + + + {{'settings.gravity.zero' | i18n}} + + +
+ + + {{'settings.success' | i18n}} + +
+
+
\ No newline at end of file diff --git a/src/app/pages/settings/settings.page.scss b/src/app/pages/settings/settings.page.scss index 9ee20ad..ebacda2 100644 --- a/src/app/pages/settings/settings.page.scss +++ b/src/app/pages/settings/settings.page.scss @@ -1,3 +1,20 @@ -mat-form-field { +mat-form-field, mat-slider { display: block; } + +form { + margin-left: 15px; + margin-bottom: 15px; + + @media screen and (min-width: 576px) { + max-width: 100%; + } + + @media screen and (min-width: 768px) { + max-width: 80%; + } + + @media screen and (min-width: 992px) { + max-width: 50%; + } +} \ No newline at end of file diff --git a/src/app/pages/settings/settings.page.ts b/src/app/pages/settings/settings.page.ts index 352e6d7..fb754f8 100644 --- a/src/app/pages/settings/settings.page.ts +++ b/src/app/pages/settings/settings.page.ts @@ -26,15 +26,20 @@ export class PageSettings implements OnInit { username: [ { disabled: true }, Validators.nullValidator ], email: [ '', Validators.nullValidator ], about: [ '', Validators.nullValidator ], + gravity: [ '', Validators.nullValidator ], }); this.form.get('username').disable(); this.userService.get().subscribe(user => { this.user = user; + if (!this.user.settings) { + this.user.settings = {}; + } this.form.get('username').setValue(this.user.username); this.form.get('email').setValue(this.user.email); this.form.get('about').setValue(this.user.about); + this.form.get('gravity').setValue(this.user.settings.gravity || this.user.metadata.defaultGravity); }) } @@ -42,6 +47,11 @@ export class PageSettings implements OnInit { return this.form.controls[ controlName ].errors != null; } + resetGravity(): void { + this.user.settings.gravity = null; + this.form.get('gravity').setValue(this.user.metadata.defaultGravity); + } + save(): void { if (this.working) { return; @@ -53,8 +63,21 @@ export class PageSettings implements OnInit { this.user.about = this.form.get('about').value; this.user.email = this.form.get('email').value; + if (!this.user.settings) { + this.user.settings = {}; + } + + if (this.form.get('gravity').value != this.user.metadata.defaultGravity && !this.user.settings.gravity) { + this.user.settings.gravity = this.form.get('gravity').value; + } else if (this.user.settings.gravity) { + this.user.settings.gravity = this.form.get('gravity').value; + } + this.userService.update(this.user).subscribe((data) => { this.user = data; + if (!this.user.settings) { + this.user.settings = {}; + } this.working = false; this.success = true; }, (error) => { diff --git a/src/app/pages/submission/submission.page.html b/src/app/pages/submission/submission.page.html index 3bdd329..3da82c0 100644 --- a/src/app/pages/submission/submission.page.html +++ b/src/app/pages/submission/submission.page.html @@ -1,44 +1,48 @@ -
- - -

{{'submission.info' | i18n}}

+
+ + + +

{{'submission.info' | i18n}}

- - - - {{'entryType.' + entryType + '.icon' | i18n}} {{'entryType.' + entryType | i18n}} - - - {{'entryType.' + entryType + '.icon' | i18n}} {{'entryType.' + entryType | i18n}} - - - + + + + {{'entryType.' + entryType + '.icon' | i18n}} {{'entryType.' + entryType | i18n}} + + + {{'entryType.' + entryType + '.icon' | i18n}} {{'entryType.' + entryType | i18n}} + + + - - - - {{'submission.url.error' | i18n}} - - + + + + {{'submission.url.error' | i18n}} + + - - - - {{'submission.title.error' | i18n}} - - - - - - {{'submission.text.error' | i18n}} - - -
- - - -
- - \ No newline at end of file + + + + {{'submission.title.error' | i18n}} + + + + + + {{'submission.text.error' | i18n}} + + + + + + + + +
\ No newline at end of file diff --git a/src/app/pages/submission/submission.page.scss b/src/app/pages/submission/submission.page.scss index 9ee20ad..0c0ddc6 100644 --- a/src/app/pages/submission/submission.page.scss +++ b/src/app/pages/submission/submission.page.scss @@ -1,3 +1,20 @@ mat-form-field { display: block; } + +form { + margin-left: 15px; + margin-bottom: 15px; + + @media screen and (min-width: 576px) { + max-width: 100%; + } + + @media screen and (min-width: 768px) { + max-width: 80%; + } + + @media screen and (min-width: 992px) { + max-width: 50%; + } +} \ No newline at end of file diff --git a/src/app/pages/user/user.page.html b/src/app/pages/user/user.page.html index 7436bfa..63c5917 100644 --- a/src/app/pages/user/user.page.html +++ b/src/app/pages/user/user.page.html @@ -2,6 +2,10 @@ + + + + diff --git a/src/styles.scss b/src/styles.scss index 10870f0..c13d265 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -102,11 +102,6 @@ ui-main { bottom: 0; } -mat-card { - max-width: 400px; - margin: 2em auto; -} - mat-form-field { display: block; }
{{'settings' | i18n}}
{{'user.username' | i18n}} {{user.username}}