Code source wiki de Organization Chart Macro
Afficher les derniers auteurs
| author | version | line-number | content |
|---|---|---|---|
| 1 | == Description == | ||
| 2 | |||
| 3 | This macro allows to display an organization chart either from data provided as a wiki list, either from data provided as json, either from the users of the wiki using a "manager" field in the user profile. | ||
| 4 | |||
| 5 | To configure the XWiki fields, visit the [[OrgChartSetup]] page. | ||
| 6 | |||
| 7 | {{toc start=2 /}} | ||
| 8 | |||
| 9 | == Macro Parameters == | ||
| 10 | |||
| 11 | |= Parameter Name |= Description |= Possible values |= Default value | ||
| 12 | | source | | list, json, xwiki | list if there is a content parameter, xwiki if not | ||
| 13 | | content field | wiki list or json to use as data source | see examples | empty | ||
| 14 | | user | user to start the organizational chart in xwiki source mode| any user document (XWiki.ID)| If none provided the macro will look for the first user having no manager and being a manager of at least on person | ||
| 15 | | managerfield | name of the field used to store the manager of a person| any users field in the XWiki.XWiki Users class| manager | ||
| 16 | | titlefield | name of the field used to store the title of a person| any field in the XWiki.XWikiUsers class| title | ||
| 17 | |||
| 18 | == Simple Organization Chart using an unordered list == | ||
| 19 | |||
| 20 | {{code}} | ||
| 21 | {{orgchart}} | ||
| 22 | * Jef | ||
| 23 | ** John | ||
| 24 | ** Joe | ||
| 25 | *** Patrick | ||
| 26 | *** Marie | ||
| 27 | {{/orgchart}} | ||
| 28 | {{/code}} | ||
| 29 | |||
| 30 | {{orgchart}} | ||
| 31 | * Jef | ||
| 32 | ** John | ||
| 33 | ** Joe | ||
| 34 | *** Patrick | ||
| 35 | *** Marie | ||
| 36 | {{/orgchart}} | ||
| 37 | |||
| 38 | == Simple Organization Chart using json == | ||
| 39 | |||
| 40 | {{code}} | ||
| 41 | {{orgchart source="json"}} | ||
| 42 | { | ||
| 43 | 'name': 'Lao Lao', | ||
| 44 | 'title': 'general manager', | ||
| 45 | 'children': [ | ||
| 46 | { 'name': 'Bo Miao', 'title': 'department manager' }, | ||
| 47 | { 'name': 'Su Miao', 'title': 'department manager', | ||
| 48 | 'children': [ | ||
| 49 | { 'name': 'Tie Hua', 'title': 'senior engineer' }, | ||
| 50 | { 'name': 'Hei Hei', 'title': 'senior engineer', | ||
| 51 | 'children': [ | ||
| 52 | { 'name': 'Dan Dan', 'title': 'engineer' } | ||
| 53 | ] | ||
| 54 | }, | ||
| 55 | { 'name': 'Pang Pang', 'title': 'senior engineer' } | ||
| 56 | ] | ||
| 57 | }, | ||
| 58 | { 'name': 'Hong Miao', 'title': 'department manager' } | ||
| 59 | ] | ||
| 60 | } | ||
| 61 | {{/orgchart}} | ||
| 62 | {{/code}} | ||
| 63 | |||
| 64 | {{orgchart source="json"}} | ||
| 65 | { | ||
| 66 | 'name': 'Lao Lao', | ||
| 67 | 'title': 'general manager', | ||
| 68 | 'children': [ | ||
| 69 | { 'name': 'Bo Miao', 'title': 'department manager' }, | ||
| 70 | { 'name': 'Su Miao', 'title': 'department manager', | ||
| 71 | 'children': [ | ||
| 72 | { 'name': 'Tie Hua', 'title': 'senior engineer' }, | ||
| 73 | { 'name': 'Hei Hei', 'title': 'senior engineer', | ||
| 74 | 'children': [ | ||
| 75 | { 'name': 'Dan Dan', 'title': 'engineer' } | ||
| 76 | ] | ||
| 77 | }, | ||
| 78 | { 'name': 'Pang Pang', 'title': 'senior engineer' } | ||
| 79 | ] | ||
| 80 | }, | ||
| 81 | { 'name': 'Hong Miao', 'title': 'department manager' } | ||
| 82 | ] | ||
| 83 | } | ||
| 84 | {{/orgchart}} | ||
| 85 | |||
| 86 | == Organization Chart based on XWiki users == | ||
| 87 | |||
| 88 | For this organization chart to work you need to create a field in the XWiki.XWikiUsers class to hold the manager of a user. | ||
| 89 | Also you need to provide the top of the organization chart to start with. | ||
| 90 | |||
| 91 | {{code}} | ||
| 92 | {{orgchart source="xwiki" user="XWiki.Admin" managerfield="manager" titlefield="title" /}} | ||
| 93 | {{/code}} | ||
| 94 | |||
| 95 | {{orgchart source="xwiki" user="XWiki.Admin" managerfield="manager" titlefield="title" /}} | ||
| 96 | |||
| 97 | XWiki can also find automatically a user that had reporters and no manager to start the tree | ||
| 98 | |||
| 99 | {{code}} | ||
| 100 | {{orgchart /}} | ||
| 101 | {{/code}} | ||
| 102 | |||
| 103 | {{orgchart /}} |