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

Dodanie modala potwierdzenia dla wszystkich resouców + podbicie wersj… #1017

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion frontend-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@babel/plugin-proposal-throw-expressions": "^7.12.13",
"@types/lodash.isequal": "4.5.5",
"@types/react-router": "5.1.14",
"antd": "4.2.4",
"antd": "4.9.0",
"classnames": "2.3.1",
"dva": "2.6.0-beta.22",
"jest": "26.6.3",
Expand Down
2 changes: 1 addition & 1 deletion frontend-project/src/components/FetchLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
import { Link } from 'umi';
import { formatMessage } from 'umi-plugin-react/locale';
import { localeKeys } from '../locales/pl-PL';
import { openNotificationWithIcon } from '../models/global';
import { openNotificationWithIcon } from '../utils/utils';
import { AutocompleteFunctionType, AutocompleteServiceType } from '../services/autocomplete';
import { Awaited, KeysWithValsOfType } from '../services/common';
import { ResourceWithId } from '../services/service';
Expand Down
2 changes: 1 addition & 1 deletion frontend-project/src/components/FetchSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { useEffect, useState } from 'react';
import { formatMessage } from 'umi-plugin-react/locale';
import { unionBy, sortBy } from 'lodash';
import { useDebounce } from '../hooks/useDebounce';
import { openNotificationWithIcon } from '../models/global';
import { openNotificationWithIcon } from '../utils/utils';
import { AutocompleteFunctionType, AutocompleteServiceType } from '../services/autocomplete';
import { Awaited, KeysWithValsOfType, OptionType } from '../services/common';
import { QQ } from '../utils/QQ';
Expand Down
106 changes: 0 additions & 106 deletions frontend-project/src/components/Modals/Confirmation/index.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions frontend-project/src/components/SelectLang/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { GlobalOutlined } from '@ant-design/icons';
import { Menu } from 'antd';
import { getLocale, setLocale } from 'umi-plugin-react/locale';
import { ClickParam } from 'antd/es/menu';
import React, { FC } from 'react';
import classNames from 'classnames';
import HeaderDropdown from '../HeaderDropdown';
Expand All @@ -15,7 +14,8 @@ const SelectLang: FC<SelectLangProps> = props => {
const { className } = props;
const selectedLang = getLocale();

const changeLang = ({ key }: ClickParam): void => setLocale(key);
const changeLang = ({ key }: { key: React.Key }): void =>
typeof key === 'string' && setLocale(key);

const locales = ['pl-PL', 'en-US'];
const languageLabels = {
Expand Down
1 change: 1 addition & 0 deletions frontend-project/src/locales/en-US/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const globalsLocale = {
saveAndEdit: 'Save and edit',
},
modal: {
title: 'Removal of {name} element',
confirm: 'Confirm',
cancel: 'Cancel',
description: 'Are you sure you want to proceed?',
Expand Down
1 change: 1 addition & 0 deletions frontend-project/src/locales/pl-PL/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const globalsLocale = {
saveAndEdit: 'Zapisz i edytuj',
},
modal: {
title: 'Usunięcie elementu {name}',
confirm: 'Potwierdź',
cancel: 'Anuluj',
description: 'Czy chcesz kontynuować?',
Expand Down
7 changes: 0 additions & 7 deletions frontend-project/src/models/global.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { notification } from 'antd';
import { IconType } from 'antd/lib/notification';

export interface GlobalModelState {
collapsed: boolean;
}

export const openNotificationWithIcon = (message: IconType, title: string, description: string) => {
notification[message]({ message: title, description });
};

const GlobalModel = {
namespace: 'global',
state: {
Expand Down
21 changes: 12 additions & 9 deletions frontend-project/src/pages/cases/CasesListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AutocompleteService } from '@/services/autocomplete';
import LettersListView from '../letters/LettersListView';
import EventsListView from '../events/EventsListView';
import NotesListView from '../notes/NotesListView';
import { openRemoveConfirmationModal } from '../../utils/utils';

const { TabPane } = Tabs;

Expand All @@ -38,14 +39,16 @@ export default function CaseListsListView() {
const tableActionRef = useRef<ActionType>();
const { fields, list } = localeKeys.cases;

function onEdit(id: number) {
router.push(`/cases/edit/${id}`);
function onEdit(_case: Case) {
router.push(`/cases/edit/${_case.id}`);
}

function onRemove(id: number) {
CasesService.remove(id)
.then(() => tableActionRef.current?.reload())
.catch(() => tableActionRef.current?.reload());
function onRemove(_case: Case) {
openRemoveConfirmationModal(_case.name, () =>
CasesService.remove(_case.id)
.then(() => tableActionRef.current?.reload())
.catch(() => tableActionRef.current?.reload()),
);
}

const columns: ProColumns<Case>[] = [
Expand Down Expand Up @@ -105,14 +108,14 @@ export default function CaseListsListView() {
{
title: formatMessage({ id: localeKeys.lists.actions }),
dataIndex: 'id',
render: (id: number) => (
render: (_, record: Case) => (
<Space>
<Tooltip title={formatMessage({ id: localeKeys.lists.edit })}>
<Button
type="default"
shape="circle"
icon={<EditOutlined />}
onClick={() => onEdit(id)}
onClick={() => onEdit(record)}
/>
</Tooltip>
<Tooltip title={formatMessage({ id: localeKeys.lists.delete })}>
Expand All @@ -121,7 +124,7 @@ export default function CaseListsListView() {
danger
shape="circle"
icon={<DeleteOutlined />}
onClick={() => onRemove(id)}
onClick={() => onRemove(record)}
/>
</Tooltip>
</Space>
Expand Down
21 changes: 12 additions & 9 deletions frontend-project/src/pages/channels/ChannelsListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import router from 'umi/router';
import { Link } from 'umi';
import { localeKeys } from '@/locales/pl-PL';
import { ChannelsService } from '@/services/channels';
import { openRemoveConfirmationModal } from '@/utils/utils';

export interface IconProps {
arg: boolean;
Expand All @@ -30,14 +31,16 @@ export default function ChannelsListView() {
const tableActionRef = useRef<ActionType>();
const { fields, list } = localeKeys.channels;

function onEdit(id: number) {
router.push(`/channels/edit/${id}`);
function onEdit(channel: Channel) {
router.push(`/channels/edit/${channel.id}`);
}

function onRemove(id: number) {
ChannelsService.remove(id)
.then(() => tableActionRef.current?.reload())
.catch(() => tableActionRef.current?.reload());
function onRemove(channel: Channel) {
openRemoveConfirmationModal(channel.name, () =>
ChannelsService.remove(channel.id)
.then(() => tableActionRef.current?.reload())
.catch(() => tableActionRef.current?.reload()),
);
}

const columns: ProColumns<Channel>[] = [
Expand Down Expand Up @@ -89,14 +92,14 @@ export default function ChannelsListView() {
{
title: formatMessage({ id: localeKeys.lists.actions }),
dataIndex: 'id',
render: (id: number) => (
render: (_, record: Channel) => (
<Space>
<Tooltip title={formatMessage({ id: localeKeys.lists.edit })}>
<Button
type="default"
shape="circle"
icon={<EditOutlined />}
onClick={() => onEdit(id)}
onClick={() => onEdit(record)}
/>
</Tooltip>
<Tooltip title={formatMessage({ id: localeKeys.lists.delete })}>
Expand All @@ -105,7 +108,7 @@ export default function ChannelsListView() {
danger
shape="circle"
icon={<DeleteOutlined />}
onClick={() => onRemove(id)}
onClick={() => onRemove(record)}
/>
</Tooltip>
</Space>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
import { Link } from 'umi';
import { localeKeys } from '@/locales/pl-PL';
import { DocumentTypesService } from '@/services/documentTypes';
import { openRemoveConfirmationModal } from '@/utils/utils';

export default function DocumentTypesListView() {
const tableActionRef = useRef<ActionType>();
const { fields, list } = localeKeys.documentTypes;

function onEdit(id: number) {
router.push(`/documentTypes/edit/${id}`);
function onEdit(documentType: DocumentType) {
router.push(`/documentTypes/edit/${documentType.id}`);
}

function onRemove(id: number) {
DocumentTypesService.remove(id)
.then(() => tableActionRef.current?.reload())
.catch(() => tableActionRef.current?.reload());
function onRemove(documentType: DocumentType) {
openRemoveConfirmationModal(documentType.name, () =>
DocumentTypesService.remove(documentType.id)
.then(() => tableActionRef.current?.reload())
.catch(() => tableActionRef.current?.reload()),
);
}

const columns: ProColumns<DocumentType>[] = [
Expand All @@ -35,14 +38,14 @@ export default function DocumentTypesListView() {
{
title: formatMessage({ id: localeKeys.lists.actions }),
dataIndex: 'id',
render: (id: number) => (
render: (_, record: DocumentType) => (
<Space>
<Tooltip title={formatMessage({ id: localeKeys.lists.edit })}>
<Button
type="default"
shape="circle"
icon={<EditOutlined />}
onClick={() => onEdit(id)}
onClick={() => onEdit(record)}
/>
</Tooltip>
<Tooltip title={formatMessage({ id: localeKeys.lists.delete })}>
Expand All @@ -51,7 +54,7 @@ export default function DocumentTypesListView() {
danger
shape="circle"
icon={<DeleteOutlined />}
onClick={() => onRemove(id)}
onClick={() => onRemove(record)}
/>
</Tooltip>
</Space>
Expand Down
Loading