-
Notifications
You must be signed in to change notification settings - Fork 383
/
wfsdownload.js
67 lines (65 loc) · 1.77 KB
/
wfsdownload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright 2017, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import {
DOWNLOAD_OPTIONS_CHANGE,
DOWNLOAD_FEATURES,
DOWNLOAD_FINISHED,
FORMAT_OPTIONS_FETCH,
FORMAT_OPTIONS_UPDATE
} from '../actions/wfsdownload';
/**
* reducer for wfsdownload
* @memberof reducers
* @param {Object} [state={downloadOptions: {}}] The initial state
* @param {Object} action the action
* @return {Object} the new state
*
* @prop {object} downloadOptions the options for WFS download
* @prop {string} downloadOptions.selectedFormat the format selectedFormat
* @prop {boolean} downloadOptions.singlePage export only the current page, not the whole data
*/
function wfsdownload( state = {downloadOptions: {singlePage: true}}, action) {
switch (action.type) {
case DOWNLOAD_FEATURES:
return {
...state,
loading: true
};
case DOWNLOAD_OPTIONS_CHANGE:
return {
...state,
downloadOptions: {
...state.downloadOptions,
[action.key]: action.value
}
};
case FORMAT_OPTIONS_FETCH:
return {
...state,
layer: action.layer,
wfsFormats: [],
formatsLoading: true
};
case DOWNLOAD_FINISHED: {
return {
...state,
loading: false
};
}
case FORMAT_OPTIONS_UPDATE: {
return {
...state,
wfsFormats: action.wfsFormats,
formatsLoading: false
};
}
default:
return state;
}
}
export default wfsdownload;