|
|
@@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, Component, DestroyRef, OnInit, computed, injec
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
-import { ChevronLeft, ChevronRight, LoaderCircle, LucideAngularModule, Pencil, Plus, RefreshCw, Search, Trash2, X } from 'lucide-angular';
|
|
|
+import { ChevronLeft, ChevronRight, Eye, LoaderCircle, LucideAngularModule, Pencil, Plus, RefreshCw, Search, Trash2, X } from 'lucide-angular';
|
|
|
import { AdminClassSchema, AdminFieldSchema, ResourcePage } from '../admin.models';
|
|
|
import { CloudFunctionsService } from '../cloud-functions.service';
|
|
|
|
|
|
@@ -28,12 +28,14 @@ export class AdminResourceComponent implements OnInit {
|
|
|
readonly draft = signal<Record<string, unknown>>({});
|
|
|
readonly fieldErrors = signal<Record<string, string>>({});
|
|
|
readonly fieldInputs = signal<Record<string, string>>({});
|
|
|
- readonly icons = { ChevronLeft, ChevronRight, LoaderCircle, Pencil, Plus, RefreshCw, Search, Trash2, X };
|
|
|
+ readonly icons = { ChevronLeft, ChevronRight, Eye, LoaderCircle, Pencil, Plus, RefreshCw, Search, Trash2, X };
|
|
|
readonly columns = computed(() => {
|
|
|
const fields = this.schema()?.fields ?? [];
|
|
|
const preferred = ['objectId', 'name', 'title', 'username', 'realName', 'mobile', 'sourceKey', 'status', 'createdAt', 'updatedAt'];
|
|
|
- return [...fields].sort((a, b) => preferred.indexOf(a.name) - preferred.indexOf(b.name)).slice(0, 7);
|
|
|
+ const rank = (name: string): number => { const index = preferred.indexOf(name); return index < 0 ? preferred.length : index; };
|
|
|
+ return fields.map((field, index) => ({ field, index })).sort((a, b) => rank(a.field.name) - rank(b.field.name) || a.index - b.index).map(({ field }) => field).slice(0, 7);
|
|
|
});
|
|
|
+ readonly pageCount = computed(() => Math.max(1, Math.ceil((this.page()?.total ?? 0) / (this.page()?.pageSize || 20))));
|
|
|
private readonly functions = inject(CloudFunctionsService);
|
|
|
private readonly route = inject(ActivatedRoute);
|
|
|
private readonly destroyRef = inject(DestroyRef);
|