{
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)
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)
{%#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')%}">
}]);
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;
}]);