Skip to content

Commit

Permalink
Merge pull request #472 from bettyblocks/acceptance
Browse files Browse the repository at this point in the history
Merge acceptance into master
  • Loading branch information
nulian authored Oct 7, 2020
2 parents 34e803d + e89137b commit 6b239e1
Show file tree
Hide file tree
Showing 43 changed files with 2,654 additions and 1,059 deletions.
144 changes: 144 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "component-set",
"version": "1.32.6",
"version": "1.37.0",
"main": "dist/templates.json",
"license": "UNLICENSED",
"private": false,
"devDependencies": {
"@betty-blocks/cli": "^23.12.0",
"@betty-blocks/cli": "^23.15.0",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-angular": "^8.3.4",
"@commitlint/prompt-cli": "^8.3.5",
Expand Down
30 changes: 17 additions & 13 deletions src/components/autoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
orientation: 'HORIZONTAL',
jsx: (() => {
const {
label,
defaultValue,
required,
disabled,
Expand All @@ -17,18 +16,18 @@
fullWidth,
margin,
helperText,
actionInputId,
model,
multiple,
freeSolo,
searchProperty,
valueProperty,
property,
propertyLabelOverride,
closeOnSelect,
renderCheckboxes,
showError,
hideLabel,
customModelAttribute: customModelAttributeObj,
property,
nameAttribute,
} = options;
const { Autocomplete } = window.MaterialUI.Lab;
const {
Expand All @@ -43,18 +42,17 @@
CheckBox,
CheckBoxOutlineBlank,
} = window.MaterialUI.Icons;
const { useText, getProperty, getActionInput, useGetAll, env } = B;
const { useText, getProperty, getCustomModelAttribute, useGetAll, env } = B;
const isDev = env === 'dev';
const displayError = showError === 'built-in';
const [currentValue, setCurrentValue] = useState(useText(defaultValue));
const placeholderText = useText(placeholder);
const helper = useText(helperText);
const nameAttributeValue = useText(nameAttribute);

const { label: propertyLabelText, kind, values: listValues } =
getProperty(property) || {};
const propLabelOverride = useText(propertyLabelOverride);
const propertyLabel = propLabelOverride || propertyLabelText;
const labelText = property ? propertyLabel : useText(label);
const { id: customModelAttributeId, label } = customModelAttributeObj;
const { kind, values: listValues } = getProperty(property) || {};
const labelText = useText(label);

const textFieldProps = {
disabled,
Expand All @@ -71,7 +69,13 @@
classes: { root: classes.formControl },
};

const actionInput = getActionInput(actionInputId);
const customModelAttribute = getCustomModelAttribute(
customModelAttributeId,
);

const customModelAttributeName =
customModelAttribute && customModelAttribute.name;

const searchProp = getProperty(searchProperty) || {};
const valueProp = getProperty(valueProperty) || {};
const [searchParam, setSearchParam] = useState('');
Expand Down Expand Up @@ -282,7 +286,7 @@
<TextField
{...params}
{...textFieldProps}
name={actionInput && actionInput.name}
name={nameAttributeValue || customModelAttributeName}
key={currentValue ? 'hasValue' : 'isEmpty'}
required={required && !currentValue}
InputProps={{
Expand Down Expand Up @@ -348,7 +352,7 @@
<input
type="hidden"
key={currentValue ? 'hasValue' : 'isEmpty'}
name={actionInput && actionInput.name}
name={customModelAttribute && customModelAttribute.name}
value={currentValue}
/>
<TextField
Expand Down
13 changes: 13 additions & 0 deletions src/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
visible,
actionId,
buttonText,
actionProperties,
} = options;

const { env, useText, useAction } = B;
Expand All @@ -40,8 +41,20 @@
const [isLoading, setIsLoading] = useState(false);
const toggleVisibility = () => setIsVisible(s => !s);

const propertyMappings = new Map(actionProperties);
const input = Array.from(propertyMappings.keys()).reduce((acc, key) => {
const propertyId = propertyMappings.get(key);

const value = isDev ? '' : B.useProperty(propertyId);
acc[key] = value;
return acc;
}, {});

const [actionCallback, { loading }] = (isAction &&
useAction(actionId, {
variables: {
input,
},
onCompleted(data) {
B.triggerEvent('onActionSuccess', data.actionb5);
},
Expand Down
Loading

0 comments on commit 6b239e1

Please sign in to comment.