From 33d768de54a4f73b4412d80932e9c315dab57b72 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Fri, 3 Jul 2015 18:04:39 -0700 Subject: [PATCH] added deletion and duplication buttons to EditForm --- public/modules/forms/css/form.css | 22 +++ .../directives/edit-form.client.directive.js | 20 +- .../services/form-fields.client.service.js | 4 - .../views/directiveViews/form/edit-form.html | 181 ++++++++++-------- 4 files changed, 140 insertions(+), 87 deletions(-) diff --git a/public/modules/forms/css/form.css b/public/modules/forms/css/form.css index a86df517..3855e210 100644 --- a/public/modules/forms/css/form.css +++ b/public/modules/forms/css/form.css @@ -21,6 +21,28 @@ padding-top: 3em; } +.current-fields .tool-panel > .panel-default:hover { + border-color: #9d9d9d; + cursor: pointer; +} + +.current-fields .tool-panel > .panel-default .panel-heading { + background-color: #fff; + color: #9d9d9d!important; +} + .current-fields .tool-panel > .panel-default .panel-heading:hover { + background-color: #eee; + color: #000!important; + cursor: pointer; + } +.current-fields .tool-panel > .panel-default .panel-heading a { + color: inherit; +} +.current-fields .tool-panel > .panel-default .panel-heading a:hover{ + text-decoration: none; +} + + /*Style for edit fields tab*/ .admin-form .tab-content .add-field { border-right: 1px solid #ddd; diff --git a/public/modules/forms/directives/edit-form.client.directive.js b/public/modules/forms/directives/edit-form.client.directive.js index 19d94f32..0c4e4ab1 100644 --- a/public/modules/forms/directives/edit-form.client.directive.js +++ b/public/modules/forms/directives/edit-form.client.directive.js @@ -33,14 +33,30 @@ angular.module('forms').directive('editFormDirective', ['$http', '$timeout', 'ti }; // deletes particular field on button click - $scope.deleteField = function (field_id){ + $scope.deleteField = function (hashKey){ + console.log($scope.form.form_fields); for(var i = 0; i < $scope.form.form_fields.length; i++){ - if($scope.form.form_fields[i].field_id === field_id){ + console.log($scope.form.form_fields[i].$$hashKey === hashKey); + if($scope.form.form_fields[i].$$hashKey === hashKey){ $scope.form.form_fields.splice(i, 1); + break; } } }; + $scope.duplicateField = function (field, field_index){ + for(var i = 0; i < $scope.form.form_fields.length; i++){ + if($scope.form.form_fields[i].field_id === field.field_id){ + $scope.form.form_fields.splice(field_index+1, 0, field); + break; + } + } + }; + + $scope.hover = function(field) { + // Shows/hides the delete button on hover + return field.showTools = !field.showTools; + }; // add new option to the field $scope.addOption = function (field){ diff --git a/public/modules/forms/services/form-fields.client.service.js b/public/modules/forms/services/form-fields.client.service.js index 8cbea794..de101195 100644 --- a/public/modules/forms/services/form-fields.client.service.js +++ b/public/modules/forms/services/form-fields.client.service.js @@ -31,10 +31,6 @@ angular.module('forms').service('FormFields', [ name : 'checkbox', value : 'Checkbox' }, - { - name : 'hidden', - value : 'Hidden' - } ]; } diff --git a/public/modules/forms/views/directiveViews/form/edit-form.html b/public/modules/forms/views/directiveViews/form/edit-form.html index 4556c6da..0c422bc9 100644 --- a/public/modules/forms/views/directiveViews/form/edit-form.html +++ b/public/modules/forms/views/directiveViews/form/edit-form.html @@ -11,10 +11,10 @@ - + - + {{type.value}} @@ -23,91 +23,110 @@
-
-

No fields added yet.

- - - -
- - - - - - - - - - {{field.title}} - - - - -
-
-
- + +
+
+ + -

-
-
Field Type:
-
{{field.fieldType}}
-
-
-
Field Title:
-
-
-
-
Field Default Value:
-
-
-
-
Field Options:
-
-
- - - Value: {{ option.option_value }} + + + + + + + + + + + {{field.title}} + + +
+ + +

+
+
Field Type:
+
{{field.fieldType}}
+
+
+
Field Title:
+
+
+
+
Field Default Value:
+
+
+
+
Field Options:
+
+
+ + + Value: {{ option.option_value }} +
+ +
+
+ +

+ +
+
Required:
+
+ + +
+
+ +

+ +
+
Disabled:
+
+ + +
-
-
- -

- -
-
Required:
-
- - -
-
- -

- -
-
Disabled:
-
- - + + +
+
+
+
+
+ + +
- - +
+
+
+
+
+ + + +
+
+
+