-
Notifications
You must be signed in to change notification settings - Fork 630
Rules for Condition Groups #3737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
neatbyte-vnobis
wants to merge
11
commits into
next
Choose a base branch
from
neatbyte/condition-group-field-rules
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8b6a05c
feat: created rules for condition group
neatbyte-vnobis 04bc3c7
fix: fixed issue with form preview, fixed an array of available field…
neatbyte-vnobis 1dd221d
Merge branch 'next' into neatbyte/condition-group-field-rules
neatbyte-vnobis 793955b
fix: refactored condition group field
neatbyte-vnobis ad76a64
Merge branch 'next' into neatbyte/condition-group-field-rules
neatbyte-vnobis b52fbcd
Merge branch 'next' into neatbyte/condition-group-field-rules
neatbyte-vnobis 97a1d9c
fix: using @webiny/validation for form step rules instead of lodash
neatbyte-vnobis b7e4ba4
fix: added @webiny/validation package for page-builder deps.
neatbyte-vnobis 0548ee0
Merge branch 'next' into neatbyte/condition-group-field-rules
neatbyte-vnobis 4cbc675
fix: improved ui for rules tabs, refactored validation for rules
neatbyte-vnobis 3a6a7dd
fix: removed unused styled component, changed format of the comments
neatbyte-vnobis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
31 changes: 31 additions & 0 deletions
31
.../app-form-builder/src/admin/components/FormEditor/Context/functions/getContainerLayout.ts
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FbFormModel, FbFormStep, DropDestination, DropSource } from "~/types"; | ||
|
||
interface ContainerLayoutParams { | ||
data: FbFormModel; | ||
destination: DropDestination; | ||
source: DropSource; | ||
} | ||
/* | ||
This is a helper function that gets layout from the container based on its type. | ||
* If "source" or "destination" is Condition Group then it would take layout from the settings of the Condition Group field. | ||
* If "source" or "destination" is Step that it would take layout from the step itself. | ||
*/ | ||
export default (params: ContainerLayoutParams) => { | ||
const { data, destination, source } = params; | ||
|
||
const sourceContainer = | ||
source.containerType === "conditionGroup" | ||
? (data.fields.find(field => field._id === source.containerId)?.settings as FbFormStep) | ||
: (data.steps.find(step => step.id === source.containerId) as FbFormStep); | ||
|
||
const destinationContainer = | ||
destination.containerType === "conditionGroup" | ||
? (data.fields.find(field => field._id === destination.containerId) | ||
?.settings as FbFormStep) | ||
: (data.steps.find(step => step.id === destination.containerId) as FbFormStep); | ||
|
||
return { | ||
sourceContainer, | ||
destinationContainer | ||
}; | ||
}; |
55 changes: 55 additions & 0 deletions
55
...m-builder/src/admin/components/FormEditor/Context/functions/handleDeleteConditionGroup.ts
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FbFormModelField, FbFormStep, FbFormModel } from "~/types"; | ||
|
||
import { deleteField } from "./index"; | ||
|
||
interface DeleteConditionGroupParams { | ||
data: FbFormModel; | ||
formStep: FbFormStep; | ||
stepFields: FbFormModelField[]; | ||
conditionGroup: FbFormModelField; | ||
conditionGroupFields: FbFormModelField[]; | ||
} | ||
/* | ||
When we delete condition group we also need to delete fields inside of it, | ||
because those fields belong directly (they are being stored in the setting of the condition group) to the condition group and not the step. | ||
*/ | ||
export default (params: DeleteConditionGroupParams) => { | ||
const { data, formStep, stepFields, conditionGroup, conditionGroupFields } = params; | ||
|
||
const deleteConditionGroup = () => { | ||
const layout = stepFields.map(field => { | ||
if (field._id === conditionGroup._id) { | ||
deleteField({ | ||
field, | ||
data, | ||
containerType: "step", | ||
containerId: formStep.id | ||
}); | ||
return; | ||
} else { | ||
return field; | ||
} | ||
}); | ||
|
||
return layout; | ||
}; | ||
|
||
const deleteConditionGroupFields = () => { | ||
const layout = conditionGroupFields.map(field => { | ||
if (!conditionGroup._id) { | ||
return; | ||
} | ||
deleteField({ | ||
field, | ||
data, | ||
containerType: "conditionGroup", | ||
containerId: conditionGroup._id | ||
}); | ||
}); | ||
|
||
return layout; | ||
}; | ||
deleteConditionGroupFields(); | ||
|
||
deleteConditionGroup(); | ||
}; |
This file contains hidden or 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
10 changes: 5 additions & 5 deletions
10
...der/src/admin/components/FormEditor/Context/functions/handleMoveField/getFieldPosition.ts
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.