<commit_before>// Filename: views/tasks/tasksTab.js
define([
	'jquery',
	'underscore',
	'backbone',
	'toastr',
	'services/task',
	'views/collection/tasks',
	'i18n!nls/strings',
	'text!templates/tasks/tasksTab.html'
], function($, _, Backbone, toastr, TaskService, TasksView, strings, tasksTemplate) {

	var TasksTabView = Backbone.View.extend({

		template: _.template(tasksTemplate),

		events: {
		  'executeTask': 'onExecuteTask',
			'deleteTask': 'onDeleteTask'
		},

		initialize: function(options) {
			this.userId = options.userId;
			this.hubId = options.hubId;
		},

		remove: function() {
			if (this.tasksView) {
				this.tasksView.remove();
			}
			Backbone.View.prototype.remove.call(this);
		},

		render: function() {
			this.$el.html(this.template({
				strings: strings
			}));

			if (this.tasksView) {
				this.tasksView.remove();
			}

			TaskService.getTasks(this, function(ctx, model) {
				ctx.tasksView = new TasksView({model: model});
				ctx.$el.find('.tasks').html(
					ctx.tasksView.render().el
				);
			}, function(ctx, model) {
				toastr.error(strings.ErrorOccurred);
			});

			return this;
		},

    onExecuteTask: function(event, task) {
      if (confirm(strings.AreYouSureYouWantToManuallyExecute + ' \"' + task.get('name') + '\"?')) {
        TaskService.executeTask(this, task.get('@id'), function() {
          toastr.success(strings.TaskExecuteSuccess);
        }, function() {
          toastr.error(strings.TaskExecuteFailure);
        });
      }
    },

		onDeleteTask: function(event, task) {
			if (confirm(strings.AreYouSureYouWantToDelete + ' \"' + task.get('name') + '\"?')) {
				task.destroy({
					context: this,
					success: function(model, response, options) {
						toastr.success(strings.TaskDeleteSuccess);
						options.context.render();
					},
					error: function(model, response, options) {
						if (response.status === 202) {
							toastr.success(strings.TaskDeleteSuccess);
							options.context.render();
						} else {
							toastr.error(strings.TaskDeleteFailure);
						}
					}
				});
			}
		}

	});

	return TasksTabView;
});
<commit_msg>Manual execution of a task now fires a task execution event.<commit_after>// Filename: views/tasks/tasksTab.js
define([
	'jquery',
	'underscore',
	'backbone',
	'toastr',
	'services/task',
	'views/collection/tasks',
	'i18n!nls/strings',
	'text!templates/tasks/tasksTab.html'
], function($, _, Backbone, toastr, TaskService, TasksView, strings, tasksTemplate) {

	var TasksTabView = Backbone.View.extend({

		template: _.template(tasksTemplate),

		events: {
		  'executeTask': 'onExecuteTask',
			'deleteTask': 'onDeleteTask'
		},

		initialize: function(options) {
			this.userId = options.userId;
			this.hubId = options.hubId;
		},

		remove: function() {
			if (this.tasksView) {
				this.tasksView.remove();
			}
			Backbone.View.prototype.remove.call(this);
		},

		render: function() {
			this.$el.html(this.template({
				strings: strings
			}));

			if (this.tasksView) {
				this.tasksView.remove();
			}

			TaskService.getTasks(this, function(ctx, model) {
				ctx.tasksView = new TasksView({model: model});
				ctx.$el.find('.tasks').html(
					ctx.tasksView.render().el
				);
			}, function(ctx, model) {
				toastr.error(strings.ErrorOccurred);
			});

			return this;
		},

    onExecuteTask: function(event, task) {
      if (confirm(strings.AreYouSureYouWantToManuallyExecute + ' \"' + task.get('name') + '\"?')) {
        TaskService.executeTask(this, task.get('@id'), null, function() {
          toastr.error(strings.TaskExecuteFailure);
        });
      }
    },

		onDeleteTask: function(event, task) {
			if (confirm(strings.AreYouSureYouWantToDelete + ' \"' + task.get('name') + '\"?')) {
				task.destroy({
					context: this,
					success: function(model, response, options) {
						toastr.success(strings.TaskDeleteSuccess);
						options.context.render();
					},
					error: function(model, response, options) {
						if (response.status === 202) {
							toastr.success(strings.TaskDeleteSuccess);
							options.context.render();
						} else {
							toastr.error(strings.TaskDeleteFailure);
						}
					}
				});
			}
		}

	});

	return TasksTabView;
});

{'fraction_non_alphanumeric': 0.16448775849774186, 'fraction_numerical': 0.002376990729736154, 'mean_word_length': 3.1539980256663376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '915640', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1385, 'n_words': 215}