Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Genesys Website
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Website
Commits
0d148b49
Commit
0d148b49
authored
Jan 09, 2019
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Don't update Subset and Dataset basic info unless form is dirty
- Prevents updates on simple UI navigation
parent
6eca93c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
src/datasets/ui/dashboard/dataset-stepper/steps/basic-info/index.tsx
...s/ui/dashboard/dataset-stepper/steps/basic-info/index.tsx
+10
-6
src/subsets/ui/dashboard/subset-stepper/steps/basic-info/index.tsx
...ts/ui/dashboard/subset-stepper/steps/basic-info/index.tsx
+10
-3
No files found.
src/datasets/ui/dashboard/dataset-stepper/steps/basic-info/index.tsx
View file @
0d148b49
import
*
as
React
from
'
react
'
;
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
submit
,
isInvalid
}
from
'
redux-form
'
;
import
{
submit
,
is
Dirty
,
is
Invalid
}
from
'
redux-form
'
;
// actions
import
{
loadMyPartners
}
from
'
partners/actions/dashboard
'
;
import
{
loadCrops
}
from
'
crop/actions/public
'
;
...
...
@@ -10,14 +10,13 @@ import { DATASET_BASIC_INFO_FORM } from 'datasets/constants';
// models
import
Partner
from
'
model/genesys/Partner
'
;
import
Crop
from
'
model/genesys/Crop
'
;
// utilities
import
{
log
}
from
'
utilities/debug
'
;
// ui
import
StepperTemplate
from
'
ui/common/stepper/StepperTemplate
'
;
import
BasicInfoForm
from
'
./BasicInfoForm
'
;
interface
IDatasetProps
extends
React
.
ClassAttributes
<
any
>
{
isFormDirty
:
boolean
;
loadMyPartners
:
any
;
myPartners
:
Partner
[];
submit
:
any
;
...
...
@@ -28,9 +27,13 @@ interface IDatasetProps extends React.ClassAttributes<any> {
class
BasicInfoStep
extends
StepperTemplate
<
IDatasetProps
>
{
protected
gotoStep
=
(
id
)
=>
{
const
{
submit
,
onGotoStep
}
=
this
.
props
;
log
(
'
Saving form
'
);
submit
(
DATASET_BASIC_INFO_FORM
);
const
{
submit
,
isFormDirty
,
onGotoStep
}
=
this
.
props
;
if
(
isFormDirty
)
{
// log('Saving form');
submit
(
DATASET_BASIC_INFO_FORM
);
}
else
{
console
.
log
(
`
Form
${
DATASET_BASIC_INFO_FORM
}
not dirty
`
);
}
setTimeout
(()
=>
onGotoStep
(
id
));
}
...
...
@@ -52,6 +55,7 @@ const mapStateToProps = (state, ownProps) => ({
crops
:
state
.
crop
.
public
.
list
,
myPartners
:
state
.
partner
.
dashboard
.
myPartners
,
isInvalidForm
:
isInvalid
(
DATASET_BASIC_INFO_FORM
)(
state
),
isFormDirty
:
isDirty
(
DATASET_BASIC_INFO_FORM
)(
state
),
});
const
mapDispatchToProps
=
(
dispatch
)
=>
bindActionCreators
({
...
...
src/subsets/ui/dashboard/subset-stepper/steps/basic-info/index.tsx
View file @
0d148b49
import
*
as
React
from
'
react
'
;
import
{
translate
}
from
'
react-i18next
'
;
import
{
bindActionCreators
}
from
'
redux
'
;
import
{
isInvalid
,
submit
}
from
'
redux-form
'
;
import
{
isInvalid
,
isDirty
,
submit
}
from
'
redux-form
'
;
import
{
connect
}
from
'
react-redux
'
;
// constants
import
{
SUBSET_FORM
}
from
'
subsets/constants
'
;
...
...
@@ -13,6 +13,7 @@ import StepperTemplate from 'ui/common/stepper/StepperTemplate';
interface
ISubsetProps
extends
React
.
ClassAttributes
<
any
>
{
isInvalidForm
:
boolean
;
isFormDirty
:
boolean
;
submit
:
any
;
crops
:
Crop
[];
t
:
any
;
...
...
@@ -23,9 +24,14 @@ class BasicInfoStep extends StepperTemplate<ISubsetProps> {
protected
renderContent
=
()
=>
(<
BasicInfoForm
initialValues
=
{
this
.
props
.
item
}
t
=
{
this
.
props
.
t
}
crops
=
{
this
.
props
.
crops
}
/>);
protected
gotoStep
=
(
id
)
=>
{
const
{
onGotoStep
,
submit
}
=
this
.
props
;
const
{
onGotoStep
,
submit
,
isFormDirty
}
=
this
.
props
;
if
(
onGotoStep
)
{
submit
(
SUBSET_FORM
);
if
(
isFormDirty
)
{
submit
(
SUBSET_FORM
);
}
else
{
console
.
log
(
`
Form
${
SUBSET_FORM
}
not dirty
`
);
}
setTimeout
(()
=>
onGotoStep
(
id
));
}
}
...
...
@@ -39,6 +45,7 @@ class BasicInfoStep extends StepperTemplate<ISubsetProps> {
const
mapStateToProps
=
(
state
,
ownProps
)
=>
({
crops
:
state
.
crop
.
public
.
list
,
isInvalidForm
:
isInvalid
(
SUBSET_FORM
)(
state
),
isFormDirty
:
isDirty
(
SUBSET_FORM
)(
state
),
});
const
mapDispatchToProps
=
(
dispatch
)
=>
bindActionCreators
({
...
...
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