-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #394 - Replace UpdateValueAction with UpdateFieldAction
- Loading branch information
Showing
3 changed files
with
11 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
||
|
@@ -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, | ||
|
@@ -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; | ||
|
91 changes: 0 additions & 91 deletions
91
core/app/core/src/lib/fields/field-logic/update-value/update-value.action.ts
This file was deleted.
Oops, something went wrong.