Skip to content

Commit 4b2e457

Browse files
committed
hestiacp#1286 FIx issues with overwriting user_ and editting it again
1 parent 8dca2d7 commit 4b2e457

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

web/js/pages/add_db.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
66
$(elm).parent().find('.hint').html('');
77
}
88
// remove prefix from value in order to eliminate duplicates
9-
if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
10-
hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
11-
}
9+
//if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
10+
// hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
11+
//}
1212

1313
$(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
1414
}
@@ -21,9 +21,9 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
2121
$(elm).parent().find('.hint').html('');
2222
}
2323
// remove prefix from value in order to eliminate duplicates
24-
if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
25-
hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
26-
}
24+
//if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
25+
// hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
26+
//}
2727
$(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
2828
}
2929

web/js/pages/edit_db.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
55
if (hint.trim() == '') {
66
$(elm).parent().find('.hint').html('');
77
}
8-
// remove prefix from value in order to eliminate duplicates
9-
if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
10-
hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
11-
}
12-
138
$(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
149
}
1510

@@ -20,10 +15,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
2015
if (hint.trim() == '') {
2116
$(elm).parent().find('.hint').html('');
2217
}
23-
// remove prefix from value in order to eliminate duplicates
24-
if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
25-
hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
26-
}
2718
$(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
2819
}
2920

@@ -32,9 +23,13 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
3223
App.Listeners.DB.keypress_db_username = function() {
3324
var ref = $('input[name="v_dbuser"]');
3425
var current_val = ref.val();
26+
if (current_val.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
27+
current_val = current_val.slice(GLOBAL.DB_DBNAME_PREFIX.length, current_val.length);
28+
ref.val(current_val);
29+
}
3530
if (current_val.trim() != '') {
3631
App.Actions.DB.update_db_username_hint(ref, current_val);
37-
}
32+
}
3833

3934
ref.bind('keypress input', function(evt) {
4035
clearTimeout(window.frp_usr_tmt);
@@ -50,9 +45,13 @@ App.Listeners.DB.keypress_db_username = function() {
5045
App.Listeners.DB.keypress_db_databasename = function() {
5146
var ref = $('input[name="v_database"]');
5247
var current_val = ref.val();
53-
if (current_val.trim() != '') {
54-
App.Actions.DB.update_db_databasename_hint(ref, current_val);
48+
if (current_val.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
49+
current_val = current_val.slice(GLOBAL.DB_DBNAME_PREFIX.length, current_val.length);
50+
ref.val(current_val);
5551
}
52+
if (current_val.trim() != '') {
53+
App.Actions.DB.update_db_username_hint(ref, current_val);
54+
}
5655

5756
ref.bind('keypress input', function(evt) {
5857
clearTimeout(window.frp_dbn_tmt);
@@ -97,6 +96,7 @@ App.Listeners.DB.keypress_v_password();
9796
App.Listeners.DB.keypress_db_username();
9897
App.Listeners.DB.keypress_db_databasename();
9998

99+
100100
randomString = function(min_length = 16) {
101101
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
102102
var string_length = min_length;

0 commit comments

Comments
 (0)