diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 17:01:04 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 17:01:04 +0200 |
| commit | c80b4686ec46504cf7050c4698d16646f18dc70d (patch) | |
| tree | 58ea11abc45987f02ed7a5844d938328be915bbd /public/bundle.js | |
| parent | c6148423fa2ebec86fa8c4c4cfc189b77a3949ec (diff) | |
deleting tasks
Diffstat (limited to 'public/bundle.js')
| -rw-r--r-- | public/bundle.js | 171 |
1 files changed, 107 insertions, 64 deletions
diff --git a/public/bundle.js b/public/bundle.js index 7d0a053..e4eba64 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -2708,7 +2708,7 @@ exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)( Object.defineProperty(exports, "__esModule", { - value: true + value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); @@ -2725,6 +2725,12 @@ var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); var util = _interopRequireWildcard(_util); +var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -2734,84 +2740,105 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var TaskList = function (_Component) { - _inherits(TaskList, _Component); + _inherits(TaskList, _Component); - function TaskList(props) { - _classCallCheck(this, TaskList); + function TaskList(props) { + _classCallCheck(this, TaskList); - return _possibleConstructorReturn(this, (TaskList.__proto__ || Object.getPrototypeOf(TaskList)).call(this)); - } + return _possibleConstructorReturn(this, (TaskList.__proto__ || Object.getPrototypeOf(TaskList)).call(this)); + } - _createClass(TaskList, [{ - key: 'render', - value: function render() { - var _props = this.props, - title = _props.title, - tasks = _props.tasks; + _createClass(TaskList, [{ + key: 'render', + value: function render() { + var _this2 = this; - var time = 0; + var _props = this.props, + title = _props.title, + tasks = _props.tasks; - var _util$sort$orderByFn = util.sort.orderByFn('date desc'), - mapFn = _util$sort$orderByFn.mapFn, - sortFn = _util$sort$orderByFn.sortFn; + var time = 0; - var taskList = tasks.map(mapFn).sort(sortFn).map(function (pair) { - var task = pair[1]; - var dataset_type = void 0, - dataset_name = void 0; - if (task.dataset.indexOf('/') !== -1) { - var _task$dataset$split = task.dataset.split('/'); + var _util$sort$orderByFn = util.sort.orderByFn('date desc'), + mapFn = _util$sort$orderByFn.mapFn, + sortFn = _util$sort$orderByFn.sortFn; - var _task$dataset$split2 = _slicedToArray(_task$dataset$split, 2); + var taskList = tasks.map(mapFn).sort(sortFn).map(function (pair) { + var task = pair[1]; + var dataset_type = void 0, + dataset_name = void 0; + if (task.dataset.indexOf('/') !== -1) { + var _task$dataset$split = task.dataset.split('/'); - dataset_type = _task$dataset$split2[0]; - dataset_name = _task$dataset$split2[1]; - } else { - dataset_name = task.dataset; - } - return (0, _preact.h)( - 'div', - { 'class': 'row' }, - (0, _preact.h)( - 'div', - { 'class': 'activity' }, - task.activity, - ' ', - task.module, - ' ', - dataset_type - ), - (0, _preact.h)( - 'div', - { 'class': 'dataset' }, - dataset_name - ), - (0, _preact.h)( - 'div', - { className: "age " + util.carbon_date(task.updated_at) }, - util.get_age(task.updated_at) - ) - ); - }); - return (0, _preact.h)( - 'div', - { 'class': 'taskList rows' }, - taskList - ); - } - }]); + var _task$dataset$split2 = _slicedToArray(_task$dataset$split, 2); + + dataset_type = _task$dataset$split2[0]; + dataset_name = _task$dataset$split2[1]; + } else { + dataset_name = task.dataset; + } + return (0, _preact.h)( + 'div', + { 'class': 'row' }, + (0, _preact.h)( + 'div', + { 'class': 'activity' }, + task.activity, + ' ', + task.module, + ' ', + dataset_type + ), + (0, _preact.h)( + 'div', + { 'class': 'dataset' }, + dataset_name + ), + (0, _preact.h)( + 'div', + { className: "age " + util.carbon_date(task.updated_at) }, + util.get_age(task.updated_at) + ), + (0, _preact.h)( + 'div', + { 'class': 'options' }, + (0, _preact.h)( + 'span', + { 'class': 'destroy', onClick: function onClick() { + return _this2.handleDestroy(task); + } }, + 'x' + ) + ) + ); + }); + return (0, _preact.h)( + 'div', + { 'class': 'taskList rows' }, + taskList + ); + } + }, { + key: 'handleDestroy', + value: function handleDestroy(task) { + var yes = confirm('Are you sure you want to delete this task?'); + if (yes) { + _actions2.default.task.destroy(task); + } + } + }]); - return TaskList; + return TaskList; }(_preact.Component); var mapStateToProps = function mapStateToProps(state) { - return {}; + return {}; }; var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { - return { - // actions: bindActionCreators(liveActions, dispatch) - }; + return { + // actions: bindActionCreators(liveActions, dispatch) + }; }; exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(TaskList); @@ -6943,6 +6970,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var queueInitialState = { @@ -6987,6 +7016,20 @@ var queueReducer = function queueReducer() { return _extends({}, state, { tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data)) }); + case _types2.default.task.destroy: + var _state$tasks = state.tasks, + deletedTask = _state$tasks[action.data.id], + taskLookup = _objectWithoutProperties(_state$tasks, [action.data.id]); + + return _extends({}, state, { + queue: state.queue.filter(function (id) { + return id !== deletedTask.id; + }), + completed: state.completed.filter(function (id) { + return id !== deletedTask.id; + }), + tasks: taskLookup + }); case _types2.default.task.task_finish: return _extends({}, state, { queue: state.queue.filter(function (a) { |
