From ee6b6d9afc6efd8cdda6e918e0051ef0dfeb075c Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 30 Oct 2023 10:01:18 +0900 Subject: [PATCH] fix: field order (#71) --- .../channel/field/field.mysql.service.ts | 4 +-- .../src/domains/feedback/feedback.service.ts | 25 +++---------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/apps/api/src/domains/channel/field/field.mysql.service.ts b/apps/api/src/domains/channel/field/field.mysql.service.ts index 89d830cae..41feabdfc 100644 --- a/apps/api/src/domains/channel/field/field.mysql.service.ts +++ b/apps/api/src/domains/channel/field/field.mysql.service.ts @@ -101,7 +101,6 @@ export class FieldMySQLService { this.checkReservedFieldKey(fields); const fieldsToCreate: CreateFieldDto[] = [ - ...fields, { name: 'ID', key: 'id', @@ -134,6 +133,7 @@ export class FieldMySQLService { status: FieldStatusEnum.ACTIVE, description: '', }, + ...fields, ]; const fieldEntities = []; @@ -158,7 +158,7 @@ export class FieldMySQLService { return await this.repository.find({ where: { channel: { id: channelId } }, relations: { options: true }, - order: { createdAt: 'DESC' }, + order: { createdAt: 'ASC' }, }); } diff --git a/apps/api/src/domains/feedback/feedback.service.ts b/apps/api/src/domains/feedback/feedback.service.ts index 6973f13a7..974d59399 100644 --- a/apps/api/src/domains/feedback/feedback.service.ts +++ b/apps/api/src/domains/feedback/feedback.service.ts @@ -162,27 +162,10 @@ export class FeedbackService { }); const worksheet = workbook.addWorksheet('Sheet 1'); - const headerOrderForType = ['DEFAULT', 'API', 'ADMIN']; - const headers = fields - .sort((a, b) => { - const typeA = headerOrderForType.indexOf(a.type); - const typeB = headerOrderForType.indexOf(b.type); - - if (typeA !== typeB) return typeA - typeB; - - if (a.type === 'DEFAULT' && b.type === 'DEFAULT') { - const nameOrder = ['ID', 'Created', 'Updated', 'Issue']; - const nameA = nameOrder.indexOf(a.name); - const nameB = nameOrder.indexOf(b.name); - return nameA - nameB; - } - - return 0; - }) - .map((field) => ({ - header: field.name, - key: field.name, - })); + const headers = fields.map((field) => ({ + header: field.name, + key: field.name, + })); worksheet.columns = headers; const pageSize = 1000;