Skip to content

Commit 443d1dd

Browse files
AlecRustjaapmarcus
andauthored
Fix mail account sidebar not updating (hestiacp#3037)
* Fix mail account sidebar not updating * Add extra white line * Update edit_mail_acc.html Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 6f2db8b commit 443d1dd

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

web/js/pages/add_mail_acc.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ applyRandomString = function(min_length = 16) {
118118
var randomString = randomString2(min_length);
119119
$('input[name=v_password]').val(randomString);
120120
if($('input[name=v_password]').attr('type') == 'text')
121-
$('#v_password').text(randomString);
121+
$('.js-password-output').text(randomString);
122122
else
123-
$('#v_password').text(Array(randomString.length+1).join('*'));
123+
$('.js-password-output').text(Array(randomString.length+1).join('*'));
124124
App.Actions.MAIL_ACC.update_password_meter();
125125
generate_mail_credentials();
126126
}
127127

128128
generate_mail_credentials = function() {
129129
var div = $('.mail-infoblock').clone();
130130
div.find('#mail_configuration').remove();
131-
var pass=$('#v_password').text();
131+
var pass=$('.js-password-output').text();
132132
var output = div.text();
133133
output=output.replace(/(?:\r\n|\r|\n|\t)/g, "|");
134134
output=output.replace(/ {2}/g, "");
@@ -140,29 +140,29 @@ generate_mail_credentials = function() {
140140
output=output.replace(/ $/, "");
141141
output=output.replace(/:\|/g, ": ");
142142
output=output.replace(/\|/g, "\n");
143-
$('#v_credentials').val(output);
143+
$('.js-hidden-credentials').val(output);
144144
}
145145

146146
$(document).ready(function() {
147-
$('#v_account').text($('input[name=v_account]').val());
148-
$('#v_password').text($('input[name=v_password]').val());
147+
$('.js-account-output').text($('input[name=v_account]').val());
148+
$('.js-password-output').text($('input[name=v_password]').val());
149149
generate_mail_credentials();
150150

151151
$('input[name=v_account]').change(function(){
152-
$('#v_account').text($(this).val());
152+
$('.js-account-output').text($(this).val());
153153
generate_mail_credentials();
154154
});
155155

156156
$('input[name=v_password]').change(function(){
157157
if($('input[name=v_password]').attr('type') == 'text')
158-
$('#v_password').text($(this).val());
158+
$('.js-password-output').text($(this).val());
159159
else
160-
$('#v_password').text(Array($(this).val().length+1).join('*'));
160+
$('.js-password-output').text(Array($(this).val().length+1).join('*'));
161161
generate_mail_credentials();
162162
});
163163

164164
$('.toggle-psw-visibility-icon').click(function(){
165-
$('#v_password').text($('input[name=v_password]').val());
165+
$('.js-password-output').text($('input[name=v_password]').val());
166166
generate_mail_credentials();
167167
});
168168

web/js/pages/edit_mail_acc.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ applyRandomString = function (min_length = 16) {
109109
var randomString = randomString2(min_length);
110110
$("input[name=v_password]").val(randomString);
111111
if ($("input[name=v_password]").attr("type") == "text")
112-
$("#v_password").text(randomString);
112+
$(".js-password-output").text(randomString);
113113
else
114-
$("#v_password").text(Array(randomString.length + 1).join("*"));
114+
$(".js-password-output").text(Array(randomString.length + 1).join("*"));
115115
App.Actions.MAIL_ACC.update_password_meter();
116116
generate_mail_credentials();
117117
};
118118

119119
generate_mail_credentials = function() {
120120
var div = $('.mail-infoblock').clone();
121121
div.find('#mail_configuration').remove();
122-
var pass=div.find('#v_password').text();
123-
if (pass=="") div.find('#v_password').text(' ');
122+
var pass=div.find('.js-password-output').text();
123+
if (pass=="") div.find('.js-password-output').text(' ');
124124
var output = div.text();
125125
output=output.replace(/(?:\r\n|\r|\n|\t)/g, "|");
126126
output=output.replace(/ {2}/g, "");
@@ -132,32 +132,32 @@ generate_mail_credentials = function() {
132132
output=output.replace(/ $/, "");
133133
output=output.replace(/:\|/g, ": ");
134134
output=output.replace(/\|/g, "\n");
135-
$('#v_credentials').val(output);
135+
$('.js-hidden-credentials').val(output);
136136
}
137137

138138
$(document).ready(function() {
139-
$('#v_account').text($('input[name=v_account]').val());
140-
$('#v_password').text($('input[name=v_password]').val());
139+
$('.js-account-output').text($('input[name=v_account]').val());
140+
$('.js-password-output').text($('input[name=v_password]').val());
141141
generate_mail_credentials();
142142

143143
$('input[name=v_account]').change(function(){
144-
$('#v_account').text($(this).val());
144+
$('.js-account-output').text($(this).val());
145145
generate_mail_credentials();
146146
});
147147

148148
$('input[name=v_password]').change(function(){
149149
if($('input[name=v_password]').attr('type') == 'text')
150-
$('#v_password').text($(this).val());
150+
$('.js-password-output').text($(this).val());
151151
else
152-
$('#v_password').text(Array($(this).val().length+1).join('*'));
152+
$('.js-password-output').text(Array($(this).val().length+1).join('*'));
153153
generate_mail_credentials();
154154
});
155155

156156
$('.toggle-psw-visibility-icon').click(function(){
157157
if($('input[name=v_password]').attr('type') == 'text')
158-
$('#v_password').text($('input[name=v_password]').val());
158+
$('.js-password-output').text($('input[name=v_password]').val());
159159
else
160-
$('#v_password').text(Array($('input[name=v_password]').val().length+1).join('*'));
160+
$('.js-password-output').text(Array($('input[name=v_password]').val().length+1).join('*'));
161161
generate_mail_credentials();
162162
});
163163

web/templates/pages/add_mail_acc.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ <h1 class="form-title"><?=_('Adding Mail Account');?></h1>
100100
<?=_('Send login credentials to email address') ?>
101101
</label>
102102
<input type="email" class="form-control" name="v_send_email" id="v_send_email" value="<?=htmlentities(trim($v_send_email, "'"))?>">
103-
<input type="hidden" name="v_credentials" id="v_credentials">
103+
<input type="hidden" name="v_credentials" class="js-hidden-credentials">
104104
</div>
105105
</div>
106106
<div>
107107
<div class="mail-infoblock">
108108
<table>
109109
<tr><td colspan="2"><strong><?=strtoupper(_('Common account settings'));?></strong></td><tr>
110-
<tr><td><?=_('Username');?>: </td><td><span id="v_account">example</span>@<?=htmlentities(trim($v_domain, "'"))?></td></tr>
111-
<tr><td><?=_('Password');?>: </td><td><span id="v_password"></span></td></tr>
112-
<?php if ($_SESSION['WEBMAIL_SYSTEM']) {?><tr><td><?=_('Webmail');?>: </td><td><a class="vst" href="http://<?=htmlentities($v_webmail_alias)?>" target="_blank">http://<?=htmlentities($v_webmail_alias)?></a></td></tr><?php } ?>
110+
<tr><td><?=_('Username');?>: </td><td><span class="js-account-output">example</span>@<?=htmlentities(trim($v_domain, "'"))?></td></tr>
111+
<tr><td><?=_('Password');?>: </td><td><span class="js-password-output"></span></td></tr>
112+
<?php if ($_SESSION['WEBMAIL_SYSTEM']) {?><tr><td><?=_('Webmail');?>: </td><td><a class="vst" href="http://<?=htmlentities($v_webmail_alias)?>" target="_blank">http://<?=htmlentities($v_webmail_alias)?></a></td></tr>
113+
<?php } ?>
113114
<tr><td><?=_('Hostname');?>: </td><td>mail.<?=htmlentities($v_domain)?></td></tr>
114115

115116
<tr><td colspan="2"><strong><?=strtoupper(_('IMAP settings'));?></strong></td></tr>

web/templates/pages/edit_mail_acc.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h1 class="form-title"><?=_('Editing Mail Account');?></h1>
5151
<?=_('Send login credentials to email address') ?>
5252
</label>
5353
<input type="email" class="form-control" name="v_send_email" id="v_send_email" value="<?=htmlentities(trim($v_send_email, "'"))?>">
54-
<input type="hidden" name="v_credentials" id="v_credentials">
54+
<input type="hidden" name="v_credentials" class="js-hidden-credentials">
5555
</div>
5656
<div class="u-mb10">
5757
<label for="v_quota" class="form-label">
@@ -113,9 +113,10 @@ <h1 class="form-title"><?=_('Editing Mail Account');?></h1>
113113
<div class="mail-infoblock">
114114
<table>
115115
<tr><td colspan="2"><strong><?=strtoupper(_('Common account settings'));?></strong></td><tr>
116-
<tr><td><?=_('Username');?>: </td><td><span id="v_account"></span>@<?=htmlentities(trim($v_domain, "'"))?></td></tr>
117-
<tr><td><?=_('Password');?>: </td><td><span id="v_password"></span></td></tr>
118-
<?php if ($_SESSION['WEBMAIL_SYSTEM']) {?><tr><td><?=_('Webmail');?>: </td><td><a class="vst" href="http://<?=htmlentities($v_webmail_alias)?>" target="_blank">http://<?=htmlentities($v_webmail_alias)?></a></td></tr><?php } ?>
116+
<tr><td><?=_('Username');?>: </td><td><span class="js-account-output"></span>@<?=htmlentities(trim($v_domain, "'"))?></td></tr>
117+
<tr><td><?=_('Password');?>: </td><td><span class="js-password-output"></span></td></tr>
118+
<?php if ($_SESSION['WEBMAIL_SYSTEM']) {?><tr><td><?=_('Webmail');?>: </td><td><a class="vst" href="http://<?=htmlentities($v_webmail_alias)?>" target="_blank">http://<?=htmlentities($v_webmail_alias)?></a></td></tr>
119+
<?php } ?>
119120
<tr><td><?=_('Hostname');?>: </td><td>mail.<?=htmlentities($v_domain)?></td></tr>
120121

121122
<tr><td colspan="2"><strong><?=strtoupper(_('IMAP settings'));?></strong></td></tr>

0 commit comments

Comments
 (0)