Палитра инструментов
Реализация
Этап 1. Создание формы справочника
Данный этап разделяется на три части:
Создание схемы
Создать схему, в качестве наследника указать схему TNObject.
Добавить в схему свойства, которые должны быть в справочнике.
language | xml |
---|---|
title | ExtendsDirectory |
linenumbers | true |
collapse | true |
Создание формы справочника
Данный этап разделяется на три части:
Создать схему ExtendsDirectory, в качестве наследника указать схему TNObject.
Добавить в схему свойства (свойства описывают тип данных), которые должны быть в справочнике.
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version='1.0' encoding='UTF-8'?>
<schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema">
<schema extends="TNObject" name="ExtendsDirectory">
<meta>
<documentation>Пример расширенного справочника</documentation>
</meta>
<string name="type" default-value="Расширенный справочник" computed="true"/>
<string name="showIdent" computed="true" temporal="true">
<calc-values>
<script lang="SPEL" event="open"><![CDATA['Справочник']]></script>
</calc-values>
</string>
<string name="value">
<meta>
<documentation>Значение</documentation>
</meta>
<storage-field name="value"/>
</string>
<string name="description">
<meta>
<documentation>Описание</documentation>
</meta>
<storage-field name="description"/>
</string>
</schema>
</schemas> |
Форма
Создать форму ExtendsDirectoryForm на основании схемы ExtendsDirectory.
На форме создать три основные секции: Header (Шапка), RootMenu (Акции), Attributes (Реквизитная часть).
В Header подключить свойства схемы: type и showIdent
В Attributes подключить свойства схемы: value и description
В RootMenu создать штатный набор действий:
- button.hideSystem.Save=Скрыть системную кнопку Сохранить (системная операция)
- button.Create=Создать справочник (указать схему, по которой будет создаваться форма ExtendsDirectory)
- button.SaveNew=Сохранить (добавить системные условие применения TNObjectIsShowSaveButtonForNew)
- button.Save=Сохранить (добавить системные условие применения TNObjectIsShowSaveButton)
- button.Edit=Редактировать (добавить условие применения, чтобы видели пользователи с ролью ClassEditor)
- button.Delete=Удалить (добавить js-обработчик операций и условие применения, чтобы видели пользователи с ролью Supervisor и Trash)
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version='1.0' encoding='UTF-8'?> <ui xmlns="http://www.intertrust.ru/schema/palette/tn-ui"> <form id="ExtendsDirectoryForm" schema-ref="ExtendsDirectory" showtabs="true" projection="default"> <properties> <hide condition-union="AND"> <negative-condition-ref ref="edit" /> <negative-condition-ref ref="read" /> </hide> </properties> <component> <section id="Header"> <component> <field attribute-ref="showIdent"> <properties> <read-only condition-union="AND"> <condition>true</condition> </read-only> </properties> <appearance importance="normal" align="left"> <label-style unit="symbol" width="4" /> <alt-appearancies> <alt-appearance> <appearance-ref ref="css_headerElementWithIcon" /> <enable condition-union="AND"> <condition>true</condition> </enable> </alt-appearance> </alt-appearancies> </appearance> </field> <section group="true" id="Header_Top"> <component> <field attribute-ref="type"> <properties> <read-only condition-union="AND"> <condition>true</condition> </read-only> </properties> <appearance importance="normal"> <label-style> <style id="tunFontSize14"/> <style id="tunBold" /> </label-style> </appearance> </field> </component> <appearance field-layout="horizontal" /> </section> </component> </section> <section id="RootMenu"> <component> <button name="${button.hideSystem.Save:Скрыть системную кнопку Сохранить}"> <properties> <hide condition-union="AND"> <condition-ref ref="openAtDirectory" /> <condition>true</condition> </hide> </properties> <action> <system name="SAVE" /> </action> </button> <button name="${button.Create:Создать справочник}"> <icon code="90" /> <properties> <hide condition-union="AND"> <negative-condition-ref ref="read"/> </hide> </properties> <action> <custom> <create schema-ref="ExtendsDirectory"> <module-current>true</module-current> </create> </custom> </action> </button> <button name="${button.SaveNew:Сохранить}"> <icon code="92" /> <properties> <hide condition-union="AND"> <negative-condition-ref ref="TNObjectIsShowSaveButtonForNew" /> </hide> </properties> <action> <custom> <save /> </custom> </action> </button> <button name="${button.Save:Сохранить}"> <icon code="92" /> <properties> <hide condition-union="AND"> <negative-condition-ref ref="TNObjectIsShowSaveButton" /> </hide> </properties> <action> <custom> <save-existing /> </custom> </action> </button> <button name="${button.Edit:Редактировать}"> <properties> <hide condition-union="AND"> <condition-ref ref="isClassEditor" /> <condition>true</condition> </hide> </properties> <action> <system name="EDIT" /> </action> </button> <button name="${button.Delete:Удалить}"> <properties> <hide condition-union="AND"> <negative-condition-ref ref="classifierCanDelete"/> </hide> </properties> <icon code="94"/> <action position="12"> <custom> <operation> <handler-ref ref="DeleteClassifier"/> </operation> </custom> </action> </button> </component> </section> <section name="${tab.Attributes:Реквизиты}" id="Attributes"> <component> <field attribute-ref="value" name="${field.Value:Значение:}"> <properties> <requre condition-union="AND"> <negative-condition-ref ref="edit" /> <condition>true</condition> </requre> </properties> <appearance importance="normal"> <limit max-lenght="512" /> </appearance> </field> <field attribute-ref="description" name="${field.Description:Описание:}" </properties> <appearance importance="normal"> <limit max-lenght="512" /> </appearance> </field> <field attribute-ref="description" name="${field.Description:Описание:}"> <properties> <requre condition-union="AND"> <negative-condition-ref ref="edit" /> <condition>true</condition> </requre> </properties> <appearance importance="normal"> <limit max-lenght="512" /> </appearance> </field> </component> </section> </component> </form> </ui> |
Документ
В документе указать:
- схема ExtendsDirectory,
- имя формы TunableObjectClassifier,
- модуль InternalDocs
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version='1.0' encoding='UTF-8'?>
<catalog xmlns="http://www.intertrust.ru/schema/palette/cat-ui">
<tunable-object form-name="TunableObjectClassifier" name="${ExtendsDirectory:Расширенный справочник}" schema-ref="ExtendsDirectory">
<module ident="InternalDocs"/>
</tunable-object>
</catalog> |
Отображение данных справочника
Коллекция
Идентификаторы созданных справочников хранятся в таблице tunable_classifier, реквизитная часть храниться в tn_ таблицах.
Создать коллекцию InternalDocs_(cls-directory-extends), которая будет выводить информацию: Значение, Описание
Примечание |
---|
Коллекция должна находиться в папке src/main/resources/override/catalog/collection/InternalDocs_(cls-directory-extends) |
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<collection name="InternalDocs_(cls-directory-extends)" replace="runtime" idField="id" useClone="false">
<prototype>
<![CDATA[
select
id,
created_date,
module,
self_1,
self_2,
self_3,
value,
description
from
(
select
tc.id, tc.created_date, tc.module as module, '<id>' as self_1, ':' as self_2, '</>' as self_3,
coalesce ((
select
tfs.value
from
tn_field_string tfs
left join tn_field tf on
tf.owner = tc.id
and tf.owner_type = tc.id_type
where
tf.id = tfs.id
and tf.cmjfield ilike '%' || 'value' || '%' ), 'Не указано') as value,
coalesce ((
select
tfs.value
from
tn_field_string tfs
left join tn_field tf on
tf.owner = tc.id
and tf.owner_type = tc.id_type
where
tf.id = tfs.id
and tf.cmjfield ilike '%' || 'description' || '%' ), 'Не указано') as description
from
tunable_classifier tc
where
tc.schema = 'ExtendsDirectory' ) s
where
1 = 1
::where-clause
]]>
</prototype>
<counting-prototype>
<![CDATA[
SELECT
count(1)
FROM (select
tc.id, tc.created_date, tc.module as module, '<id>' as self_1, ':' as self_2, '</>' as self_3
from
tunable_classifier tc
where
tc.schema = 'ExtendsDirectory') s
WHERE 1 = 1
::where-clause
]]>
</counting-prototype>
<filter name="MODULE">
<criteria placeholder="where-clause">
<![CDATA[
Module = {0}
]]>
</criteria>
</filter>
</collection> |
Создать бин-коллекции InternalDocs_(cls-directory-extends)Metadata
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"
default-lazy-init="true">
<bean id="InternalDocs_(cls-directory-extends)Metadata"
class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.CollectionMetadataNew"
p:caseSensitiveFieldNames="true">
<constructor-arg>
<list value-type="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field">
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field" p:name="self">
<property name="virtualField">
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.TnUnidVirtualField">
<property name="realFields">
<list>
<value>self_1</value>
<value>Module</value>
<value>self_2</value>
<value>id</value>
<value>created_date</value>
<value>self_3</value>
</list>
</property>
<property name="separator" value=""/>
<property name="emptySeparator" value="true"/>
</bean>
</property>
</bean>
</list>
</constructor-arg>
</bean>
</beans> |
Дескриптор
Создать дескриптор cls-directory-extends и подключить к нему кастомную коллекцию (cls-directory-extends)
Указать в дескрипторе колонки value и description. Важно: подключаются описатели колонок (column), а не сами колонки из sql
Также нужно указать модуль, по которому будут фильтроваться отбираемые данные.
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version='1.0' encoding='UTF-8'?> <catalog xmlns="http://www.intertrust.ru/schema/palette/cat-ui"> <column name="value" subject="${column.value:Значение}" extends="string"> <meta> <properties> <documentation>Значение</documentation> </meta> <requre condition-union="AND</column> </catalog> |
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version='1.0' encoding='UTF-8'?> <catalog xmlns="http://www.intertrust.ru/schema/palette/cat-ui"> <custom-descriptor id="cls-directory-extends" view="(cls-directory-extends)" ident="InternalDocs" style="default" name="Расширенный справочник"> <negative-condition-ref ref="edit<builder name="ru.intertrust.cm_sochi.srv.uicollections.UiBuilder" /> <table> <condition>true</condition><columns> </requre><column-ref ref="self"/> </properties><column-ref ref="value"/> <appearance importance<column-ref ref="normaldescription"/> </columns> <limit max-lenght="512" /></table> <actions> <action </appearance>id="TUNABLE_OBJECT" name="${cls-directory-extends.TUNABLE_OBJECT:TUNABLE_OBJECT}"> <create </field>object-ref="TUNABLE_OBJECT" /> </component>action> </section>actions> </component><custom-actions schema-ref="ExtendsDirectory"/> </form>custom-descriptor> </ui>catalog> |
Создание документа
В документе указать:
- схема ExtendsDirectory,
- имя формы TunableObjectClassifier,
- модуль InternalDocs
Представление
Создать представление extendsDirectory и подключить его к навигатору helpers (Справочники)
Подключить к представлению дескриптор cls-directory-extends
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version='1.0' encoding='UTF-8'?> <catalog xmlns="http://www.intertrust.ru/schema/palette/cat-ui"> <tunable-object form-name="TunableObjectClassifier<view parent-ref="helpers" id="extendsDirectory" name="${catalog.folder.ExtendsDirectory:Расширенный справочник}" position="200" schema-> <descriptor-ref ref="ExtendsDirectorycls-directory-extends"/> <source> <module ident="InternalDocs"/> </source> </tunable-object>view> </catalog> |