mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
Add the option to add item at the top of the list (#5270)
Co-authored-by: Bassea <andre.basse@spiegel.de>
This commit is contained in:
parent
c912b6aa23
commit
fda1950583
@ -882,6 +882,7 @@ combo 还有一个作用是增加层级,比如返回的数据是一个深层
|
||||
| joinValues | `boolean` | `true` | 默认为 `true` 当扁平化开启的时候,是否用分隔符的形式发送给后端,否则采用 array 的方式。 |
|
||||
| delimiter | `string` | `false` | 当扁平化开启并且 joinValues 为 true 时,用什么分隔符。 |
|
||||
| addable | `boolean` | `false` | 是否可新增 |
|
||||
| addattop | `boolean` | `false` | 在顶部添加 |
|
||||
| removable | `boolean` | `false` | 是否可删除 |
|
||||
| deleteApi | [API](../../../docs/types/api) | | 如果配置了,则删除前会发送一个 api,请求成功才完成删除 |
|
||||
| deleteConfirmText | `string` | `"确认要删除?"` | 当配置 `deleteApi` 才生效!删除时用来做用户确认 |
|
||||
|
@ -117,6 +117,11 @@ export interface ComboControlSchema extends FormBaseControlSchema {
|
||||
*/
|
||||
addable?: boolean;
|
||||
|
||||
/**
|
||||
* Add at top
|
||||
*/
|
||||
addattop?: boolean;
|
||||
|
||||
/**
|
||||
* 数组输入框的子项
|
||||
*/
|
||||
@ -459,7 +464,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
||||
}
|
||||
|
||||
addItemWith(condition: ComboCondition) {
|
||||
const {flat, joinValues, delimiter, scaffold, disabled, submitOnChange} =
|
||||
const {flat, joinValues, addattop, delimiter, scaffold, disabled, submitOnChange} =
|
||||
this.props;
|
||||
|
||||
if (disabled) {
|
||||
@ -481,6 +486,10 @@ export default class ComboControl extends React.Component<ComboProps> {
|
||||
value = value.join(delimiter || ',');
|
||||
}
|
||||
|
||||
if (addattop === true){
|
||||
value.unshift(value.pop());
|
||||
}
|
||||
|
||||
this.props.onChange(value, submitOnChange, true);
|
||||
}
|
||||
|
||||
@ -488,6 +497,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
||||
const {
|
||||
flat,
|
||||
joinValues,
|
||||
addattop,
|
||||
delimiter,
|
||||
scaffold,
|
||||
disabled,
|
||||
@ -527,6 +537,10 @@ export default class ComboControl extends React.Component<ComboProps> {
|
||||
value = value.join(delimiter || ',');
|
||||
}
|
||||
|
||||
if (addattop === true){
|
||||
value.unshift(value.pop());
|
||||
}
|
||||
|
||||
this.props.onChange(value, submitOnChange, true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user