From a076630b9c5cbe14936262efe27742120e691ea2 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 27 Apr 2009 00:20:20 +0000 Subject: [PATCH] MINOR: changed field adding to use a dropdown field rather the a list of links that was getting unmanagable with all the fields --- code/editor/FieldEditor.php | 4 +-- css/FieldEditor.css | 46 +++++++++++++++------------------- javascript/UserForm.js | 8 +++--- templates/FieldEditor.ss | 21 ++++------------ templates/Includes/AddField.ss | 12 +++++++++ 5 files changed, 43 insertions(+), 48 deletions(-) create mode 100644 templates/Includes/AddField.ss diff --git a/code/editor/FieldEditor.php b/code/editor/FieldEditor.php index f5c8f39..c38524b 100755 --- a/code/editor/FieldEditor.php +++ b/code/editor/FieldEditor.php @@ -66,7 +66,7 @@ class FieldEditor extends FormField { foreach($fields as $field => $title) { // get the nice title and strip out field $niceTitle = trim(str_ireplace("Field", "", eval("return $title::\$singular_name;"))); - if($title != 'MultipleOptionField') { + if($niceTitle) { $output->push(new ArrayData(array( 'ClassName' => $field, 'Title' => "$niceTitle" @@ -77,7 +77,7 @@ class FieldEditor extends FormField { } return false; } - + /** * Handles saving the page. Needs to keep an eye on fields * and options which have been removed / added diff --git a/css/FieldEditor.css b/css/FieldEditor.css index 2577284..823b3a2 100755 --- a/css/FieldEditor.css +++ b/css/FieldEditor.css @@ -6,34 +6,28 @@ /* Add a Field Menu ---------------------------------------- */ .MenuHolder { - color: #999; + color: #999; + border: 1px solid #ddd; + background: #f4f4f4; + overflow: hidden; + padding: 4px 10px; } - .MenuHolder ul { - background: #e7e7e7; - border: 1px solid #c6c6c6; - padding: 8px; + .MenuHolder h2 { + float: left; + } + + .MenuHolder select { + float: left; + width: 240px; + margin: 7px 0 0 8px; + font-size: 11px; + } + + .MenuHolder .submit { + float: left; + margin: 7px 0 0 4px; + font-size: 11px; } - .MenuHolder li { - display: inline; - font-size: 11px; - padding: 2px 0; - } - .MenuHolder li a { - padding: 5px 4px 3px 4px; - font-weight: bold; - border: 1px solid transparent; - text-decoration: none; - } - .MenuHolder li a:hover { - background: #f4f4f4; - border: 1px solid #c6c6c6; - } - .MenuHolder li.addField { - background: url(../../cms/images/add.gif) no-repeat center left; - padding-left: 20px; - text-transform: uppercase; - } - /* Options / Settings Area ---------------------------------------- */ .FormOptions { diff --git a/javascript/UserForm.js b/javascript/UserForm.js index 9dfd81b..e755026 100644 --- a/javascript/UserForm.js +++ b/javascript/UserForm.js @@ -31,7 +31,7 @@ * area. the type information should all be on this object */ - $("div.FieldEditor ul.Menu li a").livequery('click',function() { + $("div.FieldEditor .MenuHolder .submit").livequery('click',function() { // if this form is readonly... if($("#Fields").hasClass('readonly')) return false; @@ -43,8 +43,8 @@ var action = $("#Form_EditForm").attr("action") + '/field/Fields/addfield'; var length = $(".FieldInfo").length + 1; var securityID = ($("#SecurityID").length > 0) ? '&SecurityID='+$("#SecurityID").attr("value") : ''; - var type = $(this).attr("ID"); - + var type = $(this).siblings("select").val(); + //send ajax request to the page $.ajax({ type: "GET", @@ -69,7 +69,7 @@ statusMessage(ss.i18n._t('UserForms.ERRORCREATINGFIELD', 'Error Creating Field')); } }); - + return false; }); /** * Upon renaming a field we should go through and rename all the diff --git a/templates/FieldEditor.ss b/templates/FieldEditor.ss index d9064f9..1bc2fa5 100755 --- a/templates/FieldEditor.ss +++ b/templates/FieldEditor.ss @@ -1,12 +1,7 @@
- + + <% include AddField %> +
    <% control Fields %> @@ -18,15 +13,9 @@ <% end_control %>
- + <% include AddField %> +

Form Options

<% control FormOptions %> diff --git a/templates/Includes/AddField.ss b/templates/Includes/AddField.ss new file mode 100644 index 0000000..8b0111b --- /dev/null +++ b/templates/Includes/AddField.ss @@ -0,0 +1,12 @@ + \ No newline at end of file