feat: add refresh functionality to various components
- Implemented refresh event emission in multiple list components across partner and superAdmin modules. - Updated consumers and customers list components to handle refresh actions. - Enhanced dashboard component to fetch partner info on initialization. - Introduced new API method in PartnerService to retrieve current partner data. - Modified PartnerStore to utilize the new API method for fetching partner information. - Updated UI elements to reflect changes in partner and license management, including new fields for license renewals. - Added a new POS display component for better presentation of POS terminal information. - Updated layout service and top bar to reflect new titles and improve user experience. - Refactored existing components to ensure consistency and maintainability.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { AppCardComponent, KeyValueComponent } from '@/shared/components';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, effect, EventEmitter, Input, Output, signal } from '@angular/core';
|
||||
import { Button } from 'primeng/button';
|
||||
import { IPosEntity, POS_VARIANT_FIELDS, PosVariant } from './models/posEntity.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-pos-entity-display',
|
||||
standalone: true,
|
||||
imports: [CommonModule, AppCardComponent, Button, KeyValueComponent],
|
||||
templateUrl: './pos-display.component.html',
|
||||
})
|
||||
export class PosDisplayComponent {
|
||||
@Input() variant: PosVariant = 'full';
|
||||
@Input() pos = signal<IPosEntity | undefined>(undefined);
|
||||
@Input() editMode = signal<boolean>(false);
|
||||
@Input() cardTitle = 'اطلاعات پایانهی فروش';
|
||||
@Input() showMoreActions = true;
|
||||
|
||||
@Output() editModeChange = new EventEmitter<boolean>();
|
||||
@Output() onMoreAction = new EventEmitter<void>();
|
||||
@Output() onSubmit = new EventEmitter<void>();
|
||||
|
||||
visibleFields = signal<Array<keyof IPosEntity>>([]);
|
||||
isEditing = signal<boolean>(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
this.visibleFields.set(POS_VARIANT_FIELDS[this.variant] || POS_VARIANT_FIELDS.full);
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
this.isEditing.set(this.editMode());
|
||||
});
|
||||
}
|
||||
|
||||
get fieldLabels(): Record<string, string> {
|
||||
return {
|
||||
name: 'عنوان',
|
||||
pos_type: 'نوع پایانه',
|
||||
serial_number: 'شماره سریال',
|
||||
device: 'نوع دستگاه',
|
||||
model: 'مدل دستگاه',
|
||||
provider: 'ارایهدهنده',
|
||||
};
|
||||
}
|
||||
|
||||
isFieldVisible(field: keyof IPosEntity): boolean {
|
||||
return this.visibleFields().includes(field);
|
||||
}
|
||||
|
||||
getFieldValue(field: keyof IPosEntity): any {
|
||||
const posData = this.pos();
|
||||
if (!posData) return null;
|
||||
|
||||
if (field === 'device' && posData.device) {
|
||||
return posData.device.name;
|
||||
}
|
||||
if (field === 'provider' && posData.provider) {
|
||||
return posData.provider.name;
|
||||
}
|
||||
return posData[field];
|
||||
}
|
||||
|
||||
toggleEditMode(): void {
|
||||
const newMode = !this.isEditing();
|
||||
this.isEditing.set(newMode);
|
||||
this.editModeChange.emit(newMode);
|
||||
}
|
||||
|
||||
handleMoreAction(): void {
|
||||
this.onMoreAction.emit();
|
||||
}
|
||||
|
||||
handleSubmit(): void {
|
||||
this.onSubmit.emit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user