Skip to content
Snippets Groups Projects
Commit 9133c419 authored by Robbie Luijben's avatar Robbie Luijben Committed by Fanna Lautenbach
Browse files

Select group when creating a work spec and propogate group values properly

parent ae3e1ecb
No related branches found
No related tags found
1 merge request!72Select group when creating a work spec and propogate group values properly
......@@ -19,6 +19,26 @@
self.loadWorkflows();
});
self.groups = ko.observableArray(
groups
);
self.selectedGroup = ko.observable(existingGroup);
self.selectedGroup.subscribe((context) => {
const group = self.groups() && self.groups().filter(group => group.id === self.selectedGroup())[0];
if (group) {
self.selectedProcessingSite(group.processing_site);
self.selectedTag(group.selected_workflow_tag);
self.selectedWorkflow(group.selected_workflow);
} else {
// setting the processing site to null will cause the loadWorkflows
// function to trigger, which in turn will clear the previously selected
// filled in workflow and tag
self.selectedProcessingSite(null);
}
});
self.loadWorkflows = function() {
const selectedProcessingSite = self.selectedProcessingSite();
......@@ -33,9 +53,15 @@
const workflows = data.results;
self.workflows(workflows);
self.selectedTag(self.existing_workflow_tag);
self.selectedWorkflow(self.existing_workflow);
const group = self.groups() && self.groups().filter(group => group.id === self.selectedGroup())[0];
if (group) {
self.selectedTag(group.selected_workflow_tag);
self.selectedWorkflow(group.selected_workflow);
} else {
self.selectedTag(self.existing_workflow_tag);
self.selectedWorkflow(self.existing_workflow);
}
}).finally(() => {
self.isLoading(false);
});
......
......@@ -167,6 +167,8 @@
const existingWorkflowTag = '{{ object.selected_workflow_tag|default_if_none:"null" }}';
const processingSites = {{ processing_sites | json }};
const existingProcessingSite = '{{ object.processing_site.name }}';
const groups = null;
const existingGroup = null;
</script>
<script src="{% static 'update_workflow.js' %}"></script>
{% endblock %}
......@@ -30,8 +30,16 @@
<a class="tooltip-dias tooltip-dias-right custom--tooltip"
data-tooltip="{{ form.group.help_text }}">m</a>
</div>
<div class="input-select-wrapper icon--inline icon-after icon-after--angle-down margin-left margin-bottom">
{% render_field form.group class="input input--select custom__input--fixed-width" %}
<div class="input-select-wrapper icon--inline icon-after icon-after--angle-down">
<select class="input input--select custom__input--fixed-width margin-left margin-bottom"
name="group"
data-bind="options:groups,
optionsCaption: '---------',
optionsText: function(item) { return item.name },
optionsValue: 'id',
value: selectedGroup"
test-id="group">
</select>
</div>
</div>
......@@ -245,6 +253,8 @@
const existingWorkflowTag = '{{ object.selected_workflow_tag|default_if_none:"null" }}';
const processingSites = {{ processing_sites | json }};
const existingProcessingSite = '{{ object.processing_site.name }}';
const groups = {{ groups | json }};
const existingGroup = '{{ object.group.id|default_if_none:"null" }}';
</script>
<script src="{% static 'update_workflow.js' %}"></script>
{% endblock %}
......@@ -128,6 +128,11 @@
<div class="table__cell">{{ object.created_by }}</div>
</div>
<div class="table__row table__row--dark table__row--padding">
<div class="table__cell table__cell--title">Group</div>
<div class="table__cell">{{ object.group.name }}</div>
</div>
<div class="table__row table__row--dark table__row--padding">
<div class="table__cell table__cell--title">Submission status</div>
<div class="table__cell">
......
......@@ -110,6 +110,7 @@ class WorkSpecificationCreateUpdateView(LoginRequiredMixin, CanAccessWorkSpecifi
specification = None
context["filters"] = filters_preprocessor.preprocess(specification)
context["processing_sites"] = list(ATDBProcessingSite.objects.values("name", "url"))
context["groups"] = list(Group.objects.values("name", "id", "processing_site", "selected_workflow", "selected_workflow_tag"))
return context
def create_successor(self, specification):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment