Skip to content

Commit 27cff69

Browse files
committed
Merge pull request #3110 from kobotoolbox/3109-custom-export-settings-save-bug-fix
Project downloads settings not saving properly bug fix
2 parents d56621b + 86f9ce4 commit 27cff69

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

jsapp/js/components/library/myLibraryStore.es6

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const myLibraryStore = Reflux.createStore({
2525
PAGE_SIZE: 100,
2626
DEFAULT_ORDER_COLUMN: ASSETS_TABLE_COLUMNS['date-modified'],
2727

28-
isVirgin: true,
28+
isInitialised: false,
2929

3030
data: {
3131
isFetchingData: false,
@@ -69,7 +69,7 @@ const myLibraryStore = Reflux.createStore({
6969
* otherwise wait until route changes to a library (see `onRouteChange`)
7070
*/
7171
startupStore() {
72-
if (this.isVirgin && isOnLibraryRoute() && !this.data.isFetchingData) {
72+
if (!this.isInitialised && isOnLibraryRoute() && !this.data.isFetchingData) {
7373
this.fetchData(true);
7474
}
7575
},
@@ -133,7 +133,7 @@ const myLibraryStore = Reflux.createStore({
133133
},
134134

135135
onRouteChange(data) {
136-
if (this.isVirgin && isOnLibraryRoute() && !this.data.isFetchingData) {
136+
if (!this.isInitialised && isOnLibraryRoute() && !this.data.isFetchingData) {
137137
this.fetchData(true);
138138
} else if (
139139
(
@@ -186,7 +186,7 @@ const myLibraryStore = Reflux.createStore({
186186
this.data.totalUserAssets = this.data.totalSearchAssets;
187187
}
188188
this.data.isFetchingData = false;
189-
this.isVirgin = false;
189+
this.isInitialised = true;
190190
this.trigger(this.data);
191191
},
192192

jsapp/js/components/library/ownedCollectionsStore.es6

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {isOnLibraryRoute} from './libraryUtils';
77
import {ASSET_TYPES} from 'js/constants';
88

99
const ownedCollectionsStore = Reflux.createStore({
10-
isVirgin: true,
10+
isInitialised: false,
1111

1212
data: {
1313
isFetchingData: false,
@@ -33,7 +33,7 @@ const ownedCollectionsStore = Reflux.createStore({
3333

3434
startupStore() {
3535
if (
36-
this.isVirgin &&
36+
!this.isInitialised &&
3737
isOnLibraryRoute() &&
3838
stores.session.currentAccount !== undefined &&
3939
!this.data.isFetchingData
@@ -47,7 +47,7 @@ const ownedCollectionsStore = Reflux.createStore({
4747
onGetCollectionsCompleted(response) {
4848
this.data.collections = response.results;
4949
this.data.isFetchingData = false;
50-
this.isVirgin = false;
50+
this.isInitialised = true;
5151
this.trigger(this.data);
5252
},
5353

jsapp/js/components/library/publicCollectionsStore.es6

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const publicCollectionsStore = Reflux.createStore({
2828
PAGE_SIZE: 100,
2929
DEFAULT_ORDER_COLUMN: ASSETS_TABLE_COLUMNS['date-modified'],
3030

31-
isVirgin: true,
31+
isInitialised: false,
3232

3333
data: {
3434
isFetchingData: false,
@@ -66,7 +66,7 @@ const publicCollectionsStore = Reflux.createStore({
6666
* otherwise wait until route changes to a library (see `onRouteChange`)
6767
*/
6868
startupStore() {
69-
if (this.isVirgin && isOnPublicCollectionsRoute() && !this.data.isFetchingData) {
69+
if (!this.isInitialised && isOnPublicCollectionsRoute() && !this.data.isFetchingData) {
7070
this.fetchData(true);
7171
}
7272
},
@@ -129,7 +129,7 @@ const publicCollectionsStore = Reflux.createStore({
129129
},
130130

131131
onRouteChange(data) {
132-
if (this.isVirgin && isOnPublicCollectionsRoute() && !this.data.isFetchingData) {
132+
if (!this.isInitialised && isOnPublicCollectionsRoute() && !this.data.isFetchingData) {
133133
this.fetchData(true);
134134
} else if (
135135
this.previousPath.startsWith(ROUTES.PUBLIC_COLLECTIONS) === false &&
@@ -172,7 +172,7 @@ const publicCollectionsStore = Reflux.createStore({
172172
}
173173
this.data.totalSearchAssets = response.count;
174174
this.data.isFetchingData = false;
175-
this.isVirgin = false;
175+
this.isInitialised = true;
176176
this.trigger(this.data);
177177
},
178178

jsapp/js/components/library/singleCollectionStore.es6

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const singleCollectionStore = Reflux.createStore({
2626
PAGE_SIZE: 100,
2727
DEFAULT_ORDER_COLUMN: ASSETS_TABLE_COLUMNS['date-modified'],
2828

29-
isVirgin: true,
29+
isInitialised: false,
3030

3131
data: {
3232
isFetchingData: false,
@@ -65,7 +65,7 @@ const singleCollectionStore = Reflux.createStore({
6565
* otherwise wait until route changes to a library (see `onRouteChange`)
6666
*/
6767
startupStore() {
68-
if (this.isVirgin && isOnLibraryAssetRoute() && !this.data.isFetchingData) {
68+
if (!this.isInitialised && isOnLibraryAssetRoute() && !this.data.isFetchingData) {
6969
this.fetchData(true);
7070
}
7171
},
@@ -134,7 +134,7 @@ const singleCollectionStore = Reflux.createStore({
134134
},
135135

136136
onRouteChange(data) {
137-
if (this.isVirgin && isOnLibraryAssetRoute() && !this.data.isFetchingData) {
137+
if (!this.isInitialised && isOnLibraryAssetRoute() && !this.data.isFetchingData) {
138138
this.fetchData(true);
139139
} else if (
140140
(
@@ -173,7 +173,7 @@ const singleCollectionStore = Reflux.createStore({
173173
this.data.totalUserAssets = this.data.totalSearchAssets;
174174
}
175175
this.data.isFetchingData = false;
176-
this.isVirgin = false;
176+
this.isInitialised = true;
177177
this.trigger(this.data);
178178
},
179179

jsapp/js/components/projectDownloads/projectExportsCreator.es6

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ export default class ProjectExportsCreator extends React.Component {
278278
}
279279

280280
onAnyInputChange(statePropName, newValue) {
281+
this.clearSelectedDefinedExport();
281282
const newStateObj = {};
282283
newStateObj[statePropName] = newValue;
283284
this.setState(newStateObj);
284-
this.clearSelectedDefinedExport();
285285
}
286286

287287
onSelectedExportTypeChange(newValue) {
@@ -290,6 +290,7 @@ export default class ProjectExportsCreator extends React.Component {
290290
}
291291

292292
onSelectedRowsChange(newRowsArray) {
293+
this.clearSelectedDefinedExport();
293294
const newSelectedRows = new Set();
294295
newRowsArray.forEach((item) => {
295296
if (item.checked) {
@@ -301,11 +302,13 @@ export default class ProjectExportsCreator extends React.Component {
301302

302303
selectAllRows(evt) {
303304
evt.preventDefault();
305+
this.clearSelectedDefinedExport();
304306
this.setState({selectedRows: new Set(this.getAllSelectableRows())});
305307
}
306308

307309
clearSelectedRows(evt) {
308310
evt.preventDefault();
311+
this.clearSelectedDefinedExport();
309312
this.setState({selectedRows: new Set()});
310313
}
311314

@@ -392,7 +395,8 @@ export default class ProjectExportsCreator extends React.Component {
392395
payload.name = this.state.customExportName || this.generateExportName();
393396
}
394397

395-
// unless custom selection is enabled, we send empty fields (it means "all fields" for backend)
398+
// unless custom selection is enabled, we send empty fields (it means "all
399+
// fields" for backend); otherwise we send the selected rows
396400
if (this.state.isCustomSelectionEnabled) {
397401
payload.export_settings.fields = Array.from(this.state.selectedRows);
398402
}
@@ -603,7 +607,10 @@ export default class ProjectExportsCreator extends React.Component {
603607
/>
604608

605609
<bem.ProjectDownloads__textButton
606-
disabled={!this.state.isCustomSelectionEnabled}
610+
disabled={(
611+
!this.state.isCustomSelectionEnabled ||
612+
this.state.selectedRows.size === this.state.selectableRowsCount
613+
)}
607614
onClick={this.selectAllRows}
608615
>
609616
{t('Select all')}
@@ -612,7 +619,10 @@ export default class ProjectExportsCreator extends React.Component {
612619
<span className='project-downloads__vr'/>
613620

614621
<bem.ProjectDownloads__textButton
615-
disabled={!this.state.isCustomSelectionEnabled}
622+
disabled={(
623+
!this.state.isCustomSelectionEnabled ||
624+
this.state.selectedRows.size === 0
625+
)}
616626
onClick={this.clearSelectedRows}
617627
>
618628
{t('Deselect all')}

0 commit comments

Comments
 (0)