项目

一般

简介

插件 » Redmine view customize 自定义Redmine界面视图插件

Redmine View Customize

发布于: https://github.com/onozaty/redmine-view-customize
兼容于: Redmine 5.1.*, 5.0.*, 4.2.*, 4.1.*, 4.0.*, 3.4.*, 3.3.*, 3.2.*, 3.1.*, 3.0.*, 2.6.*, 2.5.*, 2.4.*, 2.3.*, 2.2.*, 2.1.*, 2.0.*

最新版本: 3.5.0 更新日期: 2024-01-08 14:31

基本介绍

Redmine view customize插件允许自定义Redmine的界面视图,该插件通过匹配预置条件的方式向Redmine页面插入JavaScript、CSS 、HTML代码的方式实现对页面的修改。如下为具体的使用方法:

当插件成功安装后,在管理界面中将能看到“View customize”视图定制菜单:

点击“View customize”进入详细配置界面:

点击“New view customize”进入新增定制视图:

“Path pattern” 采用正则表达式定义,如果它匹配某个页面路径,则会插入对应代码并执行。

下面是几个样例.
  • .* : All pages
  • /issues$ : Issue list
  • /issues/[0-9]+ : Issue detail page

“Insertion position” 是代码插入的位置。

  • “Head of all pages” (The same position as the version before v1.2.0)
  • “Bottom of issue form”
  • Issue input fields are reconstructed when trackers or statuses are changed. If “Bottom of issue form” is specified, it will be executed again when reconstructed.
  • “Bottom of issue detail”

页面如果不存在对应的插入位置,则代码将不会插入。例如, 如果你的“Path pattern”定义是 .*, 但仅 “Bottom of issue detail” 定义为 “Insertion position",那么“issue detail page”的底部会执行代码.

“Type” 则用于选择代码类型 (“JavaScript”, “CSS” or “HTML”) 同时要输入对应类型的真实代码。

“Comment"可以放置有关定制的概要描述,此处内容会显示在列表当中。如果没有输入“Comment",“Code”会直接显示在列表中。

The specified code is executed 匹配“Path pattern”的自定义页面将执行具体指定的代码。

Edit / Delete 编辑

plugin_block_poster

点击定制列表前的序号可查看详细内容。

点击 “Delete”删除

点击 “Edit” 切换至编辑页。输入内容与创建时的条目是一致的。

Disable / Private 停用或保密

你可以通过取消“Enabled”可禁用。如果启用 “Private”,则仅作者可见。

如果确保“Private”没有问题,那么它就可以发布给大家了。

ViewCustomize.context (JavaScript)

你能使用ViewCustomize.context获取有关users和projects(用户和项目)信息。

ViewCustomize.context 内容如下:

ViewCustomize = {
  "context": {
    "user": {
      "id": 1,
      "login": "admin",
      "admin": true,
      "firstname": "Redmine",
      "lastname": "Admin",
      "lastLoginOn": "2019-09-22T14:44:53Z",
      "groups": [
        {"id": 5, "name": "Group1"}
      ],
      "apiKey": "3dd35b5ad8456d90d21ef882f7aea651d367a9d8",
      "customFields": [
        {"id": 1, "name": "[Custom field] Text", "value": "text"},
        {"id": 2, "name": "[Custom field] List", "value": ["B", "A"]},
        {"id": 3, "name": "[Custom field] Boolean", "value": "1"}
      ]
    },
    "project": {
      "identifier": "project-a",
      "name": "Project A",
      "roles": [
        {"id": 6, "name": "RoleX"}
      ],
      "customFields": [
        {"id": 4, "name": "[Project Custom field] Text", "value": "text"}
      ]
    },
    "issue": {
      "id": 1
    }
  }
}

例如,要用户的 API access key 可用 ViewCustomize.context.user.apiKey.

API access key
The API access key is created when the "Show" link of the API access key on the My account page is click for the first time.
"API access key"密钥可在Redmine"我的账号"页面获取(前提是Redmine要首先在API设置中启用"REST web service")。

要启用API access key,Redmine设置页面中的"API"页签中的 "Enable REST web service" 选项必须为启用状态。

举例

  • onozaty/redmine-view-customize-scripts: Script list for "Redmine View Customize Plugin"
  • Supported versions
    • Redmine 3.1.x - 3.4.x, 4.0.x or later
    • 1.2.2 : Redmine 2.0.x - 3.4.x