From 3a14a26bc65edc8f08dfd595beb651e5de48103d Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 1 Oct 2014 16:07:10 +1000 Subject: [PATCH] refactor wysiwyg --- .../enterprises/controllers/enterprise_controller.js.coffee | 5 ++--- app/assets/stylesheets/admin/openfoodnetwork.css.scss | 2 +- app/helpers/admin/injection_helper.rb | 4 ++++ app/views/admin/enterprises/_form.html.haml | 4 +--- app/views/admin/enterprises/_ng_form.html.haml | 1 + 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee index 4b710dda85..46eb4a84c1 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee @@ -1,10 +1,9 @@ angular.module("admin.enterprises") - .controller "enterpriseCtrl", ($scope, Enterprise, PaymentMethods, ShippingMethods) -> + .controller "enterpriseCtrl", ($scope, Enterprise, longDescription, PaymentMethods, ShippingMethods) -> $scope.Enterprise = Enterprise.enterprise $scope.PaymentMethods = PaymentMethods.paymentMethods $scope.ShippingMethods = ShippingMethods.shippingMethods - $scope.htmlVariable = Enterprise.enterprise.long_description - + $scope.htmlVariable = longDescription for payment_method in $scope.PaymentMethods payment_method.selected = payment_method.id in $scope.Enterprise.payment_method_ids diff --git a/app/assets/stylesheets/admin/openfoodnetwork.css.scss b/app/assets/stylesheets/admin/openfoodnetwork.css.scss index 8b07d1a368..8ad03d8259 100644 --- a/app/assets/stylesheets/admin/openfoodnetwork.css.scss +++ b/app/assets/stylesheets/admin/openfoodnetwork.css.scss @@ -211,7 +211,7 @@ table#listing_enterprise_groups { } // textAngular wysiwyg -.text-angular .btn-group { +text-angular .btn-group { display: inline; margin-right: 8px; button { diff --git a/app/helpers/admin/injection_helper.rb b/app/helpers/admin/injection_helper.rb index 7fec829fe7..bba4d6bc3f 100644 --- a/app/helpers/admin/injection_helper.rb +++ b/app/helpers/admin/injection_helper.rb @@ -41,6 +41,10 @@ module Admin render partial: "admin/json/injection_ams", locals: {ngModule: 'ofn.admin', name: 'SpreeApiKey', json: "'#{@spree_api_key.to_s}'"} end + def admin_inject_enterprise_long_description + render partial: "admin/json/injection_ams", locals: {ngModule: 'admin.enterprises', name: 'longDescription', json: "'#{@enterprise.long_description.to_s}'"} + end + def admin_inject_json_ams(ngModule, name, data, serializer, opts = {}) json = serializer.new(data).to_json diff --git a/app/views/admin/enterprises/_form.html.haml b/app/views/admin/enterprises/_form.html.haml index 729c16eb53..921807b425 100644 --- a/app/views/admin/enterprises/_form.html.haml +++ b/app/views/admin/enterprises/_form.html.haml @@ -187,11 +187,9 @@ -# ['bold', 'italics', 'underline', 'strikeThrough', 'ul', 'ol', 'redo', 'undo', 'clear'], -# ['justifyLeft','justifyCenter','justifyRight','indent','outdent'], -# ['html', 'insertImage', 'insertLink', 'insertVideo'] - %text-angular{'ng-model' => 'htmlVariable', 'class' => 'text-angular', + %text-angular{'ng-model' => 'htmlVariable', 'id' => 'enterprise_long_description', 'name' => 'enterprise[long_description]', 'class' => 'text-angular', 'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]", 'placeholder' => 'Tell customers about yourself. This information appears on your public profile.'} - -# Use a hidden rails form field bound to the textAngular wysiwit field above, using the htmlVariable model. So rails knows to save it. - = f.text_area :long_description, rows: 6, 'ng-model' => 'htmlVariable', 'hidden' => 'true' %fieldset.eleven.columns.alpha.no-border-bottom %legend IMAGES .row diff --git a/app/views/admin/enterprises/_ng_form.html.haml b/app/views/admin/enterprises/_ng_form.html.haml index 0ccd963d31..18e9d6ed36 100644 --- a/app/views/admin/enterprises/_ng_form.html.haml +++ b/app/views/admin/enterprises/_ng_form.html.haml @@ -1,4 +1,5 @@ = admin_inject_enterprise += admin_inject_enterprise_long_description = admin_inject_payment_methods = admin_inject_shipping_methods