Develop with NRP

NRP provides an action to create what we call a Full-Package that can be used in any other plugin.

What is Full-Package?

A Full-Package is a full NRP items linked together:

  • PlanningItem

  • ⮑ Assignment

  • ⮑ Article

How can i create a Full-Package?

NRP uses Dashboard Actions to expose its function to create a Full-Package

In your plugin you can ask Dashboard to give you the action and utilise it in your plugin.

First thing you need to do is to require an action from your plugin so you can map it later in Plugin Mappings to the action from NRP.

Follow the steps in Require an Action.

After you register your required action you need to map the NRP action to your plugin in order to use it

example

In your plugin register function:

import { register } from 'Dashboard'

register({
    application: Application,

    requirements: {
        actions: [
            {
                id: 'NRP_CREATE_FULL_PACKAGE',
                name: 'Create a full NRP pacakge.',
                description: 'Action to handle creating a full package from NRP.'
            }
        ]
    }
})

Map NRP action to your plugin

In Dashboard go to store and click on your plugin after you install it and then click on Mappings

From there you should see your required action:

By clicking on Select action, you should see all the available actions from all the installed plugins, including the NRP action.

By selecting the correct option and clicking on save, your plugin now has the create full package method, and it's ready to be used.

Make sure that you have NRP plugin installed and configured and active in your Dashboard so you can see the option in Select action

Use create full package in your plugin

After we registered the required action and mapped it to the correct on from NRP, we can use it in plugin

See how to utilise Dashboard actions in your plugin here

example

import {
    useRef
} from 'react'

import {
    useAction,
    getMappedId
} from 'Dashboard'

const MyComponent = () => {
    const createFullPackageAction = useRef(
        useAction(
            getMappedId('@plugin_bundle', 'action', 'NRP_CREATE_FULL_PACKAGE')
        )
    )

    const handleCreateFullPackage = () => {
        createFullPackageAction.current({
            headline: 'My package headline!',
            startDate: '2020-02-26T15:14:28.708Z',
            assigneeInfo: {
                name: 'Author name', // the Author concept name.
                uuid: 'b25b129e-5951-4d03-8739-7bd3714b95fb' // the Author concept uuid.
            }
        }).then(results => {
            console.log('Successfully created a full package with NRP:', results)
        }).catch(error => {
            console.log('Error while creating a full package with NRP:', error)
        })
    }

    return (
        <div>
            <button onClick={handleCreateFullPackage}>
                Create a full package with NRP
            </button>
        </div>
    )
}

If the request went fine you should see the results from the action looks like:

Params tabel

Create full package action is a function returning a promise which resolves with the full package items info and rejects if something went wrong, and it accepts one argument type object with the following keys:

Key

Type

Required

Description

headline

String

x

Headline for all the package items: PlanningItem, Assignment and Article

startDate

String

x

Start date for all the package items in ISO format

assigneeInfo

Object

x

An object contains the assignee info: uuid and name to link it to the Assignment and the Article