diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs index ff7a7422b8bb..24dca67915a3 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/update/_entityFile_-update.component.html.ejs @@ -99,6 +99,9 @@ _%> <%_ } else if (field.fieldTypeBoolean) { _%> [readonly]="true"<% } %>/> + <%_ } else if (field.fieldTypeTime) { _%> + [readonly]="true"<% } %>/> <%_ } else { _%> [readonly]="editForm.get('<%= primaryKey.name %>')!.disabled"<% } else if (readonly) { %> [readonly]="true"<% } %>/> diff --git a/generators/base-application/support/field-utils.ts b/generators/base-application/support/field-utils.ts index aced4dcc6aa9..90644820b2f6 100644 --- a/generators/base-application/support/field-utils.ts +++ b/generators/base-application/support/field-utils.ts @@ -33,6 +33,7 @@ const { STRING, UUID, ZONED_DATE_TIME, + LOCAL_TIME, IMAGE_BLOB, ANY_BLOB, TEXT_BLOB, @@ -50,6 +51,7 @@ export function fieldIsEnum(fieldType) { LOCAL_DATE, INSTANT, ZONED_DATE_TIME, + LOCAL_TIME, DURATION, UUID, BOOLEAN, diff --git a/generators/base-application/support/prepare-entity.ts b/generators/base-application/support/prepare-entity.ts index 620751eadb3c..a2375b3c7154 100644 --- a/generators/base-application/support/prepare-entity.ts +++ b/generators/base-application/support/prepare-entity.ts @@ -52,7 +52,7 @@ const NO_MAPPER = MapperTypes.NO; const { CASSANDRA, COUCHBASE, NEO4J, SQL, MONGODB } = databaseTypes; -const { INSTANT, ZONED_DATE_TIME, DURATION, LOCAL_DATE, BIG_DECIMAL } = fieldTypes.CommonDBTypes; +const { INSTANT, ZONED_DATE_TIME, DURATION, LOCAL_DATE, BIG_DECIMAL, LOCAL_TIME } = fieldTypes.CommonDBTypes; const { BYTES, BYTE_BUFFER } = fieldTypes.RelationalOnlyDBTypes; const { IMAGE, TEXT } = fieldTypes.BlobTypes; @@ -549,6 +549,7 @@ export function preparePostEntityCommonDerivedProperties(entity: Entity) { entity.anyFieldIsZonedDateTime = fieldsType.includes(ZONED_DATE_TIME); entity.anyFieldIsInstant = fieldsType.includes(INSTANT); + entity.anyFieldIsTime = fieldsType.includes(LOCAL_TIME); entity.anyFieldIsDuration = fieldsType.includes(DURATION); entity.anyFieldIsLocalDate = fieldsType.includes(LOCAL_DATE); entity.anyFieldIsBigDecimal = fieldsType.includes(BIG_DECIMAL); diff --git a/generators/base-application/support/prepare-field.ts b/generators/base-application/support/prepare-field.ts index c4964454025f..c857f1134df5 100644 --- a/generators/base-application/support/prepare-field.ts +++ b/generators/base-application/support/prepare-field.ts @@ -51,6 +51,7 @@ const { ANY_BLOB, TEXT_BLOB, BLOB, + LOCAL_TIME, } = CommonDBTypes; const { BYTES, BYTE_BUFFER } = RelationalOnlyDBTypes; @@ -262,6 +263,7 @@ function _derivedProperties(field) { fieldTypeTimed: fieldType === ZONED_DATE_TIME || fieldType === INSTANT, fieldTypeCharSequence: fieldType === STRING || fieldType === UUID || fieldType === TEXT_BLOB, fieldTypeTemporal: fieldType === ZONED_DATE_TIME || fieldType === INSTANT || fieldType === LOCAL_DATE, + fieldTypeTime: fieldType === LOCAL_TIME, fieldValidationRequired: validationRules.includes(REQUIRED), fieldValidationMin: validationRules.includes(MIN), fieldValidationMinLength: validationRules.includes(MINLENGTH), diff --git a/generators/bootstrap-application/generator.spec.ts b/generators/bootstrap-application/generator.spec.ts index 80b5f3d4589d..126cc70858ca 100644 --- a/generators/bootstrap-application/generator.spec.ts +++ b/generators/bootstrap-application/generator.spec.ts @@ -184,6 +184,7 @@ describe(`generator - ${generator}`, () => { "anyFieldIsDuration": false, "anyFieldIsInstant": false, "anyFieldIsLocalDate": false, + "anyFieldIsTime": false, "anyFieldIsTimeDerived": false, "anyFieldIsUUID": true, "anyFieldIsZonedDateTime": false, @@ -305,6 +306,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": false, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": true, "fieldTypeZonedDateTime": false, @@ -403,6 +405,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": true, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -503,6 +506,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": true, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -593,6 +597,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": true, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -683,6 +688,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": true, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -778,6 +784,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": true, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -869,6 +876,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": false, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -951,6 +959,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": true, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": false, "fieldTypeZonedDateTime": false, @@ -1161,6 +1170,7 @@ describe(`generator - ${generator}`, () => { "anyFieldIsDuration": false, "anyFieldIsInstant": false, "anyFieldIsLocalDate": false, + "anyFieldIsTime": false, "anyFieldIsTimeDerived": false, "anyFieldIsUUID": true, "anyFieldIsZonedDateTime": false, @@ -1272,6 +1282,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": false, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": true, "fieldTypeZonedDateTime": false, @@ -1536,6 +1547,7 @@ describe(`generator - ${generator}`, () => { "anyFieldIsDuration": false, "anyFieldIsInstant": false, "anyFieldIsLocalDate": false, + "anyFieldIsTime": false, "anyFieldIsTimeDerived": false, "anyFieldIsUUID": true, "anyFieldIsZonedDateTime": false, @@ -1647,6 +1659,7 @@ describe(`generator - ${generator}`, () => { "fieldTypeString": false, "fieldTypeTemporal": false, "fieldTypeTextBlob": false, + "fieldTypeTime": false, "fieldTypeTimed": false, "fieldTypeUUID": true, "fieldTypeZonedDateTime": false, diff --git a/generators/client/support/entity-definition.ts b/generators/client/support/entity-definition.ts index 57cc2ad71a37..d33dd490fb81 100644 --- a/generators/client/support/entity-definition.ts +++ b/generators/client/support/entity-definition.ts @@ -39,6 +39,7 @@ const { ZONED_DATE_TIME: TYPE_ZONED_DATE_TIME, INSTANT: TYPE_INSTANT, DURATION: TYPE_DURATION, + LOCAL_TIME: TYPE_TIME, } = dbTypes.CommonDBTypes; const TYPE_BYTES = dbTypes.RelationalOnlyDBTypes.BYTES; @@ -85,7 +86,7 @@ const generateEntityClientFields = ( tsType = 'boolean'; } else if ([TYPE_INTEGER, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, TYPE_BIG_DECIMAL].includes(fieldType)) { tsType = 'number'; - } else if ([TYPE_STRING, TYPE_UUID, TYPE_DURATION, TYPE_BYTES, TYPE_BYTE_BUFFER].includes(fieldType)) { + } else if ([TYPE_STRING, TYPE_UUID, TYPE_DURATION, TYPE_BYTES, TYPE_BYTE_BUFFER, TYPE_TIME].includes(fieldType)) { tsType = 'string'; if ([TYPE_BYTES, TYPE_BYTE_BUFFER].includes(fieldType) && field.fieldTypeBlobContent !== 'text') { variablesWithTypes.push(`${fieldName}ContentType?: ${nullable ? 'string | null' : 'string'}`); diff --git a/generators/client/support/types-utils.spec.ts b/generators/client/support/types-utils.spec.ts index 49f904ac8f76..517d3a7f7a9d 100644 --- a/generators/client/support/types-utils.spec.ts +++ b/generators/client/support/types-utils.spec.ts @@ -24,6 +24,7 @@ describe('generator - client - support - type-utils', () => { "Instant": "dayjs.Dayjs", "Integer": "number", "LocalDate": "dayjs.Dayjs", + "LocalTime": "string", "Long": "number", "String": "string", "TextBlob": "string", diff --git a/generators/entity/prompts.ts b/generators/entity/prompts.ts index 07eb986cd1b6..d7f5a74084d4 100644 --- a/generators/entity/prompts.ts +++ b/generators/entity/prompts.ts @@ -44,8 +44,22 @@ const { NO: NO_MAPPER, MAPSTRUCT } = MapperTypes; const { CommonDBTypes, RelationalOnlyDBTypes, BlobTypes } = fieldTypes; -const { BIG_DECIMAL, BOOLEAN, DOUBLE, DURATION, ENUM, FLOAT, INTEGER, INSTANT, LOCAL_DATE, LONG, STRING, UUID, ZONED_DATE_TIME } = - CommonDBTypes; +const { + BIG_DECIMAL, + BOOLEAN, + DOUBLE, + DURATION, + ENUM, + FLOAT, + INTEGER, + INSTANT, + LOCAL_DATE, + LONG, + STRING, + UUID, + ZONED_DATE_TIME, + LOCAL_TIME, +} = CommonDBTypes; const { BYTES, BYTE_BUFFER } = RelationalOnlyDBTypes; const { ANY, IMAGE, TEXT } = BlobTypes; @@ -485,7 +499,7 @@ async function askForField(this: EntityGenerator) { { value: BOOLEAN, name: 'Boolean' }, { value: ENUM, name: 'Enumeration (Java enum type)' }, { value: UUID, name: 'UUID' }, - { value: UUID, name: 'UUID' }, + { value: LOCAL_TIME, name: 'LocalTime' }, ...(databaseType === CASSANDRA ? [{ value: BYTE_BUFFER, name: '[BETA] Blob' }] : [{ value: BYTES, name: '[BETA] Blob' }]), ], default: 0, diff --git a/generators/java/generators/domain/templates/src/main/java/_package_/_entityPackage_/domain/_persistClass_.java.jhi.ejs b/generators/java/generators/domain/templates/src/main/java/_package_/_entityPackage_/domain/_persistClass_.java.jhi.ejs index dd91a88ba956..d8754678e23b 100644 --- a/generators/java/generators/domain/templates/src/main/java/_package_/_entityPackage_/domain/_persistClass_.java.jhi.ejs +++ b/generators/java/generators/domain/templates/src/main/java/_package_/_entityPackage_/domain/_persistClass_.java.jhi.ejs @@ -67,6 +67,8 @@ import java.time.Instant; import java.time.LocalDate; <%_ } if (anyFieldIsZonedDateTime) { _%> import java.time.ZonedDateTime; +<%_ } if (anyFieldIsTime) { _%> +import java.time.LocalTime; <%_ } if (anyFieldIsDuration) { _%> import java.time.Duration; <%_ } if (entityContainsCollectionField) { _%> diff --git a/generators/liquibase/support/prepare-field.ts b/generators/liquibase/support/prepare-field.ts index d0307c9f89fb..7950d58419a5 100644 --- a/generators/liquibase/support/prepare-field.ts +++ b/generators/liquibase/support/prepare-field.ts @@ -25,7 +25,8 @@ import type { ApplicationType } from '../../../lib/types/application/application const { MYSQL, MARIADB } = databaseTypes; const { CommonDBTypes, RelationalOnlyDBTypes, BlobTypes } = fieldTypes; -const { STRING, INTEGER, LONG, BIG_DECIMAL, FLOAT, DOUBLE, UUID, BOOLEAN, LOCAL_DATE, ZONED_DATE_TIME, INSTANT, DURATION } = CommonDBTypes; +const { STRING, INTEGER, LONG, BIG_DECIMAL, FLOAT, DOUBLE, UUID, BOOLEAN, LOCAL_DATE, ZONED_DATE_TIME, INSTANT, DURATION, LOCAL_TIME } = + CommonDBTypes; const { BYTES } = RelationalOnlyDBTypes; const { TEXT } = BlobTypes; @@ -74,6 +75,10 @@ function parseLiquibaseColumnType(field: Field) { return 'bigint'; } + if (fieldType === LOCAL_TIME) { + return 'time'; + } + if (fieldType === UUID) { // eslint-disable-next-line no-template-curly-in-string return '${uuidType}'; diff --git a/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.tsx.ejs b/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.tsx.ejs index af6bfc9cf988..b529dad234ce 100644 --- a/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.tsx.ejs @@ -250,6 +250,10 @@ _%> type="date" <%- include('react_validators'); %> /> + <%_ } else if (field.fieldTypeTime) { _%> + type="time" + placeholder="HH:mm" + <%- include('react_validators'); %> <%_ } else if (field.fieldIsEnum) {_%> type="select" > diff --git a/generators/vue/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.vue.ejs b/generators/vue/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.vue.ejs index ea434b06b591..711be7a7d4c5 100644 --- a/generators/vue/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.vue.ejs +++ b/generators/vue/templates/src/main/webapp/app/entities/_entityFolder_/_entityFile_-update.vue.ejs @@ -23,6 +23,8 @@ fieldInputType = 'date'; } else if (field.fieldTypeTimed) { fieldInputType = 'datetime-local'; + } else if (field.fieldTypeTime) { + fieldInputType = 'time'; } else if (field.fieldTypeBoolean) { fieldInputType = 'checkbox'; fieldInputClass = 'form-check'; diff --git a/lib/application/field-types.ts b/lib/application/field-types.ts index 8df39dcf8f27..6c983002485d 100644 --- a/lib/application/field-types.ts +++ b/lib/application/field-types.ts @@ -25,6 +25,7 @@ const fieldTypes = { ZONED_DATE_TIME: 'ZonedDateTime', INSTANT: 'Instant', DURATION: 'Duration', + TIME: 'LocalTime', BYTES: 'byte[]', // Supported by mongodb at CI samples BYTE_BUFFER: 'ByteBuffer', ...blobFieldTypes, diff --git a/lib/jhipster/field-types.ts b/lib/jhipster/field-types.ts index bd90862063ab..fd68a7cd7bd2 100644 --- a/lib/jhipster/field-types.ts +++ b/lib/jhipster/field-types.ts @@ -47,6 +47,7 @@ export const CommonDBTypes = { DURATION: 'Duration', BYTES: 'byte[]', // Supported by mongodb at CI samples BYTE_BUFFER: 'ByteBuffer', // Supported by cassandra at CI samples + LOCAL_TIME: 'LocalTime', }; export const RelationalOnlyDBTypes = { @@ -78,6 +79,7 @@ const CommonDBValidations = { UUID: new Set([REQUIRED, UNIQUE]), Instant: new Set([REQUIRED, UNIQUE]), Duration: new Set([REQUIRED, UNIQUE]), + LocalTime: new Set([REQUIRED, UNIQUE]), }; export default { diff --git a/lib/types/application/entity.d.ts b/lib/types/application/entity.d.ts index 73a1788f56a7..05428ea50638 100644 --- a/lib/types/application/entity.d.ts +++ b/lib/types/application/entity.d.ts @@ -129,6 +129,7 @@ export interface Entity