Skip to content

Commit

Permalink
Merge pull request #4074 from HugsDaniel/defacepocalypse
Browse files Browse the repository at this point in the history
[Defacepocalypse] De-deface product properties index
  • Loading branch information
luisramos0 authored Aug 28, 2019
2 parents cd263b7 + 7d21d88 commit 265e76e
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 38 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/admin/select2.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.select2-container {
.select2-choice {
.select2-search-choice-close {
display: none;
display: none !important;
}
.select2-arrow {
width: 22px;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%tr.product_property.fields{"data-hook" => "product_property", id: "spree_#{dom_id(f.object)}"}
%td.no-border
%span.handle
= f.hidden_field :id
%td.property_name
- if spree_current_user.admin?
= f.text_field :property_name, class: 'autocomplete'
- else
= f.select :property_name, @properties, { include_blank: true }, { class: 'select2 fullwidth' }
%td.value
= f.text_field :value, class: 'autocomplete'
%td.actions
- if f.object.persisted?
= link_to_delete f.object, no_text: true
71 changes: 71 additions & 0 deletions app/views/spree/admin/product_properties/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
= render partial: 'spree/admin/shared/product_sub_menu'

= render partial: 'spree/admin/shared/product_tabs', locals: { current: 'Product Properties' }

= render partial: 'spree/shared/error_messages', locals: { target: @product }

- content_for :page_actions do
%ul.tollbar.inline-menu
%li
= link_to_add_fields Spree.t(:add_product_properties), 'tbody#product_properties', class: 'icon-plus button'
%li
%span#new_ptype_link
= link_to Spree.t(:select_from_prototype), available_admin_prototypes_url, remote: true, 'data-update' => 'prototypes', class: 'button icon-copy'

= form_for @product, url: admin_product_url(@product), method: :put do |f|
%fieldset.no-border-top
.add_product_properties
#prototypes
= image_tag 'select2-spinner.gif', plugin: 'spree', style: 'display:none;', id: 'busy_indicator'

%table.index.sortable{"data-sortable-link" => update_positions_admin_product_product_properties_url}
%thead
%tr
%th.no-border
%th= t('admin.products.properties.property_name')
%th= t('admin.description')
%th.actions
%tbody#product_properties
= f.fields_for :product_properties do |pp_form|
= render partial: 'product_property_fields', locals: { f: pp_form }
= f.check_box :inherits_properties
= f.label :inherits_properties, t(".inherits_properties_checkbox_hint", supplier: @product.supplier.name)
%br
%br
#inherited_properties
%table.index
%thead
%tr
%th= t('admin.products.properties.inherited_property')
%th= t('admin.description')
%th.actions
%tbody#producer_properties
- @product.supplier.producer_properties.each do |producer_property|
%tr
%td= producer_property.property.presentation
%td= producer_property.value
%td.actions
= render partial: 'spree/admin/shared/edit_resource_links'
= hidden_field_tag 'clear_product_properties', 'true'
:coffee
$(document).ready ->
$("#inherited_properties").toggle $("input#product_inherits_properties").is(':checked')
$("input#product_inherits_properties").change ->
$("#inherited_properties").toggle $(this).is(':checked')

:javascript
var properties = #{raw(@properties.to_json)};
$("#product_properties input.autocomplete").live("keydown", function(){
already_auto_completed = $(this).is('ac_input');
if (!already_auto_completed) {
$(this).autocomplete({source: properties});
$(this).focus();
}
});
4 changes: 4 additions & 0 deletions app/views/spree/admin/shared/_edit_resource_links.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.form-buttons.filter-actions.actions
= button Spree.t('actions.update'), 'icon-refresh'
%span.or= Spree.t(:or)
= button_link_to Spree.t('actions.cancel'), collection_url, icon: 'icon-remove'
6 changes: 6 additions & 0 deletions app/views/spree/admin/shared/_product_sub_menu.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- content_for :sub_menu do
%ul#sub_nav.inline-menu
= tab :products, match_path: '/products'
= tab :option_types, match_path: '/option_types'
= tab :properties
= tab :prototypes
11 changes: 11 additions & 0 deletions app/views/spree/shared/_error_messages.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- if target && target.errors.any?
#errorExplanation.errorExplanation
%h2
= Spree.t(:errors_prohibited_this_record_from_being_saved, count: target.errors.count)
\:
%p
= Spree.t(:there_were_problems_with_the_following_fields)
\:
%ul
- target.errors.full_messages.each do |msg|
%li= msg

0 comments on commit 265e76e

Please sign in to comment.