Make admin_fields_edit be Angular-powered.
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 1 Apr 2014 01:34:44 +0000 (21:34 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 1 Apr 2014 01:37:49 +0000 (21:37 -0400)
Roll includes/hoplite to 38d8c893ebfb727e6f70ee86a155431e8d9fd571.

admin/fields.php
admin/templates/admin_fields_edit.tpl
includes/hoplite
static/admin.js

index a23a626a0ef5679e2f3b77d7a4b9f45e53d24893..39c60da1392d6ef5ecd832dcd2fc29f9c562a691 100644 (file)
@@ -31,7 +31,7 @@ class FieldsAction extends http\ActionController implements TemplatePreCaching
 {
        public function TemplateSet()
        {
-               return array('admin_fields_list', 'admin_fields_edit');
+               return ['admin_fields_list', 'admin_fields_edit'];
        }
 
        public function ActionList(http\Request $request, http\Response $response)
@@ -58,7 +58,8 @@ class FieldsAction extends http\ActionController implements TemplatePreCaching
                if ($request->http_method != 'POST')
                        $this->controller()->StopWithCode(http\ResponseCode::METHOD_NOT_ALLOWED);
 
-               $this->controller()->StopWithRedirect($this->controller()->MakeURL('/fields/list'));
+               var_dump($request);
+               //$this->controller()->StopWithRedirect($this->controller()->MakeURL('/fields/list'));
        }
 
        protected function _GetActionMethod(http\Request $request)
index ff3e1aa618d249d17a60f29288335aab099afe39..c46a7245e0ebfcfe248e9cde384883e81eef5a62 100644 (file)
@@ -1,5 +1,16 @@
 {%#import 'admin_header'%}
 
+<script>
+       var ModelData = {%= $field | json %};
+       var FieldTypes = {%= [
+               bugdar\Field::TYPE_TEXT,
+               bugdar\Field::TYPE_BOOL,
+               bugdar\Field::TYPE_LIST,
+               bugdar\Field::TYPE_DATE,
+               bugdar\Field::TYPE_USER
+       ] | json %};
+</script>
+
 <div ng-app="bugdar.admin.fields">
 <div ng-controller="FieldEditor">
 
 
        <form action="{%#url '/fields/save'%}" method="post">
 
-               <script type="text/ng-template" id="-/admin/fields/field-type-option.tpl">
-                       <option value="{{fieldType}}" ng-selected="fieldType == type">{{fieldType}}</option>
-               </script>
-
                <label>
                        {%=T('Title:')%}
-                       <input type="text" name="title" value="{%= $field->title %}">
+                       <input type="text" name="title" ng-model="field.title">
                </label>
 
                <label>
                        {%=T('Description:')%}
-                       <input type="text" name="description" value="{%= $field->description %}">
+                       <input type="text" name="description" ng-model="field.description">
                </label>
 
                <label>
                        {%=T('Field Type')%}
-                       <select name="type" {%= ($is_new) ?: 'disabled' %}>
-                               <option field-type="{%= bugdar\Field::TYPE_TEXT %}"></option>
-                               <option field-type="{%= bugdar\Field::TYPE_BOOL %}"></option>
-                               <option field-type="{%= bugdar\Field::TYPE_LIST %}"></option>
-                               <option field-type="{%= bugdar\Field::TYPE_DATE %}"></option>
-                               <option field-type="{%= bugdar\Field::TYPE_USER %}"></option>
+                       <select name="type" {%= ($is_new) ?: 'disabled' %} ng-model="field.type">
+                               <option ng-repeat="type in fieldTypes" value="{{type}}" ng-selected="type == field.type">{{type}}</option>
                        </select>
                </label>
 
                <label>
                        {%=T('Required:')%}
-                       <input type="checkbox" name="required" {%= $field->required ? 'checked' : '' %}>
+                       <input type="checkbox" name="required" ng-checked="field.required" value="1">
                </label>
 
                <label>
                        {%=T('Can Be Searched:')%}
-                       <input type="checkbox" name="can_search" {%= $field->can_search ? 'checked' : '' %}>
+                       <input type="checkbox" name="can_search" ng-checked="field.can_search" value="1">
                </label>
 
                <input type="submit" value="{%=T('Save Field')%}">
index dc08cff4b89d90466ebc2b3f2a8dc38b611558ab..38d8c893ebfb727e6f70ee86a155431e8d9fd571 160000 (submodule)
@@ -1 +1 @@
-Subproject commit dc08cff4b89d90466ebc2b3f2a8dc38b611558ab
+Subproject commit 38d8c893ebfb727e6f70ee86a155431e8d9fd571
index 2029413828d32831d36085c184e792187f80259f..a5d45abb3a34dea1410d825b09081d805a7b8a05 100644 (file)
@@ -15,15 +15,7 @@ angular.module('bugdar.admin.settings', [])
        }]);
 
 angular.module('bugdar.admin.fields', [])
-       .directive('fieldType', ['$templateCache', function($templateCache) {
-               return {
-                       restrict: 'A',
-                       replace: true,
-                       template: $templateCache.get('-/admin/fields/field-type-option.tpl'),
-                       scope: {
-                               fieldType: '@'
-                       }
-               };
-       }])
        .controller('FieldEditor', ['$scope', function($scope) {
+               $scope.field = ModelData;
+               $scope.fieldTypes = FieldTypes;
        }]);