mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Adds an endpoint for calling the plugin code to "locate" something
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
|
||||
/* exported
|
||||
installPlugin,
|
||||
locateItemOrLocation
|
||||
*/
|
||||
|
||||
function installPlugin() {
|
||||
@ -24,3 +25,50 @@ function installPlugin() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function locateItemOrLocation(options={}) {
|
||||
|
||||
if (!options.item && !options.location) {
|
||||
console.error("locateItemOrLocation: Either 'item' or 'location' must be provided!");
|
||||
return;
|
||||
}
|
||||
|
||||
function performLocate(plugin) {
|
||||
inventreePut(
|
||||
'{% url "api-locate-plugin" %}',
|
||||
{
|
||||
plugin: plugin,
|
||||
item: options.item,
|
||||
location: options.location,
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Request the list of available 'locate' plugins
|
||||
inventreeGet(
|
||||
'{% url "api-plugin-list" %}',
|
||||
{
|
||||
mixin: 'locate',
|
||||
},
|
||||
{
|
||||
success: function(plugins) {
|
||||
// No 'locate' plugins are available!
|
||||
if (plugins.length == 0) {
|
||||
console.warn("No 'locate' plugins are available");
|
||||
} else if (plugins.length == 1) {
|
||||
// Only a single locate plugin is available
|
||||
performLocate(plugins[0].key);
|
||||
} else {
|
||||
// More than 1 location plugin available
|
||||
// Select from a list
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user