Skip to content

Commit

Permalink
Merge pull request #91 from skbkontur/gurikov/EDITSKS-4386_change-all…
Browse files Browse the repository at this point in the history
…-buttons-to-checkboxes

added checkBox in place of Button
  • Loading branch information
mgmman authored Sep 25, 2024
2 parents 8b808bf + 5246ea5 commit a49b9ca
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Check front code
run: yarn --cwd db-viewer-ui lint

- name: Build docker-compose environment
- name: Build docker compose environment
run: docker compose up -d --wait

- name: Run db-viewer api
Expand All @@ -69,7 +69,7 @@ jobs:

- name: Stop docker containers
if: always()
run: docker rm -f db-viewer-api && docker-compose down
run: docker rm -f db-viewer-api && docker compose down

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
36 changes: 19 additions & 17 deletions db-viewer-ui/src/Components/FieldSelector/FieldSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface FieldSelectorProps {
showSelectAllButton?: boolean;
}

function filterFieldDefintionsByText(fieldDefinitions: FieldDefinition[], text: string): FieldDefinition[] {
function filterFieldDefinitionsByText(fieldDefinitions: FieldDefinition[], text: string): FieldDefinition[] {
if (!text) {
return fieldDefinitions;
}
Expand Down Expand Up @@ -80,27 +80,29 @@ export function FieldSelector({
);
};

const fieldDefinitionsFiltered = filterFieldDefintionsByText(fieldDefinitions, searchText);
const fieldDefinitionsFiltered = filterFieldDefinitionsByText(fieldDefinitions, searchText);

const nothingToDisplay = <span className={jsStyles.nothingToDisplay(theme)}>Ничего не найдено</span>;
const allFieldsSelected = isAllFieldSelected(fieldDefinitionsFiltered);
return (
<div className={jsStyles.root()}>
<Input
data-tid="FilterInput"
leftIcon={<SearchLoupeIcon16Regular />}
value={searchText}
width={300}
onValueChange={setSearchText}
/>
{showSelectAllButton && (
<div
data-tid={"TypesSelectAll"}
onClick={() => handleSelectAll(fieldDefinitionsFiltered)}
className={jsStyles.selectAll(theme)}>
{allFieldsSelected ? "Снять выбор с найденных" : "Выбрать все найденные"}
</div>
)}
<RowStack gap={5} verticalAlign="baseline">
<Input
data-tid="FilterInput"
leftIcon={<SearchLoupeIcon16Regular />}
value={searchText}
width={300}
onValueChange={setSearchText}
/>
{showSelectAllButton && (
<Checkbox
data-tid="TypesSelectAll"
onValueChange={() => handleSelectAll(fieldDefinitionsFiltered)}
checked={allFieldsSelected}>
Все найденные
</Checkbox>
)}
</RowStack>
<RowStack data-tid="ColumnCheckboxes" className={jsStyles.fieldList()} block gap={4}>
{fieldDefinitionsFiltered.length === 0 ? <Fit>{nothingToDisplay}</Fit> : null}

Expand Down
13 changes: 13 additions & 0 deletions db-viewer-ui/stories/Commons/FieldSelector.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ export const Default = (): React.ReactElement => (
/>
);

export const WithSelectAll = (): React.ReactElement => (
<FieldSelector
hiddenFields={[]}
fieldDefinitions={[
{ name: "name1", caption: "Name 1" },
{ name: "name2", caption: "Name 2" },
]}
onShowField={action("onShowField")}
onHideField={action("onHideField")}
showSelectAllButton
/>
);

export const LongStrings = (): React.ReactElement => (
<FieldSelector
hiddenFields={[]}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8",
"version": "1.8-prerelease.4",
"assemblyVersion": {
"precision": "build"
},
Expand Down

0 comments on commit a49b9ca

Please sign in to comment.