Enhance icon picker UI and usability
This commit is contained in:
committed by
Aditya Chandel
parent
0f6141ad6c
commit
225824b6f5
@@ -9,7 +9,7 @@
|
||||
|
||||
<p-step-panel [value]="1">
|
||||
<ng-template #content let-activateCallback="activateCallback">
|
||||
<div class="flex flex-col justify-between w-full md:w-[40rem] max-w-[50rem] mx-auto">
|
||||
<div class="flex flex-col justify-between w-full md:w-[45rem] max-w-[50rem] mx-auto">
|
||||
|
||||
<div class="flex-grow flex items-center justify-center">
|
||||
<div class="grid grid-cols-[auto,1fr] gap-x-6 gap-y-10 border border-[var(--border-color)] p-6 rounded-xl w-full">
|
||||
@@ -46,7 +46,6 @@
|
||||
tooltipPosition="right"></i>
|
||||
</div>
|
||||
</div>
|
||||
<app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end pt-6">
|
||||
@@ -63,7 +62,7 @@
|
||||
|
||||
<p-step-panel [value]="2">
|
||||
<ng-template #content let-activateCallback="activateCallback">
|
||||
<div class="flex flex-col justify-between w-[24rem] md:w-[40rem] max-w-[50rem] mx-auto">
|
||||
<div class="flex flex-col justify-between w-[24rem] md:w-[45rem] max-w-[50rem] mx-auto">
|
||||
|
||||
<div class="flex-grow flex items-center justify-center">
|
||||
<div class="flex flex-col gap-6 border border-[var(--border-color)] px-2 py-4 md:p-6 rounded-xl w-full">
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DirectoryPickerComponent} from '../../../utilities/component/directory-picker/directory-picker.component';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Router} from '@angular/router';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component';
|
||||
import {Button} from 'primeng/button';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {Step, StepList, StepPanel, StepPanels, Stepper} from 'primeng/stepper';
|
||||
@@ -13,18 +12,16 @@ import {InputText} from 'primeng/inputtext';
|
||||
import {Library} from '../../model/library.model';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import { IconPickerService } from '../../../utilities/services/icon-picker.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-creator',
|
||||
standalone: true,
|
||||
templateUrl: './library-creator.component.html',
|
||||
imports: [Button, TableModule, StepPanel, IconPickerComponent, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip],
|
||||
imports: [Button, TableModule, StepPanel, FormsModule, InputText, Stepper, StepList, Step, StepPanels, ToggleSwitch, Tooltip],
|
||||
styleUrl: './library-creator.component.scss'
|
||||
})
|
||||
export class LibraryCreatorComponent implements OnInit {
|
||||
|
||||
@ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined;
|
||||
|
||||
chosenLibraryName: string = '';
|
||||
folders: string[] = [];
|
||||
selectedIcon: string | null = null;
|
||||
@@ -35,13 +32,13 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
directoryPickerDialogRef!: DynamicDialogRef<DirectoryPickerComponent>;
|
||||
watch: boolean = false;
|
||||
|
||||
private dialogService = inject(DialogService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dialogService = inject(DialogService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private libraryService = inject(LibraryService);
|
||||
private messageService = inject(MessageService);
|
||||
private router = inject(Router);
|
||||
|
||||
private libraryService = inject(LibraryService);
|
||||
private messageService = inject(MessageService);
|
||||
private router = inject(Router);
|
||||
private iconPicker = inject(IconPickerService);
|
||||
|
||||
ngOnInit(): void {
|
||||
const data = this.dynamicDialogConfig?.data;
|
||||
@@ -59,7 +56,7 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
openDirectoryPicker() {
|
||||
openDirectoryPicker(): void {
|
||||
this.directoryPickerDialogRef = this.dialogService.open(DirectoryPickerComponent, {
|
||||
header: 'Select Media Directory',
|
||||
modal: true,
|
||||
@@ -74,6 +71,14 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
openIconPicker(): void {
|
||||
this.iconPicker.open().subscribe(icon => {
|
||||
if (icon) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addFolder(folder: string): void {
|
||||
this.folders.push(folder);
|
||||
}
|
||||
@@ -82,17 +87,7 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
this.folders.splice(index, 1);
|
||||
}
|
||||
|
||||
openIconPicker() {
|
||||
if (this.iconPicker) {
|
||||
this.iconPicker.open();
|
||||
}
|
||||
}
|
||||
|
||||
onIconSelected(icon: string) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
|
||||
clearSelectedIcon() {
|
||||
clearSelectedIcon(): void {
|
||||
this.selectedIcon = null;
|
||||
}
|
||||
|
||||
@@ -104,7 +99,25 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
return this.folders.length > 0;
|
||||
}
|
||||
|
||||
createOrUpdateLibrary() {
|
||||
validateLibraryNameAndProceed(activateCallback: Function): void {
|
||||
let trimmedLibraryName = this.chosenLibraryName.trim();
|
||||
if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) {
|
||||
let exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName);
|
||||
if (exists) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Library Name Exists',
|
||||
detail: 'This library name is already taken.',
|
||||
});
|
||||
} else {
|
||||
activateCallback(2);
|
||||
}
|
||||
} else {
|
||||
activateCallback(2);
|
||||
}
|
||||
}
|
||||
|
||||
createOrUpdateLibrary(): void {
|
||||
if (this.mode === 'edit') {
|
||||
const library: Library = {
|
||||
name: this.chosenLibraryName,
|
||||
@@ -142,23 +155,4 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
validateLibraryNameAndProceed(activateCallback: Function) {
|
||||
let trimmedLibraryName = this.chosenLibraryName.trim();
|
||||
if (trimmedLibraryName && trimmedLibraryName != this.editModeLibraryName) {
|
||||
let exists = this.libraryService.doesLibraryExistByName(trimmedLibraryName);
|
||||
if (exists) {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Library Name Exists',
|
||||
detail: 'This library name is already taken.',
|
||||
});
|
||||
} else {
|
||||
activateCallback(2);
|
||||
}
|
||||
} else {
|
||||
activateCallback(2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="p-4 min-w-[26rem] min-h-[30rem] flex flex-col">
|
||||
|
||||
<div class="flex flex-col flex-grow">
|
||||
<!-- Dynamic shelves content -->
|
||||
|
||||
@for (shelf of (shelfState$ | async)?.shelves; track shelf) {
|
||||
<div>
|
||||
<div class="flex flex-row items-center gap-4 py-2">
|
||||
@@ -11,7 +11,6 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Button section, anchored to the bottom -->
|
||||
<div class="flex justify-between items-center pt-4 mt-auto">
|
||||
<p-button outlined="true" label="Create Shelf" (onClick)="createShelfDialog()"></p-button>
|
||||
<div class="flex gap-4">
|
||||
@@ -21,10 +20,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Icon picker component -->
|
||||
<app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker>
|
||||
|
||||
<!-- Shelf dialog component -->
|
||||
<p-dialog [style]="{ width: '26rem', height: '30rem' }" [(visible)]="displayShelfDialog" header="Create Shelf" [modal]="true" [draggable]="false" [closable]="true" (onHide)="closeShelfDialog()">
|
||||
<div class="py-2">
|
||||
<label for="shelfName">Shelf Name</label>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {MessageService, PrimeTemplate} from 'primeng/api';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
@@ -7,14 +7,14 @@ import {Observable} from 'rxjs';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {map, tap} from 'rxjs/operators';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component';
|
||||
import {ShelfState} from '../../model/state/shelf-state.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import {AsyncPipe} from '@angular/common';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {IconPickerService} from '../../../utilities/services/icon-picker.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-assigner',
|
||||
@@ -25,7 +25,6 @@ import {InputText} from 'primeng/inputtext';
|
||||
Checkbox,
|
||||
AsyncPipe,
|
||||
FormsModule,
|
||||
IconPickerComponent,
|
||||
Dialog,
|
||||
InputText,
|
||||
PrimeTemplate
|
||||
@@ -39,6 +38,7 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
private iconPickerService = inject(IconPickerService);
|
||||
|
||||
shelfState$: Observable<ShelfState> = this.shelfService.shelfState$;
|
||||
book: Book = this.dynamicDialogConfig.data.book;
|
||||
@@ -49,8 +49,6 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
isMultiBooks: boolean = this.dynamicDialogConfig.data.isMultiBooks;
|
||||
selectedIcon: string | null = null;
|
||||
|
||||
@ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined;
|
||||
|
||||
ngOnInit(): void {
|
||||
if (!this.isMultiBooks && this.book.shelves) {
|
||||
this.shelfState$.pipe(
|
||||
@@ -124,16 +122,14 @@ export class ShelfAssignerComponent implements OnInit {
|
||||
}
|
||||
|
||||
openIconPicker() {
|
||||
if (this.iconPicker) {
|
||||
this.iconPicker.open();
|
||||
}
|
||||
this.iconPickerService.open().subscribe(icon => {
|
||||
if (icon) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
clearSelectedIcon() {
|
||||
this.selectedIcon = null;
|
||||
}
|
||||
|
||||
onIconSelected(icon: string) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,3 @@
|
||||
<p-button label="Save" icon="pi pi-check" (onClick)="save()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<app-icon-picker (iconSelected)="onIconSelected($event)"></app-icon-picker>
|
||||
|
||||
+9
-13
@@ -1,19 +1,18 @@
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Button} from 'primeng/button';
|
||||
import {IconPickerComponent} from '../../../utilities/component/icon-picker/icon-picker.component';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {IconPickerService} from '../../../utilities/services/icon-picker.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-edit-dialog',
|
||||
imports: [
|
||||
Button,
|
||||
IconPickerComponent,
|
||||
InputText,
|
||||
ReactiveFormsModule,
|
||||
FormsModule
|
||||
@@ -28,13 +27,12 @@ export class ShelfEditDialogComponent implements OnInit{
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private iconPickerService = inject(IconPickerService);
|
||||
|
||||
shelfName: string = '';
|
||||
selectedIcon: string | null = null;
|
||||
shelf!: Shelf | undefined;
|
||||
|
||||
@ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined;
|
||||
|
||||
ngOnInit(): void {
|
||||
const shelfId = this.dynamicDialogConfig?.data.shelfId;
|
||||
this.shelf = this.shelfService.getShelfById(shelfId);
|
||||
@@ -45,19 +43,17 @@ export class ShelfEditDialogComponent implements OnInit{
|
||||
}
|
||||
|
||||
openIconPicker() {
|
||||
if (this.iconPicker) {
|
||||
this.iconPicker.open();
|
||||
}
|
||||
this.iconPickerService.open().subscribe(icon => {
|
||||
if (icon) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
clearSelectedIcon() {
|
||||
this.selectedIcon = null;
|
||||
}
|
||||
|
||||
onIconSelected(icon: string) {
|
||||
this.selectedIcon = icon;
|
||||
}
|
||||
|
||||
save() {
|
||||
const shelf: Shelf = {
|
||||
name: this.shelfName,
|
||||
|
||||
Reference in New Issue
Block a user