Importing dependencies into SP widget

A Oliver
Kilo Explorer

Morning all,

I'm trying to import the dragula libraries into a custom Service Portal widget.

I've tried both of these versions of Dragula for angular 1

  1. GitHub - luckylooke/dragular: Angular drag and drop based on dragula.js. Visit
  2. GitHub - bevacqua/angularjs-dragula: Drag and drop so simple it hurts

I've had success previously with a different drag and drop library, but I need some of the extra features of dragula.

In particular, for the directive and service providers, when I load these in the widget, I get "require not defined" and "module not defined".

At present I'm just trying to load the libraries with the widget, I'm yet to call dragula inside my widget anywhere.

Any hints as to how to correctly import a more complex library such as this, I'd be grateful.

Cheers

3 REPLIES 3

NickBain
Tera Contributor

Hi Alex



Not sure Service Portal is cut out for that. Normally it's straightforward to add external libraries, Dragular looks a bit more complex.



The portal guru nathanfirth might know?


nathanfirth
Tera Guru

The "require not defined" is because they're using require.js to include the JS files and dependencies. That won't work in Service Portal so you'll want to find the distribution version of the JS file (try using the JS file in the "dist" folder) and see if that solves it. Also are you trying to add it as an Angular Provider, Dependency, or JS Include?


If I remove the service and directive files from the angular providers list for my widget, it gets rid of the module and required not found issue.


Then with just the dragula lib files from the dist folder as a dependency I get the following error in my console on load:




Unknown provider: dragularServiceProvider <- dragularService