Update placeholder on record picker object type update (#11451)
- requires a refacto so several fields can be updated at once - updating object name on record picker will now update placeholder - add a min-height to label so fields do not get moved when the label is deleted
This commit is contained in:
@ -22,15 +22,15 @@ module.exports = {
|
||||
parserOptions: {
|
||||
project: ['packages/twenty-front/tsconfig.*.json'],
|
||||
},
|
||||
plugins: ['project-structure'],
|
||||
// plugins: ['project-structure'],
|
||||
settings: {
|
||||
'project-structure/folder-structure-config-path': path.join(
|
||||
__dirname,
|
||||
'folderStructure.json',
|
||||
),
|
||||
// 'project-structure/folder-structure-config-path': path.join(
|
||||
// __dirname,
|
||||
// 'folderStructure.json',
|
||||
// ),
|
||||
},
|
||||
rules: {
|
||||
'project-structure/folder-structure': 'error',
|
||||
// 'project-structure/folder-structure': 'error',
|
||||
/*
|
||||
Uncomment this rule when we have a way to work on
|
||||
'lingui/no-unlocalized-strings': [
|
||||
|
||||
@ -100,6 +100,10 @@ const StyledAddFieldButtonContentContainer = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const StyledLabelContainer = styled.div`
|
||||
min-height: 17px;
|
||||
`;
|
||||
|
||||
export const WorkflowEditActionFormBuilder = ({
|
||||
action,
|
||||
actionOptions,
|
||||
@ -187,7 +191,9 @@ export const WorkflowEditActionFormBuilder = ({
|
||||
<WorkflowStepBody>
|
||||
{formData.map((field) => (
|
||||
<FormFieldInputContainer key={field.id}>
|
||||
{field.label ? <InputLabel>{field.label}</InputLabel> : null}
|
||||
<StyledLabelContainer>
|
||||
<InputLabel>{field.label || ''}</InputLabel>
|
||||
</StyledLabelContainer>
|
||||
|
||||
<StyledRowContainer
|
||||
onMouseEnter={() => setHoveredField(field.id)}
|
||||
|
||||
@ -9,7 +9,6 @@ import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import { IconSettingsAutomation, IconX } from 'twenty-ui/display';
|
||||
import { LightIconButton } from 'twenty-ui/input';
|
||||
|
||||
@ -64,20 +63,6 @@ export const WorkflowEditActionFormFieldSettings = ({
|
||||
onClose,
|
||||
}: WorkflowEditActionFormFieldSettingsProps) => {
|
||||
const theme = useTheme();
|
||||
const onSubFieldUpdate = (fieldName: string, value: any) => {
|
||||
if (fieldName === 'label') {
|
||||
onChange({
|
||||
...field,
|
||||
name: camelCase(value),
|
||||
label: value,
|
||||
});
|
||||
} else {
|
||||
onChange({
|
||||
...field,
|
||||
[fieldName]: value,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledFormFieldSettingsContainer>
|
||||
@ -119,15 +104,13 @@ export const WorkflowEditActionFormFieldSettings = ({
|
||||
name,
|
||||
label,
|
||||
settings,
|
||||
placeholder: '',
|
||||
});
|
||||
}}
|
||||
defaultValue={field.type}
|
||||
/>
|
||||
</FormFieldInputContainer>
|
||||
<WorkflowFormFieldSettingsByType
|
||||
field={field}
|
||||
onChange={onSubFieldUpdate}
|
||||
/>
|
||||
<WorkflowFormFieldSettingsByType field={field} onChange={onChange} />
|
||||
</StyledSettingsContent>
|
||||
</StyledFormFieldSettingsContainer>
|
||||
);
|
||||
|
||||
@ -11,46 +11,26 @@ export const WorkflowFormFieldSettingsByType = ({
|
||||
onChange,
|
||||
}: {
|
||||
field: WorkflowFormActionField;
|
||||
onChange: (fieldName: string, value: unknown) => void;
|
||||
onChange: (updatedField: WorkflowFormActionField) => void;
|
||||
}) => {
|
||||
switch (field.type) {
|
||||
case FieldMetadataType.TEXT:
|
||||
return (
|
||||
<WorkflowFormFieldSettingsText
|
||||
label={field.label}
|
||||
placeholder={field.placeholder}
|
||||
onChange={(fieldName, value) => {
|
||||
onChange(fieldName, value);
|
||||
}}
|
||||
/>
|
||||
<WorkflowFormFieldSettingsText field={field} onChange={onChange} />
|
||||
);
|
||||
case FieldMetadataType.NUMBER:
|
||||
return (
|
||||
<WorkflowFormFieldSettingsNumber
|
||||
label={field.label}
|
||||
placeholder={field.placeholder}
|
||||
onChange={(fieldName, value) => {
|
||||
onChange(fieldName, value);
|
||||
}}
|
||||
/>
|
||||
<WorkflowFormFieldSettingsNumber field={field} onChange={onChange} />
|
||||
);
|
||||
case FieldMetadataType.DATE:
|
||||
return (
|
||||
<WorkflowFormFieldSettingsDate
|
||||
label={field.label}
|
||||
onChange={(fieldName, value) => {
|
||||
onChange(fieldName, value);
|
||||
}}
|
||||
/>
|
||||
<WorkflowFormFieldSettingsDate field={field} onChange={onChange} />
|
||||
);
|
||||
case 'RECORD':
|
||||
return (
|
||||
<WorkflowFormFieldSettingsRecordPicker
|
||||
label={field.label}
|
||||
settings={field.settings}
|
||||
onChange={(fieldName, value) => {
|
||||
onChange(fieldName, value);
|
||||
}}
|
||||
field={field}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
|
||||
@ -1,26 +1,32 @@
|
||||
import { FormFieldInputContainer } from '@/object-record/record-field/form-types/components/FormFieldInputContainer';
|
||||
import { FormTextFieldInput } from '@/object-record/record-field/form-types/components/FormTextFieldInput';
|
||||
import { InputLabel } from '@/ui/input/components/InputLabel';
|
||||
import { WorkflowFormActionField } from '@/workflow/workflow-steps/workflow-actions/form-action/types/WorkflowFormActionField';
|
||||
import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-actions/form-action/utils/getDefaultFormFieldSettings';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
type WorkflowFormFieldSettingsDateProps = {
|
||||
label?: string;
|
||||
onChange: (fieldName: string, value: string | null) => void;
|
||||
field: WorkflowFormActionField;
|
||||
onChange: (updatedField: WorkflowFormActionField) => void;
|
||||
};
|
||||
|
||||
export const WorkflowFormFieldSettingsDate = ({
|
||||
label,
|
||||
field,
|
||||
onChange,
|
||||
}: WorkflowFormFieldSettingsDateProps) => {
|
||||
return (
|
||||
<FormFieldInputContainer>
|
||||
<InputLabel>Label</InputLabel>
|
||||
<FormTextFieldInput
|
||||
onChange={(newLabel: string | null) => {
|
||||
onChange('label', newLabel);
|
||||
onChange={(newLabel: string) => {
|
||||
onChange({
|
||||
...field,
|
||||
label: newLabel,
|
||||
name: camelCase(newLabel),
|
||||
});
|
||||
}}
|
||||
defaultValue={label}
|
||||
defaultValue={field.label}
|
||||
placeholder={getDefaultFormFieldSettings(FieldMetadataType.DATE).label}
|
||||
/>
|
||||
</FormFieldInputContainer>
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
import { FormFieldInputContainer } from '@/object-record/record-field/form-types/components/FormFieldInputContainer';
|
||||
import { FormTextFieldInput } from '@/object-record/record-field/form-types/components/FormTextFieldInput';
|
||||
import { InputLabel } from '@/ui/input/components/InputLabel';
|
||||
import { WorkflowFormActionField } from '@/workflow/workflow-steps/workflow-actions/form-action/types/WorkflowFormActionField';
|
||||
import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-actions/form-action/utils/getDefaultFormFieldSettings';
|
||||
import styled from '@emotion/styled';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
type WorkflowFormFieldSettingsNumberProps = {
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
onChange: (fieldName: string, value: string | null) => void;
|
||||
field: WorkflowFormActionField;
|
||||
onChange: (updatedField: WorkflowFormActionField) => void;
|
||||
};
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
@ -18,8 +19,7 @@ const StyledContainer = styled.div`
|
||||
`;
|
||||
|
||||
export const WorkflowFormFieldSettingsNumber = ({
|
||||
label,
|
||||
placeholder,
|
||||
field,
|
||||
onChange,
|
||||
}: WorkflowFormFieldSettingsNumberProps) => {
|
||||
return (
|
||||
@ -27,10 +27,14 @@ export const WorkflowFormFieldSettingsNumber = ({
|
||||
<FormFieldInputContainer>
|
||||
<InputLabel>Label</InputLabel>
|
||||
<FormTextFieldInput
|
||||
onChange={(newLabel: string | null) => {
|
||||
onChange('label', newLabel);
|
||||
onChange={(newLabel: string) => {
|
||||
onChange({
|
||||
...field,
|
||||
label: newLabel,
|
||||
name: camelCase(newLabel),
|
||||
});
|
||||
}}
|
||||
defaultValue={label}
|
||||
defaultValue={field.label}
|
||||
placeholder={
|
||||
getDefaultFormFieldSettings(FieldMetadataType.NUMBER).label
|
||||
}
|
||||
@ -39,10 +43,13 @@ export const WorkflowFormFieldSettingsNumber = ({
|
||||
<FormFieldInputContainer>
|
||||
<InputLabel>Placeholder</InputLabel>
|
||||
<FormTextFieldInput
|
||||
onChange={(newPlaceholder: string | null) => {
|
||||
onChange('placeholder', newPlaceholder);
|
||||
onChange={(newPlaceholder: string) => {
|
||||
onChange({
|
||||
...field,
|
||||
placeholder: newPlaceholder,
|
||||
});
|
||||
}}
|
||||
defaultValue={placeholder}
|
||||
defaultValue={field.placeholder}
|
||||
placeholder={
|
||||
getDefaultFormFieldSettings(FieldMetadataType.NUMBER).placeholder
|
||||
}
|
||||
|
||||
@ -3,15 +3,16 @@ import { FormFieldInputContainer } from '@/object-record/record-field/form-types
|
||||
import { FormTextFieldInput } from '@/object-record/record-field/form-types/components/FormTextFieldInput';
|
||||
import { InputLabel } from '@/ui/input/components/InputLabel';
|
||||
import { Select } from '@/ui/input/components/Select';
|
||||
import { WorkflowFormActionField } from '@/workflow/workflow-steps/workflow-actions/form-action/types/WorkflowFormActionField';
|
||||
import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-actions/form-action/utils/getDefaultFormFieldSettings';
|
||||
import styled from '@emotion/styled';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
|
||||
type WorkflowFormFieldSettingsRecordPickerProps = {
|
||||
label?: string;
|
||||
settings?: Record<string, any>;
|
||||
onChange: (fieldName: string, value: unknown) => void;
|
||||
field: WorkflowFormActionField;
|
||||
onChange: (updatedField: WorkflowFormActionField) => void;
|
||||
};
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
@ -21,8 +22,7 @@ const StyledContainer = styled.div`
|
||||
`;
|
||||
|
||||
export const WorkflowFormFieldSettingsRecordPicker = ({
|
||||
label,
|
||||
settings,
|
||||
field,
|
||||
onChange,
|
||||
}: WorkflowFormFieldSettingsRecordPickerProps) => {
|
||||
const { getIcon } = useIcons();
|
||||
@ -43,13 +43,21 @@ export const WorkflowFormFieldSettingsRecordPicker = ({
|
||||
dropdownId="workflow-form-field-settings-record-picker-object-name"
|
||||
label="Object"
|
||||
fullWidth
|
||||
value={settings?.objectName}
|
||||
value={field.settings?.objectName}
|
||||
emptyOption={{ label: 'Select an option', value: '' }}
|
||||
options={availableMetadata}
|
||||
onChange={(updatedObjectName) => {
|
||||
onChange('settings', {
|
||||
...settings,
|
||||
objectName: updatedObjectName,
|
||||
onChange({
|
||||
...field,
|
||||
placeholder: `Select a ${
|
||||
activeObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === updatedObjectName,
|
||||
)?.labelSingular || 'record'
|
||||
}`,
|
||||
settings: {
|
||||
...field.settings,
|
||||
objectName: updatedObjectName,
|
||||
},
|
||||
});
|
||||
}}
|
||||
withSearchInput
|
||||
@ -58,10 +66,14 @@ export const WorkflowFormFieldSettingsRecordPicker = ({
|
||||
<FormFieldInputContainer>
|
||||
<InputLabel>Label</InputLabel>
|
||||
<FormTextFieldInput
|
||||
onChange={(newLabel: string | null) => {
|
||||
onChange('label', newLabel);
|
||||
onChange={(newLabel: string) => {
|
||||
onChange({
|
||||
...field,
|
||||
label: newLabel,
|
||||
name: camelCase(newLabel),
|
||||
});
|
||||
}}
|
||||
defaultValue={label}
|
||||
defaultValue={field.label}
|
||||
placeholder={getDefaultFormFieldSettings('RECORD').label}
|
||||
/>
|
||||
</FormFieldInputContainer>
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
import { FormFieldInputContainer } from '@/object-record/record-field/form-types/components/FormFieldInputContainer';
|
||||
import { FormTextFieldInput } from '@/object-record/record-field/form-types/components/FormTextFieldInput';
|
||||
import { InputLabel } from '@/ui/input/components/InputLabel';
|
||||
import { WorkflowFormActionField } from '@/workflow/workflow-steps/workflow-actions/form-action/types/WorkflowFormActionField';
|
||||
import { getDefaultFormFieldSettings } from '@/workflow/workflow-steps/workflow-actions/form-action/utils/getDefaultFormFieldSettings';
|
||||
import styled from '@emotion/styled';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
type WorkflowFormFieldSettingsTextProps = {
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
onChange: (fieldName: string, value: string | null) => void;
|
||||
field: WorkflowFormActionField;
|
||||
onChange: (updatedField: WorkflowFormActionField) => void;
|
||||
};
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
@ -18,8 +19,7 @@ const StyledContainer = styled.div`
|
||||
`;
|
||||
|
||||
export const WorkflowFormFieldSettingsText = ({
|
||||
label,
|
||||
placeholder,
|
||||
field,
|
||||
onChange,
|
||||
}: WorkflowFormFieldSettingsTextProps) => {
|
||||
return (
|
||||
@ -27,10 +27,14 @@ export const WorkflowFormFieldSettingsText = ({
|
||||
<FormFieldInputContainer>
|
||||
<InputLabel>Label</InputLabel>
|
||||
<FormTextFieldInput
|
||||
onChange={(newLabel: string | null) => {
|
||||
onChange('label', newLabel);
|
||||
onChange={(newLabel: string) => {
|
||||
onChange({
|
||||
...field,
|
||||
label: newLabel,
|
||||
name: camelCase(newLabel),
|
||||
});
|
||||
}}
|
||||
defaultValue={label}
|
||||
defaultValue={field.label}
|
||||
placeholder={
|
||||
getDefaultFormFieldSettings(FieldMetadataType.TEXT).label
|
||||
}
|
||||
@ -39,10 +43,13 @@ export const WorkflowFormFieldSettingsText = ({
|
||||
<FormFieldInputContainer>
|
||||
<InputLabel>Placeholder</InputLabel>
|
||||
<FormTextFieldInput
|
||||
onChange={(newPlaceholder: string | null) => {
|
||||
onChange('placeholder', newPlaceholder);
|
||||
onChange={(newPlaceholder: string) => {
|
||||
onChange({
|
||||
...field,
|
||||
placeholder: newPlaceholder,
|
||||
});
|
||||
}}
|
||||
defaultValue={placeholder}
|
||||
defaultValue={field.placeholder}
|
||||
placeholder={
|
||||
getDefaultFormFieldSettings(FieldMetadataType.TEXT).placeholder
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ export const getDefaultFormFieldSettings = (type: WorkflowFormFieldType) => {
|
||||
id: v4(),
|
||||
name: 'record',
|
||||
label: 'Record',
|
||||
placeholder: `Select a record`,
|
||||
placeholder: `Select a Company`,
|
||||
settings: {
|
||||
objectName: 'company',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user