Edit part parameter template from settings view

This commit is contained in:
Oliver Walters 2019-09-07 20:28:38 +10:00
parent 55669c79c2
commit 42ade0e0b7
3 changed files with 31 additions and 0 deletions

View File

@ -21,6 +21,8 @@ part_attachment_urls = [
part_parameter_urls = [
url('^template/new/', views.PartParameterTemplateCreate.as_view(), name='part-param-template-create'),
url('^template/(?P<pk>\d+)/edit/', views.PartParameterTemplateEdit.as_view(), name='part-param-template-edit'),
#url('^template/(?P<pk>\d+)/delete/', views.PartParameterTemplateDelete.as_view(), name='part-param-template-edit'),
url('^new/', views.PartParameterCreate.as_view(), name='part-param-create'),
url('^(?P<pk>\d+)/edit/', views.PartParameterEdit.as_view(), name='part-param-edit'),

View File

@ -1446,6 +1446,14 @@ class PartParameterTemplateCreate(AjaxCreateView):
ajax_form_title = 'Create Part Parameter Template'
class PartParameterTemplateEdit(AjaxUpdateView):
""" View for editing a PartParameterTemplate """
model = PartParameterTemplate
form_class = part_forms.EditPartParameterTemplateForm
ajax_form_title = 'Edit Part Parameter Template'
class PartParameterCreate(AjaxCreateView):
""" View for creating a new PartParameter """

View File

@ -43,7 +43,16 @@
title: 'Units',
sortable: 'true',
},
{
formatter: function(value, row, index, field) {
var bEdit = "<button title='Edit Template' class='template-edit btn btn-default btn-glyph' type='button' pk='" + row.pk + "'><span class='glyphicon glyphicon-edit'></span></button>";
var bDel = "<button title='Delete Template' class='template-delete btn btn-default btn-glyph' type='button' pk='" + row.pk + "'><span class='glyphicon glyphicon-trash'></span></button>";
var html = "<div class='btn-group' role='group'>" + bEdit + bDel + "</div>";
return html;
}
}
]
});
@ -55,4 +64,16 @@
});
});
$("#param-table").on('click', '.template-edit', function() {
var button = $(this);
var url = "/part/parameter/template/" + button.attr('pk') + "/edit/";
launchModalForm(url, {
success: function() {
$("#param-table").bootstrapTable('refresh');
}
});
});
{% endblock %}