Changing "Use TLS/Use SSL" radio buttons on the notification template form (for email)

This commit is contained in:
jaredevantabor 2017-01-13 16:56:57 -08:00
parent 839db07d9a
commit 2217594f27
3 changed files with 60 additions and 33 deletions

View File

@ -115,6 +115,17 @@ export default ['$rootScope', 'Rest', 'Wait', 'NotificationsFormObject',
});
};
$scope.emailOptionsChange = function () {
if ($scope.email_options === 'use_ssl') {
$scope.use_ssl = true;
$scope.use_tls = false;
}
else if ($scope.email_options === 'use_tls') {
$scope.use_ssl = false;
$scope.use_tls = true;
}
};
// Save
$scope.formSave = function() {
var params,
@ -156,13 +167,13 @@ export default ['$rootScope', 'Rest', 'Wait', 'NotificationsFormObject',
.filter(i => (form.fields[i].ngShow && form.fields[i].ngShow.indexOf(v) > -1))
.map(i => [i, processValue($scope[i], i, form.fields[i])]));
delete params.notification_configuration.checkbox_group;
delete params.notification_configuration.email_options;
for (var j = 0; j < form.fields.checkbox_group.fields.length; j++) {
if (form.fields.checkbox_group.fields[j].ngShow && form.fields.checkbox_group.fields[j].ngShow.indexOf(v) > -1) {
params.notification_configuration[form.fields.checkbox_group.fields[j].name] = Boolean($scope[form.fields.checkbox_group.fields[j].name]);
for(var j = 0; j < form.fields.email_options.options.length; j++) {
if(form.fields.email_options.options[j].ngShow && form.fields.email_options.options[j].ngShow.indexOf(v) > -1) {
params.notification_configuration[form.fields.email_options.options[j].value] = Boolean($scope[form.fields.email_options.options[j].value]);
}
}
}
Wait('start');
Rest.setUrl(url);

View File

@ -67,15 +67,25 @@ export default ['Rest', 'Wait',
master[fld] = data[fld];
}
if (form.fields[fld].type === 'checkbox_group') {
// Loop across the group and put the child data on scope
for (var j = 0; j < form.fields[fld].fields.length; j++) {
if (data.notification_configuration[form.fields[fld].fields[j].name]) {
$scope[form.fields[fld].fields[j].name] = data.notification_configuration[form.fields[fld].fields[j].name];
master[form.fields[fld].fields[j].name] = data.notification_configuration[form.fields[fld].fields[j].name];
}
if(form.fields[fld].type === 'radio_group') {
if(data.notification_configuration.use_ssl === true){
$scope.email_options = "use_ssl";
master.email_options = "use_ssl";
$scope.use_ssl = true;
master.use_ssl = true;
$scope.use_tls = false;
master.use_tls = false;
}
} else {
if(data.notification_configuration.use_tls === true){
$scope.email_options = "use_tls";
master.email_options = "use_tls";
$scope.use_ssl = false;
master.use_ssl = false;
$scope.use_tls = true;
master.use_tls = true;
}
}
else {
if (data.notification_configuration[fld]) {
$scope[fld] = data.notification_configuration[fld];
master[fld] = data.notification_configuration[fld];
@ -193,6 +203,17 @@ export default ['Rest', 'Wait',
});
};
$scope.emailOptionsChange = function () {
if ($scope.email_options === 'use_ssl') {
$scope.use_ssl = true;
$scope.use_tls = false;
}
else if ($scope.email_options === 'use_tls') {
$scope.use_ssl = false;
$scope.use_tls = true;
}
};
$scope.formSave = function() {
var params,
v = $scope.notification_type.value;
@ -233,13 +254,10 @@ export default ['Rest', 'Wait',
.filter(i => (form.fields[i].ngShow && form.fields[i].ngShow.indexOf(v) > -1))
.map(i => [i, processValue($scope[i], i, form.fields[i])]));
delete params.notification_configuration.checkbox_group;
delete params.notification_configuration.email_options;
for (var j = 0; j < form.fields.checkbox_group.fields.length; j++) {
if (form.fields.checkbox_group.fields[j].ngShow && form.fields.checkbox_group.fields[j].ngShow.indexOf(v) > -1) {
params.notification_configuration[form.fields.checkbox_group.fields[j].name] = Boolean($scope[form.fields.checkbox_group.fields[j].name]);
}
}
params.notification_configuration.use_ssl = $scope.use_ssl;
params.notification_configuration.use_tls = $scope.use_tls;
Wait('start');
Rest.setUrl(url + id + '/');

View File

@ -388,25 +388,23 @@ export default ['i18n', function(i18n) {
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
checkbox_group: {
label: i18n._('Options'),
type: 'checkbox_group',
email_options: {
label: 'Options',
type: 'radio_group',
subForm: 'typeSubForm',
ngShow: "notification_type.value == 'email'",
fields: [{
name: 'use_tls',
label: i18n._('Use TLS'),
type: 'checkbox',
class: 'squeeze',
ngChange: "emailOptionsChange()",
options: [{
value: 'use_tls',
label: 'Use TLS',
ngShow: "notification_type.value == 'email' ",
labelClass: 'checkbox-options stack-inline',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
labelClass: 'checkbox-options stack-inline'
}, {
name: 'use_ssl',
label: i18n._('Use SSL'),
type: 'checkbox',
value: 'use_ssl',
label: 'Use SSL',
ngShow: "notification_type.value == 'email'",
labelClass: 'checkbox-options stack-inline',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
labelClass: 'checkbox-options stack-inline'
}]
}
},