Skip to content

Commit

Permalink
fix: condition dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachakra16 committed Mar 28, 2023
1 parent 783def8 commit fc261a8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/modules/Collection/AddField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ export default function AddField({ propertyName, pageId, handleClose }: Props) {
buttonText="Add Condition when Field is Visible"
collection={collection}
buttonWidth="fit"
dropDownPortal={true}
/>
{/* {["shortText", "longText", "ethAddress"].includes(
type.value
Expand Down
1 change: 1 addition & 0 deletions app/modules/Collection/Automation/SingleAutomation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ export default function SingleAutomation({
firstRowMessage="It is true that"
buttonText="Add Condition"
collection={collection}
dropDownPortal={false}
/>
</Box>
</Box>
Expand Down
5 changes: 5 additions & 0 deletions app/modules/Collection/Common/AddConditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = {
buttonText: string;
firstRowMessage?: string;
collection: CollectionType;
dropDownPortal: boolean;
buttonWidth?: string;
};

Expand All @@ -23,6 +24,7 @@ export default function AddConditions({
buttonText,
collection,
buttonWidth,
dropDownPortal,
}: Props) {
const fieldOptions = Object.entries(collection.properties)
.filter((field) => !["multiURL"].includes(field[1].type))
Expand Down Expand Up @@ -102,6 +104,7 @@ export default function AddConditions({
}}
multiple={false}
isClearable={false}
portal={dropDownPortal}
/>
</Box>
<Box
Expand All @@ -122,6 +125,7 @@ export default function AddConditions({
}}
multiple={false}
isClearable={false}
portal={dropDownPortal}
/>
</Box>
<Box
Expand All @@ -140,6 +144,7 @@ export default function AddConditions({
collection={collection}
propertyId={condition?.data?.field?.value}
comparatorValue={condition?.data?.comparator?.value}
dropDownPortal={dropDownPortal}
/>
</Box>
</Box>
Expand Down
17 changes: 17 additions & 0 deletions app/modules/Collection/Common/FilterValueField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Props = {
onChange: (value: any) => void;
collection: CollectionType;
propertyId: string;
dropDownPortal: boolean;

comparatorValue: string;
};

Expand All @@ -20,6 +22,7 @@ export default function FilterValueField({
collection,
propertyId,
comparatorValue,
dropDownPortal,
}: Props) {
const type = collection?.properties[propertyId]?.type;
const [memberOptions, setMemberOptions] = useState<Option[]>([]);
Expand Down Expand Up @@ -91,6 +94,7 @@ export default function FilterValueField({
}}
multiple={false}
isClearable={false}
portal={dropDownPortal}
/>
);
case "is not":
Expand All @@ -103,6 +107,7 @@ export default function FilterValueField({
}}
multiple={false}
isClearable={false}
portal={dropDownPortal}
/>
);
case "is one of":
Expand All @@ -115,6 +120,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
default:
Expand All @@ -132,6 +138,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);

Expand All @@ -145,6 +152,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
case "includes one of":
Expand All @@ -157,6 +165,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
default:
Expand All @@ -173,6 +182,7 @@ export default function FilterValueField({
onChange(option);
}}
multiple={false}
portal={dropDownPortal}
/>
);
case "is not":
Expand All @@ -184,6 +194,7 @@ export default function FilterValueField({
onChange(option);
}}
multiple={false}
portal={dropDownPortal}
/>
);
case "is one of":
Expand All @@ -196,6 +207,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
default:
Expand All @@ -212,6 +224,7 @@ export default function FilterValueField({
onChange(option);
}}
multiple={true}
portal={dropDownPortal}
/>
);

Expand All @@ -225,6 +238,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
case "includes one of":
Expand All @@ -237,6 +251,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
default:
Expand Down Expand Up @@ -277,6 +292,7 @@ export default function FilterValueField({
}}
multiple={false}
isClearable={false}
portal={dropDownPortal}
/>
);
case "token is one of":
Expand All @@ -289,6 +305,7 @@ export default function FilterValueField({
}}
multiple={true}
isClearable={false}
portal={dropDownPortal}
/>
);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function MultiChoiceVotingOnMultipleResponses() {
firstRowMessage="Responses where"
buttonText="Add Condition"
collection={collection}
dropDownPortal={true}
/>
</Stack>
</Stack>
Expand Down
26 changes: 20 additions & 6 deletions app/modules/CollectionProject/EditValue/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ type Props = {
function EditValue({ value, setValue, propertyName, dataId, disabled }: Props) {
const [isEditing, setIsEditing] = useState(false);
const fieldInput = useRef<any>();
const { localCollection: collection, updateCollection } =
useLocalCollection();
const {
localCollection: collection,
updateCollection,
colorMapping,
} = useLocalCollection();
const property = collection.properties[propertyName];
const [options, setOptions] = useState<any>([]);
const [filteredOptions, setFilteredOptions] = useState<any>([]);
Expand Down Expand Up @@ -100,7 +103,7 @@ function EditValue({ value, setValue, propertyName, dataId, disabled }: Props) {
<CustomTag
mode={mode}
key={val.value}
borderCol={val.color}
borderCol={colorMapping[val.value]}
>
<Stack
direction="horizontal"
Expand Down Expand Up @@ -169,7 +172,7 @@ function EditValue({ value, setValue, propertyName, dataId, disabled }: Props) {
<CustomTag
mode={mode}
key={val.value}
borderCol={val.color}
borderCol={colorMapping[val.value]}
>
{" "}
{property.type === "multiSelect" && (
Expand Down Expand Up @@ -218,7 +221,10 @@ function EditValue({ value, setValue, propertyName, dataId, disabled }: Props) {
}
}}
>
<CustomTag mode={mode} borderCol={value.color}>
<CustomTag
mode={mode}
borderCol={colorMapping[value.value]}
>
{property.type === "user" && (
<Stack
direction="horizontal"
Expand Down Expand Up @@ -474,9 +480,17 @@ function EditValue({ value, setValue, propertyName, dataId, disabled }: Props) {
value={value}
propertyName={propertyName}
handleClose={(reward) => {
setIsEditing(false);
console.log({ reward });
if (
((!reward.value && reward.value !== 0) ||
!reward.token ||
!reward.chain) &&
dataId &&
!collection.data?.[dataId]?.[propertyName]?.value
)
return;
setValue(reward);
setIsEditing(false);
}}
dataId={dataId}
/>
Expand Down
1 change: 1 addition & 0 deletions app/modules/CollectionProject/Filtering/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function Filter() {
firstRowMessage="Add a filter"
buttonText="Add Filter"
collection={collection}
dropDownPortal={true}
/>
</Stack>
</Box>
Expand Down

0 comments on commit fc261a8

Please sign in to comment.