mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-11 06:42:56 +01:00
fix: showPopup replace error (#82)
Error: "TypeError: Cannot read properties of undefined (reading 'replace')"
This commit is contained in:
@@ -230,7 +230,7 @@ NodeContext.prototype.deregisterComponentModel = function (componentModel) {
|
|||||||
|
|
||||||
NodeContext.prototype.fetchComponentBundle = async function (name) {
|
NodeContext.prototype.fetchComponentBundle = async function (name) {
|
||||||
const fetchBundle = async (name) => {
|
const fetchBundle = async (name) => {
|
||||||
let baseUrl = Noodl.Env["BaseUrl"] || '/';
|
let baseUrl = Noodl.Env['BaseUrl'] || '/';
|
||||||
let bundleUrl = `${baseUrl}noodl_bundles/${name}.json`;
|
let bundleUrl = `${baseUrl}noodl_bundles/${name}.json`;
|
||||||
|
|
||||||
const response = await fetch(bundleUrl);
|
const response = await fetch(bundleUrl);
|
||||||
@@ -455,6 +455,15 @@ NodeContext.prototype.setPopupCallbacks = function ({ onShow, onClose }) {
|
|||||||
this.onClosePopup = onClose;
|
this.onClosePopup = onClose;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} popupComponent
|
||||||
|
* @param {Record<string, unknown>} params
|
||||||
|
* @param {{
|
||||||
|
* senderNode?: unknown;
|
||||||
|
* onClosePopup?: (action?: string, results: object) => void;
|
||||||
|
* }} args
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
NodeContext.prototype.showPopup = async function (popupComponent, params, args) {
|
NodeContext.prototype.showPopup = async function (popupComponent, params, args) {
|
||||||
if (!this.onShowPopup) return;
|
if (!this.onShowPopup) return;
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,18 @@ const { RouterHandler } = require('../nodes/navigation/router-handler');
|
|||||||
const NoodlRuntime = require('@noodl/runtime');
|
const NoodlRuntime = require('@noodl/runtime');
|
||||||
|
|
||||||
const navigation = {
|
const navigation = {
|
||||||
|
/**
|
||||||
|
* This is set by "packages/noodl-viewer-react/src/noodl-js-api.js"
|
||||||
|
* @type {NoodlRuntime}
|
||||||
|
*/
|
||||||
|
_noodlRuntime: undefined,
|
||||||
|
|
||||||
async showPopup(componentPath, params) {
|
async showPopup(componentPath, params) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
navigation._noodlRuntime.context.showPopup(componentPath, params, {
|
navigation._noodlRuntime.context.showPopup(componentPath, params, {
|
||||||
onClosePopup: (action, results) => {
|
onClosePopup: (action, results) => {
|
||||||
resolve({
|
resolve({
|
||||||
action: action.replace('closeAction-', ''),
|
action: action?.replace('closeAction-', ''),
|
||||||
parameters: results
|
parameters: results
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user