Создать справочник "Расширенный справочник" в прикладном модуле Внутренние документы.
Справочник состоит из полей:
Расширенный справочник должен находится в разделе "Справочники\Расширенные справочники".
Создать справочник может только пользователь с ролью ClassEditor.
Палитра инструментов
|
Данный этап разделяется на три части:
Схема данных описывает структуру данных объекта. Элементом Схемы данных является Свойство схемы. Свойство схемы может соответствовать одному полю документа или может являться ссылкой на другую Схему данных, описывающую составную часть объекта. |
Создать схему 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> |
С помощью иерархической структуры Секций и Полей описывается структура интерфейса формы –отображение объекта, описанного Схемой данных, в web-клиенте. Секцию верхнего уровня, соответствующую Схеме самостоятельного объекта, можно назвать Формой объекта. Секция верхнего уровня обязательно сопоставляется со Схемой данных, а Поля формы сопоставляются со Свойствами указанной Схемы. Способ отображения полей в web-клиенте зависит от типа Свойства Схемы. |
Создать форму ExtendsDirectoryForm на основании схемы ExtendsDirectory.
На форме создать три основные секции: Header (Шапка), RootMenu (Акции), Attributes (Реквизитная часть).
В Header подключить свойства схемы: type и showIdent
В Attributes подключить свойства схемы: value и description
В RootMenu создать штатный набор действий:
<?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> <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> |
С помощью документа система предоставляет пользователь создавать его. |
В документе указать:
<?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> |
Для отображения данных из sql-таблицы используются конфигурируемые коллекции + бин коллекции, метаданные возвращаемой коллекции |
Идентификаторы созданных справочников хранятся в таблице 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> |
С помощью дескриптора задаются колонки, которые будут отображаться в WEB-интерфейсе, а также кнопки. |
Создать дескриптор 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> <documentation>Значение</documentation> </meta> </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="Расширенный справочник"> <builder name="ru.intertrust.cm_sochi.srv.uicollections.UiBuilder" /> <table> <columns> <column-ref ref="self"/> <column-ref ref="value"/> <column-ref ref="description"/> </columns> </table> <actions> <action id="TUNABLE_OBJECT" name="${cls-directory-extends.TUNABLE_OBJECT:TUNABLE_OBJECT}"> <create object-ref="TUNABLE_OBJECT" /> </action> </actions> <custom-actions schema-ref="ExtendsDirectory"/> </custom-descriptor> </catalog> |
С помощью представлений происходит подключение дескриптора к навигационной панели |
Создать представление extendsDirectory и подключить его к навигатору helpers (Справочники)
Подключить к представлению дескриптор cls-directory-extends
<?xml version='1.0' encoding='UTF-8'?> <catalog xmlns="http://www.intertrust.ru/schema/palette/cat-ui"> <view parent-ref="helpers" id="extendsDirectory" name="${catalog.folder.ExtendsDirectory:Расширенный справочник}" position="200"> <descriptor-ref ref="cls-directory-extends"/> <source> <module ident="InternalDocs"/> </source> </view> </catalog> |
Пример расширенного справочника: InternalDocs_(cls-directory-extends).zip - кастомная коллекция, example.zip - схемы, формы, дескрипторы и т.д. |