Aw4751 eslint fixes
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -123,56 +123,56 @@ export const initialState: State = {
|
||||
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
||||
switch (action.type) {
|
||||
case ROUTER_NAVIGATION: {
|
||||
let a = action as RouterNavigationAction;
|
||||
const a = action as RouterNavigationAction;
|
||||
return tassign(state);
|
||||
}
|
||||
case mapActions.SETMAPSTATE: {
|
||||
let a = action as mapActions.SetMapState;
|
||||
const a = action as mapActions.SetMapState;
|
||||
return tassign(state, {
|
||||
mapState: a.mapState
|
||||
});
|
||||
}
|
||||
case mapActions.SETQUERYSTATE: {
|
||||
let a = action as mapActions.SetQueryState;
|
||||
const a = action as mapActions.SetQueryState;
|
||||
return tassign(state, { queryState: tassign(a.queryState ),replaceUrl:a.replaceUrl});
|
||||
}
|
||||
case mapActions.SETSTATE: {
|
||||
let a = action as mapActions.SetState;
|
||||
const a = action as mapActions.SetState;
|
||||
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState)});
|
||||
}
|
||||
case mapActions.SETVIEWEXTENT: {
|
||||
let a = action as mapActions.SetViewExtent;
|
||||
const a = action as mapActions.SetViewExtent;
|
||||
return tassign(state, { viewExtent: a.extent });
|
||||
}
|
||||
case mapActions.SETPARENT: {
|
||||
let a = action as mapActions.SetParent;
|
||||
const a = action as mapActions.SetParent;
|
||||
return tassign(state, {
|
||||
parentCode : a.parentCode
|
||||
});
|
||||
}
|
||||
case mapActions.STARTSEARCHSUCCESS: {
|
||||
let a = action as mapActions.StartSearchSuccess;
|
||||
const a = action as mapActions.StartSearchSuccess;
|
||||
return tassign(state, {
|
||||
features: a.features,
|
||||
inSearch:false
|
||||
});
|
||||
}
|
||||
case mapActions.SETFEATURES: {
|
||||
let a = action as mapActions.SetFeatures;
|
||||
const a = action as mapActions.SetFeatures;
|
||||
return tassign(state, {
|
||||
features: a.features
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTFEATURE: {
|
||||
let a = action as mapActions.SelectFeature;
|
||||
const a = action as mapActions.SelectFeature;
|
||||
return tassign(state, {
|
||||
selectedFeature: state.selectedItem?state.selectedFeature: a.feature
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTITEM: {
|
||||
let a = action as mapActions.SelectItem;
|
||||
let itemCode = state.selectedItem ? state.selectedItem.code : "";
|
||||
let inSearch = a.itemCode != itemCode;
|
||||
const a = action as mapActions.SelectItem;
|
||||
const itemCode = state.selectedItem ? state.selectedItem.code : "";
|
||||
const inSearch = a.itemCode != itemCode;
|
||||
return tassign(state, {
|
||||
selectedItem: null,
|
||||
selectedItemLayer: null,
|
||||
@@ -182,7 +182,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTITEMSUCCESS: {
|
||||
let a = action as mapActions.SelectItemSuccess;
|
||||
const a = action as mapActions.SelectItemSuccess;
|
||||
return tassign(state, {
|
||||
inSearch:false,
|
||||
selectedItem: a.item,
|
||||
@@ -195,8 +195,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
});
|
||||
}
|
||||
case mapActions.SETSELECTEDITEMLAYER: {
|
||||
let a = action as mapActions.SetSelectedItemLayer;
|
||||
var itemLayer = null;
|
||||
const a = action as mapActions.SetSelectedItemLayer;
|
||||
let itemLayer = null;
|
||||
if (a.item && "vnd.farmmaps.itemtype.layer,vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(a.item.itemType) >=0 ) {
|
||||
itemLayer = new ItemLayer(a.item);
|
||||
itemLayer.layerIndex = a.layerIndex>=0?a.layerIndex:a.item.data.layers?a.item.data.layers[0].index:-1;
|
||||
@@ -209,12 +209,12 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
});
|
||||
}
|
||||
case mapActions.SELECTTEMPORALITEMSSUCCESS:{
|
||||
let a = action as mapActions.SelectTemporalItemsSuccess;
|
||||
let selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer;
|
||||
const a = action as mapActions.SelectTemporalItemsSuccess;
|
||||
const selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer;
|
||||
let layerIndex=-1;
|
||||
selectedItemLayer.temporalItems = a.temporalItems;
|
||||
if(a.temporalItems.length>0) {
|
||||
let item = a.temporalItems[a.temporalItems.length-1];
|
||||
const item = a.temporalItems[a.temporalItems.length-1];
|
||||
layerIndex = item.data.layers[0].index;
|
||||
selectedItemLayer.selectedItemLayer = new ItemLayer(item,1,true,layerIndex);
|
||||
} else {
|
||||
@@ -223,16 +223,16 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
selectedItemLayer.previousItemLayer = a.temporalItems.length>1?new ItemLayer(a.temporalItems[a.temporalItems.length-2],0,true,layerIndex):null;
|
||||
selectedItemLayer.nextItemLayer = null;
|
||||
if(selectedItemLayer.selectedItemLayer) {
|
||||
let layerIndex = selectedItemLayer.selectedItemLayer.item.data.layers[0].index;
|
||||
const layerIndex = selectedItemLayer.selectedItemLayer.item.data.layers[0].index;
|
||||
selectedItemLayer.layerIndex = layerIndex;
|
||||
}
|
||||
|
||||
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)});
|
||||
}
|
||||
case mapActions.NEXTTEMPORAL: {
|
||||
let temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
||||
const temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
||||
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
|
||||
let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
||||
const index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
||||
if(index == (temporalLayer.temporalItems.length-1)) {
|
||||
return state;
|
||||
} else {
|
||||
@@ -258,9 +258,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
}
|
||||
case mapActions.PREVIOUSTEMPORAL: {
|
||||
let temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
||||
const temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
||||
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
|
||||
let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
||||
const index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
||||
if(index == 0) {
|
||||
return state;
|
||||
} else {
|
||||
@@ -289,8 +289,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
//todo implement
|
||||
}
|
||||
case mapActions.STARTSEARCH: {
|
||||
let a = action as mapActions.StartSearch;
|
||||
let panelVisible = a.queryState.itemCode!=null ||a.queryState.itemType!=null||a.queryState.parentCode!=null || a.queryState.query != null || a.queryState.tags != null;
|
||||
const a = action as mapActions.StartSearch;
|
||||
const panelVisible = a.queryState.itemCode!=null ||a.queryState.itemType!=null||a.queryState.parentCode!=null || a.queryState.query != null || a.queryState.tags != null;
|
||||
return tassign(state, {
|
||||
selectedItem: null,
|
||||
features:[],
|
||||
@@ -306,7 +306,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
return tassign(state,{inSearch:false});
|
||||
}
|
||||
case mapActions.DOQUERY: {
|
||||
let a = action as mapActions.DoQuery;
|
||||
const a = action as mapActions.DoQuery;
|
||||
return tassign(state, {
|
||||
query: tassign(state.query,
|
||||
{
|
||||
@@ -321,8 +321,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
|
||||
case mapActions.ADDFEATURESUCCESS: {
|
||||
let a = action as mapActions.AddFeatureSuccess;
|
||||
let features = state.features.slice();
|
||||
const a = action as mapActions.AddFeatureSuccess;
|
||||
const features = state.features.slice();
|
||||
features.push(a.feature);
|
||||
return tassign(state, {
|
||||
panelVisible: true,
|
||||
@@ -334,8 +334,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
});
|
||||
}
|
||||
case mapActions.UPDATEFEATURESUCCESS: {
|
||||
let a = action as mapActions.UpdateFeatureSuccess;
|
||||
let features: any[] = [];
|
||||
const a = action as mapActions.UpdateFeatureSuccess;
|
||||
const features: any[] = [];
|
||||
var index = -1;
|
||||
for (var i = 0; i < state.features.length; i++) {
|
||||
if (state.features[i].getId() == a.feature.getId()) {
|
||||
@@ -356,15 +356,15 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
return tassign(state, { searchCollapsed: state.panelVisible ? false: true,showLayerSwitcher:false});
|
||||
}
|
||||
case mapActions.SETEXTENT: {
|
||||
let a = action as mapActions.SetExtent;
|
||||
const a = action as mapActions.SetExtent;
|
||||
return tassign(state, { extent: a.extent });
|
||||
}
|
||||
case mapActions.ADDLAYER: {
|
||||
let a = action as mapActions.AddLayer;
|
||||
let itemLayers = state.overlayLayers.slice(0);
|
||||
let itemLayer = new ItemLayer(a.item);
|
||||
const a = action as mapActions.AddLayer;
|
||||
const itemLayers = state.overlayLayers.slice(0);
|
||||
const itemLayer = new ItemLayer(a.item);
|
||||
itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex;
|
||||
let existing = itemLayers.filter(il => il.item.code == itemLayer.item.code && il.layerIndex == itemLayer.layerIndex);
|
||||
const existing = itemLayers.filter(il => il.item.code == itemLayer.item.code && il.layerIndex == itemLayer.layerIndex);
|
||||
if(existing.length==0) {
|
||||
itemLayers.push(itemLayer);
|
||||
return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer });
|
||||
@@ -374,10 +374,10 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
|
||||
}
|
||||
case mapActions.REMOVELAYER: {
|
||||
let a = action as mapActions.RemoveLayer;
|
||||
let newLayers = state.overlayLayers.slice(0);
|
||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
var selectedOverlayLayer: IItemLayer = null;
|
||||
const a = action as mapActions.RemoveLayer;
|
||||
const newLayers = state.overlayLayers.slice(0);
|
||||
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
let selectedOverlayLayer: IItemLayer = null;
|
||||
if (i>0 && state.overlayLayers.length > 1)
|
||||
selectedOverlayLayer = state.overlayLayers[i - 1];
|
||||
else if (i == 0 && state.overlayLayers.length > 1)
|
||||
@@ -389,49 +389,49 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
return tassign(state, {overlayLayers: [], selectedOverlayLayer: null});
|
||||
}
|
||||
case mapActions.SETVISIBILITY: {
|
||||
let a = action as mapActions.SetVisibility;
|
||||
const a = action as mapActions.SetVisibility;
|
||||
if(state.selectedItemLayer == a.itemLayer) {
|
||||
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{visible:a.visibility})});
|
||||
} else {
|
||||
let newLayers = state.overlayLayers.slice(0);
|
||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
const newLayers = state.overlayLayers.slice(0);
|
||||
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
newLayers[i].visible = a.visibility;
|
||||
return tassign(state, { overlayLayers: newLayers });
|
||||
}
|
||||
}
|
||||
case mapActions.SETOPACITY: {
|
||||
let a = action as mapActions.SetOpacity;
|
||||
const a = action as mapActions.SetOpacity;
|
||||
if(state.selectedItemLayer == a.itemLayer) {
|
||||
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{opacity:a.opacity})});
|
||||
} else {
|
||||
let newLayers = state.overlayLayers.slice(0);
|
||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
const newLayers = state.overlayLayers.slice(0);
|
||||
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
newLayers[i].opacity = a.opacity;
|
||||
return tassign(state, { overlayLayers: newLayers });
|
||||
}
|
||||
}
|
||||
case mapActions.SETLAYERINDEX: {
|
||||
let a = action as mapActions.SetLayerIndex;
|
||||
const a = action as mapActions.SetLayerIndex;
|
||||
if (a.itemLayer == null) {
|
||||
if(state.selectedItemLayer.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
||||
var newItemlayer = tassign(state.selectedItemLayer,{layerIndex:a.layerIndex});
|
||||
let tl = newItemlayer as ITemporalItemLayer;
|
||||
const tl = newItemlayer as ITemporalItemLayer;
|
||||
if(tl.previousItemLayer) {
|
||||
let nl = new ItemLayer(tl.previousItemLayer.item);
|
||||
const nl = new ItemLayer(tl.previousItemLayer.item);
|
||||
nl.opacity = tl.previousItemLayer.opacity;
|
||||
nl.visible = tl.previousItemLayer.visible;
|
||||
nl.layerIndex = a.layerIndex;
|
||||
tl.previousItemLayer = nl;
|
||||
}
|
||||
if(tl.selectedItemLayer) {
|
||||
let nl = new ItemLayer(tl.selectedItemLayer.item);
|
||||
const nl = new ItemLayer(tl.selectedItemLayer.item);
|
||||
nl.opacity = tl.selectedItemLayer.opacity;
|
||||
nl.visible = tl.selectedItemLayer.visible;
|
||||
nl.layerIndex = a.layerIndex;
|
||||
tl.selectedItemLayer = nl;
|
||||
}
|
||||
if(tl.nextItemLayer) {
|
||||
let nl = new ItemLayer(tl.nextItemLayer.item);
|
||||
const nl = new ItemLayer(tl.nextItemLayer.item);
|
||||
nl.opacity = tl.nextItemLayer.opacity;
|
||||
nl.visible = tl.nextItemLayer.visible;
|
||||
nl.layerIndex = a.layerIndex;
|
||||
@@ -444,24 +444,24 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
return tassign(state, { selectedItemLayer: newItemlayer})
|
||||
} else {
|
||||
let newLayers = state.overlayLayers.slice(0);
|
||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
const newLayers = state.overlayLayers.slice(0);
|
||||
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||
newLayers[i].layerIndex = a.layerIndex;
|
||||
return tassign(state, { overlayLayers: newLayers });
|
||||
}
|
||||
}
|
||||
case mapActions.LOADBASELAYERSSUCCESS: {
|
||||
let a =action as mapActions.LoadBaseLayersSuccess;
|
||||
let baseLayers:ItemLayer[] = [];
|
||||
for (let item of a.items) {
|
||||
var l = new ItemLayer(item);
|
||||
const a =action as mapActions.LoadBaseLayersSuccess;
|
||||
const baseLayers:ItemLayer[] = [];
|
||||
for (const item of a.items) {
|
||||
const l = new ItemLayer(item);
|
||||
l.visible = false;
|
||||
baseLayers.push(l);
|
||||
}
|
||||
var selectedBaseLayer: IItemLayer = null;
|
||||
let selectedBaseLayer: IItemLayer = null;
|
||||
var mapState = tassign(state.mapState);
|
||||
let sb = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode);
|
||||
let db = baseLayers.filter(layer => layer.item.data && layer.item.data.default === true);
|
||||
const sb = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode);
|
||||
const db = baseLayers.filter(layer => layer.item.data && layer.item.data.default === true);
|
||||
if (baseLayers.length > 0 && mapState.baseLayerCode != "" && sb.length>0) {
|
||||
selectedBaseLayer = sb[0];
|
||||
selectedBaseLayer.visible = true;
|
||||
@@ -476,22 +476,22 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
return tassign(state, { mapState:mapState, baseLayers: baseLayers, selectedBaseLayer: selectedBaseLayer });
|
||||
}
|
||||
case mapActions.SELECTBASELAYER: {
|
||||
let a = action as mapActions.SelectBaseLayer;
|
||||
let baseLayers = state.baseLayers.slice(0);
|
||||
const a = action as mapActions.SelectBaseLayer;
|
||||
const baseLayers = state.baseLayers.slice(0);
|
||||
baseLayers.forEach((l) => l.visible = false);
|
||||
let i = state.baseLayers.indexOf(a.itemLayer);
|
||||
const i = state.baseLayers.indexOf(a.itemLayer);
|
||||
baseLayers[i].visible = true;
|
||||
var mapState = tassign(state.mapState);
|
||||
mapState.baseLayerCode = a.itemLayer.item.code;
|
||||
return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer });
|
||||
}
|
||||
case mapActions.SELECTOVERLAYLAYER: {
|
||||
let a = action as mapActions.SelectOverlayLayer;
|
||||
const a = action as mapActions.SelectOverlayLayer;
|
||||
return tassign(state, { selectedOverlayLayer: a.itemLayer });
|
||||
}
|
||||
|
||||
case mapActions.CLEAR: {
|
||||
let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
|
||||
const newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
|
||||
return tassign(state, {
|
||||
panelVisible: false,
|
||||
panelCollapsed:false,
|
||||
@@ -511,41 +511,41 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
});
|
||||
}
|
||||
case mapActions.SETSTYLE:{
|
||||
let a = action as mapActions.SetStyle;
|
||||
let styles = tassign(state.styles);
|
||||
const a = action as mapActions.SetStyle;
|
||||
const styles = tassign(state.styles);
|
||||
styles[a.itemType] = a.style;
|
||||
return tassign(state,{styles:styles});
|
||||
}
|
||||
case mapActions.SHOWLAYERSWITCHER:{
|
||||
let a = action as mapActions.ShowLayerSwitcher;
|
||||
const a = action as mapActions.ShowLayerSwitcher;
|
||||
return tassign(state,{showLayerSwitcher:a.show});
|
||||
}
|
||||
case mapActions.TOGGLESHOWDATALAYERSLIDE:{
|
||||
return tassign(state,{showDataLayerSlide:!state.showDataLayerSlide});
|
||||
}
|
||||
case mapActions.SETREPLACEURL: {
|
||||
let a= action as mapActions.SetReplaceUrl;
|
||||
const a= action as mapActions.SetReplaceUrl;
|
||||
return tassign(state,{replaceUrl:a.replaceUrl});
|
||||
}
|
||||
case mapActions.TOGGLELAYERVALUESENABLED: {
|
||||
return tassign(state,{layerValuesEnabled:!state.layerValuesEnabled});
|
||||
}
|
||||
case mapActions.SETLAYERVALUESLOCATION: {
|
||||
let a= action as mapActions.SetLayerValuesLocation;
|
||||
const a= action as mapActions.SetLayerValuesLocation;
|
||||
return tassign(state,{layerValuesX: a.x, layerValuesY:a.y,layerValues:[]});
|
||||
}
|
||||
case mapActions.GETLAYERVALUESUCCESS:{
|
||||
let a= action as mapActions.GetLayerValueSuccess;
|
||||
let v = state.layerValues.slice(0);
|
||||
const a= action as mapActions.GetLayerValueSuccess;
|
||||
const v = state.layerValues.slice(0);
|
||||
v.push(a.layervalue);
|
||||
return tassign(state,{layerValues:v});
|
||||
}
|
||||
case mapActions.SETVIEWSTATE:{
|
||||
let a= action as mapActions.SetViewState;
|
||||
const a= action as mapActions.SetViewState;
|
||||
return tassign(state,{viewEnabled:a.enabled});
|
||||
}
|
||||
case commonActions.ITEMDELETEDEVENT:{
|
||||
let a= action as commonActions.ItemDeletedEvent;
|
||||
const a= action as commonActions.ItemDeletedEvent;
|
||||
if(state.selectedItem && state.selectedItem.code == a.itemCode) {
|
||||
return tassign(state,{
|
||||
selectedItem: null,
|
||||
@@ -562,7 +562,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
}
|
||||
if(index>=0) {
|
||||
let newFeatures = state.features.slice(0);
|
||||
const newFeatures = state.features.slice(0);
|
||||
newFeatures.splice(index,1);
|
||||
return tassign(state,{features:newFeatures});
|
||||
}
|
||||
|
Reference in New Issue
Block a user