Merge pull request #2055 from SchrodingersGat/test-template-table-fix

Fix callback for test template table
This commit is contained in:
Oliver 2021-09-14 10:58:57 +10:00 committed by GitHub
commit d73a7176fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 37 deletions

View File

@ -667,6 +667,8 @@
});
onPanelLoad("test-templates", function() {
// Load test template table
loadPartTestTemplateTable(
$("#test-template-table"),
{
@ -677,11 +679,8 @@
}
);
// Callback for "add test template" button
$("#add-test-template").click(function() {
function reloadTestTemplateTable() {
$("#test-template-table").bootstrapTable("refresh");
}
constructForm('{% url "api-part-test-template-list" %}', {
method: 'POST',
@ -697,39 +696,10 @@
}
},
title: '{% trans "Add Test Result Template" %}',
onSuccess: reloadTestTemplateTable
onSuccess: function() {
$("#test-template-table").bootstrapTable("refresh");
}
});
$("#test-template-table").on('click', '.button-test-edit', function() {
var pk = $(this).attr('pk');
var url = `/api/part/test-template/${pk}/`;
constructForm(url, {
fields: {
test_name: {},
description: {},
required: {},
requires_value: {},
requires_attachment: {},
},
title: '{% trans "Edit Test Result Template" %}',
onSuccess: reloadTestTemplateTable,
});
});
$("#test-template-table").on('click', '.button-test-delete', function() {
var pk = $(this).attr('pk');
var url = `/api/part/test-template/${pk}/`;
constructForm(url, {
method: 'DELETE',
title: '{% trans "Delete Test Result Template" %}',
onSuccess: reloadTestTemplateTable,
});
});
});
});

View File

@ -1252,7 +1252,43 @@ function loadPartTestTemplateTable(table, options) {
}
}
}
]
],
onPostBody: function() {
table.find('.button-test-edit').click(function() {
var pk = $(this).attr('pk');
var url = `/api/part/test-template/${pk}/`;
constructForm(url, {
fields: {
test_name: {},
description: {},
required: {},
requires_value: {},
requires_attachment: {},
},
title: '{% trans "Edit Test Result Template" %}',
onSuccess: function() {
table.bootstrapTable('refresh');
},
});
});
table.find('.button-test-delete').click(function() {
var pk = $(this).attr('pk');
var url = `/api/part/test-template/${pk}/`;
constructForm(url, {
method: 'DELETE',
title: '{% trans "Delete Test Result Template" %}',
onSuccess: function() {
table.bootstrapTable('refresh');
},
});
});
}
});
}