-
Notifications
You must be signed in to change notification settings - Fork 109
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
Sub-PR: expression fields base #1095
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7f9d767
chore: changed the iframe preview site in playground to example.com
Skaiir d90a17c
feat: expression field viewer component
Skaiir 6701ac5
feat: expression field editor component
Skaiir f5ff9e9
feat: expression field properties panel
Skaiir 7afd27f
chore: added a helper function to test properties panel structure
Skaiir 634aa2a
chore: added expression field unit tests
Skaiir 6c3c771
chore: expression field schema changes
Skaiir 3d201cd
chore: playground root refactor / prevent double form load
Skaiir 00d4d9a
fix: ensure palette renderer is immediately initialised
Skaiir 40f0165
chore: remove unreliable tests
Skaiir 8737817
chore: updated snapshots
Skaiir 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
Binary file modified
BIN
+721 Bytes
(100%)
e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.06 KB
(100%)
e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+717 Bytes
(100%)
e2e/visual/empty-ui.spec.js-snapshots/empty-playground-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.75 KB
(100%)
e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.5 KB
(100%)
e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.04 KB
(100%)
e2e/visual/groups-ui.spec.js-snapshots/groups-playground-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+745 Bytes
(100%)
e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.14 KB
(100%)
e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+609 Bytes
(100%)
e2e/visual/no-theme.spec.js-snapshots/no-theme---editor-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+762 Bytes
(100%)
e2e/visual/theming.spec.js-snapshots/theming---editor-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+807 Bytes
(100%)
e2e/visual/theming.spec.js-snapshots/theming---editor-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+688 Bytes
(100%)
e2e/visual/theming.spec.js-snapshots/theming---editor-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { PaletteRenderer } from './PaletteRenderer'; | ||
|
||
export const PaletteModule = { | ||
__init__: [ 'palette' ], | ||
palette: [ 'type', PaletteRenderer ] | ||
}; |
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
76 changes: 76 additions & 0 deletions
76
packages/form-js-editor/src/features/properties-panel/entries/ExpressionFieldEntries.js
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { FeelEntry, isFeelEntryEdited, SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel'; | ||
import { useService, useVariables } from '../hooks'; | ||
|
||
export function ExpressionFieldEntries(props) { | ||
const { editField, field, id } = props; | ||
|
||
const entries = []; | ||
|
||
entries.push({ | ||
id: `${id}-expression`, | ||
component: ExpressionFieldExpression, | ||
isEdited: isFeelEntryEdited, | ||
editField, | ||
field, | ||
isDefaultVisible: (field) => field.type === 'expression' | ||
}); | ||
|
||
entries.push({ | ||
id: `${id}-computeOn`, | ||
component: ExpressionFieldComputeOn, | ||
isEdited: isSelectEntryEdited, | ||
editField, | ||
field, | ||
isDefaultVisible: (field) => field.type === 'expression' | ||
}); | ||
|
||
return entries; | ||
} | ||
|
||
function ExpressionFieldExpression(props) { | ||
const { editField, field, id } = props; | ||
|
||
const debounce = useService('debounce'); | ||
const variables = useVariables().map(name => ({ name })); | ||
|
||
const getValue = () => field.expression || ''; | ||
|
||
const setValue = (value) => { | ||
editField(field, [ 'expression' ], value); | ||
}; | ||
|
||
return FeelEntry({ | ||
debounce, | ||
description: 'Define an expression to calculate the value of this field', | ||
element: field, | ||
feel: 'required', | ||
getValue, | ||
id, | ||
label: 'Target value', | ||
setValue, | ||
variables | ||
}); | ||
} | ||
|
||
function ExpressionFieldComputeOn(props) { | ||
const { editField, field, id } = props; | ||
|
||
const getValue = () => field.computeOn || ''; | ||
|
||
const setValue = (value) => { | ||
editField(field, [ 'computeOn' ], value); | ||
}; | ||
|
||
const getOptions = () => ([ | ||
{ value: 'change', label: 'Value changes' }, | ||
{ value: 'presubmit', label: 'Form submission' } | ||
]); | ||
|
||
return SelectEntry({ | ||
id, | ||
label: 'Compute on', | ||
getValue, | ||
setValue, | ||
getOptions | ||
}); | ||
} |
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
32 changes: 32 additions & 0 deletions
32
packages/form-js-editor/src/render/components/editor-form-fields/EditorExpressionField.js
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ExpressionField, iconsByType } from '@bpmn-io/form-js-viewer'; | ||
import { editorFormFieldClasses } from '../Util'; | ||
import { useService } from '../../hooks'; | ||
|
||
const type = 'expression'; | ||
|
||
export function EditorExpressionField(props) { | ||
const { field } = props; | ||
const { expression = '' } = field; | ||
|
||
const Icon = iconsByType('expression'); | ||
const expressionLanguage = useService('expressionLanguage'); | ||
|
||
let placeholderContent = 'Expression is empty'; | ||
|
||
if (expression.trim() && expressionLanguage.isExpression(expression)) { | ||
placeholderContent = 'Expression'; | ||
} | ||
|
||
return ( | ||
<div class={ editorFormFieldClasses(type) }> | ||
<div class="fjs-form-field-placeholder"> | ||
<Icon viewBox="0 0 54 54" />{placeholderContent} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
EditorExpressionField.config = { | ||
...ExpressionField.config, | ||
escapeGridRender: false | ||
}; |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This could be simplified to a list comprehension