From 7cda9e528e03d2431dfab7cba82e1b383c4d432b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 25 May 2015 22:25:05 -0400 Subject: [PATCH] Start working on the admin field editor UI. --- admin/templates/admin_fields_edit.tpl | 49 +++++++++++++++++++++++---- includes/hoplite | 2 +- includes/model_field.php | 7 ++++ static/admin.js | 19 +++++++++++ 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/admin/templates/admin_fields_edit.tpl b/admin/templates/admin_fields_edit.tpl index c46a724..320bcec 100644 --- a/admin/templates/admin_fields_edit.tpl +++ b/admin/templates/admin_fields_edit.tpl @@ -2,13 +2,7 @@
@@ -45,6 +39,47 @@ + +
+
+ + + +
+ +
+ +
+ +
+ + + +
+
+ diff --git a/includes/hoplite b/includes/hoplite index 2dbb698..31600ee 160000 --- a/includes/hoplite +++ b/includes/hoplite @@ -1 +1 @@ -Subproject commit 2dbb698f2da9339190cc1e3d2e8bfb1f803ebc84 +Subproject commit 31600eeb381d24a83267ad4d892df3692ed0faea diff --git a/includes/model_field.php b/includes/model_field.php index c8e5fc9..90c9cd1 100644 --- a/includes/model_field.php +++ b/includes/model_field.php @@ -52,6 +52,13 @@ class Field extends \hoplite\data\Model const TYPE_DATE = 'date'; const TYPE_USER = 'user'; // }} + public static $field_types = [ + self::TYPE_TEXT, + self::TYPE_BOOL, + self::TYPE_LIST, + self::TYPE_DATE, + self::TYPE_USER + ]; // Usergroup access controls {{ const ACCESS_NONE = 0; diff --git a/static/admin.js b/static/admin.js index a5d45ab..f106772 100644 --- a/static/admin.js +++ b/static/admin.js @@ -18,4 +18,23 @@ angular.module('bugdar.admin.fields', []) .controller('FieldEditor', ['$scope', function($scope) { $scope.field = ModelData; $scope.fieldTypes = FieldTypes; + + $scope.listOptionsAsText = function() { + var options = $scope.listOptions(); + if (options.length == 0) + return ''; + return options.join('\n').trim(); + }; + + $scope.listOptions = function() { + var rawOptions = ($scope.field.rawListOptions || '').trim(); + if (rawOptions.length == 0) + return []; + + var options = rawOptions.split('\n'); + for (var i = 0; i < options.length; ++i) + options[i] = options[i].trim(); + + return options; + }; }]); -- 2.43.5