Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem when creating new instance on overlay #188

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {InputFieldComponent} from '../../fields';
import {map, Observable, of, startWith, Subscription} from 'rxjs';
import * as locale from 'locale-codes';
import {MatAutocompleteTrigger} from '@angular/material/autocomplete';
import {isDataTypeLangString} from '@ame/shared';

@Component({
selector: 'ame-entity-instance-table',
Expand Down Expand Up @@ -164,14 +165,28 @@ export class EntityInstanceTableComponent extends InputFieldComponent<DefaultEnt
return propertiesFormArray;
}

private createValueControl(propertyValue: string | number | boolean | DefaultEntityInstance, validators): FormControl {
private createValueControl(
propertyValue: string | number | boolean | DefaultEntityInstance,
validators: ValidationErrors | null,
): FormControl {
const isEntityValue = propertyValue instanceof DefaultEntityInstance;
return new FormControl({value: propertyValue, disabled: isEntityValue}, validators);
}

private addLanguageControl(group: UntypedFormGroup, propertyLanguage: string, validators, property): void {
if (propertyLanguage) {
const languageControl = new FormControl({value: propertyLanguage, disabled: true}, validators);
private addLanguageControl(
group: UntypedFormGroup,
propertyLanguage: string,
validators: ValidationErrors | null,
property: DefaultProperty,
): void {
if ((propertyLanguage || propertyLanguage === '') && isDataTypeLangString(property)) {
const languageControl = new FormControl(
{
value: propertyLanguage,
disabled: propertyLanguage !== '',
},
validators,
);
this.subscribeToLangValueChanges(languageControl, property);
group.addControl('language', languageControl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ import {SharedSettingsTitleComponent} from './components/shape-settings/shared-s
import {LanguageTranslateModule} from '@ame/translation';
import {ElementIconComponent} from '../../../../shared/src/lib/components/element/element.component';
import {MatDividerModule} from '@angular/material/divider';
import { EntityInstanceComponent, EntityInstanceModalComponent, EntityInstanceModalTableComponent, EntityInstanceSearchBarComponent, EntityInstanceTableComponent, EntityInstanceViewComponent } from './components/entity-instance';
import {
EntityInstanceComponent,
EntityInstanceModalComponent,
EntityInstanceModalTableComponent,
EntityInstanceSearchBarComponent,
EntityInstanceTableComponent,
EntityInstanceViewComponent,
} from './components/entity-instance';

@NgModule({
providers: [EditorModelService],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class DefaultEntityInstance extends Base implements EntityValue {
this.properties = properties?.map(key => ({key, value: ''})) || [];
}

public addProperty(overWrittenProperty: OverWrittenProperty<any>, value: string | DefaultEntityInstance = '', language?: string) {
public addProperty(overWrittenProperty: OverWrittenProperty<any>, value: string | DefaultEntityInstance = '', language = '') {
this.properties.push({key: overWrittenProperty, value, language});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ import {
MxGraphShapeOverlayService,
MxGraphVisitorHelper,
} from '@ame/mx-graph';
import {Base, BaseMetaModelElement, DefaultEntity, DefaultEntityInstance, DefaultEnumeration, OverWrittenPropertyKeys} from '@ame/meta-model';
import {
Base,
BaseMetaModelElement,
DefaultEntity,
DefaultEntityInstance,
DefaultEnumeration,
OverWrittenPropertyKeys,
} from '@ame/meta-model';
import {SammLanguageSettingsService} from '@ame/settings-dialog';
import {BaseEntityModelService} from './base-entity-model.service';

Expand Down
4 changes: 3 additions & 1 deletion core/libs/mx-graph/src/lib/services/mx-graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ export class MxGraphService {
public updateEntityValuesWithCellReference(deletedEntityValueCells: Array<mxgraph.mxCell>): void {
deletedEntityValueCells
.filter(entityValueCell => entityValueCell.isVertex())
.forEach(entityValueCell => this.updateEntityValuesWithReference(MxGraphHelper.getModelElement<DefaultEntityInstance>(entityValueCell)));
.forEach(entityValueCell =>
this.updateEntityValuesWithReference(MxGraphHelper.getModelElement<DefaultEntityInstance>(entityValueCell)),
);
}

private applyDelta(cell: mxgraph.mxCell, deltaX: number, deltaY: number, formattedCells: mxgraph.mxCell[]) {
Expand Down
Loading