Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: compute currentPage store property reference correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Sep 10, 2018
1 parent 7c9248f commit 7aa82a1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/model/element-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ export class ElementAction {

public getStoreProperty(): UserStoreProperty | undefined {
const storeAction = this.getStoreAction();
const actionPropId = storeAction && storeAction.getUserStorePropertyId();

if (storeAction && storeAction.getType() === Types.UserStoreActionType.SetPage) {
return this.userStore.getPageProperty();
if (actionPropId) {
return this.userStore.getPropertyById(actionPropId);
}

if (!this.storePropertyId) {
Expand Down
5 changes: 5 additions & 0 deletions src/model/user-store-action/user-store-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export class UserStoreAction {
this.userStore = userStore;
}

@Mobx.action
public setUserStoreProperty(userStoreProperty: UserStoreProperty): void {
this.userStorePropertyId = userStoreProperty.getId();
}

public toJSON(): Types.SerializedUserStoreAction {
return {
model: Types.ModelName.UserStoreAction,
Expand Down
5 changes: 5 additions & 0 deletions src/model/user-store-property/user-store-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export class UserStoreProperty {
this.concreteValue = value;
}

@Mobx.action
public setValueType(valueType: Types.UserStorePropertyValueType): void {
this.valueType = valueType;
}

public setProject(project: Project): void {
this.project = project;
}
Expand Down
8 changes: 8 additions & 0 deletions src/model/user-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export class UserStore {
});
}

this.currentPageProperty.setValueType(Types.UserStorePropertyValueType.Page);

(init.properties || []).forEach(prop => this.addProperty(prop));

const actions = init.actions || [];
Expand Down Expand Up @@ -146,6 +148,12 @@ export class UserStore {

actions.forEach(action => this.addAction(action));

const switchPageAction = [...this.actions.values()].find(a => a.getName() === 'Switch Page');

if (switchPageAction) {
switchPageAction.setUserStoreProperty(this.currentPageProperty);
}

(init.references || []).forEach(reference => this.addReference(reference));

this.enhancer = init.enhancer;
Expand Down

0 comments on commit 7aa82a1

Please sign in to comment.