API wrapper for more convenient writing of Targetprocess mashups.
npm install targetprocess-mashup-helper
var helper = require('targetprocess-mashup-helper')
You can require separate modules to decrease package size
var customUnits = require('targetprocess-mashup-helper/lib/customUnits')
Alias to .events.addBusListener
.
Alias to .events.addBusListenerOnce
.
Alias to .configurator.getAppConfigurator
.
Add listener to component bus by name.
helper.events.addBusListener('description', 'afterRender', function(e, renderData) {
//...
});
Same as .addBusListener(busName, eventName, callback, true)
.
Get application configurator and returns its promise.
helper.configurator.getAppConfigurator().then(function(configurator) {
// ...
});
Hash of constants to configure entity types custom unit is applied to.
Hash of constants to configure card sizes custom unit is applied to.
Add custom unit to registry, make it allowed to add to card.
Config:
id
(string) unit unique id.name
(string) name in library.outerClassName
(string | function) class name of unit wrapper for best styling.template
(object | string) template config, will be used astemplate.markup
if string.markup
(string) unit output injqote
format. Has access to unit data asthis.data
. E.g.<div class="tau-board-unit__value"><%= this.data.value %></div>
. Wrap template with class to get quick outputtau-board-unit__value
.customFunctions
(object) map of functions, which will be accessible inside template as<%= fn.someCustomFunction() %>
.
model
(object | string) data config, maps result of select query to data. E.g:{title: "title"}
, result data will be{title: <title of entity>}
sampleData
(object | string) sample data will be passed to unit template when using in librarytypes
(array) list of entity types of cards, where unit accessible, all types by default. UsecustomUnits.types
as values.sizes
(array) list of card sizes where unit is accessible, all sizes by default. UsecustomUnits.sizes
as values.priority
(number) order of custom unit in customize card tab (more is closer to an end, can use negative).hideIf
(function) check if unit will be hide entirely from card, e.g. if there is no data.isEditable
(boolean | function) check if unit is editableeditorComponentName
(string | function) name of editor componenteditorData
(object | function) transform unit data to editor data, by default pass unit data as is.
helper.customUnits.add({
id: 'good_field',
name: 'Good Field',
template: '<div class="tau-board-unit__value"><%= this.data.value %></div>',
model: {
value: '"Hello there"'
},
sampleData: {
value: '"Hello from library"'
}
});
helper.customUnits.add({
id: 'my_entity_state',
name: 'My Entity State',
template: '<div class="tau-board-unit__value"><%= this.data.entityState.id %> <%= this.data.entityState.name %></div>',
model: {
entityState: 'entityState'
},
sampleData: {
entityState: {
id: 12,
name: 'In Progress'
}
},
sizes: [cu.sizes.S],
types: [cu.types.STORY, cu.types.BUG]
});
helper.customUnits.add({
id: 'espn_custom_field',
name: 'ESPN',
template: '<div class="tau-board-unit__value">ESPN: <%= this.data.customField.value %></div>',
hideIf: function(data) {
return !data.customField;
},
model: {
customField: 'CustomValues.Get("ESPN")'
},
sampleData: {
customField: {
value: '231231224'
}
},
isEditable: true,
editorComponentName: 'customField.text.editor',
editorData: function(data) {
return {
cf: data.customField
};
}
});
Add attribute data-component-name
to component top DOM element for better debugging or using inside .addBusListener
function.
Output events and data of particular buses. predicate
can be a string -- name or id of bus (can be found after call of debug.showComponentsNames()
), function (bus, eventName, data)
or if is ommitted, all events of all buses will be logged. logger
is a function of (busName, eventName, data)
, it writes to console.log
. by default.
To publish new version, just commit/push using AngularJS Git Commit Message Conventions
New versions are automatically published to NPM from Travis CI with help of semantic-release when commit messages are formatted properly.
- feat: feature description
- fix: bug fix
- docs: documentation
- style: formatting, missing semi colons, …
- refactor: description
- test: description (when adding missing tests)
- chore: maintain infrastructure
- revert: (header of reverted commit)