门户:如何使用增加按钮

在本操作方法中,我们使用CreateBrick添加一个快速请求按钮。

名称:如何增加按钮

类型:如何

听众:管理员IntegratorDeveloper

水平:中等

持续时间:30分钟

关键词:portal,  Customization

iTop版本:2.3.0

先决条件

您将需要:

  • 知道如何将iTop扩展和升级用作系统,
  • 装有安装了演示数据和增强门户的iTop系统,
  • 可以访问具有足够权利的账号来连接到门户(通常这意味着拥有门户用户描述)。

该教程的目的

在此教程中,您将学习如何:

  • 将砖添加到默认的门户
  • 使用CreateBrick砖块制作一个按钮,以打开门户中任何位置的创建表单

Create button

分步说明

创建扩展

首先,我们需要创建一个iTop扩展,它将扩展门户XML配置以添加新的砖。从自定义指南中检查扩展模块部分(iTop定制)(如有必要)。

  1. 该扩展命名为sample-portal-add-button。
  2. 删除main.sample-portal-add-button.php文件,因为我们不需要任何PHP代码。

您应该具有以下结构:

Module structure

更改门户配置

现在有了扩展,我们只需要制作一个XML delta,然后将变更和门户配置添加到砖中即可。打开datamodel.sample-portal-add-button.xml文件并粘贴以下代码:

datamodel.sample-portal-add-button.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
  <module_designs>
    <module_design id="itop-portal" xsi:type="portal">
      <bricks>
        <brick id="quick-new-user-request" xsi:type="Combodo\iTop\Portal\Brick\CreateBrick" _delta="define">
          <active>true</active>
          <rank>
            <default>70</default>
          </rank>
          <width>4</width>
          <modal>true</modal>
          <title>
            <default>Brick:Portal:QuickNewUserRequest:Title</default>
          </title>
          <visible>
            <home>false</home>
          </visible>
          <decoration_class>
            <default>fa fa-bolt fa-2x fa-fw</default>
          </decoration_class>
          <!-- Class that will be create created with the form -->
          <class>UserRequest</class>
          <rules>
            <rule id="contact-to-userrequest"/>
          </rules>
        </brick>
      </bricks>
    </module_design>
  </module_designs>
</itop_design>

这会为门户添加一块积木,它将:

  • 在首页和导航菜单中都放置在其他砖块之后,因为它的排名大于其他砖块的排名。
  • 不显示在主页上。
  • 在模式对话框中打开表单,而不是重定向到整个页面。
  • 制作一个表单以创建类UserRequest的对象。
  • 带有联系人到用户请求功能规则的一些预设。

该按钮标签的字典条目

编辑文件en.dict.sample-portal-add-button.php以添加按钮标签的条目,如下所示:

en.dict.sample-portal-add-button.php
 
<?php
Dict::Add('EN US', 'English', 'English', (
        'Brick:Portal:QuickNewUserRequest:Title' => 'Quick new request',
));

您可以为其他语言重复相同的运维。

升级系统

最后,运行iTop系统的升级,并选中新扩展名选项,然后访问门户。您应该在导航菜单上看到新的Quick new request按钮。单击它,创建表单将打开。

Et voilà !

https://www.itophub.io/wiki/media?w=800&tok=c9dcdc&media=2_7_0%3Acustomization%3Asample-portal-add-create-button-3.png

与默认的UserRequest创建流程的主要区别在于,您不必通过服务目录来选择ServiceSubcategory。允许您从门户的任何位置创建对象。

资料下载

您可以在此处找到一些示例主题的扩展:: sample-portal-add-button-1.0.0-145.zip

原贴链接:https://www.itophub.io/wiki/page?id=2_7_0%3Acustomization%3Aportal_howto_addbutton


Portal: How to add a create button

In this How to, we use the CreateBrick to add a quick request button.

name:
How to add a create button
type:
How To
audience:
AdministratorIntegratorDeveloper
level:
Intermediate
duration:
30min
keyword:
PortalCustomization
iTop version:
2.3.0

Prerequisites

What you will need to:

  • Know how to make an iTop extension and upgrade your system,

  • Have an iTop system with the demo data and the enhanced portal installed,

  • Have access to an account with enough rights to connect to the portal (usually this means having the Portal User profile).

Aim of this tutorial

In this tutorial, you will learn how to:

  • Add a brick to the default portal

  • Use the CreateBrick brick to make a button opening a creation form anywhere in the portal

Create button

Step by step instructions

Creating the extension

First, we need to create an iTop extension that will alter the portal XML configuration to add a new brick. Check the Extension modules part from the customization guide (iTop Customization) if necessary.

  1. Name the extension as sample-portal-add-button.

  2. Remove the main.sample-portal-add-button.php file as we won't need any PHP code.

You should have the following structure:Module structure

Changing the portal configuration

Now that we have the extension, we just need to make an XML delta and change the portal configuration to add the brick. Open the datamodel.sample-portal-add-button.xml file and paste the following code:

datamodel.sample-portal-add-button.xml
 
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
  <module_designs>
    <module_design id="itop-portal" xsi:type="portal">
      <bricks>
        <brick id="quick-new-user-request" xsi:type="Combodo\iTop\Portal\Brick\CreateBrick" _delta="define">
          <active>true</active>
          <rank>
            <default>70</default>
          </rank>
          <width>4</width>
          <modal>true</modal>
          <title>
            <default>Brick:Portal:QuickNewUserRequest:Title</default>
          </title>
          <visible>
            <home>false</home>
          </visible>
          <decoration_class>
            <default>fa fa-bolt fa-2x fa-fw</default>
          </decoration_class>
          <!-- Class that will be create created with the form -->
          <class>UserRequest</class>
          <rules>
            <rule id="contact-to-userrequest"/>
          </rules>
        </brick>
      </bricks>
    </module_design>
  </module_designs>
</itop_design>

This adds a brick to the portal that will :

  • Be placed after the other bricks in both the home page and the navigation menu as its rank is greater than those from other bricks.

  • Not be displayed on the home page.

  • Open the form in a modal dialog instead of redirecting to a whole page.

  • Make a form to create a object of class UserRequest.

  • With some presets from the contact-to-userrequest action rule.

Dictionary entry for the label of the button

Edit the file en.dict.sample-portal-add-button.php to add an entry for the label of the button, as shown below:

en.dict.sample-portal-add-button.php
 
<?php
Dict::Add('EN US', 'English', 'English', (
        'Brick:Portal:QuickNewUserRequest:Title' => 'Quick new request',
));

You can repeat the same operation for other languages.

Upgrading the system

Finally run an upgrade of your iTop system with the new extension option checked and access the portal. You should see the new Quick new request button on the navigation menu. Click it and a creation form will open.

Et voilà !

https://www.itophub.io/wiki/media?w=800&tok=c9dcdc&media=2_7_0%3Acustomization%3Asample-portal-add-create-button-3.png

The main difference with the default UserRequest creation process is that you don't have to go through the services catalog to choose the ServiceSubcategory; allowing you to create objects from anywhere in the portal.

Downloads

You can find this extension with some example themes here: sample-portal-add-button-1.0.0-145.zip

标签:
由 superadmin 在 2020/08/27, 17:29 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司