Browse Source

update: account package for the latest upgrade (state management and html properties)

pull/25690/head
sumeyye 2 months ago
parent
commit
58e43f7844
  1. 2
      npm/ng-packs/packages/account/project.json
  2. 10
      npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.html
  3. 8
      npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts
  4. 2
      npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.html
  5. 8
      npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.ts
  6. 4
      npm/ng-packs/packages/account/src/lib/components/login/login.component.html
  7. 10
      npm/ng-packs/packages/account/src/lib/components/login/login.component.ts
  8. 12
      npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html
  9. 8
      npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.ts
  10. 9
      npm/ng-packs/packages/account/src/lib/components/register/register.component.html
  11. 8
      npm/ng-packs/packages/account/src/lib/components/register/register.component.ts
  12. 9
      npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.html
  13. 10
      npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts

2
npm/ng-packs/packages/account/project.json

@ -31,7 +31,7 @@
"executor": "@nx/vitest:test", "executor": "@nx/vitest:test",
"outputs": ["{options.reportsDirectory}"], "outputs": ["{options.reportsDirectory}"],
"options": { "options": {
"reportsDirectory": "../../coverage/packages/account" "reportsDirectory": "{projectRoot}/../../coverage/packages/account"
} }
} }
} }

10
npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.html

@ -1,4 +1,10 @@
<form [formGroup]="form" (ngSubmit)="onSubmit()" [mapErrorsFn]="mapErrorsFn" [validateOnSubmit]="true" class="abp-md-form"> <form
[formGroup]="form"
(ngSubmit)="onSubmit()"
[mapErrorsFn]="mapErrorsFn"
[validateOnSubmit]="true"
class="abp-md-form"
>
@if (!hideCurrentPassword) { @if (!hideCurrentPassword) {
<div class="mb-3 form-group"> <div class="mb-3 form-group">
<label for="current-password" class="form-label">{{ <label for="current-password" class="form-label">{{
@ -45,7 +51,7 @@
iconClass="fa fa-check" iconClass="fa fa-check"
buttonClass="btn btn-primary color-white" buttonClass="btn btn-primary color-white"
buttonType="submit" buttonType="submit"
[loading]="inProgress" [loading]="inProgress()"
[disabled]="form?.invalid" [disabled]="form?.invalid"
>{{ 'AbpIdentity::Save' | abpLocalization }}</abp-button >{{ 'AbpIdentity::Save' | abpLocalization }}</abp-button
> >

8
npm/ng-packs/packages/account/src/lib/components/change-password/change-password.component.ts

@ -1,6 +1,6 @@
import { ProfileService } from '@abp/ng.account.core/proxy'; import { ProfileService } from '@abp/ng.account.core/proxy';
import { ButtonComponent, getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; import { ButtonComponent, getPasswordValidators, ToasterService } from '@abp/ng.theme.shared';
import { Component, Injector, OnInit, inject } from '@angular/core'; import { Component, Injector, OnInit, inject, signal } from '@angular/core';
import { import {
ReactiveFormsModule, ReactiveFormsModule,
UntypedFormBuilder, UntypedFormBuilder,
@ -40,7 +40,7 @@ export class ChangePasswordComponent
form!: UntypedFormGroup; form!: UntypedFormGroup;
inProgress?: boolean; readonly inProgress = signal(false);
hideCurrentPassword?: boolean; hideCurrentPassword?: boolean;
@ -81,13 +81,13 @@ export class ChangePasswordComponent
onSubmit() { onSubmit() {
if (this.form.invalid) return; if (this.form.invalid) return;
this.inProgress = true; this.inProgress.set(true);
this.profileService this.profileService
.changePassword({ .changePassword({
...(!this.hideCurrentPassword && { currentPassword: this.form.get('password')?.value }), ...(!this.hideCurrentPassword && { currentPassword: this.form.get('password')?.value }),
newPassword: this.form.get('newPassword')?.value, newPassword: this.form.get('newPassword')?.value,
}) })
.pipe(finalize(() => (this.inProgress = false))) .pipe(finalize(() => this.inProgress.set(false)))
.subscribe({ .subscribe({
next: () => { next: () => {
this.form.reset(); this.form.reset();

2
npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.html

@ -13,7 +13,7 @@
<abp-button <abp-button
class="d-block" class="d-block"
buttonClass="mt-2 mb-3 btn btn-primary btn-block" buttonClass="mt-2 mb-3 btn btn-primary btn-block"
[loading]="inProgress" [loading]="inProgress()"
buttonType="submit" buttonType="submit"
[disabled]="form?.invalid" [disabled]="form?.invalid"
> >

8
npm/ng-packs/packages/account/src/lib/components/forgot-password/forgot-password.component.ts

@ -1,5 +1,5 @@
import { AccountService } from '@abp/ng.account.core/proxy'; import { AccountService } from '@abp/ng.account.core/proxy';
import { Component, inject } from '@angular/core'; import { Component, inject, signal } from '@angular/core';
import { import {
ReactiveFormsModule, ReactiveFormsModule,
UntypedFormBuilder, UntypedFormBuilder,
@ -29,7 +29,7 @@ export class ForgotPasswordComponent {
form: UntypedFormGroup; form: UntypedFormGroup;
inProgress?: boolean; readonly inProgress = signal(false);
isEmailSent = false; isEmailSent = false;
@ -42,14 +42,14 @@ export class ForgotPasswordComponent {
onSubmit() { onSubmit() {
if (this.form.invalid) return; if (this.form.invalid) return;
this.inProgress = true; this.inProgress.set(true);
this.accountService this.accountService
.sendPasswordResetCode({ .sendPasswordResetCode({
email: this.form.get('email')?.value, email: this.form.get('email')?.value,
appName: 'Angular', appName: 'Angular',
}) })
.pipe(finalize(() => (this.inProgress = false))) .pipe(finalize(() => this.inProgress.set(false)))
.subscribe(() => { .subscribe(() => {
this.isEmailSent = true; this.isEmailSent = true;
}); });

4
npm/ng-packs/packages/account/src/lib/components/login/login.component.html

@ -7,7 +7,7 @@
}}</a> }}</a>
</strong> </strong>
} }
<form [formGroup]="form" (ngSubmit)="onSubmit()" validateOnSubmit class="mt-4"> <form [formGroup]="form" (ngSubmit)="onSubmit()" [validateOnSubmit]="true" class="mt-4">
<div class="mb-3 form-group"> <div class="mb-3 form-group">
<label for="login-input-user-name-or-email-address" class="form-label">{{ <label for="login-input-user-name-or-email-address" class="form-label">{{
'AbpAccount::UserNameOrEmailAddress' | abpLocalization 'AbpAccount::UserNameOrEmailAddress' | abpLocalization
@ -56,7 +56,7 @@
</div> </div>
<abp-button <abp-button
[loading]="inProgress" [loading]="inProgress()"
buttonType="submit" buttonType="submit"
name="Action" name="Action"
buttonClass="btn-block btn-lg mt-3 btn btn-primary" buttonClass="btn-block btn-lg mt-3 btn btn-primary"

10
npm/ng-packs/packages/account/src/lib/components/login/login.component.ts

@ -1,4 +1,4 @@
import { Component, Injector, OnInit, inject } from '@angular/core'; import { Component, Injector, OnInit, inject, signal } from '@angular/core';
import { import {
ReactiveFormsModule, ReactiveFormsModule,
UntypedFormBuilder, UntypedFormBuilder,
@ -42,7 +42,7 @@ export class LoginComponent implements OnInit {
form!: UntypedFormGroup; form!: UntypedFormGroup;
inProgress?: boolean; readonly inProgress = signal(false);
isSelfRegistrationEnabled = true; isSelfRegistrationEnabled = true;
@ -71,7 +71,7 @@ export class LoginComponent implements OnInit {
onSubmit() { onSubmit() {
if (this.form.invalid) return; if (this.form.invalid) return;
this.inProgress = true; this.inProgress.set(true);
const { username, password, rememberMe } = this.form.value; const { username, password, rememberMe } = this.form.value;
@ -88,9 +88,9 @@ export class LoginComponent implements OnInit {
'', '',
{ life: 7000 }, { life: 7000 },
); );
return throwError(err); return throwError(() => err);
}), }),
finalize(() => (this.inProgress = false)), finalize(() => this.inProgress.set(false)),
) )
.subscribe(); .subscribe();
} }

12
npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html

@ -1,14 +1,14 @@
@if (form) { @if (form) {
<form [formGroup]="form" (ngSubmit)="submit()" validateOnSubmit class="abp-md-form"> <form [formGroup]="form" (ngSubmit)="submit()" [validateOnSubmit]="true" class="abp-md-form">
<abp-extensible-form [selectedRecord]="selected"></abp-extensible-form> <abp-extensible-form [selectedRecord]="selected" />
<abp-button <abp-button
buttonType="submit" buttonType="submit"
iconClass="fa fa-check" iconClass="fa fa-check"
buttonClass="btn btn-primary color-white" buttonClass="btn btn-primary color-white"
[loading]="inProgress" [loading]="inProgress()"
>
{{ 'AbpIdentity::Save' | abpLocalization }}</abp-button
> >
{{ 'AbpIdentity::Save' | abpLocalization }}
</abp-button>
</form> </form>
} }

8
npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.ts

@ -5,7 +5,7 @@ import {
ConfirmationService, ConfirmationService,
ToasterService, ToasterService,
} from '@abp/ng.theme.shared'; } from '@abp/ng.theme.shared';
import { Component, inject, Injector, OnInit } from '@angular/core'; import { Component, inject, Injector, OnInit, signal } from '@angular/core';
import { ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { finalize, filter } from 'rxjs/operators'; import { finalize, filter } from 'rxjs/operators';
import { Account } from '../../models/account'; import { Account } from '../../models/account';
@ -61,7 +61,7 @@ export class PersonalSettingsComponent
form!: UntypedFormGroup; form!: UntypedFormGroup;
inProgress?: boolean; readonly inProgress = signal(false);
buildForm() { buildForm() {
this.selected = this.manageProfileState.getProfile(); this.selected = this.manageProfileState.getProfile();
@ -80,10 +80,10 @@ export class PersonalSettingsComponent
if (this.form.invalid) return; if (this.form.invalid) return;
const isLogOutConfirmMessageVisible = this.isLogoutConfirmMessageActive(); const isLogOutConfirmMessageVisible = this.isLogoutConfirmMessageActive();
const isRefreshTokenExists = this.authService.getRefreshToken(); const isRefreshTokenExists = this.authService.getRefreshToken();
this.inProgress = true; this.inProgress.set(true);
this.profileService this.profileService
.update(this.form.value) .update(this.form.value)
.pipe(finalize(() => (this.inProgress = false))) .pipe(finalize(() => this.inProgress.set(false)))
.subscribe(profile => { .subscribe(profile => {
this.manageProfileState.setProfile(profile); this.manageProfileState.setProfile(profile);
this.configState.refreshAppState(); this.configState.refreshAppState();

9
npm/ng-packs/packages/account/src/lib/components/register/register.component.html

@ -6,12 +6,7 @@
}}</a> }}</a>
</strong> </strong>
@if (isSelfRegistrationEnabled) { @if (isSelfRegistrationEnabled) {
<form <form [formGroup]="form" (ngSubmit)="onSubmit()" [validateOnSubmit]="true" class="mt-4">
[formGroup]="form"
(ngSubmit)="onSubmit()"
validateOnSubmit
class="mt-4"
>
<div class="mb-3 form-group"> <div class="mb-3 form-group">
<label for="input-user-name" class="form-label">{{ <label for="input-user-name" class="form-label">{{
'AbpAccount::UserName' | abpLocalization 'AbpAccount::UserName' | abpLocalization
@ -47,7 +42,7 @@
/> />
</div> </div>
<abp-button <abp-button
[loading]="inProgress" [loading]="inProgress()"
buttonType="submit" buttonType="submit"
name="Action" name="Action"
buttonClass="btn-block btn-lg mt-3 btn btn-primary" buttonClass="btn-block btn-lg mt-3 btn btn-primary"

8
npm/ng-packs/packages/account/src/lib/components/register/register.component.ts

@ -6,7 +6,7 @@ import {
LocalizationPipe, LocalizationPipe,
} from '@abp/ng.core'; } from '@abp/ng.core';
import { ButtonComponent, getPasswordValidators, ToasterService } from '@abp/ng.theme.shared'; import { ButtonComponent, getPasswordValidators, ToasterService } from '@abp/ng.theme.shared';
import { Component, Injector, OnInit, inject } from '@angular/core'; import { Component, Injector, OnInit, inject, signal } from '@angular/core';
import { import {
ReactiveFormsModule, ReactiveFormsModule,
UntypedFormBuilder, UntypedFormBuilder,
@ -44,7 +44,7 @@ export class RegisterComponent implements OnInit {
form!: UntypedFormGroup; form!: UntypedFormGroup;
inProgress?: boolean; readonly inProgress = signal(false);
isSelfRegistrationEnabled = true; isSelfRegistrationEnabled = true;
@ -84,7 +84,7 @@ export class RegisterComponent implements OnInit {
onSubmit() { onSubmit() {
if (this.form.invalid) return; if (this.form.invalid) return;
this.inProgress = true; this.inProgress.set(true);
const newUser = { const newUser = {
userName: this.form.get('username')?.value, userName: this.form.get('username')?.value,
@ -114,7 +114,7 @@ export class RegisterComponent implements OnInit {
return throwError(err); return throwError(err);
}), }),
finalize(() => (this.inProgress = false)), finalize(() => this.inProgress.set(false)),
) )
.subscribe(); .subscribe();
} }

9
npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.html

@ -1,7 +1,12 @@
<h4>{{ 'AbpAccount::ResetPassword' | abpLocalization }}</h4> <h4>{{ 'AbpAccount::ResetPassword' | abpLocalization }}</h4>
@if (!isPasswordReset) { @if (!isPasswordReset) {
<form [formGroup]="form" [mapErrorsFn]="mapErrorsFn" (ngSubmit)="onSubmit()" validateOnSubmit> <form
[formGroup]="form"
[mapErrorsFn]="mapErrorsFn"
(ngSubmit)="onSubmit()"
[validateOnSubmit]="true"
>
<p>{{ 'AbpAccount::ResetPassword_Information' | abpLocalization }}</p> <p>{{ 'AbpAccount::ResetPassword_Information' | abpLocalization }}</p>
<div class="mb-3 form-group"> <div class="mb-3 form-group">
<label for="input-password" class="form-label">{{ <label for="input-password" class="form-label">{{
@ -28,7 +33,7 @@
<abp-button <abp-button
buttonType="submit" buttonType="submit"
buttonClass="me-2 btn btn-primary" buttonClass="me-2 btn btn-primary"
[loading]="inProgress" [loading]="inProgress()"
(click)="onSubmit()" (click)="onSubmit()"
> >
{{ 'AbpAccount::Submit' | abpLocalization }} {{ 'AbpAccount::Submit' | abpLocalization }}

10
npm/ng-packs/packages/account/src/lib/components/reset-password/reset-password.component.ts

@ -1,6 +1,6 @@
import { AccountService } from '@abp/ng.account.core/proxy'; import { AccountService } from '@abp/ng.account.core/proxy';
import { ButtonComponent, getPasswordValidators } from '@abp/ng.theme.shared'; import { ButtonComponent, getPasswordValidators } from '@abp/ng.theme.shared';
import { Component, Injector, OnInit, inject } from '@angular/core'; import { Component, Injector, OnInit, inject, signal } from '@angular/core';
import { import {
ReactiveFormsModule, ReactiveFormsModule,
UntypedFormBuilder, UntypedFormBuilder,
@ -34,7 +34,7 @@ export class ResetPasswordComponent implements OnInit {
form!: UntypedFormGroup; form!: UntypedFormGroup;
inProgress = false; readonly inProgress = signal(false);
isPasswordReset = false; isPasswordReset = false;
@ -63,9 +63,9 @@ export class ResetPasswordComponent implements OnInit {
} }
onSubmit() { onSubmit() {
if (this.form.invalid || this.inProgress) return; if (this.form.invalid || this.inProgress()) return;
this.inProgress = true; this.inProgress.set(true);
this.accountService this.accountService
.resetPassword({ .resetPassword({
@ -73,7 +73,7 @@ export class ResetPasswordComponent implements OnInit {
resetToken: this.form.get('resetToken')?.value, resetToken: this.form.get('resetToken')?.value,
password: this.form.get('password')?.value, password: this.form.get('password')?.value,
}) })
.pipe(finalize(() => (this.inProgress = false))) .pipe(finalize(() => this.inProgress.set(false)))
.subscribe(() => { .subscribe(() => {
this.isPasswordReset = true; this.isPasswordReset = true;
}); });

Loading…
Cancel
Save