mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Extract the generate_url(..) function from node.js, and collection.js
This commit is contained in:
committed by
Ashesh Vashi
parent
e9b80dae9c
commit
d527769bf8
23
web/pgadmin/static/js/browser/generate_url.js
Normal file
23
web/pgadmin/static/js/browser/generate_url.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import _ from 'underscore';
|
||||
|
||||
function generate_url(baseUrl, treeInfo, actionType, nodeType, pickFunction, itemDataID) {
|
||||
let ref = '';
|
||||
_.each(
|
||||
_.sortBy(
|
||||
_.pick(treeInfo, pickFunction),
|
||||
function (treeInfoItems) {
|
||||
return treeInfoItems.priority;
|
||||
}
|
||||
),
|
||||
function (treeInfoItems) {
|
||||
ref = `${ref}/${encodeURI(treeInfoItems._id)}`;
|
||||
}
|
||||
);
|
||||
ref = itemDataID ? `${ref}/${itemDataID}` : `${ref}/`;
|
||||
|
||||
return `${baseUrl}${nodeType}/${actionType}${ref}`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generate_url: generate_url,
|
||||
};
|
||||
Reference in New Issue
Block a user