Skip to content

Commit

Permalink
Merge pull request #868 from AI4Bharat/filter-rej
Browse files Browse the repository at this point in the history
Filter - rejected
  • Loading branch information
aparna-aa authored Dec 20, 2023
2 parents 3c96d62 + 3519936 commit 2a2112f
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 99 deletions.
122 changes: 62 additions & 60 deletions src/redux/actions/api/Tasks/GetTasksByProjectId.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,66 @@
* GetTasksByProjectId
*/

import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class GetTasksByProjectIdAPI extends API {
constructor(projectId, pageNo, countPerPage, selectedFilters, taskType, pullvalue,pull, timeout = 2000) {
// console.log(pullvalue,"pullvaluepullvalue")
super("GET", timeout, false);
const datavalue = []
this.type = constants.GET_TASK_LIST;
let queryString = `?project_id=${projectId}${pageNo ? "&page="+pageNo : ""}${countPerPage ?"&records="+countPerPage : ""}`;
let querystr = pull === "All" ?"": `&editable=${pullvalue}`
for (let key in selectedFilters) {
if (selectedFilters[key] && selectedFilters[key] !== -1) {
switch (key) {
case 'annotation_status':
queryString +=`&${key}=["${selectedFilters[key]}"] ${querystr}`
break;
case 'review_status':
queryString +=`&${key}=["${selectedFilters[key]}"] ${querystr}`
break;
case 'supercheck_status':
queryString +=`&${key}=["${selectedFilters[key]}"]`
break;
default:
queryString +=`&${key}=${selectedFilters[key]}`

}
import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class GetTasksByProjectIdAPI extends API {
constructor(projectId, pageNo, countPerPage, selectedFilters, taskType, pullvalue,rejected,pull, timeout = 2000) {
// console.log(pullvalue,"pullvaluepullvalue")
super("GET", timeout, false);
const datavalue = []
this.type = constants.GET_TASK_LIST;
let queryString = `?project_id=${projectId}${pageNo ? "&page="+pageNo : ""}${countPerPage ?"&records="+countPerPage : ""}`;
let querystr = pull === "All" ?"": `&editable=${pullvalue}`
let querystr1 = rejected === "Yes" ?`&rejected=`+"True":rejected === "No"? `&rejected=`+false:""
for (let key in selectedFilters) {
if (selectedFilters[key] && selectedFilters[key] !== -1) {
switch (key) {
case 'annotation_status':
queryString +=`&${key}=["${selectedFilters[key]}"] ${querystr}${querystr1}`
break;
case 'review_status':
queryString +=`&${key}=["${selectedFilters[key]}"] ${querystr} ${querystr1}`
break;
case 'supercheck_status':
queryString +=`&${key}=["${selectedFilters[key]}"]`
break;
default:
queryString +=`&${key}=${selectedFilters[key]}`

}
}
console.log(queryString);
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getTasks+queryString}`;
}
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.taskList = res;
}
console.log(queryString);
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getTasks+queryString}`;
}
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.taskList = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization":`JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.taskList
}
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization":`JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.taskList
}
}

130 changes: 91 additions & 39 deletions src/ui/pages/component/Project/FilterList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import { Stack } from "@mui/material";

const FilterList = (props) => {
const classes = DatasetStyle();
const { filterStatusData, currentFilters, updateFilters,pull,setpull,pullvalue } = props;
const { filterStatusData, currentFilters, updateFilters, pull, setpull, rejected, setRejected, pullvalue } = props;
const [selectedStatus, setSelectedStatus] = useState(!!currentFilters?.annotation_status ? currentFilters?.annotation_status : currentFilters.review_status);
const [selectAnnotator, setSelectAnnotator] = useState("All");

const ProjectDetails = useSelector((state) => state.getProjectDetails.data);
const userDetails = useSelector((state) => state.fetchLoggedInUserData.data);
// const [selectedType, setSelectedType] = useState(selectedFilter.Annotators);
Expand All @@ -47,9 +46,10 @@ const FilterList = (props) => {
// }
// };

console.log(filterStatusData, selectedStatus, currentFilters);
const pulledstatus = currentFilters?.annotation_status ? ["Pulled By reviewer", "Not Pulled By reviewer"]
: currentFilters?.review_status ? ["Pulled By SuperChecker", "Not Pulled By SuperChecker"] : null;

const rejectedStatus = ["Yes"];
const handleStatusChange = (e) => {
let statusvalue = !!currentFilters?.annotation_status ? "annotation_status" : "review_status"
// let pullvalue = (pull == 'Pulled By reviewer' || pull == 'Pulled By SuperChecker') ? false :
Expand Down Expand Up @@ -96,9 +96,9 @@ const FilterList = (props) => {
<Box className={classes.filterContainer}>
<Stack direction="row">
<FormGroup sx={{ display: "flex", flexDirection: "column" }}>
<Typography variant="body2" sx={{ ml: 1, fontWeight: "700",fontSize:"16px" }} className={classes.filterTypo}>
{translate("label.filter.status")}
</Typography>
<Typography variant="body2" sx={{ ml: 1, fontWeight: "700", fontSize: "16px" }} className={classes.filterTypo}>
{translate("label.filter.status")}
</Typography>
{filterStatusData.Status.map((type) => {
return (
<FormControlLabel
Expand All @@ -120,60 +120,112 @@ const FilterList = (props) => {
);
})}
</FormGroup>
{currentFilters?.annotation_status ?
<FormControl sx={{ m: 1, minWidth: 120 }} size="small">
<Stack direction="column">
{currentFilters?.annotation_status ?
<FormControl sx={{ m: 1, minWidth: 120 }} size="small">
<InputLabel id="project-type-label" sx={{
fontSize: "16px",
position: "inherit",
top: "23px",
left: "-3px",
}}>Editable</InputLabel>
<Select
labelId="editable-label"
id="editable-select"
value={pull}
defaultValue={"All"}
label="editable"
onChange={(e) => setpull(e.target.value)}

>
<MenuItem value={'All'} selected>
All
</MenuItem>
{pulledstatus.map((type, index) => (
<MenuItem value={type} key={index}>
{type}
</MenuItem>
))}
</Select>
</FormControl> : currentFilters?.review_status ?
<FormControl sx={{ m: 1, minWidth: 125 }} size="small" >
<InputLabel id="project-type-label" sx={{
fontSize: "16px",
position: "inherit",
top: "23px",
left: "-3px",
}} >Editable</InputLabel>
<Select

labelId="editable-label"
id="editable-select"
value={pull}
label="editable"
defaultValue={"All"}
onChange={(e) => setpull(e.target.value)}

>
<MenuItem value={'All'} selected>All</MenuItem>
{pulledstatus.map((type, index) => (
<MenuItem value={type} key={index}>
{type}
</MenuItem>
))}
</Select>
</FormControl> : null

}
{currentFilters?.annotation_status && selectedStatus == "labeled" ? <FormControl sx={{ m: 1, minWidth: 125 }} size="small" >
<InputLabel id="project-type-label" sx={{
fontSize: "16px",
position: "inherit",
top: "23px",
left: "-3px",
}}>Editable</InputLabel>
}} >{currentFilters?.annotation_status ? "Rejected By reviewer" : currentFilters?.review_status ? "Rejected By SuperChecker" : null}</InputLabel>
<Select
labelId="editable-label"
id="editable-select"
value={pull}

labelId="rejected-label"
id="rejected-select"
value={rejected}
label={currentFilters?.annotation_status ? "Rejected By reviewer" : currentFilters?.review_status ? "Rejected By SuperChecker" : null}
defaultValue={"All"}
label="editable"
onChange={(e) => setpull(e.target.value)}
onChange={(e) => setRejected(e.target.value)}

>
<MenuItem value={'All'} selected>
All
</MenuItem>
{pulledstatus.map((type, index) => (
<MenuItem value={'All'} selected>All</MenuItem>
{rejectedStatus.map((type, index) => (
<MenuItem value={type} key={index}>
{type}
</MenuItem>
))}
</Select>
</FormControl> : currentFilters?.review_status ?
<FormControl sx={{ m: 1, minWidth: 125 }} size="small" >
<InputLabel id="project-type-label" sx={{
</FormControl> : currentFilters?.review_status && selectedStatus == "accepted_with_major_changes" || selectedStatus == "accepted_with_minor_changes" || selectedStatus == "accepted" ? <FormControl sx={{ m: 1, minWidth: 125 }} size="small" >
<InputLabel id="project-type-label" sx={{
fontSize: "16px",
position: "inherit",
top: "23px",
left: "-3px",
}} >Editable</InputLabel>
<Select
}} >{currentFilters?.annotation_status ? "Rejected By reviewer" : currentFilters?.review_status ? "Rejected By SuperChecker" : null}</InputLabel>
<Select

labelId="editable-label"
id="editable-select"
value={pull}
label="editable"
defaultValue={"All"}
onChange={(e) => setpull(e.target.value)}
labelId="rejected-label"
id="rejected-select"
value={rejected}
label={currentFilters?.annotation_status ? "Rejected By reviewer" : currentFilters?.review_status ? "Rejected By SuperChecker" : null}
defaultValue={"All"}
onChange={(e) => setRejected(e.target.value)}

>
<MenuItem value={'All'} selected>All</MenuItem>
{pulledstatus.map((type, index) => (
<MenuItem value={type} key={index}>
{type}
</MenuItem>
))}
</Select>
</FormControl> : null
>
<MenuItem value={'All'} selected>All</MenuItem>
{rejectedStatus.map((type, index) => (
<MenuItem value={type} key={index}>
{type}
</MenuItem>
))}
</Select>
</FormControl> : null}
</Stack>

}
</Stack>
<Divider />
<Box
Expand Down
5 changes: 5 additions & 0 deletions src/ui/pages/component/Project/TaskTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const TaskTable = (props) => {
const [currentPageNumber, setCurrentPageNumber] = useState(1);
const [currentRowPerPage, setCurrentRowPerPage] = useState(10);
const [anchorEl, setAnchorEl] = useState(null);
const [rejected,setRejected] = useState("All")
const [find, setFind] = useState("");
const [replace, setReplace] = useState("");
const [OpenFindAndReplaceDialog, setOpenFindAndReplaceDialog] = useState(false);
Expand Down Expand Up @@ -180,6 +181,7 @@ const TaskTable = (props) => {
selectedFilters,
props.type,
pullvalue,
rejected,
pull
);
dispatch(APITransport(taskObj));
Expand Down Expand Up @@ -1144,6 +1146,9 @@ const TaskTable = (props) => {
currentFilters={selectedFilters}
pull={pull}
setpull={setpull}
rejected={rejected}
setRejected={setRejected}
// rejValue = {rejValue}
pullvalue={pullvalue}
/>
)}
Expand Down

0 comments on commit 2a2112f

Please sign in to comment.