Skip to content

Commit

Permalink
Closes #394 - Replace UpdateValueAction with UpdateFieldAction
Browse files Browse the repository at this point in the history
  • Loading branch information
mpuyosa91 committed Jan 5, 2024
1 parent 175a87e commit 50b0b1b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 101 deletions.
1 change: 0 additions & 1 deletion core/app/core/src/lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ export * from './fields/field-logic/email-primary-select/email-primary-select.ac
export * from './fields/field-logic/required/required.action';
export * from './fields/field-logic/update-field/update-field.action';
export * from './fields/field-logic/update-flex-relate-module/update-flex-relate-module.action';
export * from './fields/field-logic/update-value/update-value.action';
export * from './fields/field-logic/update-value-backend/update-value-backend.action';
export * from './fields/field-logic-display/field-logic-display.action';
export * from './fields/field-logic-display/field-logic-display.manager';
Expand Down
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,
dislayTypeBackend: DisplayTypeBackendAction
) {
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 @@ -24,8 +24,9 @@
* the words "Supercharged by SuiteCRM".
*/

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 @@ -34,15 +35,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 @@ -61,6 +63,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 50b0b1b

Please sign in to comment.