Skip to content

Commit

Permalink
Replace UpdateValueAction with UpdateFieldAction
Browse files Browse the repository at this point in the history
  • Loading branch information
mpuyosa91 committed Dec 6, 2023
1 parent 1551c8b commit 56565e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ import {RequiredAction} from './required/required.action';
import {UpdateBaseCurrencyAction} from './currency-conversion/update-base-currency.action';
import {UpdateCurrencyAction} from './currency-conversion/update-currency.action';
import {UpdateFlexRelateModuleAction} from './update-flex-relate-module/update-flex-relate-module.action';
import {UpdateValueAction} from './update-value/update-value.action';
import {UpdateFieldAction} from './update-field/update-field.action';
import {UpdateValueBackendAction} from './update-value-backend/update-value-backend.action';
import {DisplayTypeBackendAction} from './display-type-backend/display-type-backend.action';
import {UpdateFieldAction} from './update-field/update-field.action';

@Injectable({
providedIn: 'root'
Expand All @@ -59,11 +58,10 @@ export class FieldLogicManager extends BaseActionManager<FieldLogicActionData> {
required: RequiredAction,
updateBaseCurrency: UpdateBaseCurrencyAction,
updateCurrency: UpdateCurrencyAction,
updateValue: UpdateValueAction,
updateValue: UpdateFieldAction,
updateFlexRelateModule: UpdateFlexRelateModuleAction,
updateValueBackend: UpdateValueBackendAction,
dislayTypeBackend: DisplayTypeBackendAction,
updateFieldAction: UpdateFieldAction,
) {
super();
displayType.modes.forEach(mode => this.actions[mode][displayType.key] = displayType);
Expand All @@ -75,7 +73,6 @@ export class FieldLogicManager extends BaseActionManager<FieldLogicActionData> {
updateValue.modes.forEach(mode => this.actions[mode][updateValue.key] = updateValue);
updateValueBackend.modes.forEach(mode => this.actions[mode][updateValueBackend.key] = updateValueBackend);
dislayTypeBackend.modes.forEach(mode => this.actions[mode][dislayTypeBackend.key] = dislayTypeBackend);
updateFieldAction.modes.forEach(mode => this.actions[mode][updateFieldAction.key] = updateFieldAction);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* @author SalesAgility <[email protected]>.
*/

import {isEmpty} from 'lodash-es';
import {Injectable} from '@angular/core';
import {EDITABLE_VIEW_MODES, Field, Record} from 'common';
import {ALL_VIEW_MODES, Field, Record} from 'common';
import {ActionableFieldLogicActionHandler} from '../actionable-field-logic/actionable-field-logic.action';
import {ActiveLogicChecker} from '../../../services/logic/active-logic-checker.service';

Expand All @@ -12,15 +13,16 @@ type UpdateFieldParamType = string | string[];
interface UpdateFieldParams {
nonActiveValue?: UpdateFieldParamType;
activeValue?: UpdateFieldParamType;
targetValue?: UpdateFieldParamType;
}

@Injectable({
providedIn: 'root'
})
export class UpdateFieldAction extends ActionableFieldLogicActionHandler {

key = 'updateField';
modes = EDITABLE_VIEW_MODES;
key = 'updateValue';
modes = ALL_VIEW_MODES;

constructor(
protected activeLogicChecker: ActiveLogicChecker,
Expand All @@ -39,6 +41,10 @@ export class UpdateFieldAction extends ActionableFieldLogicActionHandler {
}

private getToUpdateValue(logicIsActive: boolean, params: UpdateFieldParams): UpdateFieldParamType | null {
if (!isEmpty(params.targetValue)){
params.activeValue = params.targetValue;
}

const valueAccordingToLogicState = logicIsActive
? params.activeValue
: params.nonActiveValue;
Expand Down

This file was deleted.

0 comments on commit 56565e5

Please sign in to comment.