Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 266c83a32 -> 391686d83


# IGNITE-843 WIP on panel with edit and table.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/391686d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/391686d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/391686d8

Branch: refs/heads/ignite-843
Commit: 391686d83f0476c553901d20a22594731ff2c98c
Parents: 266c83a
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Tue Jun 16 17:49:28 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Tue Jun 16 17:49:28 2015 +0700

----------------------------------------------------------------------
 .../nodejs/public/form-models/caches.json       |   2 +-
 .../public/javascripts/controllers/caches.js    | 122 ++++++-------------
 .../nodejs/views/includes/controls.jade         |  40 +++---
 3 files changed, 55 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/391686d8/modules/webconfig/nodejs/public/form-models/caches.json
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/public/form-models/caches.json 
b/modules/webconfig/nodejs/public/form-models/caches.json
index 390f630..6fa089b 100644
--- a/modules/webconfig/nodejs/public/form-models/caches.json
+++ b/modules/webconfig/nodejs/public/form-models/caches.json
@@ -355,7 +355,7 @@
         {
           "tableLabel": "SQL functions",
           "label": "SQL function",
-          "type": "table-simple2",
+          "type": "table-simple",
           "model": "sqlFunctionClasses",
           "editIdx": -1,
           "placeholder": "Some placeholder",

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/391686d8/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/public/javascripts/controllers/caches.js 
b/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
index 58e747f..0da6d3b 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
@@ -66,61 +66,6 @@ configuratorModule.controller('cachesController', ['$scope', 
'$modal', '$http',
                 $scope.advanced = data.advanced;
             });
 
-        $scope.editIndexedTypes = function (idx) {
-            $scope.indexedTypeIdx = idx;
-
-            if (idx < 0) {
-                $scope.currKeyCls = '';
-                $scope.currValCls = '';
-            }
-            else {
-                var idxType = $scope.backupItem.indexedTypes[idx];
-
-                $scope.currKeyCls = idxType.keyClass;
-                $scope.currValCls = idxType.valueClass;
-            }
-
-            $scope.indexedTypesModal = $modal({scope: $scope, template: 
'/indexedTypes', show: true});
-        };
-
-        $scope.saveIndexedType = function (k, v) {
-            var idxTypes = $scope.backupItem.indexedTypes;
-
-            var idx = $scope.indexedTypeIdx;
-
-            if (idx < 0) {
-                var newItem = {keyClass: k, valueClass: v};
-
-                if (undefined == idxTypes)
-                    $scope.backupItem.indexedTypes = [newItem];
-                else
-                    idxTypes.push(newItem);
-            }
-            else {
-                var idxType = idxTypes[idx];
-
-                idxType.keyClass = k;
-                idxType.valueClass = v;
-            }
-
-            $scope.indexedTypesModal.hide();
-        };
-
-        $scope.removeIndexedType = function (idx) {
-            $scope.backupItem.indexedTypes.splice(idx, 1);
-        };
-
-        $scope.addSqlFunction = function (v) {
-            if (undefined == $scope.backupItem.sqlFunctionClasses)
-                $scope.backupItem.sqlFunctionClasses = [v];
-            else
-                $scope.backupItem.sqlFunctionClasses.push(v);
-        };
-
-        $scope.removeSqlFunction = function (idx) {
-            $scope.backupItem.sqlFunctionClasses.splice(idx, 1);
-        };
-
         $scope.caches = [];
 
         // When landing on the page, get caches and show them.
@@ -189,42 +134,55 @@ configuratorModule.controller('cachesController', 
['$scope', '$modal', '$http',
                 });
         };
 
-        $scope.createSimpleItem = function(desc, rows) {
-            $scope.simplePopup = {
-                rows: rows,
-                desc: desc
-            };
-
-            $scope.pupup = $modal({scope: $scope, template: '/simplePopup', 
show: true});
+        $scope.addSimpleItem = function(mdl, item) {
+            if (undefined == $scope.backupItem[mdl])
+                $scope.backupItem[mdl] = [item];
+            else
+                $scope.backupItem[mdl].push(item);
         };
 
-        $scope.saveSimpleItem = function(row) {
-            var popup = $scope.simplePopup;
-            var rows = popup.rows;
+        $scope.editIndexedTypes = function (idx) {
+            $scope.indexedTypeIdx = idx;
 
-            if (popup.index)
-                angular.extend(rows[popup.index], row);
-            else if (undefined == rows)
-                popup.rows = [row];
-            else
-                popup.rows.push(row);
+            if (idx < 0) {
+                $scope.currKeyCls = '';
+                $scope.currValCls = '';
+            }
+            else {
+                var idxType = $scope.backupItem.indexedTypes[idx];
 
-            $scope.pupup.hide();
+                $scope.currKeyCls = idxType.keyClass;
+                $scope.currValCls = idxType.valueClass;
+            }
+
+            $scope.indexedTypesModal = $modal({scope: $scope, template: 
'/indexedTypes', show: true});
         };
 
-        $scope.editSimpleItem = function(desc, rows, idx) {
-            $scope.simplePopup = {
-                desc: desc,
-                rows: rows,
-                index: idx,
-                row: angular.copy(rows[idx])
-            };
+        $scope.saveIndexedType = function (k, v) {
+            var idxTypes = $scope.backupItem.indexedTypes;
+
+            var idx = $scope.indexedTypeIdx;
+
+            if (idx < 0) {
+                var newItem = {keyClass: k, valueClass: v};
 
-            $modal({scope: $scope, template: '/simplePopup', show: true});
+                if (undefined == idxTypes)
+                    $scope.backupItem.indexedTypes = [newItem];
+                else
+                    idxTypes.push(newItem);
+            }
+            else {
+                var idxType = idxTypes[idx];
+
+                idxType.keyClass = k;
+                idxType.valueClass = v;
+            }
+
+            $scope.indexedTypesModal.hide();
         };
 
-        $scope.removeSimpleItem = function(rows, idx) {
-            rows.splice(idx, 1);
+        $scope.removeIndexedType = function (idx) {
+            $scope.backupItem.indexedTypes.splice(idx, 1);
         };
     }]
 );
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/391686d8/modules/webconfig/nodejs/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/views/includes/controls.jade 
b/modules/webconfig/nodejs/views/includes/controls.jade
index aa2e85b..bec7890 100644
--- a/modules/webconfig/nodejs/views/includes/controls.jade
+++ b/modules/webconfig/nodejs/views/includes/controls.jade
@@ -103,18 +103,6 @@ mixin form-row
             .col-sm-6.panel-details(ng-show='field.expanded && #{masterMdl}')
                 .details-row(ng-repeat='detail in field.details[#{masterMdl}]')
                     +details-row
-        div(ng-switch-when='table-simple')
-            div
-                label {{field.tableLabel}}
-                +tipLabel('field.tip')
-            button.btn.btn-primary(style='margin-left: 18px;' 
ng-click='createSimpleItem(field, #{masterMdl})') Add {{field.label}}
-            .col-sm-10.links.details-row(style='margin-bottom: 0px;' 
nh-show='#{masterMdl}[field.model].length > 0')
-                table(st-table=masterMdl)
-                    tbody
-                        tr(ng-repeat='row in #{masterMdl}')
-                            td
-                                a(ng-click='editSimpleItem(field, 
#{masterMdl}, $index)') {{$index + 1}}. {{row}}
-                                
label.fa.fa-remove(ng-click='removeSimpleItem(#{masterMdl}, $index)')
         div(ng-switch-when='indexedTypes')
             div
                 label Indexed types: {{backupItem.indexedTypes.length}}
@@ -128,24 +116,24 @@ mixin form-row
                             td
                                 a(ng-click='editIndexedTypes($index)') 
{{$index + 1}}. {{idxType.keyClass}}, {{idxType.valueClass}}
                                 
label.fa.fa-remove(ng-click='removeIndexedType($index)')
-        div(ng-switch-when='table-simple2' )
+        div(ng-switch-when='table-simple')
+            - var tblMdl = 'backupItem[field.model]'
             div
-                label SQL functions: {{backupItem.sqlFunctionClasses.length}}
+                label {{field.tableLabel}}: {{#{tblMdl}.length}}
                 +tipLabel('field.tip')
-            .links(nh-show='backupItem.sqlFunctionClasses.length > 0')
-                -var sqlFunctions = 'backupItem.sqlFunctionClasses'
-                table.col-sm-12(st-table=sqlFunctions)
+            .links(nh-show='#{tblMdl}.length > 0')
+                table.col-sm-12(st-table=tblMdl)
                     tbody
-                        tr.col-sm-12(ng-repeat='sqlFunction in 
#{sqlFunctions}')
+                        tr.col-sm-12(ng-repeat='item in #{tblMdl}')
                             td.col-sm-6
-                                a.vcenter2(ng-show='field.editIdx != 
{{$index}}' ng-click='field.editIdx = $index; inplaceSqlFx = 
backupItem.sqlFunctionClasses[$index]') {{$index + 1}}. {{sqlFunction}}
-                                input.form-control(ng-show='field.editIdx == 
{{$index}}' type='text' ng-model='inplaceSqlFx' placeholder='SQL function class 
name')
-                                i.tipField.fa.fa-remove(ng-show='field.editIdx 
!= {{$index}}' ng-click='field.editIdx = -1; removeSqlFunction($index)')
-                                
i.tipField.fa.fa-floppy-o(ng-show='field.editIdx == {{$index}}' 
ng-click='field.editIdx = -1; 
backupItem.sqlFunctionClasses[$index]=inplaceSqlFx')
+                                a.vcenter2(ng-show='field.editIdx != $index' 
ng-click='field.editIdx = $index; curValue = #{tblMdl}[$index]') {{$index + 
1}}. {{item}}
+                                input.form-control(ng-show='field.editIdx == 
$index' type='text' ng-model='curValue' placeholder='SQL function class name')
+                                i.tipField.fa.fa-remove(ng-show='field.editIdx 
!= $index' ng-click='field.editIdx = -1; #{tblMdl}.splice($index, 1)')
+                                
i.tipField.fa.fa-floppy-o(ng-show='field.editIdx == $index' 
ng-click='field.editIdx = -1; #{tblMdl}[$index]=curValue')
                             td.col-sm-1
-                                i.fa.fa-arrow-up(ng-show='{{$index}} > 0' 
ng-click='field.editIdx = -1')
-                                i.fa.fa-arrow-down(ng-show='{{$index}} < 
#{sqlFunctions}.length - 1' ng-click='field.editIdx = -1')
+                                i.fa.fa-arrow-up(ng-show='$index > 0' 
ng-click='field.editIdx = -1')
+                                i.fa.fa-arrow-down(ng-show='$index < 
#{tblMdl}.length - 1' ng-click='field.editIdx = -1')
             .col-sm-5
-                input.form-control(type='text' ng-model='newSqlFx' 
placeholder='SQL function class name')
-            button.btn.btn-primary(style='margin-left: 10px;' 
ng-click='field.editIdx = -1; addSqlFunction(newSqlFx)') Add SQL function
+                input.form-control(type='text' ng-model='newValue' 
placeholder='SQL function class name')
+            button.btn.btn-primary(style='margin-left: 10px;' 
ng-click='field.editIdx = -1; addSimpleItem(field.model, newValue)') Add 
{{field.label}}
 

Reply via email to