Skip to content

Commit 6abaf48

Browse files
authored
Merge pull request #337 from YujithIsura/newNomination
fixing issues after connecting config api
2 parents 2197b99 + 2b0c82f commit 6abaf48

File tree

12 files changed

+76
-59
lines changed

12 files changed

+76
-59
lines changed

client/src/components/CheckboxTable/CheckboxTable.jsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class CheckboxTableGrid extends React.Component {
6767

6868
componentWillMount() {
6969
const { rows, cols, CallElectionData } = this.props;
70+
debugger;
7071
let rowHeaders = [''];
7172
this.props.rows.map((value) => {
7273
rowHeaders.push(value.name);
@@ -92,6 +93,7 @@ class CheckboxTableGrid extends React.Component {
9293
rawCount++;
9394
for (let j = 0; j < cols.length; j++) {
9495
for (let h = 0; h < CallElectionData.rowData.length; h++) {
96+
// debugger;
9597
if (cols[j].id === CallElectionData.rowData[h].division_id && rows[i].id === CallElectionData.rowData[h].team_id) {
9698

9799
let allow_party = {
@@ -107,32 +109,40 @@ class CheckboxTableGrid extends React.Component {
107109
}
108110
this.setState({ rowData: this.state.rowData });
109111

110-
this.setState({ rowHeaders, columnHeaders, checkboxGrid });
112+
this.setState({ rowHeaders, columnHeaders });
111113
var rawCount = 0;
112114
var prevCol = cols[0].id;
113115
var colCount = 0;
114116
var selectedIndex = '';
115-
for (let i = 0; i < rows.length; i++) {
117+
for (let m = 0; m < rows.length; m++) {
118+
debugger;
119+
// console.log("DDD",m);
116120
let row = [];
117-
for (let j = 0; j < cols.length; j++) {
121+
for (let n = 0; n < cols.length; n++) {
122+
debugger;
123+
// console.log("ggg",m,"rrr",n);
118124
CallElectionData.rowData.map((value) => {
119-
if (cols[j].id === value.division_id && rows[i].id === value.team_id) {
120-
if (prevCol === cols[j].id) {
125+
// debugger;
126+
// console.log("cols["+n+"].id = "+ cols[n].id+" value.division_id = "+value.division_id+" rows["+m+"].id "+rows[m].id+" value.team_id "+value.team_id);
127+
if (cols[n].id == value.division_id && rows[m].id == value.team_id) {
128+
console.log("cols["+n+"].id = "+ cols[n].id+" value.division_id = "+value.division_id+" rows["+m+"].id "+rows[m].id+" value.team_id "+value.team_id);
129+
if (prevCol === cols[n].id) {
121130
colCount++;
122-
prevCol = cols[j].id;
123-
selectedIndex = j;
131+
prevCol = cols[n].id;
132+
selectedIndex = n;
124133
} else {
125-
if (j !== cols.length - 1) {
126-
prevCol = cols[j + 1].id;
134+
if (n !== cols.length - 1) {
135+
prevCol = cols[n + 1].id;
127136
}
128137
}
129138
rawCount++;
130-
checkboxGrid[i + 1][j + 1] = true;
139+
checkboxGrid[m + 1][n + 1] = true;
131140
}
132141
});
133142
}
134143
}
135-
this.findIndex(checkboxGrid);
144+
// this.findIndex(checkboxGrid);
145+
this.setState({checkboxGrid});
136146

137147
}
138148

@@ -296,6 +306,7 @@ class CheckboxTableGrid extends React.Component {
296306
pagination: false,
297307
viewColumns:false
298308
};
309+
debugger;
299310

300311
return (
301312
<MuiThemeProvider theme={this.getMuiTheme()}>

client/src/components/CheckboxTableElectionReview/CheckboxTable.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ class CheckboxTableGrid extends React.Component {
118118
let row = [];
119119
for (let j = 0; j < cols.length; j++) {
120120
rowData.map((value) => {
121-
debugger;
122-
if (cols[j].id === value.division_id && rows[i].id === value.team_id) {
121+
if (cols[j].id == value.division_id && rows[i].id == value.team_id) {
123122
if (prevCol === cols[j].id) {
124123
colCount++;
125124
prevCol = cols[j].id;
@@ -281,7 +280,7 @@ class CheckboxTableGrid extends React.Component {
281280
}
282281
} else {
283282
if(i!==0 && j!==1){
284-
colData.push(<Checkbox color="primary" checked={true} onChange={this.handleChange(i, j - 1, data)}></Checkbox>);
283+
colData.push(<Checkbox color="primary" checked={this.state.checkboxGrid[i][j - 1]} onChange={this.handleChange(i, j - 1, data)}></Checkbox>);
285284
}
286285
}
287286
}

client/src/components/NominationStep2/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class NominationPayments extends React.Component {
211211
}
212212

213213
if (this.state.election && name === 'party') {
214+
debugger;
214215
this.props.getNominationListForPayment(this.state.election, event.value);
215216
} else if (this.state.party && name === 'election') {
216217
this.props.getNominationListForPayment(event.value, this.state.party)

client/src/components/NominationStep3/NominationStep3.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class TextFields extends React.Component {
148148
}
149149
render() {
150150
const {classes,onSelectFiles,doneElement,supportdoc,closeElement,supportingDocs,handleUploadView,errorTextFileUpload} = this.props;
151-
151+
debugger;
152152

153153
const supportingDocItems = supportingDocs.map(docs => (
154154
<div>

client/src/modules/election/ActiveElectionForm.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class ActiveElectionForm extends React.Component {
393393
const { CallElectionData,rowHeaders } = this.props;
394394
var rowHeadersForRpp = rowHeaders.filter(x => x.team_party_type === "RPP");
395395
var rowHeadersForIg = rowHeaders.filter(x => x.team_party_type === "IND");
396+
debugger;
396397
const { errorTextNominationStart, errorTextNominationEnd, errorTextObjectionStart, errorTextObjectionEnd, errorTextPaymentStart, errorTextPaymentEnd, errorTextApprovalStart, errorTextApprovalEnd } = this.state;
397398
const errorTextItems = { errorTextNominationStart, errorTextNominationEnd, errorTextObjectionStart, errorTextObjectionEnd, errorTextPaymentStart, errorTextPaymentEnd, errorTextApprovalStart, errorTextApprovalEnd }
398399

client/src/modules/election/AllowNomination.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class AllowNomination extends React.Component {
100100
<div className={classes.content}>
101101
<CardContent>
102102
<form ref="form" onSubmit={this.handleSubmit}>
103-
<CheckboxTable title="" data={nomination_setup} rows={rowHeadersForRpp}></CheckboxTable>
103+
<CheckboxTable title="" data={nomination_setup} rows={data}></CheckboxTable>
104104
<CheckboxTableIg title="" data={nomination_setup} rows={rowHeadersForIg}></CheckboxTableIg>
105105
</form>
106106
</CardContent>

client/src/modules/election/AllowNominationView.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class AllowNomination extends React.Component {
5353

5454
render() {
5555
const { classes,electionData,errorTextElectorates ,rowData,rowHeaders} = this.props;
56+
debugger;
5657
// const data = rowHeaders.map((record) => {
5758
// record.id = record.team_id;
5859
// record.name = record.team_name;

client/src/modules/election/Election_process_review_details.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class Dashboard extends React.Component {
325325
<Typography variant="subtitle2" className={classes.text_a} component="p">Calculation Type : </Typography>
326326
</Grid>
327327
<Grid item xs={3} sm={2} justify="center">
328-
<Typography component="p">{(CalculationType === 'vote_and_prefrence') ? 'Vote & Preferential Based' : (CalculationType === 'pure_prefrence_based') ? 'Pure preference-based' : (CalculationType === 'pure_vote_based') ? 'Pure vote-based' : ''}</Typography>
328+
<Typography component="p">{CalculationType}</Typography>
329329
</Grid>
330330
{/* <Grid item xs={12} sm={6}>
331331
<Grid container spacing={24}>

client/src/modules/nomination/state/NominationAction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ export const setNominationStatus = (nominationSuppertDocs) => {
360360
candidateSupportDocs:nominationSuppertDocs.supportdoc,
361361
divisionId:divisionId
362362
}
363+
debugger;
363364
return function (dispatch) {
364365

365366
const response = axios

server/src/manager/candidate/candidateManager.js

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Candidate } from 'Models';
1+
import { Candidate } from 'Models';
22
var joinjs = require('join-js').default;
3-
import {List} from 'typed-immutable';
3+
import { List } from 'typed-immutable';
44
import _ from 'lodash';
55
import moment from 'moment';
66

@@ -10,13 +10,13 @@ const resultMaps = [
1010
mapId: 'candidateMap',
1111
idProperty: 'ID',
1212
// properties: ['FULL_NAME', 'DES','OCCUPATION','NIC', 'DATE_OF_BIRTH', 'GENDER','ADDRESS', 'NOMINATION_ID']
13-
properties: ['CONFIG_ID', 'KEY_NAME','VALUE']
13+
properties: ['CONFIG_ID', 'KEY_NAME', 'VALUE']
1414
}
1515
];
1616

1717

1818
const mapToCandidateModel = (candidates) => {
19-
console.log('candidates',candidates);
19+
console.log('candidates', candidates);
2020
var groupedCandidates = _.groupBy(candidates, 'CANDIDATE_ID');
2121
var expected = _.map(groupedCandidates, function (candidateProperties) {
2222
var orderedProps = [];
@@ -27,40 +27,41 @@ const mapToCandidateModel = (candidates) => {
2727
});
2828
orderedProps = _.sortBy(orderedProps, 'CANDIDATE_CONFIG_ID');
2929

30-
var candidateInfoMap = {CANDIDATE_ID:id};
30+
var candidateInfoMap = { CANDIDATE_ID: id };
3131
_.each(orderedProps, function (property) {
32-
if(property.CANDIDATE_KEY_NAME === 'DATE_OF_BIRTH'){
32+
if (property.CANDIDATE_KEY_NAME === 'DATE_OF_BIRTH') {
3333
candidateInfoMap[property.CANDIDATE_KEY_NAME] = moment(new Date(parseInt(property.CANDIDATE_VALUE))).format('YYYY-MM-DD');
34-
}else{
34+
} else {
3535
candidateInfoMap[property.CANDIDATE_KEY_NAME] = property.CANDIDATE_VALUE;
3636
}
3737
});
38-
38+
3939
return candidateInfoMap;
4040
});
41-
console.log('expected',expected);
41+
console.log('expected', expected);
4242
return expected;
4343
// const mappedCandidates = joinjs.map(candidates, resultMaps, 'candidateMap', 'CANDIDATE_');
44-
// const mappedCandidates = expected;
44+
// const mappedCandidates = expected;
45+
46+
// console.log("mappedCandidatesmappedCandidatesmappedCandidates",mappedCandidates);
47+
// return _.reduce(mappedCandidates, function(result, candidate) {
4548

46-
// console.log("mappedCandidatesmappedCandidatesmappedCandidates",mappedCandidates);
47-
// return _.reduce(mappedCandidates, function(result, candidate) {
48-
49-
// return result.push({
50-
// "id": candidate.ID,
51-
// "configId": candidate.CONFIG_ID,
52-
// "keyName": candidate.KEY_NAME,
53-
// "value": candidate.VALUE
49+
// return result.push({
50+
// "id": candidate.ID,
51+
// "configId": candidate.CONFIG_ID,
52+
// "keyName": candidate.KEY_NAME,
53+
// "value": candidate.VALUE
5454

55-
// });
56-
// },List(Candidate)());
55+
// });
56+
// },List(Candidate)());
5757

5858

5959
};
6060

61-
const mapToPartyCandidateModel = (candidates,party_list,division_list) => {
62-
console.log('candidates',candidates);
61+
const mapToPartyCandidateModel = (candidates, party_list, division_list) => {
62+
console.log('party_list', party_list);
6363
var groupedCandidates = _.groupBy(candidates, 'CANDIDATE_ID');
64+
console.log('division_list', division_list);
6465
var expected = _.map(groupedCandidates, function (candidateProperties) {
6566
var orderedProps = [];
6667
var id = "";
@@ -70,33 +71,35 @@ const mapToPartyCandidateModel = (candidates,party_list,division_list) => {
7071
});
7172
orderedProps = _.sortBy(orderedProps, 'CANDIDATE_CONFIG_ID');
7273

73-
var candidateInfoMap = {CANDIDATE_ID:id};
74+
var candidateInfoMap = { CANDIDATE_ID: id };
7475
_.each(orderedProps, function (property) {
75-
if(property.CANDIDATE_KEY_NAME === 'DATE_OF_BIRTH'){
76+
if (property.CANDIDATE_KEY_NAME === 'DATE_OF_BIRTH') {
7677
candidateInfoMap[property.CANDIDATE_KEY_NAME] = moment(new Date(parseInt(property.CANDIDATE_VALUE))).format('YYYY-MM-DD');
77-
}else{
78+
} else {
7879
candidateInfoMap[property.CANDIDATE_KEY_NAME] = property.CANDIDATE_VALUE;
7980
}
8081
});
81-
82-
return candidateInfoMap;
83-
});
84-
85-
const expectedWithParty = party_list.map(item => {
86-
//check and change the team_id variable name after finishing the party list endpoint
87-
const item2 = expected.find(o => o.team_id === item.team_id);
88-
return { ...item, ...item2};
89-
});
9082

91-
const expectedWithPartyDivision = division_list.map(item => {
92-
//check and change the vivision_id variable name after finishing the division list endpoint
93-
const item2 = expectedWithParty.find(o => o.division_id === item.division_id);
94-
return { ...item, ...item2};
83+
return candidateInfoMap;
9584
});
9685

86+
if (party_list) {
87+
const expectedWithParty = party_list.map(item => {
88+
//check and change the team_id variable name after finishing the party list endpoint
89+
const item2 = expected.find(o => o.team_id === item.team_id);
90+
return { ...item, ...item2 };
91+
});
92+
}
93+
if (division_list) {
94+
const expectedWithPartyDivision = division_list.map(item => {
95+
//check and change the vivision_id variable name after finishing the division list endpoint
96+
const item2 = expectedWithParty.find(o => o.division_id === item.division_id);
97+
return { ...item, ...item2 };
98+
});
99+
}
97100

98-
console.log('expected',expected);
99-
return expectedWithPartyDivision;
101+
console.log('expected', expected);
102+
return expected;
100103
};
101104

102105
export default {

server/src/repository/division.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ FROM NOMINATION N LEFT JOIN DIVISION_CONFIG DC ON N.DIVISION_CONFIG_ID=DC.ID
145145
LEFT JOIN CANDIDATE_DATA C ON N.ID=C.NOMINATION_ID
146146
LEFT JOIN CANDIDATE_CONFIG CC ON C.CANDIDATE_CONFIG_ID = CC.ID
147147
LEFT JOIN PAYMENT P ON N.ID=P.NOMINATION_ID
148-
WHERE N.ELECTION_ID=:election_id AND N.TEAM_ID=:team_id AND N.DIVISION_CONFIG_ID=:divisionId GROUP BY N.ID,CC.ID`;
148+
WHERE N.ELECTION_ID=:election_id AND N.TEAM_ID=:team_id GROUP BY N.ID,CC.ID`;
149149

150150
const DIVISIONS_WITH_NOMINATION_SELECT_QUERY_ALL = `SELECT
151151
N.DIVISION_CONFIG_ID AS division_id,

server/src/service/divisionService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const getDivisionsWithNomination = async (req) => {
8282
const teamId = req.params.teamId;
8383
const divisionId = req.params.divisionId;
8484
const divisions = await DivisionRepo.fetchDivisionsWithNomination(electionId, teamId,divisionId);
85-
85+
console.log(divisions,"divisions");
8686
if (!_.isEmpty(divisions)) {
8787
return DivisionManager.mapToDivisionModelWithNominations(divisions);
8888
} else {

0 commit comments

Comments
 (0)