From 209c9242d96b914fe68252df03abb9cc8488753d Mon Sep 17 00:00:00 2001 From: Keir Osborn Date: Wed, 11 Jan 2017 02:39:58 +0000 Subject: [PATCH 01/22] remove word-wrap class from enterprise.email_address and enterprise.website in javascripts/templates/partials/contact.html.haml --- app/assets/javascripts/templates/partials/contact.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/templates/partials/contact.html.haml b/app/assets/javascripts/templates/partials/contact.html.haml index d173bcf366..9779dd0f3e 100644 --- a/app/assets/javascripts/templates/partials/contact.html.haml +++ b/app/assets/javascripts/templates/partials/contact.html.haml @@ -3,9 +3,9 @@ %p.modal-header {{'contact' | t}} %p{"ng-if" => "::enterprise.phone", "ng-bind" => "::enterprise.phone"} - %p.word-wrap{"ng-if" => "::enterprise.email_address"} + %p{"ng-if" => "::enterprise.email_address"} %a{"ng-href" => "{{::enterprise.email_address | stripUrl}}", target: "_blank", mailto: true} %span.email{"ng-bind" => "::enterprise.email_address | stripUrl"} - %p.word-wrap{"ng-if" => "enterprise.website"} + %p{"ng-if" => "enterprise.website"} %a{"ng-href" => "http://{{::enterprise.website | stripUrl}}", target: "_blank", "ng-bind" => "::enterprise.website | stripUrl"} From e8999d23e1e8006193203be500a7a1e863089fdd Mon Sep 17 00:00:00 2001 From: Lynne Davis Date: Fri, 9 Dec 2016 12:07:45 +0000 Subject: [PATCH 02/22] Updated translations --- ...dd_producer_properties_warning_and_table.html.haml.deface | 4 ++-- .../index/rename_form_headings.html.haml.deface | 5 +++++ config/locales/en.yml | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface diff --git a/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface b/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface index 8d2e598c43..c31a74b9e4 100644 --- a/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface +++ b/app/overrides/spree/admin/product_properties/index/add_producer_properties_warning_and_table.html.haml.deface @@ -9,8 +9,8 @@ %table.index %thead %tr{"data-hook" => "producer_properties_header"} - %th= t(:inherited_property) - %th= t(:value) + %th= t('admin.products.properties.inherited_property') + %th= t('admin.description') %th.actions %tbody#producer_properties{"data-hook" => ""} - @product.supplier.producer_properties.each do |producer_property| diff --git a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface new file mode 100644 index 0000000000..fd40c7bca1 --- /dev/null +++ b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface @@ -0,0 +1,5 @@ +/ replace "tr[data-hook='product_properties_header']" +%tr{"data-hook" => "product_properties_header"} + %th{:colspan => "2"}= t('admin.products.properties.property_name') + %th= t('admin.description') + %th.actions \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 475942a692..962b02e908 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -109,6 +109,7 @@ en: columns: Columns actions: Actions viewing: "Viewing: %{current_view_name}" + description: Description whats_this: What's this? @@ -225,6 +226,9 @@ en: av_on: "Av. On" variants: to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order." + properties: + property_name: Property Name + inherited_property: Inherited Property variant_overrides: loading_flash: From 429ef4e2baee8ed408d73fbcf896bf248ce33354 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Mon, 21 Nov 2016 14:46:02 +0000 Subject: [PATCH 03/22] Altered product property headings for issue #522 --- .../index/rename_form_headings.html.haml.deface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface index fd40c7bca1..fb3c7d0dcc 100644 --- a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface +++ b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface @@ -2,4 +2,4 @@ %tr{"data-hook" => "product_properties_header"} %th{:colspan => "2"}= t('admin.products.properties.property_name') %th= t('admin.description') - %th.actions \ No newline at end of file + %th.actions From 0d5fde919b18337235dad190aeb61f455af8a5bd Mon Sep 17 00:00:00 2001 From: Lynne Davis Date: Fri, 24 Feb 2017 09:24:33 +0000 Subject: [PATCH 04/22] Property name spans signle col heading --- .../index/rename_form_headings.html.haml.deface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface index fb3c7d0dcc..011580c1bb 100644 --- a/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface +++ b/app/overrides/spree/admin/product_properties/index/rename_form_headings.html.haml.deface @@ -1,5 +1,5 @@ / replace "tr[data-hook='product_properties_header']" %tr{"data-hook" => "product_properties_header"} - %th{:colspan => "2"}= t('admin.products.properties.property_name') + %th= t('admin.products.properties.property_name') %th= t('admin.description') %th.actions From a94961c0a71fdf3147f30df887b6457d958d67e9 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 29 Mar 2017 14:58:19 +1100 Subject: [PATCH 05/22] Fixup merge conflicts and remove unused text --- app/views/admin/producer_properties/_form.html.haml | 4 ++-- config/locales/en.yml | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/views/admin/producer_properties/_form.html.haml b/app/views/admin/producer_properties/_form.html.haml index 249301ae40..7af322557d 100644 --- a/app/views/admin/producer_properties/_form.html.haml +++ b/app/views/admin/producer_properties/_form.html.haml @@ -4,8 +4,8 @@ %table.index.sortable{"data-hook" => "", "data-sortable-link" => main_app.update_positions_admin_enterprise_producer_properties_url(@enterprise)} %thead %tr{"data-hook" => "producer_properties_header"} - %th{colspan: "2"}= t('.property') - %th= t('.value') + %th{colspan: "2"}= t('admin.products.properties.property_name') + %th= t('admin.description') %th.actions %tbody#producer_properties{"data-hook" => ""} = f.fields_for :producer_properties do |pp_form| diff --git a/config/locales/en.yml b/config/locales/en.yml index 962b02e908..63eff8f8f2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -224,11 +224,11 @@ en: inherits_properties?: Inherits Properties? available_on: Available On av_on: "Av. On" - variants: - to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order." properties: property_name: Property Name inherited_property: Inherited Property + variants: + to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order." variant_overrides: loading_flash: @@ -507,9 +507,6 @@ en: advanced_settings: Advanced Settings update_and_close: Update and Close producer_properties: - form: - property: Property - value: Value index: title: Producer Properties shared: From e94ae20b3188029a7e5f10397032dbf8ca1d4d4a Mon Sep 17 00:00:00 2001 From: Pierre de Lacroix Date: Wed, 29 Mar 2017 12:21:41 +0200 Subject: [PATCH 06/22] fix print_ticket authorization --- app/models/spree/ability_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index e49db570cb..3814365447 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -175,7 +175,7 @@ class AbilityDecorator def add_order_management_abilities(user) # Enterprise User can only access orders that they are a distributor for can [:index, :create], Spree::Order - can [:read, :update, :fire, :resend, :invoice, :print], Spree::Order do |order| + can [:read, :update, :fire, :resend, :invoice, :print, :print_ticket], Spree::Order do |order| # We allow editing orders with a nil distributor as this state occurs # during the order creation process from the admin backend order.distributor.nil? || user.enterprises.include?(order.distributor) || order.order_cycle.andand.coordinated_by?(user) From 268bea25d0cab3a34651e41b2aac32e9504d231e Mon Sep 17 00:00:00 2001 From: Pierre de Lacroix Date: Thu, 30 Mar 2017 20:32:11 +0200 Subject: [PATCH 07/22] add qz/ folder from ofn-qz gem to list of assets --- config/application.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/application.rb b/config/application.rb index f9d6151e10..82191824ca 100644 --- a/config/application.rb +++ b/config/application.rb @@ -105,6 +105,7 @@ module Openfoodnetwork config.assets.precompile += ['mail/all.css'] config.assets.precompile += ['search/all.css', 'search/*.js'] config.assets.precompile += ['shared/*'] + config.assets.precompile += ['qz/*'] config.active_support.escape_html_entities_in_json = true end From c43dea60b7c2e22330bd9ca6011a93227d87fd36 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Thu, 17 Nov 2016 13:27:21 +0000 Subject: [PATCH 08/22] Product Descriptions formatting --- app/assets/javascripts/admin/products/products.js.coffee | 2 +- app/assets/javascripts/templates/product_modal.html.haml | 1 + app/assets/stylesheets/admin/openfoodnetwork.css.scss | 8 ++++++++ .../_form/add_description_wysiwyg.html.haml.deface | 2 ++ .../admin/products/new/replace_form.html.haml.deface | 2 +- app/serializers/api/product_serializer.rb | 2 +- 6 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface diff --git a/app/assets/javascripts/admin/products/products.js.coffee b/app/assets/javascripts/admin/products/products.js.coffee index 1952c8dded..402db8b7ff 100644 --- a/app/assets/javascripts/admin/products/products.js.coffee +++ b/app/assets/javascripts/admin/products/products.js.coffee @@ -1 +1 @@ -angular.module("admin.products", ["admin.utils"]) \ No newline at end of file +angular.module("admin.products", ["textAngular", "admin.utils"]) \ No newline at end of file diff --git a/app/assets/javascripts/templates/product_modal.html.haml b/app/assets/javascripts/templates/product_modal.html.haml index 4b21c054a4..8eeab88a0f 100644 --- a/app/assets/javascripts/templates/product_modal.html.haml +++ b/app/assets/javascripts/templates/product_modal.html.haml @@ -17,6 +17,7 @@ %div{"ng-if" => "product.description"} %hr %p.text-small{"ng-bind" => "::product.description"} + {{product.description}} %hr .columns.small-12.large-6 diff --git a/app/assets/stylesheets/admin/openfoodnetwork.css.scss b/app/assets/stylesheets/admin/openfoodnetwork.css.scss index 4b5703d317..4c16feb3c0 100644 --- a/app/assets/stylesheets/admin/openfoodnetwork.css.scss +++ b/app/assets/stylesheets/admin/openfoodnetwork.css.scss @@ -200,6 +200,13 @@ table#listing_enterprise_groups { // textAngular wysiwyg text-angular { + .ta-toolbar { + border: 1px solid #cdd9e4; + padding: 0.4em; + margin-bottom: -1px; + background-color: #f1f1f1; + border-radius: 0.25em 0.25em 0 0; + } .ta-scroll-window > .ta-bind { max-height: 400px; min-height: 100px; @@ -216,6 +223,7 @@ text-angular { margin-right: 8px; button { padding: 5px 10px; + margin-right: 0.25em; } } } diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface new file mode 100644 index 0000000000..fca5a217d0 --- /dev/null +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -0,0 +1,2 @@ +/ replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" + \ No newline at end of file diff --git a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface index 3fd5a74cb1..73347a78ef 100644 --- a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface +++ b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface @@ -72,7 +72,7 @@ = f.field_container :description do = f.label :product_description, t(:product_description) %br/ - = f.text_area :description, class: 'fullwidth', rows: 3 + %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear'],['insertLink']]"} = f.error_message_on :description .four.columns.omega{ style: "text-align: center" } %fieldset.no-border-bottom{ id: "image" } diff --git a/app/serializers/api/product_serializer.rb b/app/serializers/api/product_serializer.rb index aa353173dc..1e612f59f5 100644 --- a/app/serializers/api/product_serializer.rb +++ b/app/serializers/api/product_serializer.rb @@ -50,7 +50,7 @@ class Api::CachedProductSerializer < ActiveModel::Serializer has_one :supplier, serializer: Api::IdSerializer def description - strip_tags object.description + sanitize(object.description, options = {tags: "p, b, strong, em, i"}).html_safe end def properties_with_values From b38eab11eb53edc4178666fb9da6edc1ead86654 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Thu, 17 Nov 2016 14:46:00 +0000 Subject: [PATCH 09/22] Fixed frontend HTML display --- .../javascripts/templates/product_modal.html.haml | 5 ++--- app/serializers/api/product_serializer.rb | 11 +++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/templates/product_modal.html.haml b/app/assets/javascripts/templates/product_modal.html.haml index 8eeab88a0f..f0c77c44c0 100644 --- a/app/assets/javascripts/templates/product_modal.html.haml +++ b/app/assets/javascripts/templates/product_modal.html.haml @@ -14,10 +14,9 @@ .filter-shopfront.property-selectors.inline-block %filter-selector{ 'selector-set' => "productPropertySelectors", objects: "[product] | propertiesWithValuesOf" } - %div{"ng-if" => "product.description"} + %div{"ng-if" => "product.description_html"} %hr - %p.text-small{"ng-bind" => "::product.description"} - {{product.description}} + %p.text-small{"ng-bind-html" => "product.description_html"} %hr .columns.small-12.large-6 diff --git a/app/serializers/api/product_serializer.rb b/app/serializers/api/product_serializer.rb index 1e612f59f5..7b371c5be1 100644 --- a/app/serializers/api/product_serializer.rb +++ b/app/serializers/api/product_serializer.rb @@ -37,7 +37,7 @@ class Api::CachedProductSerializer < ActiveModel::Serializer include ActionView::Helpers::SanitizeHelper attributes :id, :name, :permalink - attributes :on_demand, :group_buy, :notes, :description + attributes :on_demand, :group_buy, :notes, :description, :description_html attributes :properties_with_values has_many :variants, serializer: Api::VariantSerializer @@ -49,8 +49,15 @@ class Api::CachedProductSerializer < ActiveModel::Serializer has_many :images, serializer: Api::ImageSerializer has_one :supplier, serializer: Api::IdSerializer + #return an unformatted descripton def description - sanitize(object.description, options = {tags: "p, b, strong, em, i"}).html_safe + strip_tags object.description + end + + #return a sanitized html description + def description_html + d = sanitize(object.description, options = {tags: "p, b, strong, em, i"}) + d.to_s.html_safe end def properties_with_values From 3591354cb183f1ba7f51ac7362f006932b74eef3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Thu, 17 Nov 2016 15:04:57 +0000 Subject: [PATCH 10/22] Minor tweaks --- .../products/_form/add_description_wysiwyg.html.haml.deface | 2 +- .../spree/admin/products/new/replace_form.html.haml.deface | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface index fca5a217d0..477c168467 100644 --- a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -1,2 +1,2 @@ / replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" - \ No newline at end of file +%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear']]"} \ No newline at end of file diff --git a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface index 73347a78ef..d91c775293 100644 --- a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface +++ b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface @@ -72,7 +72,7 @@ = f.field_container :description do = f.label :product_description, t(:product_description) %br/ - %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear'],['insertLink']]"} + %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear']]"} = f.error_message_on :description .four.columns.omega{ style: "text-align: center" } %fieldset.no-border-bottom{ id: "image" } From fcb9e9fa56ee25f9839bfb99265a730b7b6da297 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Thu, 17 Nov 2016 15:09:41 +0000 Subject: [PATCH 11/22] Changed buttons --- .../products/_form/add_description_wysiwyg.html.haml.deface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface index 477c168467..6b0d5dd7f3 100644 --- a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -1,2 +1,2 @@ / replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" -%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear']]"} \ No newline at end of file +%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear']]"} \ No newline at end of file From 0e91d0141271d022daa14334a709d9ffe33b618a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sun, 20 Nov 2016 23:20:37 +0000 Subject: [PATCH 12/22] UX improvement for selected formatting options --- app/assets/stylesheets/admin/openfoodnetwork.css.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/stylesheets/admin/openfoodnetwork.css.scss b/app/assets/stylesheets/admin/openfoodnetwork.css.scss index 4c16feb3c0..836d31b9fd 100644 --- a/app/assets/stylesheets/admin/openfoodnetwork.css.scss +++ b/app/assets/stylesheets/admin/openfoodnetwork.css.scss @@ -217,6 +217,7 @@ text-angular { } .ta-scroll-window.form-control { min-height: 100px; + box-shadow: none !important; } .btn-group { display: inline; @@ -225,6 +226,10 @@ text-angular { padding: 5px 10px; margin-right: 0.25em; } + button.active:not(:hover) { + box-shadow: 0 0 0.7em rgba(0,0,0,0.3) inset; + background-color: #4583bf; + } } } From c4bd085393dfce88f187d040d0c8a1f247130a8b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sun, 27 Nov 2016 14:25:12 +0000 Subject: [PATCH 13/22] Added Angular and textAngular to edit product page --- .../products/_form/add_description_wysiwyg.html.haml.deface | 3 ++- app/overrides/spree/admin/products/edit/add_angular.deface | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 app/overrides/spree/admin/products/edit/add_angular.deface diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface index 6b0d5dd7f3..40811cfdd8 100644 --- a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -1,2 +1,3 @@ / replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" -%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear']]"} \ No newline at end of file +%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear']]"} + != @product[:description].to_s.html_safe \ No newline at end of file diff --git a/app/overrides/spree/admin/products/edit/add_angular.deface b/app/overrides/spree/admin/products/edit/add_angular.deface new file mode 100644 index 0000000000..926c47c0ec --- /dev/null +++ b/app/overrides/spree/admin/products/edit/add_angular.deface @@ -0,0 +1,2 @@ +add_to_attributes 'fieldset.no-border-top' +attributes 'ng-app' => 'admin.products' \ No newline at end of file From fdcd3dc3e36d5131bb9475e63774c2f49dd67d23 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sun, 27 Nov 2016 15:45:36 +0000 Subject: [PATCH 14/22] Fixed Capybara not interacting with textAngular --- spec/features/admin/products_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 2d5e4dcbe8..c88b7d22bb 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -35,7 +35,7 @@ feature %q{ fill_in 'product_on_hand', with: 5 select 'Test Tax Category', from: 'product_tax_category_id' select 'Test Shipping Category', from: 'product_shipping_category_id' - fill_in 'product_description', with: "A description..." + page.find("input[name='product\[description\]']", visible: false).set('A description...') click_button 'Create' From 5808b601b87671865bc3b29062a0d83331c7e62b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sun, 27 Nov 2016 16:43:04 +0000 Subject: [PATCH 15/22] Added specs for HTML product description --- .../consumer/shopping/products_spec.rb | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 spec/features/consumer/shopping/products_spec.rb diff --git a/spec/features/consumer/shopping/products_spec.rb b/spec/features/consumer/shopping/products_spec.rb new file mode 100644 index 0000000000..cc827898c6 --- /dev/null +++ b/spec/features/consumer/shopping/products_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' + +feature "As a consumer I want to view products", js: true do + include AuthenticationWorkflow + include WebHelper + include ShopWorkflow + include UIComponentHelper + + describe "Viewing a product" do + + let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) } + let(:supplier) { create(:supplier_enterprise) } + let(:oc1) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), orders_close_at: 2.days.from_now) } + let(:product) { create(:simple_product, supplier: supplier) } + let(:variant) { product.variants.first } + let(:order) { create(:order, distributor: distributor) } + let(:exchange1) { oc1.exchanges.to_enterprises(distributor).outgoing.first } + + before do + set_order order + end + + describe "viewing HTML product descriptions" do + + before do + exchange1.update_attribute :pickup_time, "monday" + add_variant_to_order_cycle(exchange1, variant) + end + + it "shows HTML product description" do + + product.description = "

Formatted product description.

" + product.save! + + visit shop_path + select "monday", :from => "order_cycle_id" + + open_product_modal product + modal_should_be_open_for product + + within(".reveal-modal") do + html.should include("

Formatted product description.

") + end + + end + + it "does not show unsecure HTML" do + + product.description = "

Safe

" + product.save! + + visit shop_path + select "monday", :from => "order_cycle_id" + + open_product_modal product + modal_should_be_open_for product + + within(".reveal-modal") do + html.should include("

Safe

") + html.should_not include("") + end + + end + + end + end +end \ No newline at end of file From 7b370a2eb6b1067d7dc6d5683af7552d9af1dfca Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Wed, 30 Nov 2016 12:05:28 +0000 Subject: [PATCH 16/22] Removed underline option --- .../products/_form/add_description_wysiwyg.html.haml.deface | 2 +- .../spree/admin/products/new/replace_form.html.haml.deface | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface index 40811cfdd8..df61d16cd3 100644 --- a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -1,3 +1,3 @@ / replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" -%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear']]"} +%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','clear']]"} != @product[:description].to_s.html_safe \ No newline at end of file diff --git a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface index d91c775293..9013939daf 100644 --- a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface +++ b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface @@ -72,7 +72,7 @@ = f.field_container :description do = f.label :product_description, t(:product_description) %br/ - %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','underline','clear']]"} + %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','clear']]"} = f.error_message_on :description .four.columns.omega{ style: "text-align: center" } %fieldset.no-border-bottom{ id: "image" } From b04d8154085f10c10f0578df1b2e8f9fbf78d245 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sat, 17 Dec 2016 17:49:43 +0000 Subject: [PATCH 17/22] Changes for code review Fixed spec --- app/assets/javascripts/templates/product_modal.html.haml | 2 +- spec/features/admin/products_spec.rb | 3 ++- spec/features/consumer/shopping/products_spec.rb | 7 ------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/templates/product_modal.html.haml b/app/assets/javascripts/templates/product_modal.html.haml index f0c77c44c0..6282bc439e 100644 --- a/app/assets/javascripts/templates/product_modal.html.haml +++ b/app/assets/javascripts/templates/product_modal.html.haml @@ -16,7 +16,7 @@ %div{"ng-if" => "product.description_html"} %hr - %p.text-small{"ng-bind-html" => "product.description_html"} + %p.text-small{"ng-bind-html" => "::product.description_html"} %hr .columns.small-12.large-6 diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index c88b7d22bb..2cebd58dce 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -75,7 +75,8 @@ feature %q{ check 'product_on_demand' select 'Test Tax Category', from: 'product_tax_category_id' select 'Test Shipping Category', from: 'product_shipping_category_id' - fill_in 'product_description', with: "In demand, and on_demand! The hottest cakes in town." + #fill_in 'product_description', with: "In demand, and on_demand! The hottest cakes in town." + page.first("input[name='product\[description\]']", visible: false).set('In demand, and on_demand! The hottest cakes in town.') click_button 'Create' diff --git a/spec/features/consumer/shopping/products_spec.rb b/spec/features/consumer/shopping/products_spec.rb index cc827898c6..d8b0c2b792 100644 --- a/spec/features/consumer/shopping/products_spec.rb +++ b/spec/features/consumer/shopping/products_spec.rb @@ -7,7 +7,6 @@ feature "As a consumer I want to view products", js: true do include UIComponentHelper describe "Viewing a product" do - let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) } let(:supplier) { create(:supplier_enterprise) } let(:oc1) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), orders_close_at: 2.days.from_now) } @@ -21,14 +20,12 @@ feature "As a consumer I want to view products", js: true do end describe "viewing HTML product descriptions" do - before do exchange1.update_attribute :pickup_time, "monday" add_variant_to_order_cycle(exchange1, variant) end it "shows HTML product description" do - product.description = "

Formatted product description.

" product.save! @@ -41,11 +38,9 @@ feature "As a consumer I want to view products", js: true do within(".reveal-modal") do html.should include("

Formatted product description.

") end - end it "does not show unsecure HTML" do - product.description = "

Safe

" product.save! @@ -59,9 +54,7 @@ feature "As a consumer I want to view products", js: true do html.should include("

Safe

") html.should_not include("") end - end - end end end \ No newline at end of file From 05cf8c4351b26c3f7e98fc20f2b7a4b9b4fd18f4 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 31 Mar 2017 12:49:19 +1100 Subject: [PATCH 18/22] Sanitizing product description for textAngular input --- .../products/_form/add_description_wysiwyg.html.haml.deface | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface index df61d16cd3..71d3e43f9c 100644 --- a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -1,3 +1,3 @@ / replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" -%text-angular{'id' => 'product_description', 'ng-model' => 'product.description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','clear']]"} - != @product[:description].to_s.html_safe \ No newline at end of file +%text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','clear']]"} + = sanitize(@product.description) From cd55d2e2ffeafa87b237ff2f7ed064b65127c08d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sat, 1 Apr 2017 14:55:51 +0100 Subject: [PATCH 19/22] Product Description - strip weird tags on paste squashme --- .../admin/utils/directives/textangular_strip.js.coffee | 5 +++++ .../products/_form/add_description_wysiwyg.html.haml.deface | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/admin/utils/directives/textangular_strip.js.coffee diff --git a/app/assets/javascripts/admin/utils/directives/textangular_strip.js.coffee b/app/assets/javascripts/admin/utils/directives/textangular_strip.js.coffee new file mode 100644 index 0000000000..8e60221376 --- /dev/null +++ b/app/assets/javascripts/admin/utils/directives/textangular_strip.js.coffee @@ -0,0 +1,5 @@ +angular.module("admin.utils").directive "textangularStrip", () -> + restrict: 'CA' + link: (scope, element, attrs) -> + scope.stripFormatting = ($html) -> + return String($html).replace(/<[^>]+>/gm, '') diff --git a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface index 71d3e43f9c..d04e787482 100644 --- a/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface +++ b/app/overrides/spree/admin/products/_form/add_description_wysiwyg.html.haml.deface @@ -1,3 +1,3 @@ / replace "[data-hook=admin_product_form_left] code[erb-loud]:contains('f.text_area :description')" -%text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','clear']]"} +%text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'textangular-strip' => true, 'ta-paste' => "stripFormatting($html)", 'ta-toolbar' => "[['bold','italics','clear']]"} = sanitize(@product.description) From 903d1afb5334bfeb7eafee61481f8da439459122 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 5 Apr 2017 14:29:23 +1000 Subject: [PATCH 20/22] Stripping html tags from products description on new form as well --- .../spree/admin/products/new/replace_form.html.haml.deface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface index 9013939daf..01894a8965 100644 --- a/app/overrides/spree/admin/products/new/replace_form.html.haml.deface +++ b/app/overrides/spree/admin/products/new/replace_form.html.haml.deface @@ -72,7 +72,7 @@ = f.field_container :description do = f.label :product_description, t(:product_description) %br/ - %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'ta-toolbar' => "[['bold','italics','clear']]"} + %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'textangular-strip' => true, 'ta-paste' => "stripFormatting($html)", 'ta-toolbar' => "[['bold','italics','clear']]"} = f.error_message_on :description .four.columns.omega{ style: "text-align: center" } %fieldset.no-border-bottom{ id: "image" } From 80d8d18eb213bfc3c8f62927ecf8d8fbc4e94fa5 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley Date: Sat, 25 Mar 2017 12:53:35 +0000 Subject: [PATCH 21/22] Update terms of service config --- app/models/spree/app_configuration_decorator.rb | 1 - .../edit/tos_settings.html.haml.deface | 10 +++------- app/views/registration/steps/_introduction.html.haml | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/models/spree/app_configuration_decorator.rb b/app/models/spree/app_configuration_decorator.rb index 2dfda8949c..4f8a80bf96 100644 --- a/app/models/spree/app_configuration_decorator.rb +++ b/app/models/spree/app_configuration_decorator.rb @@ -6,7 +6,6 @@ Spree::AppConfiguration.class_eval do # Terms of Service Preferences preference :enterprises_require_tos, :boolean, default: false - preference :enterprise_tos_link, :string, default: "/Terms-of-service.pdf" # Tax Preferences preference :products_require_tax_category, :boolean, default: false diff --git a/app/overrides/spree/admin/general_settings/edit/tos_settings.html.haml.deface b/app/overrides/spree/admin/general_settings/edit/tos_settings.html.haml.deface index 9d573c3ac1..e0a588d740 100644 --- a/app/overrides/spree/admin/general_settings/edit/tos_settings.html.haml.deface +++ b/app/overrides/spree/admin/general_settings/edit/tos_settings.html.haml.deface @@ -2,10 +2,6 @@ %fieldset.enterprise_toc.no-border-bottom %legend{:align => "center"}= t(:enterprise_terms_of_service) - - [:enterprise_tos_link, :enterprises_require_tos].each do |pref| - - type = Spree::Config.preference_type(pref) - .field - = label_tag(pref, t(pref) + ': ') + tag(:br) if type != :boolean - = preference_field_tag(pref, Spree::Config[pref], :type => type) - = label_tag(pref, t(pref)) + tag(:br) if type == :boolean - + .field + = preference_field_tag(:enterprises_require_tos, Spree::Config[:enterprises_require_tos], :type => Spree::Config.preference_type(:enterprises_require_tos)) + = label_tag(:enterprises_require_tos, t(:enterprises_require_tos)) + tag(:br) diff --git a/app/views/registration/steps/_introduction.html.haml b/app/views/registration/steps/_introduction.html.haml index c663886a03..57055bc2ea 100644 --- a/app/views/registration/steps/_introduction.html.haml +++ b/app/views/registration/steps/_introduction.html.haml @@ -37,7 +37,7 @@ .small-12.columns{'ng-hide' => '!tos_required' } %p.tos-message #{t(:enterprise_tos_message)} - %a{href: "#{Spree::Config.enterprise_tos_link}", target: "_blank" } #{t(:enterprise_tos_link_text)} + %a{href: ContentConfig.footer_tos_url, target: "_blank" } #{t(:enterprise_tos_link_text)} %p.tos-checkbox %input{ type: 'checkbox', name: 'accept_terms', id: 'accept_terms', ng: { model: "tos_accepted" } } %label{for: "accept_terms"} #{t(:enterprise_tos_agree)} From c83ad2ecc43d8006c8fe60f2c7f3fb6d3f3781c2 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 5 Apr 2017 17:02:40 +1000 Subject: [PATCH 22/22] Fixing broken limited reached page in registration flow --- app/views/registration/index.html.haml | 2 +- app/views/registration/limit_reached.html.haml | 2 ++ spec/features/consumer/registration_spec.rb | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml index 4f23ac8700..fbfb0c175c 100644 --- a/app/views/registration/index.html.haml +++ b/app/views/registration/index.html.haml @@ -6,7 +6,7 @@ = inject_enterprise_attributes - steps = %w{about contact details finished images introduction} -- steps += %w{limit_reached logo promo social steps type} +- steps += %w{logo promo social steps type} - steps.each do |step| = render partial: "registration/steps/#{step}" = render "modal" diff --git a/app/views/registration/limit_reached.html.haml b/app/views/registration/limit_reached.html.haml index bfaec6da3d..35132cb769 100644 --- a/app/views/registration/limit_reached.html.haml +++ b/app/views/registration/limit_reached.html.haml @@ -1,2 +1,4 @@ += render partial: "registration/steps/limit_reached" + / Directive which loads the modal %div{ "ofn-registration-limit-modal" => true } diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index f6a90f6f61..c4e7af36ee 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -98,6 +98,23 @@ feature "Registration", js: true do expect(e.instagram).to eq "@InStAgRaM" end + context "when the user has no more remaining enterprises" do + before do + user.update_attributes(enterprise_limit: 0) + end + + it "displays the limit reached page" do + visit registration_path + + expect(page).to have_selector "dd", text: "Login" + switch_to_login_tab + + # Enter Login details + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_login_and_ensure_content I18n.t('limit_reached_headline') + end + end end describe "Terms of Service agreement" do