Skip to content

Commit

Permalink
make createNavigateOrTab return promise
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Jul 18, 2019
1 parent 5f33538 commit 235df9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Signum.React/Scripts/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -645,16 +645,17 @@ export function createInNewTab(pack: EntityPack<ModifiableEntity>) {
var win = window.open(url);
}

export function createNavigateOrTab(pack: EntityPack<Entity>, event: React.MouseEvent<any>) {
export function createNavigateOrTab(pack: EntityPack<Entity>, event: React.MouseEvent<any>) : Promise<void> {
if (!pack || !pack.entity)
return;
return Promise.resolve();

const es = getSettings(pack.entity.Type);
if (es && es.avoidPopup || event.ctrlKey || event.button == 1) {
createInNewTab(pack);
return Promise.resolve();
}
else {
navigate(pack);
return navigate(pack);
}
}

Expand Down
9 changes: 6 additions & 3 deletions Signum.React/Scripts/Operations/ContextualOperations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ function defaultConstructFromMany(coc: ContextualOperationContext<Entity>, ...ar
return;

API.constructFromMany<Entity, Entity>(coc.context.lites, coc.operationInfo.key, ...args).then(pack => {
Navigator.createNavigateOrTab(pack, coc.event!);
Navigator.createNavigateOrTab(pack, coc.event!)
.then(() => coc.context.markRows({}))
.done();
}).done();
}).done();

Expand Down Expand Up @@ -243,8 +245,9 @@ export function defaultContextualClick(coc: ContextualOperationContext<any>, ...
API.constructFromLite(coc.context.lites[0], coc.operationInfo.key, ...args)
.then(coc.onConstructFromSuccess || (pack => {
notifySuccess();
coc.context.markRows({});
Navigator.createNavigateOrTab(pack, coc.event!);
Navigator.createNavigateOrTab(pack, coc.event!)
.then(() => coc.context.markRows({}))
.done();
}))
.done();
} else {
Expand Down

0 comments on commit 235df9c

Please sign in to comment.