angular js wrapper for add content workflow
npm install add-content-workflow-angularjsUniversal UI workflow built in AngularJS to enable use of the add content feature from anywhere within the media intelligence family of products.
TL;DR; See example implementation here or pull this repo down and run locally to see the workflow in action. Copy-paste is your friend!
1. Include the minified JS bundle in your project
- Staging Assets URL: https://assets.meltwater.io/workflows/ng-mi-add-content/staging/add-content-workflow.min.js
- Production Assets URL: https://assets.meltwater.io/workflows/ng-mi-add-content/add-content-workflow.min.js
2. Ensure the following peer dependencies are included in your project. Newer versions of these dependencies may work just fine. Pirates will let you know ahead of time if you are required to update any of these dependencies for a new version of this module to work properly.
``html`
angular.module('app', ['ngMaterial', 'mwAppComponents', 'MW.AddContentWorkflow']);
3. You will also need @meltwater/node-translation version 1.11.109 or greater
4. Use the module in your AngularJS app by adding it to your app module dependencies
AddContentWorkflowService
5. Use the in a component controller`
javascript...
app.component('yourComponent', {
template: ,...
controller: function(AddContentWorkflowService, $mdToast) {
`
}
})
openWorkflow
6. Call the method on the service to launch the workflow. IMPORTANT: You must pass in language, timezone, and countryCode so that dates are properly formatted, translations are properly shown and, most importantly, regional restrictions are properly enforced.
`javascript...
app.component('yourComponent', {
template: ,`
controller: function(AddContentWorkflowService, $mdToast) {
this.openAddContent = function(event) {
// In a production app, you will get these values from actual user object
var userObject = {
_id: 'YOUR_USER_ID',
language: 'en',
timezone: 'America/New_York',
countryCode: 'us',
activeCompanyId: 'YOUR_COMPANY_ID'
};
// var preSelectedTagNames = ['TagName']; // This is optional. If tag names are specified, these tags will be selected in the details step of the flow
// This function returns an $mdDialog promise, which you can use to determine whether
// the initiation of adding the content was successful or not
AddContentWorkflowService.openWorkflow(event, {
userObject: userObject,
// preSelectedTags: preSelectedTags // Optional here as well
})
.then(function() {
$mdToast.show(
$mdToast.simple()
.textContent('Content added!')
);
})
.catch(function(error) {
// $mdDialog.cancel() is called internally and will also cause this catch to fire,
// so make sure there is an actual error before showing an error message to the user
if (error) {
console.error('Error adding content', error);
$mdToast.show(
$mdToast.simple()
.textContent('Error adding content...')
);
}
})
}
}
})
That should be all you need to do to start adding content from within your AngularJS app. If you have any problems or questions about how to implement, hit us up on slack in #eng-team-pirates and we will be happy to help!
TL;DR; check out example implementation here
1. Follow the steps to include the necessary dependencies for the add content workflow
2. Calling the service to show this dialog is very similar to the add content workflow and is as follows:
`javascript
AddContentWorkflowService.openContentStatusDialog(event, { documents: documents })
.then(function (documents) {
$mdToast.show(
$mdToast.simple()
.textContent('Content status reviewed')
);
})
.catch(function (error) {
// $mdDialog.cancel() is called internally and will also cause this catch to fire,
// so make sure there is an actual error before showing an error message to the user
if (error) {
console.error('Error reviewing content status', error);
$mdToast.show(
$mdToast.simple()
.textContent('Error reviewing content status...')
);
}
})
`openContentStatusDialog
The method expects the event as the first argument, and a config object with at least a documents property, which is just an Array of documents in the "fairhair" format (the format returned by Keystone)openContentStatusDialog
3. Handle the promise returned from the method and you will receive one argument to the callback which will be an array of documents that have been extended with reach and other enrichments. None of the properties you passed in will be overridden, so if you change the title or description or another field value, they will be preserved.
in the workflow-core and then in the angularjs workflow npm link @meltwater/add-content-workflow-core
2. Make sure you are logged into staging.meltwater.net, as the workflow will be using your gyda token to make requests to the add-content-bff
3. Run npm start`, wait a few moments, your default browser should open automatically