-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from agility/apps-sdk-v2-marketplace
tweak to modal params
- Loading branch information
Showing
9 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const getCloseModalID = (): string | null => { | ||
if (typeof window === 'undefined') return null | ||
const params = window.location.search | ||
const urlParams = new URLSearchParams(params) | ||
const id = urlParams.get('closeModalID') ?? null | ||
return id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { IAppEventParam, IModalParam } from '../types'; | ||
import { getOperationID } from '../lib/getOperationID'; | ||
import { Subject } from 'rxjs'; | ||
import { addOperation } from '../lib/operationAccess'; | ||
import { getAppID } from '../lib/getAppID'; | ||
import { invokeAppMethod } from '../lib/invokeAppMethod'; | ||
import { getCloseModalID } from '../lib/getCloseModalID'; | ||
|
||
/** | ||
* Closes the current modal and passes the props to the callback. Only to be used on a modal surface. | ||
* | ||
* @param {*} props | ||
*/ | ||
export const closeModal = ( props : any) => { | ||
|
||
const appID = getAppID() | ||
const closeModalID = getCloseModalID() | ||
if (!appID || !closeModalID) return | ||
|
||
const operationID = getOperationID() | ||
|
||
const arg: IAppEventParam<{ closeModalID: string, props: any }> = { | ||
appID, | ||
operationID, | ||
operationType: "closeModal", | ||
arg: { | ||
closeModalID, | ||
props | ||
} | ||
} | ||
|
||
|
||
//call the method in the parent windpow | ||
invokeAppMethod(arg) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
export interface IModalParam<T> { | ||
/** | ||
* The title to show on the model. Include this to have the built-in title bar with close button. Omit it to do your own title bar. | ||
* | ||
* @type {string} | ||
* @memberof IModalParam | ||
*/ | ||
title: string | ||
|
||
/** | ||
* The name of the modal to show. | ||
* | ||
* @type {string} | ||
* @memberof IModalParam | ||
*/ | ||
name: string | ||
|
||
/** | ||
* The props to pass to the modal. | ||
* | ||
* @type {*} | ||
* @memberof IModalParam | ||
*/ | ||
props?: any | ||
callback: (result: T) => void | ||
|
||
/** | ||
* The callback for when the modal is closed. | ||
* | ||
* @memberof IModalParam | ||
*/ | ||
callback: (result?: T) => void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters