Commit 26a6f3be authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

Confirm delete actions

removed checking from ItemsEditor
parent a696ddc4
......@@ -90,6 +90,7 @@
"dateNotProvided": "Date not provided",
"description": "Description",
"either": "Either",
"deleteDescription": "Deleting this will remove all related data.",
"errorHappen": "Error happened while processing request",
"false": "False",
"filters": "Filters",
......
......@@ -856,6 +856,7 @@
"fetch": "Fetch translations",
"fetchStarted": "Fetch started",
"fetchResult": "Result for {{lang, uppercase}}: {{result}}",
"translations": "translations from transifex",
"delete": "Remove from transifex",
"deleteStarted": "Started deleting from transifex",
"deleteSucceeded": "Article deleted from transifex successfully",
......@@ -1054,6 +1055,7 @@
"instAddress": "Institutional address",
"instAddressPlaceholder": "Address of institution of affiliation when the dataset was created.",
"add": "Add dataset creator",
"delete": "Delete dataset creator",
"autocomplete": "Creator name"
},
"location": {
......@@ -1805,6 +1807,7 @@
"subTitle": "As you explore the millions of accessions held in Genesys, you can create your own list to keep track of the results of your search. Your selections are stored here so you can return to them at any time.",
"sendRequest": "Send request",
"clearMyList": "Clear list",
"clearConfirm": "Doo you really want to delete all accessions from your local list?",
"noAccessions": "You have not added any accessions to the list.",
"zip": "ZIP",
"MCPD": "MCPD"
......@@ -1999,6 +2002,10 @@
"originalFilename": "Original filename"
}
}
},
"common": {
"file": "file",
"folder": "folder"
}
},
"requests": {
......
......@@ -39,6 +39,7 @@
"fetch": "Fetch translations",
"fetchStarted": "Fetch started",
"fetchResult": "Result for {{lang, uppercase}}: {{result}}",
"translations": "translations from transifex",
"delete": "Remove from transifex",
"deleteStarted": "Started deleting from transifex",
"deleteSucceeded": "Article deleted from transifex successfully",
......
......@@ -22,6 +22,7 @@ import ActivityPostForm from 'cms/ui/admin/c/ActivityPostForm';
import ArticleSection from 'cms/ui/c/ArticleSection';
import Footer from 'ui/layout/Footer';
import PageTitle from 'ui/common/PageTitle';
import confirm from 'utilities/confirmAlert';
const styles = () => ({
activityPost: {
......@@ -107,7 +108,7 @@ class ActivityPostEditPage extends React.Component<IArticleEditPageProps, any> {
return (
<div>
<PageTitle title={ activityPost.title ? activityPost.title.split(/<\w>|<\/\w>/).join('') : t('cms.admin.p.edit.activityPostPageTitle') }/>
<PageTitle title={ activityPost.title ? ActivityPost.htmlTitleToText(activityPost, {replacer: ' ', lowerCase: false}) : t('cms.admin.p.edit.activityPostPageTitle') }/>
<ContentHeaderWithButton
title={ <span dangerouslySetInnerHTML={ { __html: activityPost.title } }/> }
classes={ { subHeader: classes.customSubHeader } }
......@@ -155,8 +156,16 @@ class ActivityPostEditPage extends React.Component<IArticleEditPageProps, any> {
}
private onDelete = () => {
const { deleteActivityPost, id } = this.props;
deleteActivityPost(id);
const { deleteActivityPost, activityPost, id, t } = this.props;
confirm(<span>{ `${t('common:action.delete')} "${ActivityPost.htmlTitleToText(activityPost, {replacer: ' ', lowerCase: false})}" ?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteActivityPost(id);
}).catch(() => {
// don't delete
});
}
}
......
......@@ -26,6 +26,7 @@ import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import ActionButton from 'ui/common/buttons/ActionButton';
import ArticleSection from 'cms/ui/c/ArticleSection';
import ButtonBar from 'ui/common/buttons/ButtonBar';
import confirm from 'utilities/confirmAlert';
const styles = () => ({
article: {
......@@ -185,8 +186,16 @@ class ArticleEditPage extends React.Component<IArticleEditPageProps, any> {
}
private deleteFromTransifex = () => {
const { article, deleteFromTransifexRequest } = this.props;
deleteFromTransifexRequest(article.classPk.shortName, article.slug);
const { article, deleteFromTransifexRequest, t } = this.props;
confirm(<span>{ `${t('common:action.delete')} ${'cms.admin.p.edit.transifex.translations'}?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteFromTransifexRequest(article.classPk.shortName, article.slug);
}).catch(() => {
// don't delete
});
}
}
......
......@@ -160,7 +160,7 @@ function datasetsDashboard(state = INITIAL_STATE, action: { type?: string, paylo
log('Payload ADD_LOCATION', apiCall);
if (state.dataset && apiCall.data) { // && action.payload.datasetUUID === state.dataset.uuid) {
return update(state, {
dataset: { data: { locations: { $push: [apiCall] } } },
dataset: { data: { locations: { $push: [apiCall.data] } } },
});
} else {
return state;
......
......@@ -87,6 +87,7 @@
"instAddress": "Institutional address",
"instAddressPlaceholder": "Address of institution of affiliation when the dataset was created.",
"add": "Add dataset creator",
"delete": "Delete dataset creator",
"autocomplete": "Creator name"
},
"location": {
......
......@@ -16,6 +16,7 @@ import CSVConfiguration, { CSVConfig } from 'ui/common/csv-configuration/CSVConf
import ActionButton from 'ui/common/buttons/ActionButton';
import ButtonBar from 'ui/common/buttons/ButtonBar';
import Loading from 'ui/common/Loading';
import confirm from 'utilities/confirmAlert';
interface IListOfAccession extends React.ClassAttributes<any> {
classes: any;
......@@ -65,8 +66,16 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
rematchDatasetAccessions(dataset);
}
private clearList = () => {
const {dataset, clearAccessionRefList} = this.props;
clearAccessionRefList(dataset);
const {dataset, clearAccessionRefList, t} = this.props;
confirm(<span>{ `${t('datasets.dashboard.p.stepper.listOfAccessions.clearList')}?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
clearAccessionRefList(dataset);
}).catch(() => {
// don't delete
});
}
public constructor(props: any) {
......
......@@ -17,6 +17,7 @@ import Dataset from 'model/catalog/Dataset';
import DatasetCreator, { CreatorRole } from 'model/catalog/DatasetCreator';
import RadioSelection from 'ui/common/forms/RadioSelection';
import DatasetCreatorAutocompleteField from './DatasetCreatorAutocompleteField';
import confirm from 'utilities/confirmAlert';
interface IDatasetCreatorFormProps extends React.ClassAttributes<any> {
t: any;
......@@ -50,7 +51,16 @@ class DatasetCreatorForm extends React.Component<IDatasetCreatorFormProps, any>
}
public deleteCreator = (fields, index) => () => {
this.props.deleteCreatorRequest(fields.get(index));
const {deleteCreatorRequest, t} = this.props;
confirm(<span>{ `${t('datasets.dashboard.p.stepper.creators.delete')}?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteCreatorRequest(fields.get(index));
}).catch(() => {
// don't delete
});
}
public updateCreatorData = (fields, index) => (newCreator) => {
......
......@@ -20,6 +20,7 @@ import Validators from 'utilities/Validators';
import IconButton from '@material-ui/core/IconButton';
import DeleteIcon from '@material-ui/icons/Delete';
import CountryCodePicker from './CountryCodePicker';
import confirm from 'utilities/confirmAlert';
interface ILocationFormProps extends React.ClassAttributes<any> {
......@@ -60,7 +61,16 @@ class LocationForm extends React.Component<ILocationFormProps, any> {
}
protected deleteLocation = (fields, index) => () => {
this.props.deleteLocation(fields.get(index));
const {deleteLocation, t} = this.props;
confirm(<span>{ `${t('common:action.delete')} ${t('geo.common.location')} ?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteLocation(fields.get(index));
}).catch(() => {
// don't delete
});
}
protected createLocation = () => {
......
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import { log } from 'utilities/debug';
import { parse } from 'query-string';
import {log} from 'utilities/debug';
import {parse} from 'query-string';
import { listAccessibleDescriptors, moreAccessibleDescriptors, clearDescriptors } from 'descriptors/actions/dashboard';
import { addDescriptorsToDataset, removeDescriptorsFromDataset } from 'datasets/actions/editor';
import {clearDescriptors, listAccessibleDescriptors, moreAccessibleDescriptors} from 'descriptors/actions/dashboard';
import {addDescriptorsToDataset, removeDescriptorsFromDataset} from 'datasets/actions/editor';
import Descriptor from 'model/catalog/Descriptor';
import DescriptorPicker from 'descriptors/ui/c/DescriptorPicker';
import { loadCrops } from 'crop/actions/public';
import {loadCrops} from 'crop/actions/public';
import StepperTemplate from 'ui/common/stepper/StepperTemplate';
import confirm from 'utilities/confirmAlert';
class Traits extends StepperTemplate<any> {
......@@ -48,7 +49,7 @@ class Traits extends StepperTemplate<any> {
}
}
protected removeAllDescriptors = () => {
const { item: dataset, removeDescriptorsFromDataset } = this.props;
const { item: dataset, removeDescriptorsFromDataset, t } = this.props;
const uuids = [];
if (dataset && dataset.descriptors && dataset.descriptors.length > 0) {
......@@ -57,8 +58,15 @@ class Traits extends StepperTemplate<any> {
});
}
if (uuids.length) {
log(`Removing ${uuids.length} descriptor${uuids.length !== 1 ? 's' : '' }`);
removeDescriptorsFromDataset(dataset, uuids);
confirm(<span>{ `${t('common:action.delete')} ${uuids.length} ${t('descriptors.common.modelName', {count: uuids.length})}` }</span>, {
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
log(`Removing ${uuids.length} descriptor${uuids.length !== 1 ? 's' : ''}`);
removeDescriptorsFromDataset(dataset, uuids);
}).catch(() => {
// don't delete
});
}
}
protected renderContent = () => this.props.item ? (
......
import * as React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { log } from 'utilities/debug';
import DescriptorList from 'model/catalog/DescriptorList';
......@@ -20,6 +21,7 @@ import {
} from 'descriptorlists/actions/editor';
import { parse } from 'query-string';
import StepperTemplate from 'ui/common/stepper/StepperTemplate';
import confirm from 'utilities/confirmAlert';
interface IDescriptorListProps extends React.ClassAttributes<any> {
history: any;
......@@ -95,7 +97,7 @@ class SelectDescriptorsStep extends StepperTemplate<IDescriptorListProps> {
}
protected removeAllDescriptors = () => {
const { item: descriptorList, removeDescriptorsFromDescriptorList } = this.props;
const { item: descriptorList, removeDescriptorsFromDescriptorList, t } = this.props;
const uuids = [];
if (descriptorList && descriptorList.descriptors && descriptorList.descriptors.length > 0) {
......@@ -104,8 +106,16 @@ class SelectDescriptorsStep extends StepperTemplate<IDescriptorListProps> {
});
}
if (uuids.length) {
log(`Removing ${uuids.length} descriptor${uuids.length !== 1 ? 's' : '' }`);
removeDescriptorsFromDescriptorList(descriptorList, uuids);
confirm(<span>{ `${t('common:action.delete')} ${uuids.length} ${t('descriptors.common.modelName', {count: uuids.length})}` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
log(`Removing ${uuids.length} descriptor${uuids.length !== 1 ? 's' : ''}`);
removeDescriptorsFromDescriptorList(descriptorList, uuids);
}).catch(() => {
// don't delete
});
}
}
protected removeDescriptor = (descriptor: Descriptor) => {
......@@ -140,6 +150,6 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
clearDescriptors,
}, dispatch);
export default connect(
export default translate()(connect(
mapStateToProps, mapDispatchToProps,
)(SelectDescriptorsStep);
)(SelectDescriptorsStep));
......@@ -19,6 +19,7 @@ import Dialog from '@material-ui/core/Dialog';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import DimensionForm from './c/dimensionForm';
import confirm from 'utilities/confirmAlert';
interface IDimensionDialogProps extends React.ClassAttributes<any> {
loadDimension: (name: string) => void;
......@@ -44,9 +45,18 @@ class DimensionDialog extends React.Component<IDimensionDialogProps, any> {
}
private handleDelete = () => {
const {deleteDimension, dimension} = this.props;
deleteDimension(dimension);
this.hide();
const {deleteDimension, dimension, t} = this.props;
confirm(<span>{ `${t('common:action.delete')} ${dimension.title} ?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteDimension(dimension);
this.hide();
}).catch(() => {
this.hide();
});
}
public render() {
......
......@@ -12,6 +12,7 @@ import KPIParameter from 'model/kpi/KPIParameter';
import Dialog from '@material-ui/core/Dialog';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import confirm from 'utilities/confirmAlert';
import ParameterForm from './c/parameterForm';
interface IParameterDialogProps extends React.ClassAttributes<any> {
......@@ -43,12 +44,22 @@ class ParameterDialog extends React.Component<IParameterDialogProps, any> {
}
private handleDelete = () => {
const {deleteParameter, parameter} = this.props;
deleteParameter(parameter).then(() => {
clearParameterDetails();
const {deleteParameter, parameter, t} = this.props;
confirm(<span>{ `${t('common:action.delete')} ${parameter.title}?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteParameter(parameter).then(() => {
clearParameterDetails();
this.hide();
}).catch((error) => {
console.log(error);
});
this.hide();
}).catch((error) => {
console.log(error);
}).catch(() => {
this.hide();
});
}
......
......@@ -6,6 +6,7 @@
"subTitle": "As you explore the millions of accessions held in Genesys, you can create your own list to keep track of the results of your search. Your selections are stored here so you can return to them at any time.",
"sendRequest": "Send request",
"clearMyList": "Clear list",
"clearConfirm": "Doo you really want to delete all accessions from your local list?",
"noAccessions": "You have not added any accessions to the list.",
"zip": "ZIP",
"MCPD": "MCPD"
......@@ -26,4 +27,4 @@
"common": {
"menu": "My List"
}
}
\ No newline at end of file
}
......@@ -13,6 +13,7 @@ import navigateTo from 'actions/navigation';
import {clearMyList} from 'list/actions/public';
import PageTitle from 'ui/common/PageTitle';
import AddAccessionsDialog from './c/AddAccessionsDialog';
import confirm from 'utilities/confirmAlert';
interface IMyListPageProps extends React.ClassAttributes<any> {
myList: any[];
......@@ -58,8 +59,16 @@ class MyListPage extends React.Component<IMyListPageProps> {
}
private clearListAction = () => {
const {clearMyList} = this.props;
clearMyList();
const {clearMyList, t} = this.props;
confirm(<span>{ `${t('list.public.p.browse.clearConfirm')}` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
clearMyList();
}).catch(() => {
// don't delete
});
}
public render() {
......
......@@ -57,8 +57,8 @@ class PartnerPage extends React.Component<IPartnerPageProps, any> {
private onDelete = (e) => {
const { t, partner, deletePartner } = this.props;
confirm(<span>Delete <b>{ partner.name }</b>?</span>, {
description: t('common:message.confirmDelete', { what: t('partners.common.modelName') }),
confirm(<span>{ `${t('common:action.delete')}` }<b>{ partner.name }</b>?</span>, {
description: t('common:label.deleteDescription', { what: t('partners.common.modelName') }),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
......
......@@ -79,5 +79,9 @@
"originalFilename": "Original filename"
}
}
},
"common": {
"file": "file",
"folder": "folder"
}
}
......@@ -18,7 +18,7 @@ import PageTitle from 'ui/common/PageTitle';
import Button from '@material-ui/core/Button';
import { navigateTo } from 'actions/navigation';
import confirmAlert from 'utilities/confirmAlert';
import confirm from 'utilities/confirmAlert';
import ImageGalleryView from 'repository/ui/c/ImageGalleryView';
import FolderCrumbs from 'repository/ui/c/FolderCrumbs';
......@@ -85,13 +85,18 @@ class ImageGalleryPage extends React.Component<IRepositoryBrowserProps, any> {
protected deleteGallery = (e) => {
const { removeGallery, navigateTo, folderPath, t } = this.props;
removeGallery(folderPath).then((result) => {
if (result) {
navigateTo(`/admin/repository/f${folderPath}/`);
} else {
confirmAlert(<p>{ t('repository.admin.p.imageGallery.deleteGalleryAlert', {folderPath}) }</p>);
}
confirm(<span>{ `${t('repository.admin.p.imageGallery.deleteGallery')} ?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
removeGallery(folderPath).then((result) => {
if (result) {
navigateTo(`/admin/repository/f${folderPath}/`);
}
});
}).catch(() => {
// don't delete
});
}
......
......@@ -19,7 +19,7 @@ import FolderCard from './c/FolderCard';
import RepositoryFolder from 'model/repository/RepositoryFolder';
import Button from '@material-ui/core/Button';
import { navigateTo } from 'actions/navigation';
import confirmAlert from 'utilities/confirmAlert';
import confirm from 'utilities/confirmAlert';
import FolderCrumbs from './c/FolderCrumbs';
import Grid from '@material-ui/core/Grid';
......@@ -94,18 +94,32 @@ class RepositoryBrowser extends React.Component<IRepositoryBrowserProps, any> {
protected deleteFolder = (e) => {
const { deleteFolder, navigateTo, folderPath, t } = this.props;
deleteFolder(folderPath).then((result) => {
if (result) {
navigateTo('..');
} else {
confirmAlert(<p>{ t('repository.admin.p.repositoryBrowser.deleteFolderAlert', {folderPath}) }</p>);
}
confirm(<span>{ `${t('common:action.delete')} ${t('repository.common.folder')}?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
deleteFolder(folderPath).then((result) => {
if (result) {
navigateTo('..');
}
});
}).catch(() => {
// don't delete
});
}
protected deleteFile = (uuid: string) => {
this.props.removeFile(uuid);
const {removeFile, t} = this.props;
confirm(<span>{ `${t('common:action.delete')} ${t('repository.common.file')}?` }</span>, {
description: t('common:label.deleteDescription'),
confirmLabel: t('common:action.delete'),
abortLabel: t('common:action.cancel'),
}).then(() => {
removeFile(uuid);
}).catch(() => {
// don't delete
});
}
protected handleEditButton = (uuid: string) => {
......@@ -119,7 +133,7 @@ class RepositoryBrowser extends React.Component<IRepositoryBrowserProps, any> {
if (result) {
navigateTo(`/admin/repository/g${folderPath}/`);
} else {
confirmAlert(<p>{ t('repository.admin.p.repositoryBrowser.createGalleryAlert', {folderPath}) }</p>);
confirm(<p>{ t('repository.admin.p.repositoryBrowser.createGalleryAlert', {folderPath}) }</p>);
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment