Skip to content
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

Release 1.8 prep #1109

Merged
merged 13 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/form-js-editor/assets/form-js-editor-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,21 @@
border-color: var(--color-borders-group);
}

.fjs-editor-container .fjs-children .fjs-element.fjs-dashed-outlined {
border-color: var(--color-borders-group);
border-style: dashed;
}

.fjs-editor-container .fjs-children .fjs-element.fjs-editor-selected {
border-color: var(--color-children-selected-border) !important;
background-color: var(--color-children-selected-background);
border-style: solid;
}

.fjs-editor-container .fjs-children .fjs-element:hover.fjs-editor-hovered,
.fjs-editor-container .fjs-children .fjs-element:focus {
border-color: var(--color-children-hover-border);
border-style: solid;
}

.fjs-editor-container .fjs-layout-column:first-child > .fjs-element[data-field-type="group"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { PaletteEntry } from './PaletteEntry';

export const PALETTE_GROUPS = [
{
label: 'Basic input',
label: 'Input',
id: 'basic-input'
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/form-js-editor/src/features/palette/index.js
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 ]
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useService } from './hooks';
const headerlessTypes = [
'spacer',
'separator',
'expression',
'html'
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,23 @@ function Condition(props) {
return editField(field, 'conditional', { hide: value });
};

let label = 'Hide if';
let description = 'Condition under which the field is hidden';

// special case for expression fields which do not render
if (field.type === 'expression') {
label = 'Deactivate if';
description = 'Condition under which the field is deactivated';
}

return FeelEntry({
debounce,
description: 'Condition under which the field is hidden',
description,
element: field,
feel: 'required',
getValue,
id,
label: 'Hide if',
label,
setValue,
variables
});
Expand Down
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
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export { TextEntry } from './TextEntry';
export { HtmlEntry } from './HtmlEntry';
export { HeightEntry } from './HeightEntry';
export { NumberEntries } from './NumberEntries';
export { ExpressionFieldEntries } from './ExpressionFieldEntries';
export { NumberSerializationEntry } from './NumberSerializationEntry';
export { DateTimeEntry } from './DateTimeEntry';
export { DateTimeConstraintsEntry } from './DateTimeConstraintsEntry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
HtmlEntry,
HeightEntry,
NumberEntries,
ExpressionFieldEntries,
DateTimeEntry,
TableDataSourceEntry,
PaginationEntry,
Expand All @@ -43,6 +44,7 @@ export function GeneralGroup(field, editField, getService) {
...IFrameHeightEntry({ field, editField }),
...HeightEntry({ field, editField }),
...NumberEntries({ field, editField }),
...ExpressionFieldEntries({ field, editField }),
...ImageSourceEntry({ field, editField }),
...AltTextEntry({ field, editField }),
...SelectEntries({ field, editField }),
Expand Down
8 changes: 5 additions & 3 deletions packages/form-js-editor/src/render/components/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ function Element(props) {
classes.push('fjs-editor-selected');
}

if (showOutline) {
classes.push('fjs-outlined');
const grouplike = [ 'group', 'dynamiclist' ].includes(type);

if (grouplike) {
classes.push(showOutline ? 'fjs-outlined' : 'fjs-dashed-outlined');
}

if (hovered) {
Expand All @@ -182,7 +184,7 @@ function Element(props) {

return classes.join(' ');

}, [ hovered, isSelected, props.class, showOutline ]);
}, [ hovered, isSelected, props.class, showOutline, type ]);

const onRemove = (event) => {
event.stopPropagation();
Expand Down
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
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { EditorIFrame } from './EditorIFrame';
import { EditorText } from './EditorText';
import { EditorHtml } from './EditorHtml';
import { EditorTable } from './EditorTable';
import { EditorExpressionField } from './EditorExpressionField';

export const editorFormFields = [
EditorIFrame,
EditorText,
EditorHtml,
EditorTable
EditorTable,
EditorExpressionField
];
4 changes: 2 additions & 2 deletions packages/form-js-editor/test/spec/FormEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ describe('FormEditor', function() {
const exportedSchema = formEditor.saveSchema();

// then
expect(exportedSchema).to.eql(exportTagged(schema));
const tagged = exportTagged(schema);
expect(exportedSchema).to.eql(tagged);

const exportedString = JSON.stringify(exportedSchema);

expect(exportedString).not.to.contain('"_path"');
expect(exportedString).not.to.contain('"_parent"');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,45 +116,6 @@ describe('features/palette', function() {
});


it('should attach when section rendered late', async function() {

// given
const node = document.createElement('div');
document.body.appendChild(node);

let formEditor;

await act(async () => {
const result = await createEditor(schema);
formEditor = result.formEditor;
});

const palette = formEditor.get('palette');
const eventBus = formEditor.get('eventBus');

// when
await act(() => {
return palette.attachTo(node);
});

// then
expect(domQuery('.fjs-palette', paletteContainer)).to.exist;
expect(domQuery('.fjs-palette', node)).to.not.exist;

// when
await act(() => {
eventBus.fire('palette.section.rendered');
});

// then
expect(domQuery('.fjs-palette', paletteContainer)).to.not.exist;
expect(domQuery('.fjs-palette', node)).to.exist;

// cleanup
document.body.removeChild(node);
});


it('should detach', async function() {

// given
Expand Down
Loading
Loading