Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
{
"viewName": "bankcard"
},
{
"viewName": "warecreation"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
},
{
"viewName": "radio"
},
{
"viewName": "mvg"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "mvg",
"title": "Multivalue Group",
"template": "DashboardView",
"url": "/screen/components/view/mvg",
"widgets": [
{
"widgetName": "SecondLevelMenu",
"position": 0,
"gridWidth": 2
},
{
"widgetName": "emptyDoc",
"position": 1,
"gridWidth": 2,
"descriptionFile": "db/migration/liquibase/data/latest/widgets/fields/Mvg.md"
},
{
"widgetName": "wareMvgHeader",
"position": 2,
"gridWidth": 2
},
{
"widgetName": "wareMvg",
"position": 3,
"gridWidth": 2
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "warecreation",
"title": "Ware Creation",
"template": "DashboardView",
"url": "/screen/example/view/warecreation/",
"widgets": [
{
"widgetName": "wareCreation",
"position": 0,
"gridWidth": 2
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "warecreationscr",
"title": "Ware Creation",
"primaryViewName": "warecreation",
"primaryViews": [
"warecreation"
],
"navigation": {
"menu": [
{
"viewName": "warecreation"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Multivalue
With `multivalue` field is a field that can contain more than one value.

## API
| Property | Description | Type | Default |
|:---|:---| :---| :---|
| **widgetName*** | name of widget containing mvg-field | `string` | - |
| **bcName*** | business component name | `string` | - |
| **disabled** | whether input is disabled | `boolean` | undefined |
| **placeholder** | placeholder for mvg-field | `string` | - |
| **fieldKey** | name of mvg-field | `string` | - |
| **fields** | fields that should be converted into mvg | `string` | - |

## Example for using
Adding to entity:
```java
public class Ware extends BaseEntity {
//<...>
@OneToMany
Set<WareComponent> componentSet;

@OneToMany
List<WareComponent> componentList;
}
```
Adding to DTO:
```java
public class WareDTO extends DataResponseDTO {
//<...>
private MultivalueField components;

private MultivalueField componentsList;
//<...>
}
```
Converting to Multivalue in DTO constructor:
```java
public class WareDTO extends DataResponseDTO {

public WareDTO(Ware ware) {

if (ware.getComponentSet() != null) {
this.components = ware.getComponentSet().stream().peek(wc -> {
wc.getName();
}).collect(MultivalueField.toMultivalueField(
wc -> wc.getName(), WareComponent::getName
));
}
//Or like this from List
List<MultivalueFieldSingleValue> comps = new ArrayList<>();
if (ware.getComponentList() != null) {
comps = ware.getComponentList().stream().map(wc -> new MultivalueFieldSingleValue(wc.getId().toString(), wc.getName()))
.collect(Collectors.toList());
}
this.componentsList = new MultivalueField(comps);

}
}
```
Set specific fields in field meta:

| Field | Value |
|:---|:---|
| **type*** | `multivalue` |

\* - required
```ts
{
"label": "Components",
"key": "components",
"type": "multivalue"
}
```
```ts
{
"label": "Components List",
"key": "componentsList",
"type": "multivalue"
}
```

## Example
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "wareCreation",
"title": "",
"type": "Form",
"bc": "ware",
"showCondition": [],
"fields": [
{
"label": "Enter Name",
"key": "name",
"type": "input"
},
{
"label": "Enter Component 1",
"key": "component1",
"type": "input"
},
{
"label": "Enter Component 2",
"key": "component2",
"type": "input"
}
],
"axisFields": [],
"chart": [],
"options": {
"actionGroups": {},
"layout": {
"rows": [
{
"cols": [
{
"fieldKey": "name",
"span": 12
}
]
},
{
"cols": [
{
"fieldKey": "component1",
"span": 12
},
{
"fieldKey": "component2",
"span": 12
}
]
}
]
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "wareMvg",
"title": "MVG Example",
"type": "List",
"bc": "ware",
"showCondition": [],
"fields": [
{
"title": "Name",
"key": "name",
"type": "input",
"drillDown": "true"
},
{
"title": "Component 1",
"key": "component1",
"type": "input"
},
{
"title": "Component 2",
"key": "component2",
"type": "input"
},
{
"title": "Components",
"key": "components",
"type": "multivalue",
"displayedKey": "component1"
}
],
"axisFields": [],
"chart": [],
"options": {
"actionGroups": {
"include": [
"create",
"save"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "wareMvgHeader",
"type": "Header",
"title": "Wares list (MVG example)",
"showCondition": [],
"fields": [],
"axisFields": [],
"chart": [],
"options": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,39 @@
</loadData>
</changeSet>

</databaseChangeLog>
<changeSet id="wares-table" author="ifedorov">
<createTable tableName="WARE">
<column name="ID" remarks="Primary key" type="NUMBER(19, 0)">
<constraints primaryKey="true"/>
</column>
<column name="name" type="VARCHAR2(1000)"/>
<column name="component1" type="VARCHAR2(255)"/>
<column name="component2" type="VARCHAR2(255)"/>
<column defaultValueComputed="current_timestamp" name="CREATED_DATE" remarks="Дата создания"
type="TIMESTAMP(6)">
<constraints nullable="false"/>
</column>
<column defaultValueComputed="current_timestamp" name="UPDATED_DATE" remarks="Дата обновления"
type="TIMESTAMP(6)">
<constraints nullable="false"/>
</column>
<column defaultValueNumeric="1" name="CREATED_BY_USER_ID" type="NUMBER(19, 0)">
<constraints nullable="false" foreignKeyName="WARE_CREATED_BY" references="USERS"/>
</column>
<column defaultValueNumeric="1" name="LAST_UPD_BY_USER_ID" type="NUMBER(19, 0)">
<constraints nullable="false" foreignKeyName="WARE_LAST_UPD_BY" references="USERS"/>
</column>
<column defaultValueNumeric="0" name="VSTAMP" type="NUMBER(19, 0)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>

<changeSet id="wares-example" author="ifedorov">
<sql>
INSERT INTO WARE VALUES (1000000,'Ware Example 1','Component1_1','Component1_2'),(1000001,'Ware Example 2','Component2_1','Component2_2');
INSERT INTO WARE VALUES (1000002,'Ware Example 3 (with empty component2)','Component3_1');
</sql>
</changeSet>

</databaseChangeLog>
47 changes: 47 additions & 0 deletions tesler-doc-model/src/main/java/io/tesler/entity/Ware.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*-
* #%L
* TESLERDOC - Model
* %%
* Copyright (C) 2020 Tesler Contributors
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

package io.tesler.entity;

import io.tesler.model.core.entity.BaseEntity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "WARE")
@Getter
@Setter
@NoArgsConstructor
public class Ware extends BaseEntity {

@Column
String name;

@Column
String component1;

@Column
String component2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public enum TESLERDOCServiceAssociation implements EnumBcIdentifier {

customFieldsExample(CustomFieldsExampleService.class),

forceActiveExample(ForceActiveExampleService.class);
forceActiveExample(ForceActiveExampleService.class),

ware(WareService.class);

// @formatter:on

Expand Down
Loading