Update object definitions in list and map
This commit is contained in:
@@ -2,9 +2,7 @@ import { CommonModule } from '@angular/common';
|
|||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
OnInit,
|
|
||||||
computed,
|
computed,
|
||||||
effect,
|
|
||||||
forwardRef,
|
forwardRef,
|
||||||
input,
|
input,
|
||||||
model,
|
model,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ message Test {
|
|||||||
NestedMessage hello10 = 10;
|
NestedMessage hello10 = 10;
|
||||||
EnumTest enum_test = 11;
|
EnumTest enum_test = 11;
|
||||||
myimportedpackage.ImportedMessage imported_message = 12;
|
myimportedpackage.ImportedMessage imported_message = 12;
|
||||||
|
repeated ReferenceMessage obj_list = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReferenceMessage {
|
message ReferenceMessage {
|
||||||
@@ -68,7 +69,7 @@ describe('TestService', () => {
|
|||||||
|
|
||||||
expect(converted.name).toBe('Test');
|
expect(converted.name).toBe('Test');
|
||||||
|
|
||||||
expect(converted.values.length).toBe(12);
|
expect(converted.values.length).toBe(13);
|
||||||
checkNameAndType(converted, 'hello', MessageTypeEnum.String);
|
checkNameAndType(converted, 'hello', MessageTypeEnum.String);
|
||||||
checkNameAndType(converted, 'hello2', MessageTypeEnum.Numeric);
|
checkNameAndType(converted, 'hello2', MessageTypeEnum.Numeric);
|
||||||
checkNameAndType(converted, 'hello3', MessageTypeEnum.Numeric);
|
checkNameAndType(converted, 'hello3', MessageTypeEnum.Numeric);
|
||||||
@@ -81,6 +82,7 @@ describe('TestService', () => {
|
|||||||
checkNameAndType(converted, 'hello10', MessageTypeEnum.Object);
|
checkNameAndType(converted, 'hello10', MessageTypeEnum.Object);
|
||||||
checkNameAndType(converted, 'enumTest', MessageTypeEnum.Enum);
|
checkNameAndType(converted, 'enumTest', MessageTypeEnum.Enum);
|
||||||
checkNameAndType(converted, 'importedMessage', MessageTypeEnum.Object);
|
checkNameAndType(converted, 'importedMessage', MessageTypeEnum.Object);
|
||||||
|
checkNameAndType(converted, 'objList', MessageTypeEnum.List);
|
||||||
|
|
||||||
const listMessage = converted.values[6].configuration as ListMessage;
|
const listMessage = converted.values[6].configuration as ListMessage;
|
||||||
expect(listMessage.subConfiguration.type).toBe(MessageTypeEnum.String);
|
expect(listMessage.subConfiguration.type).toBe(MessageTypeEnum.String);
|
||||||
@@ -126,6 +128,15 @@ describe('TestService', () => {
|
|||||||
const enumMessage = converted.values[10].configuration as EnumMessage;
|
const enumMessage = converted.values[10].configuration as EnumMessage;
|
||||||
expect(enumMessage.options.length).toBe(1);
|
expect(enumMessage.options.length).toBe(1);
|
||||||
expect(enumMessage.options[0]).toBe('Hello');
|
expect(enumMessage.options[0]).toBe('Hello');
|
||||||
|
|
||||||
|
const objectListMessage = converted.values[12].configuration as ListMessage;
|
||||||
|
expect(objectListMessage.type).toBe(MessageTypeEnum.List);
|
||||||
|
expect(objectListMessage.subConfiguration.type).toBe(
|
||||||
|
MessageTypeEnum.Object
|
||||||
|
);
|
||||||
|
const objectListNestedMessage =
|
||||||
|
objectListMessage.subConfiguration as ObjectMessage;
|
||||||
|
expect(objectListNestedMessage.messageDefinition.values.length).toBe(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,27 @@ export class ProtoDefinitionService {
|
|||||||
.map((messageObject) => messageObject as ProtoMessage);
|
.map((messageObject) => messageObject as ProtoMessage);
|
||||||
for (const messageObject of standardMessages) {
|
for (const messageObject of standardMessages) {
|
||||||
for (const value of messageObject.values) {
|
for (const value of messageObject.values) {
|
||||||
|
let configuration: MessageConfiguration | null = null;
|
||||||
if (value.configuration.type === MessageTypeEnum.Object) {
|
if (value.configuration.type === MessageTypeEnum.Object) {
|
||||||
|
configuration = value.configuration;
|
||||||
|
} else if (value.configuration.type === MessageTypeEnum.List) {
|
||||||
|
const listConfiguration = value.configuration as ListMessage;
|
||||||
|
if (
|
||||||
|
listConfiguration.subConfiguration.type === MessageTypeEnum.Object
|
||||||
|
) {
|
||||||
|
configuration = listConfiguration.subConfiguration;
|
||||||
|
}
|
||||||
|
} else if (value.configuration.type === MessageTypeEnum.Map) {
|
||||||
|
const listConfiguration = value.configuration as MapMessage;
|
||||||
|
if (
|
||||||
|
listConfiguration.valueConfiguration.type === MessageTypeEnum.Object
|
||||||
|
) {
|
||||||
|
configuration = listConfiguration.valueConfiguration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (configuration) {
|
||||||
this.populateNestedObject(
|
this.populateNestedObject(
|
||||||
value.configuration as ObjectMessage,
|
configuration as ObjectMessage,
|
||||||
messageObject.packageName!,
|
messageObject.packageName!,
|
||||||
standardMessages
|
standardMessages
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ message Test {
|
|||||||
ReferenceMessage hello9 = 9;
|
ReferenceMessage hello9 = 9;
|
||||||
NestedMessage hello10 = 10;
|
NestedMessage hello10 = 10;
|
||||||
EnumTest enum_test = 11;
|
EnumTest enum_test = 11;
|
||||||
|
repeated ReferenceMessage obj_list = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReferenceMessage {
|
message ReferenceMessage {
|
||||||
|
|||||||
Reference in New Issue
Block a user