diff --git a/platform/forms/bundle.json b/platform/forms/bundle.json index 776d0ee596..782f2e4a2e 100644 --- a/platform/forms/bundle.json +++ b/platform/forms/bundle.json @@ -1,42 +1,53 @@ { - "name": "MCT Forms", - "description": "Form generator; includes directive and some controls.", - "extensions": { - "directives": [ - { - "key": "mctForm", - "implementation": "MCTForm.js" - } - ], - "templates": [ - { - "key": "_checkbox", - "templateUrl": "templates/_checkbox.html" - }, - { - "key": "_checkboxes", - "templateUrl": "templates/_checkboxes.html" - }, - { - "key": "_datetime", - "templateUrl": "templates/_datetime.html" - }, - { - "key": "_select", - "templateUrl": "templates/_select.html" - }, - { - "key": "_selects", - "templateUrl": "templates/_selects.html" - }, - { - "key": "_textfield", - "templateUrl": "templates/_textfield.html" - }, - { - "key": "_textfields", - "templateUrl": "templates/_textfields.html" - } - ] - } + "name": "MCT Forms", + "description": "Form generator; includes directive and some controls.", + "extensions": { + "directives": [ + { + "key": "mctForm", + "implementation": "MCTForm.js" + }, + { + "key": "mctControl", + "implementation": "MCTControl.js", + "depends": [ "controls[]" ] + } + ], + "controls": [ + { + "key": "checkbox", + "templateUrl": "templates/controls/checkbox.html" + } + ], + "templates": [ + { + "key": "_checkbox", + "templateUrl": "templates/_checkbox.html" + }, + { + "key": "_checkboxes", + "templateUrl": "templates/_checkboxes.html" + }, + { + "key": "_datetime", + "templateUrl": "templates/_datetime.html" + }, + { + "key": "_select", + "templateUrl": "templates/_select.html" + }, + { + "key": "_selects", + "templateUrl": "templates/_selects.html" + }, + { + "key": "_textfield", + "templateUrl": "templates/_textfield.html" + }, + { + "key": "_textfields", + "templateUrl": "templates/_textfields.html" + } + ] + } } \ No newline at end of file diff --git a/platform/forms/res/templates/controls/checkbox.html b/platform/forms/res/templates/controls/checkbox.html new file mode 100644 index 0000000000..a33eb4b86e --- /dev/null +++ b/platform/forms/res/templates/controls/checkbox.html @@ -0,0 +1,7 @@ + diff --git a/platform/forms/res/templates/form.html b/platform/forms/res/templates/form.html index b3dc0db27b..9b2b2c5d64 100644 --- a/platform/forms/res/templates/form.html +++ b/platform/forms/res/templates/form.html @@ -1,38 +1,42 @@ -{{structure.name}} +
+
-
{{section.name}}
+
+ {{section.name}} +
- - - - - - - - - - -
-
{{row.name}}
-
-
+
-
- {{item.control}} | Item.Key={{item.key}} | model={{model[item.key]}} - * - -
+
{{row.name}}
+
+
+ + +
+
+ +
+
- -CLICK! -
Model: {{model | json}}
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/platform/forms/src/MCTControl.js b/platform/forms/src/MCTControl.js index e48b90629b..cbac1aedce 100644 --- a/platform/forms/src/MCTControl.js +++ b/platform/forms/src/MCTControl.js @@ -21,7 +21,9 @@ define( function controller($scope) { $scope.$watch("key", function (key) { // Pass the template URL to ng-include via scope. - $scope.inclusion = controlMap[$scope.key]; + $scope.inclusion = controlMap[key]; + console.log(key); + console.log($scope.inclusion); }); } @@ -36,14 +38,35 @@ define( // template path template: '', + // ngOptions is terminal, so we need to be higher priority + priority: 1000, + // Pass through Angular's normal input field attributes scope: { + // Used to choose which form control to use + key: "=", + + // The state of the form value itself ngModel: "=", - ngOptions: "=", + + // Enabled/disabled state ngDisabled: "=", - ngPattern: "=" + + // Pattern (for input fields) + ngPattern: "=", + + // Set of choices (if any) + options: "=", + + // Structure (subtree of Form Structure) + structure: "=", + + // Name, as in "