Просмотр исходного кода

#1286 FIx issues with overwriting user_ and editting it again

Jaap Marcus 5 лет назад
Родитель
Сommit
4b2e457afc
2 измененных файлов с 18 добавлено и 18 удалено
  1. 6 6
      web/js/pages/add_db.js
  2. 12 12
      web/js/pages/edit_db.js

+ 6 - 6
web/js/pages/add_db.js

@@ -6,9 +6,9 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
         $(elm).parent().find('.hint').html('');
     } 
     // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
-    }
+    //if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
+    //    hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
+    //}
     
     $(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
 }
@@ -21,9 +21,9 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
         $(elm).parent().find('.hint').html('');
     } 
     // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
-    }
+    //if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
+    //    hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
+    //}
     $(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
 }
 

+ 12 - 12
web/js/pages/edit_db.js

@@ -5,11 +5,6 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     } 
-    // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
-    }
-    
     $(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
 }
 
@@ -20,10 +15,6 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
     if (hint.trim() == '') {
         $(elm).parent().find('.hint').html('');
     } 
-    // remove prefix from value in order to eliminate duplicates
-    if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
-        hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
-    }
     $(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
 }
 
@@ -32,9 +23,13 @@ App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
 App.Listeners.DB.keypress_db_username = function() {
     var ref = $('input[name="v_dbuser"]');
     var current_val = ref.val();
+    if (current_val.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
+        current_val = current_val.slice(GLOBAL.DB_DBNAME_PREFIX.length, current_val.length);
+        ref.val(current_val);
+    }
     if (current_val.trim() != '') {
         App.Actions.DB.update_db_username_hint(ref, current_val);
-    }
+    }    
     
     ref.bind('keypress input', function(evt) {
         clearTimeout(window.frp_usr_tmt);
@@ -50,9 +45,13 @@ App.Listeners.DB.keypress_db_username = function() {
 App.Listeners.DB.keypress_db_databasename = function() {
     var ref = $('input[name="v_database"]');
     var current_val = ref.val();
-    if (current_val.trim() != '') {
-        App.Actions.DB.update_db_databasename_hint(ref, current_val);
+    if (current_val.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
+        current_val = current_val.slice(GLOBAL.DB_DBNAME_PREFIX.length, current_val.length);
+        ref.val(current_val);
     }
+    if (current_val.trim() != '') {
+        App.Actions.DB.update_db_username_hint(ref, current_val);
+    }   
     
     ref.bind('keypress input', function(evt) {
         clearTimeout(window.frp_dbn_tmt);
@@ -97,6 +96,7 @@ App.Listeners.DB.keypress_v_password();
 App.Listeners.DB.keypress_db_username();
 App.Listeners.DB.keypress_db_databasename();
 
+
 randomString = function(min_length = 16) {
     var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
     var string_length = min_length;