Commit 04037078 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

delete callback function, trigger events instead which is much better

parent 101be640
......@@ -67,7 +67,7 @@
$.tmpl($this.options.template, {workflows: data}).appendTo($this.$element);
$("[id^=activewf_btn_]").click(function(){
var workflow_id = $(this).attr("id").split("activewf_btn_")[1];
$this.options.callback(workflow_by_id[workflow_id]);
$this.$element.trigger('select', workflow_by_id[workflow_id]);
});
$("#activewf_refresh_btn").click(function(){
$this.reload();
......@@ -125,8 +125,7 @@
'</tr>',
'{{/each}}',
'</table>',
'<p class="text-right"><a class="btn" id="activewf_refresh_btn" href="#"><i class="icon-refresh"></i> Refresh</a></p>'].join('\n'),
callback: function(workflow) {}
'<p class="text-right"><a class="btn" id="activewf_refresh_btn" href="#"><i class="icon-refresh"></i> Refresh</a></p>'].join('\n')
}
$.fn.activewf.Constructor = ActiveWF
......
......@@ -67,7 +67,7 @@
$.tmpl($this.options.template, {workflows: data}).appendTo($this.$element);
$("[id^=availablewf_btn_]").click(function(){
var workflow_class = $(this).attr("id").split("availablewf_btn_")[1];
$this.options.callback(workflow_by_class[workflow_class]);
$this.$element.trigger('select', workflow_by_class[workflow_class]);
});
}
});
......@@ -104,8 +104,7 @@
'<td>${workflow.help}</td>',
'</tr>',
'{{/each}}',
'</dl>'].join('\n'),
callback: function(workflow) {}
'</dl>'].join('\n')
}
$.fn.availablewf.Constructor = AvailableWF
......
......@@ -101,7 +101,7 @@
url: this.options.serverURL + '/run_workflow?' + params + 'callback=?',
dataType: "json",
success: function(running_wf) {
$this.options.callback(running_wf);
$this.$element.trigger('run', running_wf);
}
});
}
......@@ -254,7 +254,6 @@
'</fieldset>',
'</form>'].join('\n'),
workflowClass: null,
callback: function(running_wf) {},
displayRunButton: true,
displayResetButton: true
}
......
......@@ -277,10 +277,10 @@ $(function () {
$('#setAndRunModalBody').wfform({
workflowClass: workflow["class"],
displayRunButton: false,
displayResetButton: false,
callback: function(running_wf) {
location.assign(location.href);
}
displayResetButton: false
});
$('#setAndRunModalBody').on('run', function(event, running_wf) {
location.assign(location.href);
});
$("#reset_workflow").show();
$("#run_workflow").show();
......@@ -980,64 +980,64 @@ function addRunHandler() {
$("#back_to_workflows_list").hide();
$('#availableWorkflows').html("wait");
$('#setAndRunModal').modal();
$('#availableWorkflows').availablewf({
callback: function(workflow) {
$("#myCarousel").carousel('next');
$("#myCarousel").carousel('pause');
$("#reset_workflow").show();
$("#close").hide();
$("#run_workflow").show();
$("#back_to_workflows_list").show();
$("#back_to_workflows_list").click(function(){
$("#reset_workflow").hide();
$("#run_workflow").hide();
$("#close").show();
$("#back_to_workflows_list").hide();
$("#myCarousel").carousel('prev');
});
$('#setAndRunModalLabel').html(workflow["name"] + " <small>" + workflow["help"] + "</small>");
$('#selectedWfForm').wfform({
workflowClass: workflow["class"],
displayRunButton: false,
displayResetButton: false,
callback: function(running_wf) {
$("#reset_workflow").hide();
$("#run_workflow").hide();
$("#back_to_workflows_list").hide();
$("#refresh_workflow_status").show();
$("#myCarousel").carousel('next');
$("#myCarousel").carousel('pause');
$('#setAndRunModalLabel').html(running_wf["name"] + " <small>" + running_wf["id"] + "</small>");
$('#monitoringWorkflow').wfstatus({
workflowID: running_wf.id,
forceUsingWorkflow: running_wf
});
$.ajax({
url: 'index.php?eID=tx_nG6&type=runs_table&project_id='+$("#current_project_id").val()+'&user_id='+$("#user_id").val()+'&login_user='+$("#login_user").val()+'&page_id='+$("#ids").val(),
dataType: "html",
error: function (xhr, ajaxOptions, thrownError) {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to reload the runs table.</div>';
$("#runs").html(html);
},
success: function(data) {
if (data) {
$("#runs").html(data);
var runTable = initRunTable();
$('#delete_run').on('click', deletePRAHandler);
$("#hide_run").on('click', hideHandler);
$("#unhide_run").on('click', unhideHandler);
$("#add_run").on('click', addRunHandler);
initEditableFields();
} else {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to reload the runs table.</div>';
$("#runs").html(html);
}
}
});
}
});
}
$('#availableWorkflows').availablewf();
$('#availableWorkflows').on('select', function(event, workflow) {
$("#myCarousel").carousel('next');
$("#myCarousel").carousel('pause');
$("#reset_workflow").show();
$("#close").hide();
$("#run_workflow").show();
$("#back_to_workflows_list").show();
$("#back_to_workflows_list").click(function(){
$("#reset_workflow").hide();
$("#run_workflow").hide();
$("#close").show();
$("#back_to_workflows_list").hide();
$("#myCarousel").carousel('prev');
});
$('#setAndRunModalLabel').html(workflow["name"] + " <small>" + workflow["help"] + "</small>");
$('#selectedWfForm').wfform({
workflowClass: workflow["class"],
displayRunButton: false,
displayResetButton: false
});
});
$('#selectedWfForm').on('run', function(event, running_wf) {
$("#reset_workflow").hide();
$("#run_workflow").hide();
$("#back_to_workflows_list").hide();
$("#refresh_workflow_status").show();
$("#myCarousel").carousel('next');
$("#myCarousel").carousel('pause');
$('#setAndRunModalLabel').html(running_wf["name"] + " <small>" + running_wf["id"] + "</small>");
$('#monitoringWorkflow').wfstatus({
workflowID: running_wf.id,
forceUsingWorkflow: running_wf
});
$.ajax({
url: 'index.php?eID=tx_nG6&type=runs_table&project_id='+$("#current_project_id").val()+'&user_id='+$("#user_id").val()+'&login_user='+$("#login_user").val()+'&page_id='+$("#ids").val(),
dataType: "html",
error: function (xhr, ajaxOptions, thrownError) {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to reload the runs table.</div>';
$("#runs").html(html);
},
success: function(data) {
if (data) {
$("#runs").html(data);
var runTable = initRunTable();
$('#delete_run').on('click', deletePRAHandler);
$("#hide_run").on('click', hideHandler);
$("#unhide_run").on('click', unhideHandler);
$("#add_run").on('click', addRunHandler);
initEditableFields();
} else {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to reload the runs table.</div>';
$("#runs").html(html);
}
}
});
});
$("#reset_workflow").click(function(){ $('#selectedWfForm').wfform('reset'); });
$("#run_workflow").click(function(){ $('#selectedWfForm').wfform('run'); });
$("#refresh_workflow_status").click(function(){ $('#monitoringWorkflow').wfstatus('reload'); });
......
Supports Markdown
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