[Kimchi-devel] [PATCH 3/3] Make use of the new forms handling capabilities

Adam King rak at linux.vnet.ibm.com
Fri Mar 28 02:59:07 UTC 2014


Update the grid and repo edit code to leverage the new form js support.

Signed-off-by: Adam King <rak at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.grid.js                 |  2 +-
 ui/js/src/kimchi.repository_edit_main.js | 31 +------------------------------
 2 files changed, 2 insertions(+), 31 deletions(-)

diff --git a/ui/js/src/kimchi.grid.js b/ui/js/src/kimchi.grid.js
index f3c30c7..5f94e79 100644
--- a/ui/js/src/kimchi.grid.js
+++ b/ui/js/src/kimchi.grid.js
@@ -180,7 +180,7 @@ kimchi.widget.Grid = function(params) {
     var getValue = function(name, obj) {
     var result=undefined;
     if(!Array.isArray(name)) {
-        name=kimchi.form.parseFormName(name);
+        name=name.parseKey();
     }
     if(name.length!=0) {
         var tmpName=name.shift();
diff --git a/ui/js/src/kimchi.repository_edit_main.js b/ui/js/src/kimchi.repository_edit_main.js
index 7e9ab5c..26d6c66 100644
--- a/ui/js/src/kimchi.repository_edit_main.js
+++ b/ui/js/src/kimchi.repository_edit_main.js
@@ -15,35 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-kimchi.repository_fillForm = function(form, name, values) {
-    var name= (name=="" || !name) ? "%s" : name;
-    for(var prop in values) {
-        if ((typeof(values[prop])==="object") && !Array.isArray(values[prop])) {
-            tmpName=name.replace("%s", prop+"[%s]" );
-            kimchi.repository_fillForm(form, tmpName, values[prop]);
-        }
-        else {
-            tmpName=name.replace("%s", prop );
-            var control = $('input[name="' + tmpName + '"]', form);
-            switch($(control).attr('type')) {
-            case 'text':
-                $(control).val(values[prop]);
-                break;
-            case 'radio':
-            case 'checkbox':
-                $(control).each(function(i, c) {
-                    var matched = ('' + values[prop]) == $(c).val();
-                    $(c).prop('checked', matched);
-                });
-                break;
-            default:
-                break;
-            }
-        }
-    }
-}
-
 kimchi.repository_edit_main = function() {
 
     var editForm = $('#form-repository-edit');
@@ -58,7 +29,7 @@ kimchi.repository_edit_main = function() {
     }
 
     kimchi.retrieveRepository(kimchi.selectedRepository, function(repository) {
-        kimchi.repository_fillForm(editForm,"",repository);
+        editForm.fillWithObject(repository);
 
         $('input', editForm).on('input propertychange', function(event) {
             if($(this).val() !== '') {
-- 
1.8.1.4




More information about the Kimchi-devel mailing list