Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Select (dropdown) column type to tables#602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
FalkWolsky merged 3 commits intolowcoder-org:devfromjreyesr:feat/issue-412
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ import { ProgressComp } from "./columnTypeComps/columnProgressComp";
import { RatingComp } from "./columnTypeComps/columnRatingComp";
import { BadgeStatusComp } from "./columnTypeComps/columnStatusComp";
import { ColumnTagsComp } from "./columnTypeComps/columnTagsComp";
import { ColumnSelectComp } from "./columnTypeComps/columnSelectComp";
import { SimpleTextComp } from "./columnTypeComps/simpleTextComp";
import { ColumnNumberComp } from "./columnTypeComps/ColumnNumberComp";

Expand All@@ -38,6 +39,10 @@ const actionOptions = [
label: trans("table.tag"),
value: "tag",
},
{
label: trans("table.select"),
value: "select",
},
{
label: trans("table.badgeStatus"),
value: "badgeStatus",
Expand DownExpand Up@@ -83,6 +88,7 @@ export const ColumnTypeCompMap = {
badgeStatus: BadgeStatusComp,
link: LinkComp,
tag: ColumnTagsComp,
select: ColumnSelectComp,
links: ColumnLinksComp,
image: ImageComp,
markdown: ColumnMarkdownComp,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
import { useState } from "react";

import { SelectUIView } from "comps/comps/selectInputComp/selectCompConstants";
import { SelectOptionControl } from "comps/controls/optionsControl";
import { StringControl } from "comps/controls/codeControl";

import { trans } from "i18n";
import { ColumnTypeCompBuilder, ColumnTypeViewFn } from "../columnTypeCompBuilder";
import { ColumnValueTooltip } from "../simpleColumnTypeComps";

const childrenMap = {
text: StringControl,
options: SelectOptionControl,
};

let options: any[] = []
const getBaseValue: ColumnTypeViewFn<typeof childrenMap, string, string> = (props) => props.text;

type SelectEditProps = {
initialValue: string;
onChange: (value: string) => void;
onChangeEnd: () => void;
options: any[];
};

const SelectEdit = (props: SelectEditProps) => {
const [currentValue, setCurrentValue] = useState(props.initialValue);

return (
<SelectUIView
value={currentValue}
options={options}
onChange={(val) => {
props.onChange(val);
setCurrentValue(val)
}}
onEvent={async (eventName)=>{
if(eventName==="blur"){
props.onChangeEnd()
}
return []
}}
// @ts-ignore
style={{}}
/>
);
};


export const ColumnSelectComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
options = props.options;
const value = props.changeValue ?? getBaseValue(props, dispatch)
return props.options.find(x => x.value === value)?.label;
},
(nodeValue) => nodeValue.text.value,
getBaseValue,
)
.setEditViewFn((props) => {
return (
<SelectEdit
initialValue={props.value}
options={options}
onChange={props.onChange}
onChangeEnd={props.onChangeEnd}
/>
)})
.setPropertyViewFn((children) => {
return (
<>
{children.text.propertyView({
label: trans("table.columnValue"),
tooltip: ColumnValueTooltip,
})}
{children.options.propertyView({
title: trans("optionsControl.optionList"),
})}
</>
);
})
.build();
})();
1 change: 1 addition & 0 deletionsclient/packages/lowcoder/src/i18n/locales/en.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1245,6 +1245,7 @@ export const en = {
"link": "Link",
"links": "Links",
"tag": "Tag",
"select": "Select",
"date": "Date",
"dateTime": "Date Time",
"badgeStatus": "Status",
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp