Cities (owner: as legacy) - City.parentId (self relation) replaces the flat `province` label; the migration turns each label into a parent row («استان …») first, so nothing is lost. - Admin pickers are legacy's tree (CityTreeSelect): the top level, the country, is a heading. The city form and grid get «والد». - Restored legacy _getP: a city without its own percent takes its ancestor's. Restored the omde-customer form's city → percent autofill. - Import copies legacy parents; delete refuses a city with children; a parent loop is refused. Permissions (owner approved the deletion) - dashboard / dashboard.omde / dashboard.tak rows become dashboard.view, then are deleted. - Import maps them the same way: legacy types 102, 104, 105, 108 and 135 had lost the dashboard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { Controller, HttpCode, Post } from '@nestjs/common';
|
|
import { PrismaService } from '../../prisma/prisma.service';
|
|
|
|
/**
|
|
* Legacy `POST cities/list` — the city lookup the table filters use.
|
|
* Returns `{ rows }`, matching what the users store's setCities() reads.
|
|
*
|
|
* Deliberately NOT permission-gated: legacy called this from table models at
|
|
* module load, before any rid check, and it exposes nothing sensitive.
|
|
*/
|
|
@Controller('admin/cities')
|
|
export class AdminCitiesController {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
@Post('list')
|
|
@HttpCode(200)
|
|
async list() {
|
|
const cities = await this.prisma.city.findMany({ orderBy: { name: 'asc' } });
|
|
// legacy shape: the cities row — { id, title, parent, percent, percent_aux }.
|
|
// `parent` lets the admin pickers draw legacy's tree (PERS-02).
|
|
return {
|
|
rows: cities.map((c) => ({
|
|
id: c.id,
|
|
title: c.name,
|
|
parent: c.parentId,
|
|
percent: c.percent,
|
|
percent_aux: c.percentAux,
|
|
})),
|
|
};
|
|
}
|
|
}
|