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

Commit76a3b3e

Browse files
committed
add suffix/prefix functionality in time#1549
1 parent082e574 commit76a3b3e

File tree

1 file changed

+83
-68
lines changed
  • client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeComps

1 file changed

+83
-68
lines changed
Lines changed: 83 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,86 @@
11
import{
2-
ColumnTypeCompBuilder,
3-
ColumnTypeViewFn,
4-
}from"comps/comps/tableComp/column/columnTypeCompBuilder";
5-
import{ColumnValueTooltip}from"comps/comps/tableComp/column/simpleColumnTypeComps";
6-
import{StringControl}from"comps/controls/codeControl";
7-
import{withDefault}from"comps/generators";
8-
import{formatPropertyView}from"comps/utils/propertyUtils";
9-
import{trans}from"i18n";
10-
import{
11-
TIME_FORMAT,
12-
formatTimestamp,
13-
timestampToHumanReadable,
14-
}from"util/dateTimeUtils";
15-
import{DateEdit}from"./columnDateComp";
16-
17-
constchildrenMap={
18-
text:StringControl,
19-
format:withDefault(StringControl,TIME_FORMAT),
20-
inputFormat:withDefault(StringControl,TIME_FORMAT),
21-
};
22-
23-
letinputFormat=TIME_FORMAT;
24-
25-
constgetBaseValue:ColumnTypeViewFn<typeofchildrenMap,string,string>=(props)=>
26-
props.text;
27-
28-
exportconstTimeComp=(function(){
29-
returnnewColumnTypeCompBuilder(
30-
childrenMap,
31-
(props,dispatch)=>{
32-
inputFormat=props.inputFormat;
33-
constvalue=props.changeValue??getBaseValue(props,dispatch);
34-
35-
// Convert value to a number if it's a valid timestamp
36-
consttimestamp=Number(value);
37-
if(!isNaN(timestamp)){
38-
returnformatTimestamp(timestamp);
39-
}
40-
41-
returntimestampToHumanReadable(timestamp)??value;// Returns readable time
42-
},
43-
(nodeValue)=>{
44-
consttimestamp=Number(nodeValue.text.value);
45-
return!isNaN(timestamp)
46-
?timestampToHumanReadable(timestamp)// Convert to readable format if valid timestamp
47-
:nodeValue.text.value;// Otherwise, return original value
48-
},
49-
getBaseValue
50-
)
51-
.setEditViewFn((props)=>(
52-
<DateEdit
53-
value={props.value}
54-
onChange={props.onChange}
55-
onChangeEnd={props.onChangeEnd}
56-
showTime={true}// Ensures only time is shown
57-
inputFormat={inputFormat}
58-
/>
59-
))
60-
.setPropertyViewFn((children)=>(
2+
ColumnTypeCompBuilder,
3+
ColumnTypeViewFn,
4+
}from"comps/comps/tableComp/column/columnTypeCompBuilder";
5+
import{ColumnValueTooltip}from"comps/comps/tableComp/column/simpleColumnTypeComps";
6+
import{StringControl}from"comps/controls/codeControl";
7+
import{withDefault}from"comps/generators";
8+
import{formatPropertyView}from"comps/utils/propertyUtils";
9+
import{trans}from"i18n";
10+
import{
11+
TIME_FORMAT,
12+
formatTimestamp,
13+
timestampToHumanReadable,
14+
}from"util/dateTimeUtils";
15+
import{DateEdit}from"./columnDateComp";
16+
import{IconControl}from"comps/controls/iconControl";
17+
import{hasIcon}from"comps/utils";
18+
19+
constchildrenMap={
20+
text:StringControl,
21+
format:withDefault(StringControl,TIME_FORMAT),
22+
inputFormat:withDefault(StringControl,TIME_FORMAT),
23+
prefixIcon:IconControl,
24+
suffixIcon:IconControl,
25+
};
26+
27+
letinputFormat=TIME_FORMAT;
28+
29+
constgetBaseValue:ColumnTypeViewFn<typeofchildrenMap,string,string>=(props)=>
30+
props.text;
31+
32+
exportconstTimeComp=(function(){
33+
returnnewColumnTypeCompBuilder(
34+
childrenMap,
35+
(props,dispatch)=>{
36+
inputFormat=props.inputFormat;
37+
constvalue=props.changeValue??getBaseValue(props,dispatch);
38+
39+
// Convert value to a number if it's a valid timestamp
40+
consttimestamp=Number(value);
41+
constformattedValue=!isNaN(timestamp)
42+
?formatTimestamp(timestamp)
43+
:timestampToHumanReadable(timestamp)??value;
44+
45+
return(
6146
<>
62-
{children.text.propertyView({
63-
label:trans("table.columnValue"),
64-
tooltip:ColumnValueTooltip,
65-
})}
66-
{formatPropertyView({ children,placeholder:TIME_FORMAT})}
47+
{hasIcon(props.prefixIcon)&&<span>{props.prefixIcon}</span>}
48+
<span>{formattedValue}</span>
49+
{hasIcon(props.suffixIcon)&&<span>{props.suffixIcon}</span>}
6750
</>
68-
))
69-
.build();
70-
})();
71-
51+
);
52+
},
53+
(nodeValue)=>{
54+
consttimestamp=Number(nodeValue.text.value);
55+
return!isNaN(timestamp)
56+
?timestampToHumanReadable(timestamp)
57+
:nodeValue.text.value;
58+
},
59+
getBaseValue
60+
)
61+
.setEditViewFn((props)=>(
62+
<DateEdit
63+
value={props.value}
64+
onChange={props.onChange}
65+
onChangeEnd={props.onChangeEnd}
66+
showTime={true}// Ensures only time is shown
67+
inputFormat={inputFormat}
68+
/>
69+
))
70+
.setPropertyViewFn((children)=>(
71+
<>
72+
{children.text.propertyView({
73+
label:trans("table.columnValue"),
74+
tooltip:ColumnValueTooltip,
75+
})}
76+
{children.prefixIcon.propertyView({
77+
label:trans("button.prefixIcon"),
78+
})}
79+
{children.suffixIcon.propertyView({
80+
label:trans("button.suffixIcon"),
81+
})}
82+
{formatPropertyView({ children,placeholder:TIME_FORMAT})}
83+
</>
84+
))
85+
.build();
86+
})();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp