aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts')
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
index c192ece48..0291a3b5c 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
@@ -2,6 +2,7 @@ import * as _ from "lodash";
import {ActionOnFirstLevel} from "./firstLevel/firstLevel.actions";
import {ServiceInstanceActions} from "../../models/serviceInstanceActions";
import {ServiceState} from "./main.reducer";
+import {ServiceInstance} from "../../models/serviceInstance";
export function deleteFirstLevel(state: ServiceState, action: ActionOnFirstLevel,shouldUpdateServiceValidationCounter: boolean){
let newState = _.cloneDeep(state);
@@ -28,3 +29,26 @@ function resetUpgradeStatus(newState: any, serviceUuid: string){
newState.serviceInstance[serviceUuid].upgradedVFMSonsCounter = 0;
newState.serviceInstance[serviceUuid].isUpgraded = false;
}
+
+export const updateUniqueNames = (oldName: string, newName: string, serviceInstance: ServiceInstance): void => {
+ let existingNames = serviceInstance.existingNames;
+ if (!_.isNil(oldName) && oldName.toLowerCase() in existingNames) {
+ delete existingNames[oldName.toLowerCase()];
+ }
+ if (!_.isNil(newName)) {
+ existingNames[newName.toLowerCase()] = "";
+ }
+};
+
+
+export const calculateNextUniqueModelName = (nfModelName: string, serviceId: string, state: any, levelName: string): string => {
+ let counter: number = null;
+ while (true) {
+ let pattern = !_.isNil(counter) ? ("_" + counter) : "";
+ if (!_.isNil(state.serviceInstance[serviceId][levelName][nfModelName + pattern])) {
+ counter = counter ? (counter + 1) : 1;
+ } else {
+ return nfModelName + pattern;
+ }
+ }
+};