Skip to content
Snippets Groups Projects
Commit c8c247b0 authored by Samuel Eickelberg's avatar Samuel Eickelberg
Browse files

OP#18070 Updated initialization.service.ts, and several components to use the service.

parent 986380eb
Branches
Tags
No related merge requests found
.hintrc 0 → 100644
{
"extends": [
"development"
],
"hints": {
"axe/forms": [
"default",
{
"label": "off"
}
]
}
}
\ No newline at end of file
import { Component, Input } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { ByteDataDto } from 'src/app/generated/dcc/model/byteDataDto';
@Component({
......@@ -8,16 +8,11 @@ import { ByteDataDto } from 'src/app/generated/dcc/model/byteDataDto';
styleUrls: ['./dcc-byte-data.component.scss']
})
export class DccByteDataComponent {
@Input() byteData!: ByteDataDto
constructor(private logger: NGXLogger) {
@Input() byteData!: ByteDataDto | any;
constructor() {
}
ngOnInit(): void {
// this.logger.trace("ngOnInit::(rawInput:{})",JSON.stringify(this.dataType))
}
}
\ No newline at end of file
import { Component, Input, OnInit,Output, EventEmitter} from '@angular/core';
import { ByteDataDto } from 'src/app/generated/dcc/model/byteDataDto';
import { Component, Input, OnInit } from '@angular/core';
import { ContactDto } from 'src/app/generated/dcc/model/contactDto';
import { FormulaDto } from 'src/app/generated/dcc/model/formulaDto';
import { LangTextPair } from 'src/app/generated/dcc/model/langTextPair';
import { LanguageSpecificStringsDto } from 'src/app/generated/dcc/model/languageSpecificStringsDto';
import { LocationDto } from 'src/app/generated/dcc/model/locationDto';
import { RichContentDto } from 'src/app/generated/dcc/model/richContentDto';
import { InitializationService } from 'src/app/services/dcc/initialization.service';
@Component({
selector: 'app-dcc-contact, [app-dcc-contact]',
......@@ -16,46 +11,12 @@ import { RichContentDto } from 'src/app/generated/dcc/model/richContentDto';
export class DccContactComponent implements OnInit {
@Input() contact: ContactDto;
@Input() strict: boolean;
@Output() fileSelected = new EventEmitter<ByteDataDto>();
onFileSelected(fileData: ByteDataDto) {
console.log("ByteDataDto received in DccContactComponent:", fileData);
this.fileSelected.emit(fileData);
}
// hasAddress: boolean = false;
constructor() {
constructor(initializationService: InitializationService) {
this.strict = true;
this.contact = <ContactDto>{};
this.getEmptyContactDto();
this.contact = initializationService.getEmptyContactDto();
}
ngOnInit(): void {
}
getEmptyContactDto(): ContactDto {
var result = <ContactDto>{};
result.name = this.getEmptyLanguageSpecificStringsDto();
result.location = this.getEmptyLocationDto();
return result;
}
getEmptyLanguageSpecificStringsDto(): LanguageSpecificStringsDto {
var result = <LanguageSpecificStringsDto>{};
result.content = new Array<LangTextPair>;
result.content.push(<LangTextPair>{})
return result;
}
getEmptyLocationDto(): LocationDto {
var result = <LocationDto>{}
result.additionalInformation = this.getEmptyRichContentDto();
return result;
}
getEmptyRichContentDto(): RichContentDto {
var result = <RichContentDto>{};
result.name = this.getEmptyLanguageSpecificStringsDto();
result.textContent = this.getEmptyLanguageSpecificStringsDto();
result.byteDataContent = <ByteDataDto>{};
result.formulaContent = <FormulaDto>{};
return result;
}
}
......@@ -41,14 +41,12 @@
<mat-card-content *ngIf="isExpanded[i]">
<div>
<ng-container *ngIf="type">
<div *ngIf="type.formula"><i class="material-icons">construction</i></div>
<div *ngIf="type.byteData"><i class="material-icons">construction</i></div>
<div *ngIf="type.richContent"><i class="material-icons">construction</i></div>
<div *ngIf="type.quantity"><i class="material-icons">construction</i></div>
<div *ngIf="type.formula && type.formula.type == 'MATHML'"><app-mathml mathml="type.formula.content"></app-mathml></div>
<div *ngIf="type.byteData"><app-dcc-byte-data byteData="type.byteData"></app-dcc-byte-data></div>
<div *ngIf="type.richContent"><app-dcc-richcontent richContent="type.richContent"></app-dcc-richcontent></div>
<div *ngIf="type.quantity"><app-dcc-quantity dataType="type.quantity"></app-dcc-quantity>></div>
<div *ngIf="type.list"><i class="material-icons">construction</i></div>
</ng-container>
</div>
</mat-card-content>
</mat-card>
import { Component, Input, OnInit } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { QuantityDto } from 'src/app/generated/dcc/model/quantityDto';
import { DataDto } from 'src/app/generated/dcc/model/dataDto';
import { DimensionDto } from 'src/app/generated/dcc/model/dimensionDto';
import { LanguageSpecificStringsDto } from 'src/app/generated/dcc/model/languageSpecificStringsDto';
import { LangTextPair } from 'src/app/generated/dcc/model/langTextPair';
import { RichContentDto } from 'src/app/generated/dcc/model/richContentDto';
import { ByteDataDto } from 'src/app/generated/dcc/model/byteDataDto';
import { FormulaDto } from 'src/app/generated/dcc/model/formulaDto';
import { InitializationService } from 'src/app/services/dcc/initialization.service';
@Component({
selector: 'app-dcc-data',
......@@ -18,63 +12,14 @@ import { FormulaDto } from 'src/app/generated/dcc/model/formulaDto';
export class DccDataComponent implements OnInit {
@Input() dataTypes!: DataDto[];
selectedOption: string = 'RichContent';
options: string[] = ['RichContent', 'Formel', 'ByteData', 'Quantity', 'Liste']
selectedOption: string = 'richContent';
options: string[] = ['richContent', 'formula', 'byteData', 'quantity', 'list']
isExpanded: boolean[] = [];
byteData!: any;
formula!: any;
quantity!: any;
richContent!: any;
list!: any;
constructor(private logger: NGXLogger) {
// this.dataType = <DataDto>{};
constructor(private initializationService: InitializationService) {
}
ngOnInit(): void {
// this.logger.trace("ngOnInit::(rawInput:{})",JSON.stringify(this.dataType))
this.getEmptyDataDto();
this.getEmptyByteDataDto();
this.getEmptyFormulaDto();
this.getEmptyRichContentDto();
this.getEmptyLanguageSpecificStringsDto();
}
getEmptyDataDto() {
var result = <DataDto>{};
result.quantity = <QuantityDto>{};
result.quantity.dimension = <DimensionDto>{};
return result;
}
getEmptyByteDataDto() {
var result = <ByteDataDto>{};
result.name = this.getEmptyLanguageSpecificStringsDto();
result.mimeType = "";
result.fileName = "";
result.description = this.getEmptyRichContentDto();
return result;
}
getEmptyFormulaDto(): FormulaDto {
const result = <FormulaDto>{};
result.content = '';
result.type = FormulaDto.TypeEnum.Mathml;
return result;
}
getEmptyLanguageSpecificStringsDto(): LanguageSpecificStringsDto {
const result = <LanguageSpecificStringsDto>{};
result.content = new Array<LangTextPair>;
result.content.push(<LangTextPair>{})
return result;
}
getEmptyRichContentDto(): RichContentDto {
const result = <RichContentDto>{};
result.name = this.getEmptyLanguageSpecificStringsDto();
result.byteDataContent = <ByteDataDto>{};
result.formulaContent = <FormulaDto>{};
return result
}
onSelectionChange(event: any) {
......@@ -83,36 +28,40 @@ export class DccDataComponent implements OnInit {
addObject(option: string) {
switch (option) {
case 'ByteData':
this.dataTypes.push(this.byteData = { 'byteData': this.getEmptyByteDataDto() });
case 'byteData':
var item = this.initializationService.getEmptyDataDto();
item.byteData = this.initializationService.getEmptyByteDataDto();
this.dataTypes.push(item);
break;
case 'Formel':
this.dataTypes.push(this.formula = { 'formula': this.getEmptyFormulaDto() });
case 'formula':
var item = this.initializationService.getEmptyDataDto();
item.formula = this.initializationService.getEmptyFormulaDto();
this.dataTypes.push(item);
break;
case 'RichContent':
this.dataTypes.push(this.richContent = { 'richContent': this.getEmptyFormulaDto() });
case 'richContent':
var item = this.initializationService.getEmptyDataDto();
item.richContent = this.initializationService.getEmptyRichContentDto();
this.dataTypes.push(item);
break;
case 'Quantity':
this.dataTypes.push(this.quantity = { 'quantity': this.getEmptyFormulaDto() });
case 'quantity':
var item = this.initializationService.getEmptyDataDto();
item.quantity = this.initializationService.getEmptyQuantityDto();
this.dataTypes.push(item);
break;
case 'Liste':
this.dataTypes.push(this.list = { 'list': this.getEmptyFormulaDto() });
case 'list':
var item = this.initializationService.getEmptyDataDto();
item.list = this.initializationService.getEmptyListDto();
this.dataTypes.push(item);
break;
}
console.log(this.dataTypes)
}
// onOptionClick(option: string) {
// this.dataTypes.push(option)
// }
deleteObject(index: number) {
this.dataTypes.splice(index, 1);
this.isExpanded.splice(index,1);
this.isExpanded.splice(index, 1);
}
toggleCard(index: number) {
this.isExpanded[index] = !this.isExpanded[index]
console.log('isExpanded in Data',this.isExpanded )
}
}
......@@ -9,7 +9,7 @@ import { InitializationService } from 'src/app/services/dcc/initialization.servi
styleUrls: ['./dcc-quantity.component.scss']
})
export class DccQuantityComponent implements OnInit {
@Input() dataType: QuantityDto;
@Input() dataType: QuantityDto | any;
constructor(initializationService: InitializationService) {
this.dataType = initializationService.getEmptyQuantityDto();
......
......@@ -27,13 +27,11 @@ export class MathmlComponent implements OnInit, AfterViewInit {
renderMathML(): void {
const mathMLContent = this.mathml || (this.formulaDto && this.formulaDto.content);
if (mathMLContent && this.mathContainer?.nativeElement) {
const mathContainerElement = this.mathContainer.nativeElement;
try {
mathContainerElement.innerHTML = '';
mathContainerElement.innerHTML = mathMLContent;
this.mathService.ready().subscribe((isReady) => {
if (isReady) {
window.MathJax.startup.promise
......
import { Injectable } from '@angular/core';
import { ByteDataDto } from 'src/app/generated/dcc/model/byteDataDto';
import { ConditionDto } from 'src/app/generated/dcc/model/conditionDto';
import { ContactDto } from 'src/app/generated/dcc/model/contactDto';
import { CoverageIntervalDto } from 'src/app/generated/dcc/model/coverageIntervalDto';
......@@ -8,10 +9,12 @@ import { DimensionDto } from 'src/app/generated/dcc/model/dimensionDto';
import { EquipmentDto } from 'src/app/generated/dcc/model/equipmentDto';
import { ExpandedMUDto } from 'src/app/generated/dcc/model/expandedMUDto';
import { ExpandedUncDto } from 'src/app/generated/dcc/model/expandedUncDto';
import { FormulaDto } from 'src/app/generated/dcc/model/formulaDto';
import { HybridValues } from 'src/app/generated/dcc/model/hybridValues';
import { IdentificationDto } from 'src/app/generated/dcc/model/identificationDto';
import { LangTextPair } from 'src/app/generated/dcc/model/langTextPair';
import { LanguageSpecificStringsDto } from 'src/app/generated/dcc/model/languageSpecificStringsDto';
import { ListDto } from 'src/app/generated/dcc/model/listDto';
import { LocationDto } from 'src/app/generated/dcc/model/locationDto';
import { MethodDto } from 'src/app/generated/dcc/model/methodDto';
import { QuantityDto } from 'src/app/generated/dcc/model/quantityDto';
......@@ -127,6 +130,27 @@ export class InitializationService {
return result;
}
getEmptyByteDataDto(): ByteDataDto {
var result = <ByteDataDto>{};
result.id = '';
result.refIds = [];
result.description = this.getEmptyRichContentDto();
result.fileName = '';
result.mimeType = '';
result.content = ''; // https://www.rfc-editor.org/rfc/rfc4648#section-10
return result;
}
getEmptyFormulaDto(): FormulaDto {
var result = <FormulaDto>{};
result.id = '';
result.refIds = [];
result.refTypes = [];
result.content = '<math></math>';
result.type = FormulaDto.TypeEnum.Mathml;
return result;
}
getEmptyConditionDto(): ConditionDto {
var result = <ConditionDto>{};
result.name = this.getEmptyLanguageSpecificStringsDto();
......@@ -225,4 +249,18 @@ export class InitializationService {
result.norms = new Array<string>;
return result;
}
getEmptyListDto(): ListDto {
var result = <ListDto>{};
result.id = '';
result.refIds = [];
result.refTypes = [];
result.description = this.getEmptyRichContentDto();
result.quantities = new Array<QuantityDto>;
result.quantities.push(this.getEmptyQuantityDto());
result.usedMethods = new Array<MethodDto>;
result.quantities.push(this.getEmptyMethodDto());
result.list = new Array<ListDto>;
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment