JSDoc

This documentation is intended to help you create plugins for Datashare client. All methods currently exposed in the Core class are available to a global variable called datashare.

Example

datashare.replaceWidget('default-text', {
  card: true,
  cols: 6,
  type: 'WidgetText',
  content: "Welcome to my amazing project dashboard!",
  title: "Secret Project",
  order: "-1"
})

Core

Class representing the core application with public methods for plugins.

Kind: global class Mixes: FiltersMixin, HooksMixin, I18nMixin, PipelinesMixin, ProjectsMixin, WidgetsMixin


new Core(api, mode)

Create an application

ParamDefaultDescription

api

Datashare api interface

mode

mode of authentication ('local' or 'server'


datashare.ready : Promise.<Object>

Get a promise that is resolved when the application is ready

Kind: instance property of Core Fullfil: Object The actual application core instance.


datashare.app : Core

Deprecated

The application core instance. Deprecated in favor or the core property.

Kind: instance property of Core


datashare.core : Core

The application core instance

Kind: instance property of Core


datashare.bootstrapVue ⇒ Plugin

The Bootstrap Vue plugin instance.

Kind: instance property of Core


datashare.i18n : I18n

The I18n instance

Kind: instance property of Core


datashare.router : VueRouter

The VueRouter instance

Kind: instance property of Core


datashare.store : Vuex.Store

The Vuex instance

Kind: instance property of Core


datashare.plugin ⇒ *

The CorePlugin instance

Kind: instance property of Core


datashare.auth : Auth

The Auth module instance

Kind: instance property of Core


datashare.config : Object

The configuration object provided by Murmur

Kind: instance property of Core


datashare.api : Api

The Datashare api interface

Kind: instance property of Core


datashare.vue : Vue

The Vue app

Kind: instance property of Core


datashare.wait : VueWait

The VueWait

Kind: instance property of Core


datashare.mode : String

Get current Datashare mode

Kind: instance property of Core


datashare.use(Plugin, options) ⇒ Core

Add a Vue plugin to the app

Kind: instance method of Core Returns: Core - the current instance of Core

ParamTypeDescription

Plugin

Object

The actual Vue plugin class

options

Object

Option to pass to the plugin


datashare.useAll() ⇒ Core

Configure all default Vue plugins for this application

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useI18n() ⇒ Core

Configure vue-i18n plugin

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useBootstrapVue() ⇒ Core

Configure bootstrap-vue plugin

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useRouter() ⇒ Core

Configure vue-router plugin

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useVuex() ⇒ Core

Configure vuex plugin

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useCommons() ⇒ Core

Configure most common Vue plugins (Murmur, VueShortkey, VueScrollTo and VueCalendar)

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useWait() ⇒ Core

Configure vue-wait plugin

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.useCore() ⇒ Core

Add a $core property to the instance's Vue

Kind: instance method of Core Returns: Core - the current instance of Core


datashare.buildCorePlugin() ⇒ VueCore

Build a VueCore instance with the current Core instance as parameter of the global properties.

Kind: instance method of Core


datashare.configure() ⇒ Promise.<Object>

Load settings from the server and instantiate most the application configuration.

Kind: instance method of Core Fullfil: Core - The instance of the core application Reject: Object - The Error object


datashare.mount([selector]) ⇒ Vue

Mount the instance's vue application

Kind: instance method of Core Returns: Vue - The instantiated Vue

ParamTypeDefaultDescription

[selector]

String

#app

Query selector to the mounting point


datashare.defer()

Build a promise to be resolved when the application is configured.

Kind: instance method of Core


datashare.dispatch(name, ...args) ⇒ Core

Dispatch an event from the document root, passing the core application through event message.

Kind: instance method of Core Returns: Core - the current instance of Core

ParamTypeDescription

name

String

Name of the event to fire

...args

Mixed

Additional params to pass to the event


datashare.getUser() ⇒ Promise.<Object>

Get the current signed user.

Kind: instance method of Core Fullfil: Object Current user


datashare.loadUser() ⇒ Promise

Get and update user definition in place

Kind: instance method of Core


datashare.loadSettings() ⇒ Promise

Get settings (both from the server settings and the current mode)

Kind: instance method of Core


datashare.setPageTitle(title, [suffix])

Append the given title to the page title

Kind: instance method of Core

ParamTypeDefaultDescription

title

String

Title to append to the page

[suffix]

String

Datashare

Suffix to the title


datashare.on(event, callback)

Register a callback to an event using the EventBus singleton.

Kind: instance method of Core

ParamType

event

String

callback

*


datashare.off(event, callback)

Unregister a callback to an event using the EventBus singleton.

Kind: instance method of Core

ParamType

event

String

callback

*


datashare.emit(event, payload)

Emit an event using the EventBus singleton.

Kind: instance method of Core

ParamType

event

String

payload

*


Core.init(...options) ⇒ Core

instantiate a Core class (useful for chaining usage or mapping)

Kind: static method of Core

ParamTypeDescription

...options

Mixed

Options to pass to the Core constructor


ComponentMixin

Mixin class extending the core to add helpers for components.

Kind: global mixin


FiltersMixin

Mixin class extending the core to add helpers for filters.

Kind: global mixin


datashare.registerFilter(...args)

Register a filter

Kind: instance method of FiltersMixin

ParamTypeDefaultDescription

...args

Mixed

Filter's params.

args.type

String

Type of the filter.

args.options

Object

Options to pass to the filter constructor.

args.options.name

String

Name of the filter.

args.options.key

String

Key of the filter. Typically ElasticSearch field name.

[args.options.icon]

String

Icon of the filter.

[args.options.isSearchable]

Boolean

false

Set if this filter should be searchable or not.

[args.options.alternativeSearch]

function

()=>{})

Set a function about how to transform query term before searching for it.

[args.options.order]

Number

Order of the filter. Will be added as last filter by default.


datashare.unregisterFilter(name)

Unregister a filter

Kind: instance method of FiltersMixin

ParamTypeDescription

name

String

Name of the filter to unregister


datashare.registerFilterForProject(name, ...args)

Register a filter only for a specific project

Kind: instance method of FiltersMixin

ParamTypeDescription

name

String

Name of the project

...args

Mixed

Filter's options.

args.name

String

Name of the filter

args.type

String

Type of the filter.

args.options

Object

Options to pass to the filter constructor


datashare.unregisterFilterForProject(name, name)

Unregister a filter only for a specific project

Kind: instance method of FiltersMixin

ParamTypeDescription

name

String

Name of the project

name

String

Name of the filter


HooksMixin

Mixin class extending the core to add helpers for hooks.

Kind: global mixin


datashare.registerHook(...args)

Register a hook

Kind: instance method of HooksMixin

ParamTypeDescription

...args

Mixed

Hook's options

args.name

String

Name of the hook

args.target

String

Target of the hook

args.order

Number

Priority of the hook

args.definition

Object

Options to pass to the hook constructor


datashare.unregisterHook(name)

Unregister a specific hook

Kind: instance method of HooksMixin

ParamTypeDescription

name

String

Name of the hook


datashare.resetHook(name)

Unregister all hooks from a target

Kind: instance method of HooksMixin

ParamTypeDescription

name

String

Name of the target


datashare.resetHooks()

Unregister all hooks, on every targets

Kind: instance method of HooksMixin


datashare.registerHookForProject(project, options)

Register a hook for a specific project

Kind: instance method of HooksMixin

ParamTypeDescription

project

String

Project to add this hook to

options

Object

Hook's options

options.name

String

Name of the hook

options.target

String

Target of the hook

options.order

Number

Priority of the hook

options.definition

Object

Options to pass to the hook constructor


I18nMixin

Mixin class extending the core to add helpers for i18n.

Kind: global mixin


datashare.initializeI18n() ⇒ Promise

Initialize i18N using the local storage and load the necessary locale's messages

Kind: instance method of I18nMixin


datashare.setI18nLocale(locale) ⇒ String

Set the active locale both in local stoage and VueI18n.

Kind: instance method of I18nMixin

ParamTypeDescription

locale

String

Key of the local (fr, de, en, ja, ...)


datashare.hasI18Locale(locale) ⇒ Boolean

Check the given locale storage was loaded.

Kind: instance method of I18nMixin

ParamTypeDescription

locale

String

Key of the local (fr, de, en, ja, ...)


datashare.loadI18Locale(locale) ⇒ Promise

Load i18n messages for the given locale (if needed) and set it as the current locale.

Kind: instance method of I18nMixin

ParamTypeDescription

locale

String

Key of the local (fr, de, en, ja, ...)


PipelinesMixin

Mixin class extending the core to add helpers for pipelines.

Kind: global mixin


datashare.registerPipeline(...args, category)

Register a pipeline

Kind: instance method of PipelinesMixin

ParamTypeDescription

...args

Mixed

Pipeline's options.

args.name

String

Name of the pipeline

args.type

String | function

Type of the pipeline.

category

String

The pipeline to target


datashare.unregisterPipeline(name)

Unregister a pipeline

Kind: instance method of PipelinesMixin

ParamTypeDescription

name

String

Name of the pipeline


datashare.registerPipelineForProject(project, ...args, category)

Register a pipeline for a specific project

Kind: instance method of PipelinesMixin

ParamTypeDescription

project

String

Name of the project

...args

Mixed

Pipeline's options.

args.name

String

Name of the pipeline

args.type

String | function

Type of the pipeline.

category

String

The pipeline to target


datashare.unregisterPipelineForProject(project, name)

Unregister a pipeline for a specific project

Kind: instance method of PipelinesMixin

ParamTypeDescription

project

String

Name of the project

name

String

Name of the pipeline


ProjectsMixin

Mixin class extending the core to add helpers for projects.

Kind: global mixin


datashare.toggleForProject(name, withFn, withoutFn, mutationType, storePath)

Call a function when a project is selected

Kind: instance method of ProjectsMixin

ParamTypeDescription

name

String

Name of the project

withFn

function

Function to call when the project is selected

withoutFn

function

Function to call when the project is unselected

mutationType

String

Mutation type that will be watched for changes.

storePath

String

Path to the project in the store


datashare.createDefaultProject() ⇒ Promise:Object

Create a default project on Datashare using the API

Kind: instance method of ProjectsMixin Returns: Promise:Object - The HTTP response object


WidgetsMixin

Mixin class extending the core to add helpers for widgets.

Kind: global mixin


datashare.registerWidget(...args)

Register a widget

Kind: instance method of WidgetsMixin

ParamTypeDefaultDescription

...args

Mixed

Widget's options passed to widget constructor

args.name

String

Name of the widget

args.card

Boolean

Either or not this widget should be a card component from Boostrap.

args.cols

Number

Number of columns to fill in the grid (from 1 to 12)

[args.type]

String

WidgetEmpty

Type of the widget


datashare.unregisterWidget(name)

Unregister a widget

Kind: instance method of WidgetsMixin

ParamTypeDescription

name

String

Name of the widget to unregister


datashare.clearWidgets()

Unregister all widgets

Kind: instance method of WidgetsMixin


datashare.registerWidgetForProject(project, options)

Register a widget for a specific project

Kind: instance method of WidgetsMixin

ParamTypeDefaultDescription

project

String

Name of the project to add this widget to

options

Object

Widget's options passed to widget constructor

options.name

String

Name of the widget

options.card

Boolean

Either or not this widget should be a card component from Boostrap

options.cols

Number

Number of columns to fill in the grid (from 1 to 12)

[options.type]

String

WidgetEmpty

Type of the widget


datashare.replaceWidget(name, options)

Replace an existing widget

Kind: instance method of WidgetsMixin

ParamTypeDefaultDescription

name

String

Name of the widget to replace

options

Object

Widget's options passed to widget constructor.

options.card

Boolean

Either or not this widget should be a card component from Boostrap

options.cols

Number

Number of columns to fill in the grid (from 1 to 12)

[options.type]

String

WidgetEmpty

Type of the widget

Example

datashare.replaceWidget('default-text', {
 card: true,
 cols: 6,
 type: 'WidgetText',
 content: "Welcome to my amazing project dashboard!",
 title: "Secret Project",
 order: "-1"
})

datashare.replaceWidgetForProject(project, name, options)

Replace an existing widget for a specific project

Kind: instance method of WidgetsMixin

ParamTypeDefaultDescription

project

String

Name of the project to add this widget to

name

String

Name of the widget to replace

options

Object

Widget's options passed to widget constructor. Each widget class can define its own default values.

options.card

Boolean

Either or not this widget should be a card component from Boostrap

options.cols

Number

Number of columns to fill in the grid (from 1 to 12)

[options.type]

String

WidgetEmpty

Type of the widget


projects ⇒ Array:String

List all projects this user has access to.

Kind: global variable


projectIds ⇒ Array:String

List all projects name ids this user has access to.

Kind: global variable


defaultProject ⇒ String

Get the name of the default project

Kind: global variable


findComponent(name) ⇒ Promise.<(object|null)>

Asynchronously find a component in the lazyComponents object by its name.

Kind: global function Returns: Promise.<(object|null)> - - A promise that resolves with the found component object, or null if not found.

ParamTypeDescription

name

string

The name of the component to find.


getComponent(name) ⇒ Promise.<(object|Error)>

Asynchronously get a component from the lazyComponents object based on its name.

Kind: global function Returns: Promise.<(object|Error)> - - A promise that resolves with the found component object, or rejects with an Error if not found.

ParamTypeDescription

name

string

The name of the component to retrieve.


sameComponentNames(...names) ⇒ boolean

Check if multiple component names are the same when slugified.

Kind: global function Returns: boolean - - True if all names are the same when slugified, false otherwise.

ParamTypeDescription

...names

string

The component names to compare.


componentNameSlug(name) ⇒ string

Generate a slug from the component name using kebab case and lowercase.

Kind: global function Returns: string - - The slugified component name.

ParamTypeDescription

name

string

The name of the component to slugify.


lazyComponents() ⇒ Object

Get the lazyComponents object using require.context for lazy loading of components.

Kind: global function Returns: Object - - The lazyComponents object generated using require.context.


defaultProjectExists() ⇒ Promise:Boolean

Return true if the default project exists

Kind: global function


findProject(name) ⇒ Object

Retrieve a project by its name

Kind: global function Returns: Object - The project matching with this name

ParamTypeDescription

name

String

Name of the project to retrieve


deleteProject(name) ⇒ Promise:Integer

Delete a project by it name identifier.

Kind: global function Returns: Promise:Integer - Index of the project deleted or -1 if project does not exist

ParamTypeDescription

name

String

Name of the project to retrieve


deleteProjectFromSearch(name)

Delete a project from the search store

Kind: global function

ParamTypeDescription

name

String

Name of the project to delete fropm the store


setProject(project) ⇒ Object

Update a project in the list or add it if it doesn't exist yet.

Kind: global function Returns: Object - The project

ParamType

project

Object


Last updated

Datashare is an open source project by the International Consortium of Investigative Journalists