Skip to content

Commit

Permalink
Fix use of default model in create dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
skodapetr committed Jan 27, 2025
1 parent b22e190 commit 04a7869
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function openCreateAssociationDialogAction(
}

const state = createCreateAssociationDialogState(
classes, graph, visualModel, options.language);
classes, graph, visualModel, options.language, model.getId());

const onConfirm = (state: EditAssociationDialogState) => {
// Create association.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ function openCreateAttributeDialog(
onConfirm: (state: EditAttributeDialogState) => void,
) {
const state = createNewAttributeDialogState(
classes, graph, visualModel, options.language);
classes, graph, visualModel, options.language, model.getId());
dialogs.openDialog(createNewAttributeDialog(state, onConfirm));
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ function openCreateClassDialog(
onConfirm: (state: EditClassDialogState) => void,
) {
const state = createNewClassDialogState(
classes, graph, visualModel, options.language);
classes, graph, visualModel, options.language, model.getId());
dialogs.openDialog(createNewClassDialog(state, onConfirm));
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createCreateAssociationDialogState(
graphContext: ModelGraphContextType,
visualModel: VisualModel | null,
language: string,
defaultModelIdentifier: string | null,
): EditAssociationDialogState {

const models = [...graphContext.models.values()];
Expand All @@ -24,7 +25,8 @@ export function createCreateAssociationDialogState(

// EntityState

const entityState = createEntityStateForNew(language, vocabularies, configuration().nameToIri);
const entityState = createEntityStateForNew(
language, defaultModelIdentifier, vocabularies, configuration().nameToIri);

// SpecializationState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createNewAttributeDialogState(
graphContext: ModelGraphContextType,
visualModel: VisualModel | null,
language: string,
defaultModelIdentifier: string | null,
): EditAttributeDialogState {

const models = [...graphContext.models.values()];
Expand All @@ -24,7 +25,8 @@ export function createNewAttributeDialogState(

// EntityState

const entityState = createEntityStateForNew(language, vocabularies, configuration().nameToIri);
const entityState = createEntityStateForNew(
language, defaultModelIdentifier, vocabularies, configuration().nameToIri);

// SpecializationState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createNewClassDialogState(
graphContext: ModelGraphContextType,
visualModel: VisualModel | null,
language: string,
defaultModelIdentifier: string | null,
): EditClassDialogState {

const models = [...graphContext.models.values()];
Expand All @@ -24,7 +25,8 @@ export function createNewClassDialogState(

// EntityState

const entityState = createEntityStateForNew(language, vocabularies, configuration().nameToIri);
const entityState = createEntityStateForNew(
language, defaultModelIdentifier, vocabularies, configuration().nameToIri);

// SpecializationState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ export interface EntityState {
*/
export function createEntityStateForNew(
language: string,
defaultModelIdentifier: string | null,
vocabularies: CmeModel[],
generateIriFromName: (name: string) => string,
): EntityState {
const writableVocabularies = filterWritableModels(vocabularies);
if (writableVocabularies.length === 0) {
throw new NoWritableModelFound();
}
const selectedVocabulary = writableVocabularies[0];
const selectedVocabulary =
writableVocabularies.find(item => item.dsIdentifier === defaultModelIdentifier)
?? writableVocabularies[0];

const name = generateName();

Expand Down

0 comments on commit 04a7869

Please sign in to comment.