From 78fb9f8f768093b1a41a5af561515efcf33a9f94 Mon Sep 17 00:00:00 2001 From: Linda Joy Date: Wed, 14 Apr 2021 10:23:49 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9BFolders-Same-name-Documents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The user is able to create folders with the same name, under the same folder, in the Documents section --- .../add-folder-modal.component.html | 18 ++++++--- .../add-folder-modal.component.scss | 5 +++ .../add-folder-modal.component.ts | 38 ++++++++++++++----- .../file-manager-breadcrumbs.component.ts | 13 +++++-- 4 files changed, 55 insertions(+), 19 deletions(-) diff --git a/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.html b/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.html index d587907..4602d93 100644 --- a/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.html +++ b/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.html @@ -1,15 +1,21 @@
Add folder
- -
' - +
+
+ + ' Name - -
-
+ +
+ diff --git a/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.scss b/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.scss index e69de29..234e289 100644 --- a/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.scss +++ b/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.scss @@ -0,0 +1,5 @@ +.errorMessage { + font-size: 13px; + padding-right: 45px; + margin-top: -10px; +} \ No newline at end of file diff --git a/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.ts b/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.ts index c7fa6e4..e8c37f7 100644 --- a/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.ts +++ b/ngfire/files/src/lib/file-manager/components/add-folder-modal/add-folder-modal.component.ts @@ -1,5 +1,6 @@ import {Component, EventEmitter, OnInit, Input, Output, Inject } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { FormGroup, FormBuilder, Validators, ValidationErrors, ControlContainer } from '@angular/forms'; +import { ValidatorFn, AbstractControl } from '@angular/forms'; import * as _ from 'lodash'; import { Logger } from '@iote/bricks-angular'; @@ -18,29 +19,46 @@ export class AddFolderModalComponent implements OnInit // Form Data createFolderForm: FormGroup; - + constructor(private _fb: FormBuilder, private _dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) private _data: any, private _logger: Logger) {} - + ngOnInit() { this.createFolderForm = this._fb.group({ - name: ['', [Validators.required]] - }); - } + name: ['', [Validators.required, this.ValidateExisting(this._data.names) ]] + }, - // -- - // Create Bill + ); + + } + +// Create Bill createFolder(frm) { if(this.createFolderForm.valid) { - this._dialogRef.close(frm.name); + this._dialogRef.close(frm.name); } } -} + exitModal = () => this._dialogRef.close(); + + ValidateExisting(names: string[]): ValidatorFn + { + return (control: AbstractControl): { [key: string]: any } | null => { + const returnVal = names.includes (control.value) + ? { nameExists: true} as ValidationErrors + : null; + + return returnVal + } + } + get name(){ + return this.createFolderForm.get('name'); + } + } diff --git a/ngfire/files/src/lib/file-manager/components/file-manager-breadcrumbs/file-manager-breadcrumbs.component.ts b/ngfire/files/src/lib/file-manager/components/file-manager-breadcrumbs/file-manager-breadcrumbs.component.ts index 047c09b..c5873a7 100644 --- a/ngfire/files/src/lib/file-manager/components/file-manager-breadcrumbs/file-manager-breadcrumbs.component.ts +++ b/ngfire/files/src/lib/file-manager/components/file-manager-breadcrumbs/file-manager-breadcrumbs.component.ts @@ -8,6 +8,10 @@ import { MatDialog } from '@angular/material/dialog'; import { AddFolderModalComponent } from '../add-folder-modal/add-folder-modal.component'; import { DELETE_DIALOG_WIDTH } from '@iote/ui-workflows'; import { SubSink } from 'subsink'; +import { ChildActivationEnd } from '@angular/router'; + +import { BehaviorSubject } from 'rxjs'; + @Component({ selector: 'ngfire-file-manager-breadcrumbs', @@ -44,10 +48,13 @@ export class FileManagerCrumbComponent implements OnInit, OnDestroy filesSelected = (files: any) => this.curr.upload(files.target.files).subscribe(); addFolder() { - this._sbS.sink = this._dialog.open(AddFolderModalComponent, { width: DELETE_DIALOG_WIDTH }) + const names: string[] = this.curr.children.map(child => child.name) + this._sbS.sink = this._dialog.open(AddFolderModalComponent, + {width: DELETE_DIALOG_WIDTH, data: { names }}) .afterClosed() - .subscribe(name => - this._sbS.sink = this.curr.addFolder(name).subscribe()); + .subscribe( + name => + this._sbS.sink = this.curr.addFolder(name).subscribe()); } private _toCrumbs(position: FolderIterator, first?: boolean) : FileManagerCrumb[] From f4e4dd3e2a658af1aabb534d9a7047c6de35b215 Mon Sep 17 00:00:00 2001 From: Linda Joy Date: Wed, 14 Apr 2021 11:02:42 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9Blibs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved toastr from auth-service on reset password to component level --- ngfire/angular/src/lib/auth/services/auth.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngfire/angular/src/lib/auth/services/auth.service.ts b/ngfire/angular/src/lib/auth/services/auth.service.ts index 015dacc..69f31b6 100644 --- a/ngfire/angular/src/lib/auth/services/auth.service.ts +++ b/ngfire/angular/src/lib/auth/services/auth.service.ts @@ -35,8 +35,8 @@ export class AuthService { firebase.auth().languageCode = langCode; return firebase.auth() .sendPasswordResetEmail( email ) - .then(() => this._toastService.doSimpleToast('A password reset link has been sent to your email address.')) - .catch(() => this._toastService.doSimpleToast('An error occurred while attempting to reset your password. Please contact support.')); + // .then(() => this._toastService.doSimpleToast('A password reset link has been sent to your email address.')) + // .catch(() => this._toastService.doSimpleToast('An error occurred while attempting to reset your password. Please contact support.')); } public createUserWithEmailAndPassword(displayName: string, email: string, password: string, userProfile: UserProfile, roles: Roles)