0.6.5 • Published 4 years ago

vca-widget-user v0.6.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

WidgetUser

npm vue2

Implements different visualizations for a user.

Preconditions

Using this package requires a running version of Drops, that has already implemented issue #225. Additionally, the web server you are using to run the front end application using this widget, has to use the same domain and the same port as Drops. Drops has to be deployed using the path prefix /drops/.

Widgets

This package implements several UI elements to handle user-specific interaction with the business objects User and Crew of the Pool² (e.g. input fields to search for a user or HTML and CSS code to present a user in a standard way). Using the widgets implemented here, you can ensure that users of your microservice will have the same user experience regarding other users as using the other microservices of Pool².

Plain crew name

Since microservices should be loosely coupled, ideally they only save references to data objects managed by other microservices. Therefore, you need widgets to print a data object, if you only have a reference.

This widget prints a crew name by a given crews UUID.

npm.io

You can use it that way:

<CrewPlainName id="606693fe-c057-4f05-8b29-2cc4975dda82" />

Since it has been implemented as a simple <span> tag without any styling, you can define the font and background color as you want.

ParameterTypeOptionalDefaultDescription
idStringrequiredNo default valueThe crews UUID. It will be used for an ajax request to obtain the crew object.

There are no slots for this widget

There are no events of this widget

Crew select

It allows the user to select a crew. The widget fires an event after selection that returns the UUID of the selected crew.

npm.io

You can use it that way (crewUuid and handler are example names for variable and function):

<CrewSelect value="crewUuid" :disabled="false" v-on:input="handler" />
ParameterTypeOptionalDefaultDescription
valueStringoptional""The UUID of the crew selected by default (e.g. a previously selected value).
disabledBooleanoptionalfalseIndicates if the select box is disabled.

There are no slots for this widget

EventData
inputThe UUID of the selected crew.

Tag

Using this widget, you can show user or crew names as small (removable) tags. On click, the user will be redirected to the profile page of the user that is represented by the tag.

npm.io npm.io

You can use it that way:

<Tag uuid="606693fe-c057-4f05-8b29-2cc4975dda82" :removable="false" :crew="false" />
ParameterTypeOptionalDefaultDescription
uuidStringoptionalNo default valueThe UUID of the user whose name has to be printed.
userObjectoptionalNo default valueThe whole user object, thus an additional ajax request (in contrast to the parameter uuid) is not required.
removableBooleanoptionalfalseIndicates if the "X" button has to be visible.
crewBooleanoptionalfalseIf set to true the name of the users crew instead of the individuals name is been used.

There are no slots for this widget

EventData
vca-user-removeThe object representing the removed user.
vca-user-focusThe object representing the focused user.
vca-user-blurThe object representing the blurred user.

Avatar

Shows the avatar (profile image) of a user.

npm.io npm.io

You can use it that way:

<Avatar :user="user" type="type" />
ParameterTypeOptionalDefaultDescription
userObjectoptionalNo default valueThe whole user object.
typeStringrequired-The type can be 'medium' (4em x 4em), 'large' (10em x 10em) or 'profile' (20em x 20em).

There are no slots for this widget

There are no events of this widget

VcA Role

Shows the role of a user as a tag.

npm.io

You can use it that way:

<VcARole name="VolunteerManager" pillar="network" />
ParameterTypeOptionalDefaultDescription
nameStringoptionalNo default valueThe name of the role that will be shown. Possible values: admin, employee, supporter, VolunteerManager
pillarStringoptionalNo default valueIf the role to be shown is a volunteer manager, the area of responsibility can be described here. Possible values: network, operation, finance, education
translatedStringoptionalNo default valueIf you already have a translated string, you can force the VcARole to use it by passing it through this attribute.

There are no slots for this widget

There are no events of this widget

User Widget

Visualizes a user in various forms.

npm.io npm.io npm.io

You can use it that way:

<UserWidget uuid="13e42965-cd78-459a-97e0-35a91c01ab4d" type="large" />
ParameterTypeOptionalDefaultDescription
uuidUUIDoptionalNo default valueIf given, the printed user will be requested from Drops when the widget is created by an ajax request.
userObjectoptionalNo default valueIf given, the object will be interpreted as complete user that will be printed. No additional ajax requests are required.
typeStringrequired-Indicates the form of presentation. There are three different forms (and thus are the values of the attribute): small, medium and large
removableBooleanoptionalfalseIf the type is set to small and removable is true, a small button labeled with "X" will be shown at the right border of the widget. A click triggers a vca-user-remove event.

There are no slots for this widget

EventData
vca-user-removeThe object representing the removed user.
vca-user-focusThe object representing the focused user.
vca-user-blurThe object representing the blurred user.

User Widget List

Shows a set of users and implements functions to search through, sort and paginate the set. There are four different forms of visualizing the set: as large user widget, as medium user widget, as small user widget and as table columns.

npm.io

You can use it that way:

<WidgetUserList :options="{ lang: 'de-DE', type: { menue: true, value: 'table' }, sorting: { menue: { field: 'Supporter_firstName', dir: 'ASC' } }, pagination: { activated: true, size: 40, sliding: 20 } }" />
ParameterTypeOptionalDefaultDescription
optionsObjectoptionalSee exampleConfigures the widget. Consider: type: menue indicates if sort and search function have to be visible, type: value configures the visualization of users (allowed values: table, big widgets (large user widget), small widgets (medium user widget), tags (small user widget)), sorting: menue: field allows all attributes of a user, pagination: size defines the number of users shown on a page and pagination: sliding defines the number of users that are removed at the beginning of a page and appended at the end of page on a page switch.

There are no slots for this widget

There are no events of this widget

User Widget Autocomplete

Allows to select a list of users by an autocomplete field.

npm.io

You can use it that way:

<WidgetUserAutocomplete placeholder="Enter user name..." />
ParameterTypeOptionalDefaultDescription
placeholderStringoptionalNo default valueThe placeholder for the input field.
preselectionArray of user objectsoptional[]Used to pass all already selected users. They will be shown as removable tags.

There are no slots for this widget

EventData
vca-user-selectionAn Array of selected user objects.

Installation

npm install --save vca-widget-user

Usage

Bundler (Webpack, Rollup)

import Vue from 'vue'
import WidgetUserList from 'vca-widget-user'
// You need a specific loader for CSS files like https://github.com/webpack/css-loader
import 'vca-widget-user/dist/vca-widget-user.css'

Vue.use(WidgetUserList)

export default {
  name: 'App',
  components: { WidgetUserList },
  data () {
    return { options: {
      'type': { 'menue': true, 'value': 'table' },
      'sorting': { 'menue': { 'field': 'Supporter_firstName', 'dir': 'ASC' } },
      'lang': 'de'
    } }
  }
}

Inside your template:

<template>
  <div id="app">
    <WidgetUserList :options="options" />
  </div>
</template>

Existing internationalization

If you already use vue-i18n to handle your internationalization and localization, we have to merge our messages into yours. You can do this in your main.js before you instantiate your Vue App.

import Vue from 'vue';
...
import VueI18n from 'vue-i18n';
import WidgetUserList from 'vca-widget-user' // use `WidgetUser` if you don't need a list of users

Vue.use(VueI18n);

const i18n = new VueI18n({
    locale: locale,
    messages: {
        'en-US': require('@/lang/en_US'),
        'de-DE': require('@/lang/de_VCA'),
        'ja-JA': require('../node_modules/element-ui/lib/locale/lang/ja')
    }
});

// the most important line of code here
Vue.use(WidgetUserList, { 'i18n': i18n })

/* eslint-disable no-new */

new Vue({
  ...
  i18n,
  components: { WidgetUserList },
  ...
}).$mount('#app');

Afterwards, you don't have to use Vue.use(WidgetUserList) in your components again.

Browser

<!-- Include after Vue -->
<!-- Local files -->
<link rel="stylesheet" href="widget-user/dist/widget-user.css"></link>
<script src="vca-widget-user/dist/widget-user.js"></script>

<!-- From CDN -->
<link rel="stylesheet" href="https://unpkg.com/vca-widget-user/dist/widget-user.css"></link>
<script src="https://unpkg.com/vca-widget-user"></script>

Development

Launch visual tests

npm run dev

Launch Karma with coverage

npm run dev:coverage

Build

Bundle the js and css of to the dist folder:

npm run build

Publishing

The prepublish hook will ensure dist files are created before publishing. This way you don't need to commit them in your repository.

# Bump the version first
# It'll also commit it and create a tag
npm version
# Push the bumped package and tags
git push --follow-tags
# Ship it 🚀
npm publish

License

MIT

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.6

4 years ago

0.5.7-nvm

5 years ago

0.5.6-nvm

5 years ago

0.5.5-nvm

5 years ago

0.5.5

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.11

5 years ago

0.4.10

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.10

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago