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

Fix Set Filter Profile dialog behavior and styles #659

Merged
merged 2 commits into from
Jun 6, 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
36 changes: 19 additions & 17 deletions src/components/shared/TableFilterProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
import cn from "classnames";
import { getFilterProfiles } from "../../selectors/tableFilterProfilesSelectors";
import {
cancelEditFilterProfile,
FilterProfile,
createFilterProfile,
removeFilterProfile,
} from "../../slices/tableFilterProfilesSlice";
Expand Down Expand Up @@ -40,7 +40,7 @@ const TableFiltersProfiles = ({
// State for helping saving and editing profiles
const [profileName, setProfileName] = useState("");
const [profileDescription, setProfileDescription] = useState("");
const [, setCurrentlyEditing] = useState("");
const [currentlyEditing, setCurrentlyEditing] = useState<FilterProfile | null>(null);
const [validName, setValidName] = useState(false);

const { t } = useTranslation();
Expand Down Expand Up @@ -82,20 +82,25 @@ const TableFiltersProfiles = ({
};

const cancelEditProfile = () => {
// What was this achieving?
// if (currentlyEditing !== "") {
// dispatch(createFilterProfile(currentlyEditing));
// }
dispatch(cancelEditFilterProfile());
setSettingsMode(!settingsMode);
setFilterSettings(!showFilterSettings);
// This holds the value of the profile being edited (in edit mode), and by cancelling the process, the profile won't vanish!
if (currentlyEditing) {
dispatch(createFilterProfile(currentlyEditing));
}
setSettingsMode(true);
resetStateValues();
};

const closeFilterSetting = () => {
if (currentlyEditing) {
cancelEditProfile();
}
setFilterSettings(!showFilterSettings);
};

const resetStateValues = () => {
setProfileName("");
setProfileDescription("");
setCurrentlyEditing("");
setCurrentlyEditing(null);
setValidName(false);
};

Expand Down Expand Up @@ -141,7 +146,7 @@ const TableFiltersProfiles = ({
<header>
<button
className="button-like-anchor icon close"
onClick={() => setFilterSettings(!showFilterSettings)}
onClick={closeFilterSetting}
/>
<h4>{t("TABLE_FILTERS.PROFILES.FILTERS_HEADER")}</h4>
</header>
Expand Down Expand Up @@ -185,7 +190,7 @@ const TableFiltersProfiles = ({
className="button-like-anchor save"
onClick={() => setSettingsMode(!settingsMode)}
>
{t("TABLE_FILTERS.PROFILES.SAVE_FILTERS").substr(0, 70)}
{t("TABLE_FILTERS.PROFILES.ADD").substr(0, 70)}
</button>
</div>
</div>
Expand All @@ -196,15 +201,12 @@ const TableFiltersProfiles = ({
<header>
<button
className="button-like-anchor icon close"
onClick={() => {
setFilterSettings(!showFilterSettings);
setSettingsMode(true);
}}
onClick={closeFilterSetting}
/>
<h4>{t("TABLE_FILTERS.PROFILES.FILTER_HEADER")}</h4>
</header>
{/* Input form for save/editing profile*/}
<div>
<div className="edit-details">
<label>
{t("TABLE_FILTERS.PROFILES.NAME")}{" "}
<i className="required">*</i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,8 @@
"NAME": "Name",
"NAME_PLACEHOLDER": "Name…",
"DESCRIPTION": "Description",
"DESCRIPTION_PLACEHOLDER": "Description…"
"DESCRIPTION_PLACEHOLDER": "Description…",
"ADD": "Add"
}
},
"FILTERS": {
Expand Down
4 changes: 0 additions & 4 deletions src/slices/tableFilterProfilesSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ const tableFilterProfileSlice = createSlice({
state.profiles = state.profiles.filter(
(filterProfile) => filterProfile.name !== filterProfileToRemove.name
)
},
cancelEditFilterProfile(state) {
return
}
},
});
Expand All @@ -69,7 +66,6 @@ export const {
createFilterProfile,
editFilterProfile,
removeFilterProfile,
cancelEditFilterProfile,
} = tableFilterProfileSlice.actions;

// Export the slice reducer as the default export
Expand Down
29 changes: 25 additions & 4 deletions src/styles/components/data-filter/_filter-profiles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@
.filter-details {
@include filter-dd-mixin();

.edit-details {
padding: 5px 10px;

> label {
display: block;
line-height: 20px;
}

> input, textarea {
padding-left: 10px;
width: 100%;
margin-bottom: 10px;
resize: none;
font-size: 12px;
}

> input {
height: 30px;
}

} // edit-details

.input-container {

//padding: 10px;
Expand Down Expand Up @@ -185,8 +207,7 @@
.btn-container {
width: 100%;
float: right;
padding: 5px 5px 30px 5px;
height: 28px;
padding: 5px;
@include border-bottom-radius($main-border-radius);
background: darken($body-background, 3%);
border-top: 1px solid $main-border-color;
Expand All @@ -196,14 +217,14 @@
@include btn(white);
margin-right: 3px;
float: left;
height: inherit;
height: 28px;
} // cancel

.save {
@include btn(green);
text-shadow: none;
float: right;
height: inherit;
height: 28px;
} // save
} // input-container

Expand Down
Loading