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

Added validation check to input boxes of variables#1506

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 4 commits intodevfromfix/variable_header_control_type
Feb 5, 2025
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
@@ -0,0 +1,65 @@
import { ControlParams } from "comps/controls/controlParams";
import { CompAction, SimpleComp } from "lowcoder-core";
import { ControlPropertyViewWrapper, PopupCard, Input } from "lowcoder-design";
import { useEffect, useState } from "react";
import { trans } from "i18n";
import { checkName } from "../utils/rename";
const SimpleVariableHeaderPropertyView = ({params, comp, isCheck}: any) => {
const [error, setError] = useState<string | undefined>();
const [value, setValue] = useState(comp.value);
useEffect(() => {
setValue(comp.value);
isCheck && setError(undefined);
}, [comp]);
return (
<ControlPropertyViewWrapper {...params}>
<Input
value={value}
placeholder={params.placeholder}
onChange={(e) => {
const error = isCheck && checkName(e.target.value);
isCheck && setError(error || undefined);
setValue(e.target.value);
}}
onBlur={(e) => {
if(!isCheck || !error) comp.dispatchChangeValueAction(value);
else {
setValue(comp.value);
setError(undefined);
}
}}
/>
{isCheck && <PopupCard
editorFocus={!!error}
title={error ? trans("error") : ""}
content={error}
hasError={!!error}
/>}
</ControlPropertyViewWrapper>
);
}
export const SimpleVariableHeaderComp = (isCheck: boolean = false) => {
return class SimpleVariableHeaderComp extends SimpleComp<string> {
override reduce(action: CompAction): this {
// if (isBroadcastAction<RenameAction>(action, CompActionTypes.RENAME)) {
// if (this.getView() === action.action.oldName) {
// return super.reduce(this.changeValueAction(action.action.name));
// }
// }
return super.reduce(action);
}

readonly IGNORABLE_DEFAULT_VALUE = "";
protected getDefaultValue(): string {
return "";
}

getPropertyView() {
return this.propertyView({});
}

propertyView(params: ControlParams) {
return <SimpleVariableHeaderPropertyView params={params} comp={this} isCheck={isCheck}></SimpleVariableHeaderPropertyView>
}
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,7 +99,7 @@ const ExecuteQueryPropertyView = ({
const ExecuteQueryTmpAction = (function () {
const childrenMap = {
queryName: SimpleNameComp,
queryVariables: withDefault(keyValueListControl(false, [], "string"), [])
queryVariables: withDefault(keyValueListControl(false, [], "variable"), [])
};
return new MultiCompBuilder(childrenMap, () => {
return () => Promise.resolve(undefined as unknown);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import { StringControl } from "./codeControl";
import { ControlParams } from "./controlParams";
import { dropdownControl } from "./dropdownControl";
import { ParamsStringControl } from "./paramsControl";
import { SimpleVariableHeaderComp } from "../comps/simpleVariableHeaderComp";

const KeyValueWrapper = styled.div`
display: flex;
Expand DownExpand Up@@ -58,13 +59,20 @@ export type KeyValueControlParams = ControlParams & {
export function keyValueControl<T extends OptionsType>(
hasType: boolean = false,
types: T,
controlType: "params" | "string" = "params"
controlType: "params" | "string"| "variable"= "params"
) {
const childrenMap = {
let childrenMap = {
key: controlType === "params" ? ParamsStringControl : StringControl,
value: controlType === "params" ? ParamsStringControl : StringControl,
type: dropdownControl(types, types[0]?.value),
};
if(controlType === "variable") {
childrenMap = {
key: SimpleVariableHeaderComp(true) as any,
value: SimpleVariableHeaderComp() as any,
type: dropdownControl(types, types[0]?.value),
};
}
return class extends new MultiCompBuilder(childrenMap, (props) => {
return hasType
? {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ import { keyValueControl, KeyValueControlParams } from "./keyValueControl"
export function keyValueListControl<T extends OptionsType>(
hasType: boolean = false,
types: T | OptionsType = [],
controlType: "params" | "string" = "params"
controlType: "params" | "string"| "variable"= "params"
) {
return class extends list(keyValueControl(hasType, types, controlType)) {
getQueryParams() {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ import { keyValueListControl } from "../../controls/keyValueListControl";

export const VariablesComp = new MultiCompBuilder(
{
variables: withDefault(keyValueListControl(false, [], "string"), [{ key: "", value: "" }]),
variables: withDefault(keyValueListControl(false, [], "variable"), [{ key: "", value: "" }]),
},
(props) => props //props.variables
)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp