Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SMPPIR
Portal-SMPPIR-React
Commits
10167ff8
Commit
10167ff8
authored
Oct 10, 2017
by
Henrique V. Ehrenfried
Browse files
Add offer location to Quotas Loan
parent
f6ad189b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Components/AutocompleteApp.js
View file @
10167ff8
...
...
@@ -121,12 +121,12 @@ class AutocompleteApp extends Component {
route
=
route
+
this
.
props
.
mainPage
;
}
if
(
this
.
props
.
mainPage
===
'
student_loans
'
)
{
route
=
this
.
props
.
mainPage
+
'
?dims=institution,cod_offer_location,name_offer_location&filter=ethnic:["Preta","Parda","Indígena"]
'
;
route
=
this
.
props
.
mainPage
+
'
?dims=institution,
institution_cod,
cod_offer_location,name_offer_location&filter=ethnic:["Preta","Parda","Indígena"]
'
;
}
axios
.
get
(
`
${
serverURL
}${
route
}
`
)
.
then
(
res
=>
{
var
newData
=
this
.
organizeData
(
res
.
data
)
this
.
setState
({
data
:
newData
});
this
.
setState
({
data
:
newData
});
});
}
...
...
src/SubPages/QuotasLoan.js
View file @
10167ff8
...
...
@@ -30,7 +30,11 @@ class QuotasLoan extends Component {
student_loanss
:{},
campiList
:[],
mountInstitution
:
null
,
percent
:
10
percent
:
10
,
campi
:[],
campiNames
:[],
tagID
:
''
,
tagName
:
''
};
this
.
getDataFromAutocomplete
=
this
.
getDataFromAutocomplete
.
bind
(
this
);
this
.
getDataFromServer
=
this
.
getDataFromServer
.
bind
(
this
);
...
...
@@ -40,6 +44,8 @@ class QuotasLoan extends Component {
this
.
getData
=
this
.
getData
.
bind
(
this
);
this
.
getCampi
=
this
.
getCampi
.
bind
(
this
);
this
.
campiFilter
=
this
.
campiFilter
.
bind
(
this
);
this
.
getCampiFromServer
=
this
.
getCampiFromServer
.
bind
(
this
);
this
.
saveAutocompleteContent
=
this
.
saveAutocompleteContent
.
bind
(
this
);
}
componentWillMount
()
{
...
...
@@ -89,12 +95,15 @@ class QuotasLoan extends Component {
<
CollapsibleContainer
header
=
'
Instituição de Ensino
'
>
<
AutocompleteApp
whichAutocomplete
=
{
'
institution
'
}
mainPage
=
{
type
}
chartDiv
=
{
'
no_ies
'
}
mainPage
=
{
type
}
chartDiv
=
{
'
no_ies
'
}
saveData
=
{
this
.
getDataFromAutocomplete
}
getTags
=
{
this
.
saveAutocompleteContent
}
useMap
=
{
false
}
dropdown
=
{
'
ddCampiLoans
'
}
/
>
dropdown
=
{
'
ddCampiLoans
'
}
/
>
<
div
id
=
{
"
ddCampiLoans
"
}
style
=
{{
display
:
'
none
'
}}
>
<
DropdownCampi
campi
=
{
this
.
state
.
campiList
}
getDDValues
=
{
this
.
campiFilter
}
location
=
{
type
}
/
>
<
DropdownCampi
campi
=
{
this
.
state
.
campiList
}
getDDValues
=
{
this
.
campiFilter
}
location
=
{
type
}
campiNames
=
{
this
.
state
.
campiNames
}
/
>
<
/div
>
<
BuildBiaxialBars
data
=
{
this
.
state
.
mountInstitution
}
nameKey
=
{
'
no_ies
'
}
dataKey
=
{
'
total
'
}
dataKey2
=
{
'
percentage
'
}
year
=
{
'
no_ano_pesquisa
'
}
/
>
<
/CollapsibleContainer
>
...
...
@@ -166,10 +175,6 @@ class QuotasLoan extends Component {
else
return
<
div
><
/div
>
}
getCampi
(
data
)
{
const
unique
=
[...
new
Set
(
data
.
map
(
item
=>
item
.
no_local_oferta
))];
return
unique
}
getDataFromAutocomplete
(
data
)
{
var
typeAux
=
type
+
'
s
'
;
for
(
let
i
=
0
,
j
=
0
;
i
<
data
[
'
data
'
].
length
;
i
++
,
j
++
){
...
...
@@ -190,7 +195,9 @@ class QuotasLoan extends Component {
switch
(
data
[
'
option
'
]){
case
'
institution
'
:
currentState
[
'
Instituição de Ensino
'
]
=
data
[
'
data
'
]
this
.
setState
({
campiList
:
this
.
getCampi
(
data
[
'
data
'
])})
this
.
setState
({
IESTotal
:
data
[
'
data
'
]})
this
.
setState
({
campiList
:
this
.
getCampi
(
this
.
state
.
campi
)})
// this.setState({campiList: this.getCampi(data['data'])})
this
.
setState
(
currentState
)
let
aux
=
searchHash
(
'
Todos os campi
'
,
this
.
state
.
charts
[
'
Instituição de Ensino
'
],
'
no_local_oferta
'
)
this
.
setState
({
mountInstitution
:
aux
})
...
...
@@ -277,14 +284,70 @@ class QuotasLoan extends Component {
}
}
campiFilter
(
filter
)
{
let
aux
=
searchHash
(
filter
.
value
,
this
.
state
.
charts
[
'
Instituição de Ensino
'
],
'
no_local_oferta
'
)
this
.
setState
({
mountInstitution
:
aux
})
getData
(
e
)
{
this
.
updateCharts
()
}
getData
(
e
)
{
this
.
updateCharts
()
}
getCampi
(
data
)
{
var
unique
=
([
...
new
Set
(
data
.
map
(
item
=>
item
.
co_local_oferta
))]);
var
campi
=
[]
var
campiNames
=
[]
for
(
let
i
=
0
;
i
<
unique
.
length
;
i
++
){
let
aux
=
searchHash
(
unique
[
i
],
data
,
'
co_local_oferta
'
,
"
Number
"
)
aux
=
aux
.
sort
(
function
(
a
,
b
){
return
a
.
no_ano_pesquisa
>
b
.
no_ano_pesquisa
;
});
for
(
let
i
=
0
,
j
=
0
;
i
<
aux
.
length
;
i
++
,
j
++
){
for
(;
j
<
this
.
state
.
IESTotal
.
length
;){
if
(
aux
[
i
].
no_ano_pesquisa
===
this
.
state
.
IESTotal
[
j
].
no_ano_pesquisa
){
aux
[
i
][
'
total_IES
'
]
=
this
.
state
.
IESTotal
[
j
].
total
aux
[
i
][
'
percentage
'
]
=
aux
[
i
][
'
total
'
]
*
100
/
this
.
state
.
IESTotal
[
j
].
total
break
;
}
else
{
j
++
}
}
}
campi
.
push
(
aux
);
}
for
(
let
i
=
0
;
i
<
campi
.
length
;
i
++
){
let
maxValue
=
Math
.
max
(...
campi
[
i
].
map
(
o
=>
o
.
no_ano_pesquisa
));
campiNames
.
push
(
searchHash
(
maxValue
,
campi
[
i
],
'
no_ano_pesquisa
'
,
"
Number
"
)[
0
]);
}
this
.
setState
({
campiNames
:
[{
no_local_oferta
:
'
Todos os campi
'
,
co_local_oferta
:
0
}].
concat
(
campiNames
)})
return
unique
}
saveAutocompleteContent
(
tagID
,
tagName
){
this
.
setState
({
tagID
:
tagID
,
tagName
:
tagName
})
this
.
getCampiFromServer
(
tagID
)
}
campiFilter
(
filter
)
{
let
currentState
=
this
.
state
.
charts
if
(
filter
.
value
===
'
0
'
){
currentState
[
'
Instituição de Ensino
'
]
=
this
.
state
.
IESTotal
;
}
else
{
let
aux
=
searchHash
(
filter
.
value
,
this
.
state
.
campi
,
'
co_local_oferta
'
,
"
Number
"
)
aux
=
aux
.
sort
(
function
(
a
,
b
){
return
a
.
no_ano_pesquisa
>
b
.
no_ano_pesquisa
;
});
currentState
[
'
Instituição de Ensino
'
]
=
aux
;
}
this
.
setState
({
charts
:
currentState
})
}
getCampiFromServer
(
id
){
var
route
=
`
${
type
}
?dims=cod_offer_location,name_offer_location&filter=institution_cod:
${
id
}
`
axios
.
get
(
`
${
serverURL
}${
route
}
`
)
.
then
(
res
=>
{
const
data
=
res
.
data
.
result
this
.
setState
({
campi
:
data
});
}).
catch
(
error
=>
{
console
.
log
(
error
)
});
}
}
const
typeLoansKeys
=
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment