mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Rowy",
|
||||
"version": "2.3.0",
|
||||
"version": "2.3.1",
|
||||
"homepage": "https://rowy.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -172,12 +172,13 @@ export function emptyExtensionObject(
|
||||
user: IExtensionEditor
|
||||
): IExtension {
|
||||
return {
|
||||
name: "Untitled extension",
|
||||
name: `${type} extension`,
|
||||
active: false,
|
||||
triggers: [],
|
||||
type,
|
||||
extensionBody: extensionBodyTemplate[type] ?? extensionBodyTemplate["task"],
|
||||
requiredFields: [],
|
||||
trackedFields: [],
|
||||
conditions: `const condition: Condition = async({row, change}) => {
|
||||
// feel free to add your own code logic here
|
||||
return true;
|
||||
|
||||
@@ -19,15 +19,6 @@ export default function ConditionModal({
|
||||
setModal(EMPTY_STATE);
|
||||
};
|
||||
const handleAdd = () => {
|
||||
const labelIsEmpty = Boolean(modal.condition.label.length < 4);
|
||||
const stringValueIsEmpty = Boolean(
|
||||
modal.condition.type === "string" && modal.condition.value.length === 0
|
||||
);
|
||||
const hasDuplicate = Boolean(_find(conditions, modal.condition));
|
||||
const validation = Boolean(
|
||||
labelIsEmpty || stringValueIsEmpty || hasDuplicate
|
||||
);
|
||||
if (validation) return;
|
||||
function setConditionHack(type, condition) {
|
||||
let rCondition = condition;
|
||||
if (type === "undefined") rCondition = { ...condition, value: undefined };
|
||||
@@ -100,12 +91,7 @@ export default function ConditionModal({
|
||||
secondary: secondaryAction(modal.index),
|
||||
}}
|
||||
children={
|
||||
<Content
|
||||
isEditing={modal.index}
|
||||
condition={modal.condition}
|
||||
conditions={conditions}
|
||||
handleUpdate={handleUpdate}
|
||||
/>
|
||||
<Content condition={modal.condition} handleUpdate={handleUpdate} />
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -4,37 +4,22 @@ import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import MultiSelect from "@rowy/multiselect";
|
||||
|
||||
interface I_ConditionModalContent {
|
||||
handleUpdate: () => void;
|
||||
modal: any;
|
||||
}
|
||||
|
||||
export default function ConditionModalContent({
|
||||
isEditing,
|
||||
condition,
|
||||
conditions,
|
||||
handleUpdate,
|
||||
}: any) {
|
||||
const { label, operator, type, value } = condition;
|
||||
const labelReqLen = Boolean(condition.label.length < 1);
|
||||
const onNewHasDuplicate = Boolean(_find(conditions, condition));
|
||||
const onEditConditions = conditions.filter(
|
||||
(c) => c.value !== condition.value
|
||||
); //remove the current condition from list of conditions, to prevent false positive error on duplicate value
|
||||
const onEditHasDuplicate = Boolean(_find(onEditConditions, condition));
|
||||
|
||||
const errorTextType = (isEditing: boolean, error: string) => {
|
||||
const hasError = isEditing ? onEditHasDuplicate : onNewHasDuplicate;
|
||||
return hasError ? error : "";
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Typography variant="overline">DATA TYPE (input)</Typography>
|
||||
<MultiSelect
|
||||
options={[
|
||||
{ label: "True", value: "true" },
|
||||
{ label: "False", value: "false" },
|
||||
{ label: "Boolean", value: "boolean" },
|
||||
{ label: "Number", value: "number" },
|
||||
{ label: "String", value: "string" },
|
||||
{ label: "Undefined", value: "undefined" },
|
||||
{ label: "Null", value: "null" },
|
||||
]}
|
||||
onChange={(v) => handleUpdate("type")(v)}
|
||||
value={type}
|
||||
@@ -46,11 +31,8 @@ export default function ConditionModalContent({
|
||||
{type === "boolean" && (
|
||||
<MultiSelect
|
||||
options={[
|
||||
{ label: "Boolean", value: "boolean" },
|
||||
{ label: "Number", value: "number" },
|
||||
{ label: "String", value: "string" },
|
||||
{ label: "Undefined", value: "undefined" },
|
||||
{ label: "Null", value: "null" },
|
||||
{ label: "True", value: "true" },
|
||||
{ label: "False", value: "false" },
|
||||
]}
|
||||
onChange={(v) => handleUpdate("value")(v === "true")}
|
||||
value={value ? "true" : "false"}
|
||||
@@ -76,27 +58,22 @@ export default function ConditionModalContent({
|
||||
/>
|
||||
</div>
|
||||
<TextField
|
||||
error={isEditing ? onEditHasDuplicate : onNewHasDuplicate}
|
||||
type="number"
|
||||
label="Value"
|
||||
value={value}
|
||||
onChange={(e) => handleUpdate("value")(Number(e.target.value))}
|
||||
helperText={errorTextType(isEditing, "Number value already exists")}
|
||||
/>
|
||||
</Grid>
|
||||
)}
|
||||
{type === "string" && (
|
||||
<TextField
|
||||
error={isEditing ? onEditHasDuplicate : onNewHasDuplicate}
|
||||
fullWidth
|
||||
label="Value"
|
||||
value={value}
|
||||
onChange={(e) => handleUpdate("value")(e.target.value)}
|
||||
helperText={errorTextType(isEditing, "String value already exists")}
|
||||
/>
|
||||
)}
|
||||
<TextField
|
||||
error={labelReqLen}
|
||||
value={label}
|
||||
label="Label"
|
||||
fullWidth
|
||||
|
||||
@@ -301,7 +301,19 @@ export const ProjectContextProvider: React.FC = ({ children }) => {
|
||||
})
|
||||
.then(
|
||||
() => console.log("Field Value deleted"),
|
||||
(error) => console.error("Failed to delete", error)
|
||||
(error) => {
|
||||
if (error.code === "permission-denied") {
|
||||
enqueueSnackbar(`You don't have permission to delete this field`, {
|
||||
variant: "error",
|
||||
anchorOrigin: { horizontal: "center", vertical: "top" },
|
||||
});
|
||||
} else {
|
||||
enqueueSnackbar(error.message, {
|
||||
variant: "error",
|
||||
anchorOrigin: { horizontal: "center", vertical: "top" },
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -335,6 +347,11 @@ export const ProjectContextProvider: React.FC = ({ children }) => {
|
||||
anchorOrigin: { horizontal: "center", vertical: "top" },
|
||||
}
|
||||
);
|
||||
} else {
|
||||
enqueueSnackbar(error.message, {
|
||||
variant: "error",
|
||||
anchorOrigin: { horizontal: "center", vertical: "top" },
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -153,21 +153,30 @@ const useTableConfig = (tableId?: string) => {
|
||||
});
|
||||
};
|
||||
/** remove column by index
|
||||
* @param index of column.
|
||||
* @param key of column.
|
||||
*/
|
||||
const remove = (key: string) => {
|
||||
const { columns } = tableConfigState;
|
||||
|
||||
let updatedColumns: any = Object.values(columns)
|
||||
/**
|
||||
* Filter column, and remove key index
|
||||
* Sort and reorder column
|
||||
* Rewrite column index for firestore
|
||||
*/
|
||||
const updatedColumns: any = Object.values(columns)
|
||||
.filter((c: any) => c.key !== key)
|
||||
.sort((c: any) => c.index)
|
||||
.reduce((acc: any, curr: any, index: any) => {
|
||||
acc[curr.key] = { ...curr, index };
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const deleteColumn = { [key]: deleteField() };
|
||||
const finalColumns = { ...updatedColumns, ...deleteColumn };
|
||||
|
||||
documentDispatch({
|
||||
action: DocActions.update,
|
||||
data: { columns: updatedColumns },
|
||||
data: { columns: finalColumns },
|
||||
});
|
||||
};
|
||||
/** reorder columns by key
|
||||
|
||||
Reference in New Issue
Block a user