Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Website
Commits
37e575a1
Commit
37e575a1
authored
Nov 01, 2018
by
Maxym Borodenko
Committed by
Matija Obreza
Nov 02, 2018
Browse files
Unnecessary API calls
parent
855e8f64
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/accessions/ui/OverviewPage.tsx
View file @
37e575a1
...
...
@@ -205,7 +205,7 @@ class BrowsePage extends React.Component<IOverviewPageProps, any> {
const
mapStateToProps
=
(
state
,
ownProps
)
=>
({
paged
:
state
.
accessions
.
public
.
paged
||
undefined
,
overview
:
state
.
accessions
.
public
.
overview
,
filterCode
:
ownProps
.
match
.
params
.
filterCode
,
filterCode
:
ownProps
.
match
.
params
.
filterCode
||
''
,
currentTab
:
ownProps
.
match
.
params
.
tab
||
'
overview
'
,
// current tab, or ownProps.location.pathname
});
...
...
src/crop/actions/admin.ts
View file @
37e575a1
import
Crop
from
'
model/genesys/Crop
'
;
import
{
IReducerAction
}
from
'
model/common.model
'
;
import
{
ADMIN_RECEIVE_CROP
}
from
'
crop/constants
'
;
import
{
ADMIN_RECEIVE_CROP
,
UPDATE_CROPS_LIST
}
from
'
crop/constants
'
;
import
{
CropService
}
from
'
service/CropService
'
;
import
navigateTo
from
'
actions/navigation
'
;
import
{
loadCrops
}
from
'
./public
'
;
const
receiveCrop
=
(
cropDetails
:
Crop
):
IReducerAction
=>
({
type
:
ADMIN_RECEIVE_CROP
,
payload
:
cropDetails
,
});
const
updateCropList
=
(
cropDetails
:
Crop
):
IReducerAction
=>
({
type
:
UPDATE_CROPS_LIST
,
payload
:
cropDetails
,
});
export
const
loadCrop
=
(
shortName
:
string
)
=>
(
dispatch
)
=>
{
CropService
.
getCrop
(
shortName
)
.
then
((
details
)
=>
dispatch
(
receiveCrop
(
details
)));
return
CropService
.
getCrop
(
shortName
)
.
then
((
details
)
=>
{
dispatch
(
receiveCrop
(
details
));
});
};
export
const
saveCrop
=
(
crop
:
Crop
)
=>
(
dispatch
)
=>
{
return
CropService
.
saveCrop
(
crop
)
.
then
((
crop
)
=>
dispatch
(
receiveCrop
(
crop
)));
.
then
((
crop
)
=>
{
dispatch
(
receiveCrop
(
crop
));
dispatch
(
updateCropList
(
crop
));
});
};
export
const
createCrop
=
()
=>
(
dispatch
)
=>
{
...
...
src/crop/actions/public.ts
View file @
37e575a1
...
...
@@ -5,7 +5,6 @@ import {IReducerAction} from 'model/common.model';
import
{
log
}
from
'
utilities/debug
'
;
import
CropDetails
from
'
model/genesys/CropDetails
'
;
const
receiveCrops
=
(
crops
:
Crop
[]):
IReducerAction
=>
({
type
:
RECEIVE_CROPS
,
payload
:
crops
,
});
...
...
@@ -14,7 +13,7 @@ const receiveCropDetails = (cropDetails: CropDetails): IReducerAction => ({
});
export
const
loadCropDetails
=
(
shortName
:
string
)
=>
(
dispatch
)
=>
{
CropService
.
getCropDetails
(
shortName
)
return
CropService
.
getCropDetails
(
shortName
)
.
then
((
details
)
=>
dispatch
(
receiveCropDetails
(
details
)));
};
...
...
src/crop/constants.ts
View file @
37e575a1
...
...
@@ -7,6 +7,7 @@ export const RECEIVE_CROPS = 'App/Crop/RECEIVE_CROPS';
export
const
RECEIVE_CROP_DETAILS
=
'
App/Crop/RECEIVE_CROP_DETAILS
'
;
export
const
ADMIN_RECEIVE_CROP
=
'
App/Crop/Admin/RECEIVE_CROP
'
;
export
const
UPDATE_CROPS_LIST
=
'
App/Crop/Admin/UPDATE_CROPS_LIST
'
;
export
const
CROP_FORM
=
'
Form/CROP
'
;
// 300000 ms = 5 min
...
...
src/crop/reducers/public.ts
View file @
37e575a1
import
update
from
'
immutability-helper
'
;
import
{
IReducerAction
}
from
'
model/common.model
'
;
import
{
RECEIVE_CROP_DETAILS
,
RECEIVE_CROPS
,
ADMIN_RECEIVE_CROP
}
from
'
crop/constants
'
;
const
INITIAL_STATE
=
{
import
{
RECEIVE_CROP_DETAILS
,
RECEIVE_CROPS
,
UPDATE_CROPS_LIST
}
from
'
crop/constants
'
;
import
Crop
from
'
model/genesys/Crop
'
;
const
INITIAL_STATE
:
{
list
:
Crop
[],
lastFetched
:
number
,
details
:
Crop
,
}
=
{
list
:
null
,
lastFetched
:
0
,
details
:
null
,
...
...
@@ -18,7 +23,7 @@ export default function crop(state = INITIAL_STATE, action: IReducerAction = {ty
lastFetched
:
{
$set
:
Date
.
now
()},
});
}
case
ADMIN_RECEIVE_CROP
:
{
case
UPDATE_CROPS_LIST
:
{
const
updateIndex
=
state
.
list
&&
action
.
payload
?
state
.
list
.
findIndex
((
crop
)
=>
crop
.
shortName
===
action
.
payload
.
shortName
)
:
-
1
;
return
updateIndex
===
-
1
?
...
...
src/crop/ui/DisplayPage.tsx
View file @
37e575a1
...
...
@@ -74,8 +74,8 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
];
public
componentWillMount
()
{
const
{
loadCropDetails
,
shortName
}
=
this
.
props
;
if
(
shortName
)
{
const
{
loadCropDetails
,
shortName
,
cropDetails
}
=
this
.
props
;
if
(
shortName
&&
(
!
cropDetails
||
shortName
!==
cropDetails
.
shortName
)
)
{
loadCropDetails
(
shortName
);
}
}
...
...
src/crop/ui/EditPage.tsx
View file @
37e575a1
...
...
@@ -32,6 +32,7 @@ class CropEditPage extends React.Component<ICropEditPageProps, any> {
protected
static
needs
=
[
({
params
:
{
shortName
}})
=>
loadCrop
(
shortName
),
];
private
onSave
=
(
updatedCrop
:
Crop
)
=>
{
const
{
saveCrop
,
navigateTo
}
=
this
.
props
;
saveCrop
(
updatedCrop
)
...
...
@@ -52,7 +53,7 @@ class CropEditPage extends React.Component<ICropEditPageProps, any> {
});
}
public
component
Did
Mount
()
{
public
component
Will
Mount
()
{
const
{
crop
,
loadCrop
,
shortName
}
=
this
.
props
;
if
(
shortName
&&
(
!
crop
||
crop
.
shortName
!==
shortName
))
{
...
...
src/geo/ui/CountryDisplayPage.tsx
View file @
37e575a1
...
...
@@ -42,8 +42,8 @@ class CountryDisplayPage extends React.Component<ICountryDisplayPageProps> {
}
public
componentWillMount
()
{
const
{
loadCountryDetails
,
isoCode
}
=
this
.
props
;
if
(
isoCode
)
{
const
{
loadCountryDetails
,
isoCode
,
details
}
=
this
.
props
;
if
(
isoCode
&&
(
!
details
||
isoCode
!==
details
.
code3
)
)
{
loadCountryDetails
(
isoCode
);
}
}
...
...
src/geo/ui/RegionDisplayPage.tsx
View file @
37e575a1
...
...
@@ -44,8 +44,8 @@ class RegionDisplayPage extends React.Component<IRegionDisplayPageProps> {
}
public
componentWillMount
()
{
const
{
loadRegionDetails
,
isoCode
}
=
this
.
props
;
if
(
isoCode
)
{
const
{
loadRegionDetails
,
isoCode
,
details
}
=
this
.
props
;
if
(
isoCode
&&
(
!
details
||
isoCode
!==
details
.
isoCode
)
)
{
loadRegionDetails
(
isoCode
);
}
}
...
...
src/subsets/ui/dashboard/DashboardPage.tsx
View file @
37e575a1
import
*
as
React
from
'
react
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
parse
}
from
'
query-string
'
;
// Actions
import
{
loadMoreSubsets
}
from
'
subsets/actions/dashboard
'
;
import
{
applyFilters
}
from
'
subsets/actions/public
'
;
// Models
import
FilteredPage
from
'
model/FilteredPage
'
;
...
...
@@ -42,10 +40,7 @@ const tableHeaderProps = [
class
DashboardPage
extends
React
.
Component
<
IDashboardPageProps
>
{
protected
static
needs
=
[
({
search
,
params
:
{
filterCode
}
})
=>
{
const
qs
=
parse
(
search
||
''
);
return
applyFilters
(
filterCode
||
''
,
FilteredPage
.
fromQueryString
(
qs
));
},
()
=>
loadMoreSubsets
(),
];
constructor
(
props
:
IDashboardPageProps
,
context
:
any
)
{
...
...
@@ -85,7 +80,6 @@ const mapStateToProps = (state, ownProps) => ({
});
const
mapDispatchToProps
=
(
dispatch
)
=>
bindActionCreators
({
applyFilters
,
loadMoreSubsets
,
},
dispatch
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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