Skip to content

Commit 87cd1d3

Browse files
committed
Add ViewCustomize.context information to README
1 parent a90a22b commit 87cd1d3

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

README.ja.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,51 @@ Redmineのプラグインディレクトリに、このリポジトリを`view_c
7777

7878
まずは「Private」で動作確認したうえで、動作に問題なければ全体に公開するといった使い方ができます。
7979

80+
### ViewCustomize.context (JavaScript)
81+
82+
JavaScriptのコードでは、`ViewCustomize.context`としてユーザやプロジェクトの情報にアクセスすることができます。
83+
84+
`ViewCustomize.context`の情報は下記のようなイメージです。
85+
86+
```javascript
87+
ViewCustomize = {
88+
"context": {
89+
"user": {
90+
"id": 1,
91+
"login": "admin",
92+
"admin": true,
93+
"firstname": "Redmine",
94+
"lastname": "Admin",
95+
"groups": [
96+
{"id": 5, "name": "Group1"}
97+
],
98+
"roles": [ // ユーザに紐づく全てのロール(全プロジェクト)
99+
{"id": 4, "name": "Developer"},
100+
{"id": 6, "name": "RoleX"}
101+
],
102+
"apiKey": "3dd35b5ad8456d90d21ef882f7aea651d367a9d8",
103+
"customFields": [
104+
{"id": 1, "name": "[Custom field] Text", "value": "text"},
105+
{"id": 2, "name": "[Custom field] List", "value": ["B", "A"]},
106+
{"id": 3, "name": "[Custom field] Boolean", "value": "1"}
107+
]
108+
},
109+
"project": {
110+
"identifier": "project-a",
111+
"name": "Project A",
112+
"roles": [ // プロジェクト内でのロール
113+
{"id": 6, "name": "RoleX"}
114+
]
115+
},
116+
"issue": {
117+
"id": 1
118+
}
119+
}
120+
}
121+
```
122+
123+
例えばユーザのAPIキーにアクセスするには`ViewCustomize.context.user.apiKey`となります。
124+
80125
## 設定例
81126

82127
* [onozaty/redmine\-view\-customize\-scripts: Script list for "Redmine View Customize Plugin"](https://github.com/onozaty/redmine-view-customize-scripts)

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,51 @@ You can disable it by unchecking "Enabled". If you check "Private", it will be e
8585

8686
If you check the operation with "Private" and there is no problem in operation, it will be good to release it to the all.
8787

88+
### ViewCustomize.context (JavaScript)
89+
90+
You can access information on users and projects using `ViewCustomize.context`.
91+
92+
`ViewCustomize.context` is as follows.
93+
94+
```javascript
95+
ViewCustomize = {
96+
"context": {
97+
"user": {
98+
"id": 1,
99+
"login": "admin",
100+
"admin": true,
101+
"firstname": "Redmine",
102+
"lastname": "Admin",
103+
"groups": [
104+
{"id": 5, "name": "Group1"}
105+
],
106+
"roles": [ // All roles associated with users (all projects)
107+
{"id": 4, "name": "Developer"},
108+
{"id": 6, "name": "RoleX"}
109+
],
110+
"apiKey": "3dd35b5ad8456d90d21ef882f7aea651d367a9d8",
111+
"customFields": [
112+
{"id": 1, "name": "[Custom field] Text", "value": "text"},
113+
{"id": 2, "name": "[Custom field] List", "value": ["B", "A"]},
114+
{"id": 3, "name": "[Custom field] Boolean", "value": "1"}
115+
]
116+
},
117+
"project": {
118+
"identifier": "project-a",
119+
"name": "Project A",
120+
"roles": [ // Roles in the project
121+
{"id": 6, "name": "RoleX"}
122+
]
123+
},
124+
"issue": {
125+
"id": 1
126+
}
127+
}
128+
}
129+
```
130+
131+
For example, to access the user's API key is `ViewCustomize.context.user.apiKey`.
132+
88133
## Examples
89134

90135
* [onozaty/redmine\-view\-customize\-scripts: Script list for "Redmine View Customize Plugin"](https://github.com/onozaty/redmine-view-customize-scripts)

0 commit comments

Comments
 (0)