[Groonga-commit] groonga/groonga-admin at ee88978 [master] Support showing value types in creating a new column form

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Mar 4 20:49:54 JST 2015


Kouhei Sutou	2015-03-04 20:49:54 +0900 (Wed, 04 Mar 2015)

  New Revision: ee889783b6bae0bc00f8a3bf206e35db5568d4fa
  https://github.com/groonga/groonga-admin/commit/ee889783b6bae0bc00f8a3bf206e35db5568d4fa

  Message:
    Support showing value types in creating a new column form

  Modified files:
    app/scripts/controllers/column-new-controller.js
    app/scripts/services/schema-loader.js
    app/views/columns/new.html

  Modified: app/scripts/controllers/column-new-controller.js (+13 -0)
===================================================================
--- app/scripts/controllers/column-new-controller.js    2015-01-04 18:34:11 +0900 (47736d6)
+++ app/scripts/controllers/column-new-controller.js    2015-03-04 20:49:54 +0900 (00a932d)
@@ -32,6 +32,7 @@ angular.module('groongaAdminApp')
             flag: 'COLUMN_INDEX'
           }
         };
+        $scope.availableValueTypes = {};
         $scope.column = {
           type: $scope.availableTypes.scalar,
           sources: []
@@ -60,9 +61,21 @@ angular.module('groongaAdminApp')
         });
       }
 
+      function collectAvailableValueTypes() {
+        var types = [];
+        angular.forEach(schema.types, function(type) {
+          types.push(type.name);
+        });
+        angular.forEach(schema.tables, function(table) {
+          types.push(table.name);
+        });
+        return types.sort();
+      }
+
       initialize();
       schemaLoader()
         .then(function(_schema) {
           schema = _schema;
+          $scope.availableValueTypes = collectAvailableValueTypes();
         });
     }]);

  Modified: app/scripts/services/schema-loader.js (+67 -2)
===================================================================
--- app/scripts/services/schema-loader.js    2015-01-04 18:34:11 +0900 (5736265)
+++ app/scripts/services/schema-loader.js    2015-03-04 20:49:54 +0900 (f67f439)
@@ -14,9 +14,72 @@ angular.module('groongaAdminApp')
       var fetching = false;
       var waitingDeferes = [];
       var fetched = false;
-      var schema = {};
+      var schema;
       var client = new GroongaClient($http);
 
+      function createSchema() {
+        var newSchema = {};
+        fillTypes(newSchema);
+        return newSchema;
+      };
+
+      function fillTypes(schema) {
+        var builtinTypes = [
+          {
+            name: 'Bool'
+          },
+          {
+            name: 'Int8'
+          },
+          {
+            name: 'UInt8'
+          },
+          {
+            name: 'Int16'
+          },
+          {
+            name: 'UInt16'
+          },
+          {
+            name: 'Int32'
+          },
+          {
+            name: 'UInt32'
+          },
+          {
+            name: 'Int64'
+          },
+          {
+            name: 'UInt64'
+          },
+          {
+            name: 'Float'
+          },
+          {
+            name: 'Time'
+          },
+          {
+            name: 'ShortText'
+          },
+          {
+            name: 'Text'
+          },
+          {
+            name: 'LongText'
+          },
+          {
+            name: 'TokyoGeoPoint'
+          },
+          {
+            name: 'WGS84GeoPoint'
+          }
+        ]
+        schema.types = {};
+        angular.forEach(builtinTypes, function(type) {
+          schema.types[type.name] = type;
+        });
+      }
+
       function isTextType(typeName) {
         switch (typeName) {
         case 'ShortText':
@@ -145,6 +208,8 @@ angular.module('groongaAdminApp')
           });
       }
 
+      schema = createSchema();
+
       return function() {
         var defer;
         var loader;
@@ -165,7 +230,7 @@ angular.module('groongaAdminApp')
         loader.reload = function() {
           fetching = false;
           fetched = false;
-          schema = {};
+          schema = createSchema();
         };
         return loader;
       };

  Modified: app/views/columns/new.html (+8 -6)
===================================================================
--- app/views/columns/new.html    2015-01-04 18:34:11 +0900 (6b0928a)
+++ app/views/columns/new.html    2015-03-04 20:49:54 +0900 (3000f73)
@@ -44,13 +44,15 @@
         </select>
       </div>
       <div class="form-group"
-           ng-class="{'has-error': tableForm.keyType.$invalid}">
+           ng-class="{'has-error': tableForm.valueType.$invalid}">
         <label for="value-type" class="control-label">Value type</label>
-        <input id="value-type"
-               name="valueType"
-               type="text"
-               class="form-control"
-               ng-model="column.valueType">
+        <select id="value-type"
+                name="valueType"
+                type="select"
+                class="form-control"
+                ng-model="column.valueType"
+                ng-options="type for (index, type) in availableValueTypes">
+        </select>
       </div>
       <div class="form-group">
         <div class="form-button">
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index