Skip to content

Commit 547aee8

Browse files
committed
Change purpose options when purpose changes. See ietf-tools#342
- Legacy-Id: 2362
1 parent 9f8b0af commit 547aee8

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

ietf/liaisons/forms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django import forms
2+
from django.conf import settings
23
from django.template.loader import render_to_string
34

45
from ietf.liaisons.accounts import (can_add_outgoing_liaison, can_add_incoming_liaison,
@@ -15,6 +16,8 @@ class LiaisonForm(forms.ModelForm):
1516
organization = forms.ChoiceField()
1617
to_poc = forms.CharField(widget=ReadOnlyWidget, label="POC")
1718
cc1 = forms.CharField(widget=ReadOnlyWidget, label="CC")
19+
purpose_text = forms.CharField(widget=forms.Textarea, label='Other purpose')
20+
deadline_date = forms.DateField(label='Deadline')
1821

1922
fieldsets = (('From', ('from_field', 'replyto')),
2023
('To', ('organization', 'to_poc')),

static/css/liaisons.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@
4141
.baseform #baseform-fieldname-deadline_date {
4242
display: none;
4343
}
44+
45+
.baseform select,
46+
.baseform textarea,
47+
.baseform input {
48+
border: 1px solid lightgray;
49+
}

static/js/liaisons.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
var cc = form.find('#id_cc1');
99
var reply = form.find('#id_replyto');
1010
var purpose = form.find('#id_purpose');
11+
var other_purpose = form.find('#id_purpose_text');
12+
var deadline = form.find('#id_deadline_date');
1113
var config = {};
1214

1315
var readConfig = function() {
@@ -70,17 +72,39 @@
7072
form.find('a.from_mailto').attr('href', 'mailto:' + reply_to);
7173
};
7274

75+
var updatePurpose = function() {
76+
var datecontainer = deadline.parents('.field');
77+
var othercontainer = other_purpose.parents('.field');
78+
var selected_id = purpose.find('option:selected').val();
79+
80+
if (selected_id == '1' || selected_id == '2' || selected_id == '5') {
81+
datecontainer.show();
82+
} else {
83+
datecontainer.hide();
84+
deadline.val('');
85+
}
86+
87+
if (selected_id == '5') {
88+
othercontainer.show();
89+
} else {
90+
othercontainer.hide();
91+
other_purpose.html('');
92+
}
93+
};
94+
7395
var initTriggers = function() {
7496
organization.change(updatePOC);
7597
organization.change(updateCC);
7698
from.change(updateCC);
7799
reply.keyup(updateFrom);
100+
purpose.change(updatePurpose);
78101
};
79102

80103
var updateOnInit = function() {
81104
updateFrom();
82105
updateCC();
83106
updatePOC();
107+
updatePurpose();
84108
};
85109

86110
var initForm = function() {

0 commit comments

Comments
 (0)