AW-6046 Angular improvement
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
2024-04-15 10:29:47 +02:00
parent ede75f63f5
commit 84a1a04b19
104 changed files with 592 additions and 796 deletions

View File

@@ -1,21 +1,15 @@
import { tassign } from 'tassign';
import { IItem,Item } from '@farmmaps/common';
import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer} from '../models/item.layer';
import { IMapState} from '../models/map.state';
import { IQueryState} from '@farmmaps/common';
import { IPeriodState } from '../models/period.state';
import { IStyles} from '../models/style.cache';
import { ILayervalue } from '../models/layer.value';
import * as mapActions from '../actions/map.actions';
import {commonActions} from '@farmmaps/common';
import { createSelector, createFeatureSelector } from '@ngrx/store';
import {Feature} from 'ol';
import {Geometry} from 'ol/geom';
import { IItem, IQueryState, commonActions } from '@farmmaps/common';
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
import { createFeatureSelector, createSelector } from '@ngrx/store';
import { Feature } from 'ol';
import { Geometry } from 'ol/geom';
import { tassign } from 'tassign';
import * as mapActions from '../actions/map.actions';
import { IItemLayer, ITemporalItemLayer, ItemLayer, TemporalItemLayer } from '../models/item.layer';
import { ILayervalue } from '../models/layer.value';
import { IMapState } from '../models/map.state';
import { IPeriodState } from '../models/period.state';
import { IStyles } from '../models/style.cache';
import { MODULE_NAME } from '../module-name';
const startDate:Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1);
@@ -125,7 +119,6 @@ export const initialState: State = {
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
switch (action.type) {
case ROUTER_NAVIGATION: {
const a = action as RouterNavigationAction;
return tassign(state);
}
case mapActions.SETMAPSTATE: {
@@ -287,9 +280,6 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
return state;
}
}
case mapActions.SELECTTEMPORAL:{
//todo implement
}
case mapActions.STARTSEARCH: {
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;
@@ -338,8 +328,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
case mapActions.UPDATEFEATURESUCCESS: {
const a = action as mapActions.UpdateFeatureSuccess;
const features: any[] = [];
var index = -1;
for (var i = 0; i < state.features.length; i++) {
for (let i = 0; i < state.features.length; i++) {
if (state.features[i].getId() == a.feature.getId()) {
features.push(a.feature);
} else {
@@ -419,7 +408,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
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});
const newItemlayer = tassign(state.selectedItemLayer,{layerIndex:a.layerIndex});
const tl = newItemlayer as ITemporalItemLayer;
if(tl.previousItemLayer) {
const nl = new ItemLayer(tl.previousItemLayer.item);
@@ -443,6 +432,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
tl.nextItemLayer = nl;
}
} else {
// eslint-disable-next-line no-var
var newItemlayer = new ItemLayer(state.selectedItemLayer.item);
newItemlayer.layerIndex = a.layerIndex;
@@ -464,7 +454,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
baseLayers.push(l);
}
let selectedBaseLayer: IItemLayer = null;
var mapState = tassign(state.mapState);
const mapState = tassign(state.mapState);
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) {
@@ -486,7 +476,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
baseLayers.forEach((l) => l.visible = false);
const i = state.baseLayers.indexOf(a.itemLayer);
baseLayers[i].visible = true;
var mapState = tassign(state.mapState);
const mapState = tassign(state.mapState);
mapState.baseLayerCode = a.itemLayer.item.code;
return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer });
}
@@ -560,8 +550,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
});
}
if(state.features.length>0) {
var index = -1;
for (var i = 0; i < state.features.length; i++) {
let index = -1;
for (let i = 0; i < state.features.length; i++) {
if (state.features[i].getId() == a.itemCode ) {
index=i;
}