# j-Permissions

> j-Permissions: - jComponent v19|v20; NEW: exec {String} optional, it executes a method (path.to.method) when the user changes the value

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 846a3e1a9fcb22a99979e6269ab8a51ab821a7a3e1aecffa7c0840d882b2bf92
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- - jComponent `v19|v20`

__Configuration__:

- `placeholder {String}` a placeholder for `j-Directory` component (default: `Search`)
- `types {String}` permission types (only one character per operation!!!!) (array delimited by comma, default: `R,W`)
- `dirsource {String}` optional, path to a data-source or __NEW__: `id|name,id|name`
- `empty {String}` optional, adds a text into the empty permissions
- `disabled {Boolean}` optional, disables this component
- `default {String}` default value of `type` (default: `R`)
- `dirraw {Boolean}` optional, disables HTML encoding for text in `j-Directory` (default: `false`)
- `autoremove {Boolean}` optional, it automatically removes non-existent permissions (default: `true`)
- `autoexclude {Boolean}` optional, it excludes the used permissions from the `dirsource` (default: `true`)
- __NEW__: `exec {String}` optional, it executes a method (`path.to.method`) when the user changes the value
- __NEW__: `button {String}` optional, a button label (default: `Add`)

__Source__:

```js
[
	{
		id: "123456",
		name: 'Peter'
	},
	{
		id: "654321",
		name: 'John'
	}
]
```

__Input & Output__:

```js
['R123456', 'W123456', 'W654321']
```

Use it with `<ui-component name="permissions">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="directory"></ui-component>
<ui-component name="permissions" path="mypermissions" config="dirsource:datasource;types:R|Read,U|Update;empty:Set permissions">Permissions</ui-component>

<div class="mt10"><ui-bind path="mypermissions" config="text:JSON.stringify(value)"></ui-bind></div>

<script>
	var mypermissions = ['Radmin', 'Remployee', 'Uaccountant'];
	var datasource = [{ id: 'admin', name: 'Admin' }, { id: 'employee', name: 'Employee' }, { id: 'accountant', name: 'Accountant' }];
</script>
```
