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

[Feat]: add new pending tags in suggestions for Table Tags Column#2023

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
raheeliftikhar5 merged 1 commit intolowcoder-org:devfromiamfaran:feat/table-tags
Sep 30, 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
[Feat]: add new pending tags in suggestions for Table Tags Column
  • Loading branch information
@iamfaran
iamfaran committedSep 26, 2025
commit90b1ac09fec42b1449d8d44af1b9bfbe13c5db4c
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,8 +57,8 @@ const TagsControl = codeControl<Array<string> | string>(
{expectedType:"string | Array<string>",codeType:"JSON"}
);

functiongetTagColor(tagText :any,tagOptions:any[]){
constfoundOption=tagOptions.find((option:{label:any;})=>option.label===tagText);
functiongetTagColor(tagText:string,tagOptions:TagOption[]):string|undefined{
constfoundOption=tagOptions.find(option=>option.label===tagText);
if(foundOption){
if(foundOption.colorType==="preset"){
returnfoundOption.presetColor;
Expand All@@ -73,10 +73,10 @@ function getTagColor(tagText : any, tagOptions: any[]) {
returncolors[index];
}

functiongetTagStyle(tagText:any,tagOptions:any[]){
constfoundOption=tagOptions.find((option:{label:any;})=>option.label===tagText);
functiongetTagStyle(tagText:string,tagOptions:TagOption[]):React.CSSProperties{
constfoundOption=tagOptions.find(option=>option.label===tagText);
if(foundOption){
conststyle:any={};
conststyle:React.CSSProperties={};

// Handle color styling
if(foundOption.colorType==="custom"){
Expand DownExpand Up@@ -113,11 +113,23 @@ function getTagStyle(tagText: any, tagOptions: any[]) {
return{};
}

functiongetTagIcon(tagText:any,tagOptions:any[]){
functiongetTagIcon(tagText:string,tagOptions:TagOption[]):React.ReactNode|undefined{
constfoundOption=tagOptions.find(option=>option.label===tagText);
returnfoundOption ?foundOption.icon :undefined;
}

// Utility function to process comma-separated tags into individual tags
functionprocessTagItems(tagItems:string[]):string[]{
constresult:string[]=[];
tagItems.forEach((item)=>{
if(item.split(",")[1]){
item.split(",").forEach((tag)=>result.push(tag));
}
result.push(item);
});
returnresult;
}

constchildrenMap={
text:TagsControl,
tagColors:ColoredTagOptionControl,
Expand All@@ -128,11 +140,25 @@ const getBaseValue: ColumnTypeViewFn<typeof childrenMap, string | string[], stri
props
)=>props.text;

interfaceTagOption{
label:string;
colorType?:"preset"|"custom";
presetColor?:string;
color?:string;
textColor?:string;
border?:string;
radius?:string;
margin?:string;
padding?:string;
icon?:React.ReactNode;
onEvent?:(eventType:string)=>void;
}

typeTagEditPropsType={
value:string|string[];
onChange:(value:string|string[])=>void;
onChangeEnd:()=>void;
tagOptions:any[];
tagOptions:TagOption[];
};

exportconstWrapper=styled.div`
Expand DownExpand Up@@ -240,16 +266,7 @@ export const TagStyled = styled(Tag)`

constTagEdit=React.memo((props:TagEditPropsType)=>{
constdefaultTags=useContext(TagsContext);
const[tags,setTags]=useState(()=>{
constresult:string[]=[];
defaultTags.forEach((item)=>{
if(item.split(",")[1]){
item.split(",").forEach((tag)=>result.push(tag));
}
result.push(item);
});
returnresult;
});
const[tags,setTags]=useState(()=>processTagItems(defaultTags));
const[open,setOpen]=useState(false);
constmountedRef=useRef(true);

Expand All@@ -268,24 +285,16 @@ const TagEdit = React.memo((props: TagEditPropsType) => {
// Update tags when defaultTags changes
useEffect(()=>{
if(!mountedRef.current)return;

constresult:string[]=[];
defaultTags.forEach((item)=>{
if(item.split(",")[1]){
item.split(",").forEach((tag)=>result.push(tag));
}
result.push(item);
});
setTags(result);
setTags(processTagItems(defaultTags));
},[defaultTags]);

consthandleSearch=useCallback((value:string)=>{
if(!mountedRef.current)return;

if(defaultTags.findIndex((item)=>item.includes(value))<0){
setTags([...defaultTags,value]);
setTags([...processTagItems(defaultTags),value]);
}else{
setTags(defaultTags);
setTags(processTagItems(defaultTags));
}
props.onChange(value);
},[defaultTags,props.onChange]);
Expand DownExpand Up@@ -426,17 +435,15 @@ export const ColumnTagsComp = (function () {
consttagStyle=getTagStyle(tagText,tagOptions);

return(
<React.Fragmentkey={`${tag.split(' ').join('_')}-${index}`}>
<TagStyled
color={tagColor}
icon={tagIcon}
key={index}
style={tagStyle}
onClick={(e)=>handleTagClick(e,tagText)}
>
{tagText}
</TagStyled>
</React.Fragment>
<TagStyled
key={`${tagText.split(' ').join('_')}-${index}`}
color={tagColor}
icon={tagIcon}
style={tagStyle}
onClick={(e)=>handleTagClick(e,tagText)}
>
{tagText}
</TagStyled>
);
});
return(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -481,7 +481,6 @@ export class TableImplComp extends TableInitComp implements IContainer {
return{ ...oriRow, ...changeValues};
})
.value();
// console.info("toUpdateRowsNode. input: ", input, " res: ", res);
returnres;
});
}
Expand DownExpand Up@@ -517,14 +516,25 @@ export class TableImplComp extends TableInitComp implements IContainer {
oriDisplayData:this.oriDisplayDataNode(),
withParams:this.children.columns.withParamsNode(),
dataIndexes:this.children.columns.getColumnsNode("dataIndex"),
changeSet:this.changeSetNode(),
};
constresNode=withFunction(fromRecord(nodes),(input)=>{
constdataIndexWithParamsDict=_(input.dataIndexes)
.mapValues((dataIndex,idx)=>input.withParams[idx])
.mapKeys((withParams,idx)=>input.dataIndexes[idx])
.value();
constres=getColumnsAggr(input.oriDisplayData,dataIndexWithParamsDict);
// console.info("columnAggrNode: ", res);

constcolumnChangeSets:Record<string,Record<string,any>>={};
_.forEach(input.changeSet,(rowData,rowId)=>{
_.forEach(rowData,(value,dataIndex)=>{
if(!columnChangeSets[dataIndex]){
columnChangeSets[dataIndex]={};
}
columnChangeSets[dataIndex][rowId]=value;
});
});

constres=getColumnsAggr(input.oriDisplayData,dataIndexWithParamsDict,columnChangeSets);
returnres;
});
returnlastValueIfEqual(this,"columnAggrNode",[resNode,nodes]asconst,(a,b)=>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -230,17 +230,47 @@ export function getColumnsAggr(
oriDisplayData:JSONObject[],
dataIndexWithParamsDict:NodeToValue<
ReturnType<InstanceType<typeofColumnListComp>["withParamsNode"]>
>
>,
columnChangeSets?:Record<string,Record<string,any>>
):ColumnsAggrData{
return_.mapValues(dataIndexWithParamsDict,(withParams,dataIndex)=>{
constcompType=(withParams.wrap()asany).compType;
constres:Record<string,JSONValue>&{compType:string}={ compType};

if(compType==="tag"){
res.uniqueTags=_(oriDisplayData)
constoriginalTags=_(oriDisplayData)
.map((row)=>row[dataIndex]!)
.filter((tag)=>!!tag)
.value();

constpendingChanges=columnChangeSets?.[dataIndex]||{};
constpendingTags=_(pendingChanges)
.values()
.filter((value)=>!!value)
.value();

constextractTags=(value:any):string[]=>{
if(!value)return[];
if(_.isArray(value))returnvalue.map(String);
if(typeofvalue==="string"){
// Handle comma-separated tags
if(value.includes(",")){
returnvalue.split(",").map(tag=>tag.trim()).filter(tag=>tag);
}
return[value];
}
return[String(value)];
};

constallTags=[
...originalTags.flatMap(extractTags),
...pendingTags.flatMap(extractTags)
];

res.uniqueTags=_(allTags)
.uniq()
.value();

}elseif(compType==="badgeStatus"){
res.uniqueStatus=_(oriDisplayData)
.map((row)=>{
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp