Skip to content

Commit

Permalink
add action support method
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardo-devis-agullo committed Jan 5, 2024
1 parent da48bef commit 04d0928
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oc-client-browser",
"version": "1.7.2",
"version": "1.7.3",
"description": "OC browser client",
"main": "index.js",
"types": "index.d.ts",
Expand Down
31 changes: 30 additions & 1 deletion src/oc-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ var oc = oc || {};
callback();
};

oc.getData = function (options, cb) {
function getData(options, cb) {
cb = cb || noop;
isRequired('version', options.version);
isRequired('baseUrl', options.baseUrl);
Expand Down Expand Up @@ -317,6 +317,35 @@ var oc = oc || {};
}

oc.$.ajax(ajaxOptions);
}
oc.getData = getData;
oc.getAction = function (options) {
return new Promise((resolve, reject) => {
var renderedComponent = window.oc.renderedComponents[options.component],
baseUrl = options.baseUrl || renderedComponent.baseUrl,
version = options.version || renderedComponent.version;

getData(
{
action: options.action,
name: options.component,
version: version,
baseUrl: baseUrl,
parameters: options.parameters
},
(err, data) => {
if (err) {
return reject(err);
}
delete data.component.props._staticPath;
delete data.component.props._baseUrl;
delete data.component.props._componentName;
delete data.component.props._componentVersion;

resolve(data.component.props);
}
);
});
};

oc.build = function (options) {
Expand Down

0 comments on commit 04d0928

Please sign in to comment.