Capitalize labels objectmetadata (#11609)
Capitalize labels singular and plural from objectmetadata Fixes [#664](https://github.com/twentyhq/core-team-issues/issues/664)
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import { isDefined } from 'class-validator';
|
||||
import Stripe from 'stripe';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';
|
||||
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
|
||||
|
||||
@ -4,8 +4,8 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { i18n } from '@lingui/core';
|
||||
import { Query, QueryOptions } from '@ptc-org/nestjs-query-core';
|
||||
import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm';
|
||||
import { isDefined } from 'class-validator';
|
||||
import { APP_LOCALES, SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { FindManyOptions, FindOneOptions, In, Not, Repository } from 'typeorm';
|
||||
|
||||
import { ObjectMetadataStandardIdToIdMap } from 'src/engine/metadata-modules/object-metadata/interfaces/object-metadata-standard-id-to-id-map';
|
||||
@ -89,6 +89,13 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
objectMetadataInput.workspaceId,
|
||||
);
|
||||
|
||||
objectMetadataInput.labelSingular = capitalize(
|
||||
objectMetadataInput.labelSingular,
|
||||
);
|
||||
objectMetadataInput.labelPlural = capitalize(
|
||||
objectMetadataInput.labelPlural,
|
||||
);
|
||||
|
||||
validateObjectMetadataInputNamesOrThrow(objectMetadataInput);
|
||||
validateObjectMetadataInputLabelsOrThrow(objectMetadataInput);
|
||||
|
||||
@ -212,6 +219,18 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
input: UpdateOneObjectInput,
|
||||
workspaceId: string,
|
||||
): Promise<ObjectMetadataEntity> {
|
||||
const { update } = input;
|
||||
|
||||
if (isDefined(update.labelSingular)) {
|
||||
update.labelSingular = capitalize(update.labelSingular);
|
||||
}
|
||||
|
||||
if (isDefined(update.labelPlural)) {
|
||||
update.labelPlural = capitalize(update.labelPlural);
|
||||
}
|
||||
|
||||
input.update = update;
|
||||
|
||||
validateObjectMetadataInputNamesOrThrow(input.update);
|
||||
|
||||
const existingObjectMetadata = await this.objectMetadataRepository.findOne({
|
||||
|
||||
Reference in New Issue
Block a user