Skip to content

Commit

Permalink
Merge pull request #34 from DHTMLX/sp-next-editbar-configuration
Browse files Browse the repository at this point in the history
Editbar configuration guide and API description
  • Loading branch information
serhiipylypchuk1991 authored May 15, 2024
2 parents f4d108d + c2a7125 commit cfa0e51
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 43 deletions.
31 changes: 19 additions & 12 deletions docs/api/diagram_editor/editbar/config/controls_property.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,38 @@ description: You can learn about the controls property of Editbar in the documen
@short: Optional. A set of configurations that defines one or several custom controls

:::info
The `controls` property allows you to create custom Editbar controls based on [**Basic controls**](/api/diagram_editor/editbar/basic_controls_overview/) and/or [**Complex controls**](/api/diagram_editor/editbar/complex_controls_overview). Use the [`properties`](api/diagram_editor/editbar/config/properties_property.md) property to apply the custom control(s) to the needed elements.
The `controls` property allows you to create custom **Editbar** controls based on [**Basic controls**](api/diagram_editor/editbar/basic_controls_overview.md) and/or [**Complex controls**](api/diagram_editor/editbar/complex_controls_overview.md). Use the [`properties`](api/diagram_editor/editbar/config/properties_property.md) property to apply the custom control(s) to the needed elements (shapes, groups, swimlanes, etc.).

Refer to the [**Editbar configuration**](guides/diagram_editor/editbar.md) guide for more information about configuring!
:::

:::important
We do not recommend you to redefine default controls when creating a custom control. Use individual name for each custom control!
:::

### Usage

~~~jsx
controls?: {
[type: string]: object, // custom control
// another control
};
~~~

### Parameters

- `type` - the type name of a new control
- `object` - the configuration object of a new control
- `type` - the type name of a custom control
- `object` - the configuration object of a new control based on [**Basic controls**](api/diagram_editor/editbar/basic_controls_overview.md) and/or [**Complex controls**](api/diagram_editor/editbar/complex_controls_overview.md)

~~~jsx
controls: {
estimate: { ... }, // create new "estimate" control with custom configurations
// another control
estimate: { /*...*/ }, // create new "estimate" control with custom configurations
// another control
}
~~~

### Example

~~~jsx {16-26}
~~~jsx {16-28}
const editor = new dhx.DiagramEditor("editor_container", {
type: "org",
view: {
Expand All @@ -51,26 +54,30 @@ const editor = new dhx.DiagramEditor("editor_container", {
width: 300,
properties: {
$shape: [
{ type: "estimate" },
{ type: "name" }
{ type: "estimate" }, // apply the "estimate" custom control
{ type: "name" } // apply the "name" custom control
]
},
controls: {
estimate: {
// create the "estimate" custom control
estimate: {
type: "fieldset",
label: "Time estimate",
rows: [
{ type: "datepicker", key: "date_start", label: "Date start" },
{ type: "datepicker", key: "date_end", label: "Date end" }
]
},
// create the "name" custom control
name: { type: "input", label: "Name", key: "name" }
}
}
}
});
~~~

**Change log**: Added in v6.0
**Change log**: The property was added in v6.0

**Related article:** [**Editbar configuration**](guides/diagram_editor/editbar.md)

**Related sample**: [Diagram Editor. Default mode. PERT сhart with the legend](https://snippet.dhtmlx.com/w8mrh3ay)
**Related sample:** [Diagram Editor. Default mode. PERT сhart with the legend](https://snippet.dhtmlx.com/w8mrh3ay?mode=wide)
65 changes: 40 additions & 25 deletions docs/api/diagram_editor/editbar/config/properties_property.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ description: You can learn about the properties property of Editbar in the docum

### Description

@short: Optional. A set of configurations that modify controls for Diagram elements (shapes, groups, swimlanes, etc.)
@short: Optional. A set of configurations that modify controls for Diagram elements (shapes, groups, swimlanes etc.)

:::info
The `properties` property allows you to do the following:
- modify editbar controls for all or individual Diagram elements based on [**Basic controls**](/api/diagram_editor/editbar/basic_controls_overview/) and/or [**Complex controls**](/api/diagram_editor/editbar/complex_controls_overview)
- apply custom editbar control(s) defined via the [`controls`](api/diagram_editor/editbar/config/controls_property.md) property to Diagram elements
- specify conditions for applying an editbar control (custom or default) to Diagram elements
The `properties` config allows you to do the following:
- modify Editbar controls for all or individual Diaram elements base on [**Basic controls**](api/diagram_editor/editbar/basic_controls_overview.md) and/or [**Complex controls**](api/diagram_editor/editbar/complex_controls_overview.md)
- apply custom Editbar control(s) defined via the [`controls`](api/diagram_editor/editbar/config/controls_property.md) property to Diagram elements
- specify conditions for applying an Editbar control (custom or default) to Diagram elements

Refer to the [**Editbar configuration**](guides/diagram_editor/editbar.md) guide for more information about configuring!
:::
Expand All @@ -24,13 +24,12 @@ Refer to the [**Editbar configuration**](guides/diagram_editor/editbar.md) guide
~~~jsx
properties?: {
[type: string]: object[] | function, // custom configurations for controls applied to Diagram elements
// ...
};
~~~

### Parameters

- `type` - the type name of a Diagram element
- `type` - the name of a Diagram element or group of elements
- `object` - the configuration object of a Diagram element

or
Expand All @@ -39,23 +38,37 @@ properties?: {
- `item` - (optional) the object of the selected element
- `editor` - (required) the object of the Diagram editor

~~~jsx {3-4,8-15}
You can configure Editbar controls for a separate Diagram element, for instance **rectangle**, **circle**, **card** etc.:

~~~jsx
properties: {
// modify Editbar controls for individual elements (shapes)
rectangle: {}, // configure controls for the "rectangle" type
circle: {}, // configure controls for the "circle" type
card: {}, // configure controls for the "card" type
estimate: {}, // configure controls for the custom "estimate" type
// other elements
}
~~~

You can also configure Editbar controls for a separate group of Diagram elements. There are the following service properties to configure groups:

- [`$default`](guides/diagram_editor/editbar.md#configure-editbar-for-the-grid-area) - allows configuring Editbar controls if no elements are selected, or more than one element is selected
- [`$shape`](guides/diagram_editor/editbar.md#configure-editbar-for-shapes) - allows configuring Editbar controls for all shapes including custom shapes
- [`$group`](guides/diagram_editor/editbar.md#configure-editbar-for-group-elements) - allows configuring Editbar controls for all elements with the "group" type
- [`$swimlane`](guides/diagram_editor/editbar.md#configure-editbar-for-swimlanes) - allows configuring Editbar controls for all elements with the "swimlane" type
- [`$line`](guides/diagram_editor/editbar.md#configure-editbar-for-lines) - allows configuring Editbar controls for all elements with the "line" type
- [`$lineTitle`](guides/diagram_editor/editbar.md#configure-editbar-for-line-titles) - allows configuring Editbar controls for all elements with the "lineTitle" type

~~~jsx
properties: {
// modify the estimate element (shape)
estimate: // Diagram element
{ ... } // configuration object

// or

$shape: // type of Diagram elements
({ item, editor }) => { // the callback function that returns the configuration object
const controls = [
// some configurations
];
// ... custom logic here
return controls;
},
//... another element
$default: {},
$shape: {},
$group: {},
$swimlane: {},
$line: {},
$lineTitle: {},
// ... other parameters
}
~~~

Expand Down Expand Up @@ -111,6 +124,8 @@ const editor = new dhx.DiagramEditor("editor_container", {
});
~~~

**Change log**: Added in v6.0
**Change log**: The property was added in v6.0

**Related article:** [**Editbar configuration**](guides/diagram_editor/editbar.md)

**Related sample**: [Diagram Editor. Default mode. Network PERT chart](https://snippet.dhtmlx.com/wdijghbn)
**Related sample:** [Diagram Editor. Default mode. Customization of editbar. Added shape counter](https://snippet.dhtmlx.com/ealq0m4l?mode=wide)
167 changes: 162 additions & 5 deletions docs/guides/diagram_editor/editbar.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,170 @@
---
sidebar_label: Editbar TODO
sidebar_label: Editbar
title: Editor Guides - Editbar
description: You can learn about the Editbar of editor in the documentation of the DHTMLX JavaScript Diagram library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Diagram.
---

# Editbar
# Editbar

Здесь мы рассказываем как настроить Editbar и перечисляем несколько сценариев как настроить контролы с небольшими комментариями как в коде так и вне его.
You can configure Editbar controls for each Diagram element separately and for a [group of elements](/guides/items_index) taking into account various conditions. For this purpose, use the Editbar [`properties`](api/diagram_editor/editbar/config/properties_property.md) config.

Даем ссылки на [Basic controls](/api/diagram_editor/editbar/basic_controls_overview/) и [Complex controls](/api/diagram_editor/editbar/complex_controls_overview/), в которых детально расписаны всевозможные свойства (смотреть задачи https://tracker.webix.io/agiles/87-97/88-554?issue=DHX-4537 / https://tracker.webix.io/agiles/87-97/88-554?issue=DHX-4538)
If you want to configure Editbar controls for an individual [shape](/category/shapes), you need to specify the corresponding **shape type** within the [`properties`](api/diagram_editor/editbar/config/properties_property.md) config as shown in the example below:

Даем ссылки и детально рассказываем как настраивать контролы внутри свойств [`properties`](api/diagram_editor/editbar/config/properties_property.md) и [`controls`](api/diagram_editor/editbar/config/controls_property.md)
~~~jsx {6-9}
const editor = new dhx.DiagramEditor("editor_container", {
type: "default",
view: {
editbar: {
properties: {
rectangle: [ // configure editbar controls for the "pert" shape
{ type: "arrange", $properties: { angle: { hidden: true } }},
// ... other Editbar controls configuration
],
// ... other shapes configuration
},
// ...
},
// ...
}
});
~~~

To configure a [group of elements](/guides/items_index), you need to use the following service properties within the [`properties`](api/diagram_editor/editbar/config/properties_property.md) config:

- [`$default`](#configure-editbar-for-the-grid-area) - allows configuring Editbar controls if no elements are selected, or more than one element is selected
- [`$shape`](#configure-editbar-for-shapes) - allows configuring Editbar controls for [all shapes including custom shapes](/category/shapes)
- [`$group`](#configure-editbar-for-group-elements) - allows configuring Editbar controls for all elements with the [**group**](/groups/) type
- [`$swimlane`](#configure-editbar-for-swimlanes) - allows configuring Editbar controls for all elements with the [**swimlane**](/swimlanes/) type
- [`$line`](#configure-editbar-for-lines) allows configuring Editbar controls for all elements with the [**line**](/lines/) type
- [`$lineTitle`](#configure-editbar-for-line-titles) - allows configuring Editbar controls for all elements with the [**lineTitle**](/line_titles/) type

<iframe src="https://snippet.dhtmlx.com/ealq0m4l?mode=js" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>

## Configure Editbar for the grid area

The `$default` service property allows configuring Editbar controls if no elements are selected, or more than one element is selected.

~~~jsx
properties: {
$default: [
{
type: "gridStep",
readOnly: true,
// ...
},
// ...
]
}
~~~

**Related complex controls:** [Grid step](/api/diagram_editor/editbar/complex_controls/gridstep/), [Border](/api/diagram_editor/editbar/complex_controls/border/), [Arrange](/api/diagram_editor/editbar/complex_controls/arrange/)

## Configure Editbar for shapes

The `$shape` service property allows configuring Editbar controls for [all shapes including custom shapes](/category/shapes).

~~~jsx
properties: {
$shape: [
{
type: "position",
$properties: {
dx: { disabled: true },
// ...
},
// ...
},
// ...
]
}
~~~

**Related complex controls:** [Border](/api/diagram_editor/editbar/complex_controls/border/), [Arrange](/api/diagram_editor/editbar/complex_controls/arrange/), [Position](/api/diagram_editor/editbar/complex_controls/position/), [Size](/api/diagram_editor/editbar/complex_controls/size/), [Text align](/api/diagram_editor/editbar/complex_controls/textalign/), [Text style](/api/diagram_editor/editbar/complex_controls/textstyle/)

## Configure Editbar for group elements

The `$group` service property allows configuring Editbar controls for all elements with the [**group**](/groups/) type.

~~~jsx
properties: {
$group: [
{
type: "header",
label: "Group header style",
// ...
},
// ...
]
}
~~~

**Related complex controls:** [Border](/api/diagram_editor/editbar/complex_controls/border/), [Arrange](/api/diagram_editor/editbar/complex_controls/arrange/), [Header](/api/diagram_editor/editbar/complex_controls/header/), [Header common](/api/diagram_editor/editbar/complex_controls/headercommon/), [Header position](/api/diagram_editor/editbar/complex_controls/headerposition/), [Size](/api/diagram_editor/editbar/complex_controls/size/), [Text align](/api/diagram_editor/editbar/complex_controls/textalign/), [Text style](/api/diagram_editor/editbar/complex_controls/textstyle/)

## Configure Editbar for swimlanes

The `$swimlane` service property allows configuring Editbar controls for all elements with the [**swimlane**](/swimlanes/) type.

~~~jsx
properties: {
$swimlane: [
{
type: "header",
label: "Swimlane header style",
// ...
},
// ...
]
}
~~~

**Related complex controls:** [Border](/api/diagram_editor/editbar/complex_controls/border/), [Arrange](/api/diagram_editor/editbar/complex_controls/arrange/), [Header](/api/diagram_editor/editbar/complex_controls/header/), [Header common](/api/diagram_editor/editbar/complex_controls/headercommon/), [Header position](/api/diagram_editor/editbar/complex_controls/headerposition/), [Size](/api/diagram_editor/editbar/complex_controls/size/), [Text align](/api/diagram_editor/editbar/complex_controls/textalign/), [Text style](/api/diagram_editor/editbar/complex_controls/textstyle/)

## Configure Editbar for lines

The `$line` service property allows configuring Editbar controls for all elements with the [**line**](/lines/) type.

~~~jsx
properties: {
$line: [
{
type: "lineShape",
label: "Line connection type",
// ...
},
// ...
]
}
~~~

**Related complex controls:** [Border](/api/diagram_editor/editbar/complex_controls/border/), [Line shape](/api/diagram_editor/editbar/complex_controls/lineshape/), [Pointer view](/api/diagram_editor/editbar/complex_controls/pointerview/)

## Configure Editbar for line titles

The `$lineTitle` service property allows configuring Editbar controls for all elements with the [**lineTitle**](/line_titles/) type.

~~~jsx
properties: {
$lineTitles: [
{
type: "textAlign",
label: "Text align",
// ...
},
// ...
]
}
~~~

**Related complex controls:** [Text align](/api/diagram_editor/editbar/complex_controls/textalign/), [Text style](/api/diagram_editor/editbar/complex_controls/textstyle/)

## Create and configure custom Editbar controls

You can use the [`controls`](api/diagram_editor/editbar/config/controls_property.md) property of the Editbar view to create a custom control based on [**Basic controls**](api/diagram_editor/editbar/basic_controls_overview.md) and/or [**Complex controls**](api/diagram_editor/editbar/complex_controls_overview.md).

:::warning
We do not recommend you to use a default control type (refer to the [***Basic controls***](api/diagram_editor/editbar/basic_controls_overview.md) and/or [***Complex controls***](api/diagram_editor/editbar/complex_controls_overview.md)) as the name for a custom control. Use the unique name for each custom control to avoid errors!
:::

After creating a custom control, you need to apply it to the needed Diagram element via the [`properties`](api/diagram_editor/editbar/config/properties_property.md) property.

<iframe src="https://snippet.dhtmlx.com/w8mrh3ay?mode=js" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
2 changes: 1 addition & 1 deletion docs/guides/diagram_editor/shapebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Depending on the chosen elements, the configuration of items of a particular sec

1. Rendering of basic sections

You can render [a basic set of shapes](api/diagram_editor/shapebar/config/sections_property.md#basic) using the `sections` configuration object. For example:
You can render a basic set of shapes using the `sections` configuration object. For example:

~~~jsx
const editor = new dhx.DiagramEditor("editor_container", {
Expand Down

0 comments on commit cfa0e51

Please sign in to comment.