diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-22 16:35:33 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-22 16:35:33 +0200 |
| commit | 794a52e485e15e4bf86c849e135d49783c91539b (patch) | |
| tree | 1a06f56de34b43fddf0819ed554854c64d5255e3 /app/client/modules | |
| parent | cdcb1403e6ffeda50d0bb0ca5aab4ac68978069f (diff) | |
deletorrr
Diffstat (limited to 'app/client/modules')
| -rw-r--r-- | app/client/modules/pix2pixhd/pix2pixhd.reducer.js | 12 | ||||
| -rw-r--r-- | app/client/modules/pix2pixhd/views/pix2pixhd.results.js | 22 |
2 files changed, 33 insertions, 1 deletions
diff --git a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js index b6264ed..6b2366c 100644 --- a/app/client/modules/pix2pixhd/pix2pixhd.reducer.js +++ b/app/client/modules/pix2pixhd/pix2pixhd.reducer.js @@ -21,6 +21,18 @@ const pix2pixhdReducer = (state = pix2pixhdInitialState, action) => { ...state, results: action.results, } + case types.file.destroy: + console.log('file destroy', state.results) + if (! state.results) { + return state + } + return { + ...state, + results: { + ...state.results, + files: state.results.files.filter(file.id !== action.data.id) + } + } default: return state } diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.results.js b/app/client/modules/pix2pixhd/views/pix2pixhd.results.js index d92a403..741060b 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.results.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.results.js @@ -4,17 +4,24 @@ import { Link } from 'react-router-dom'; import { connect } from 'react-redux' import util from '../../../util' +import actions from '../../../actions' + import * as pix2pixhdActions from '../pix2pixhd.actions' import * as pix2pixhdTasks from '../pix2pixhd.tasks' import Loading from '../../../common/loading.component' import { FileList, FileRow } from '../../../common/fileList.component' +let yes_count = 0 + class Pix2pixHDResults extends Component { constructor(props){ super() if (!props.pix2pixhd.results) props.actions.load_results() } + componentDidMount(){ + yes_count = 0 + } render(){ if (! this.props.pix2pixhd.results) return <Loading progress={this.props.pix2pixhd.progress} /> @@ -32,7 +39,20 @@ class Pix2pixHDResults extends Component { linkFiles files={files} orderBy='date desc' - fields={'name date size'} + fields={'name date size delete'} + onDelete={file => { + let yes; + if (yes_count < 3) { + yes = confirm('Are you sure you want to delete this file?') + } else { + yes = true + } + if (yes) { + yes_count += 1 + console.log('delete: confirmed') + actions.file.destroy(file) + } + }} /> <br /> |
