Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1569 from fameandpartners/fix/spree-options-types…
…-form [Feature] Assign new colors for the products in the admin area
- Loading branch information
Showing
23 changed files
with
240 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('4') | ||
Rack::Utils.multipart_part_limit = 300 | ||
else | ||
puts '------------------------------------------------------------------------------------------------------' | ||
puts 'Rails is on its 4 version! Upgrade Rack to its latest version to solve rack/rack#814, "Too many open files"' | ||
puts '------------------------------------------------------------------------------------------------------' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
engines/admin_ui/app/assets/javascripts/admin_ui/chosen.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$ -> | ||
# enable chosen js | ||
$('.chosen-select').chosen | ||
allow_single_deselect: true | ||
no_results_text: 'No results matched' | ||
width: '400px' | ||
|
16 changes: 16 additions & 0 deletions
16
engines/admin_ui/app/assets/javascripts/admin_ui/create_color_options.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$ -> | ||
urlTemplate = '/fame_admin/product_colors/colors_options/:product_id' | ||
productSelect = $('#product_color_value_product_id') | ||
colorSelect = $('#product_color_value_option_value_id') | ||
|
||
productSelect.on 'change', => | ||
colorSelect.html('<option></option>') | ||
url = urlTemplate.replace(/:product_id/, productSelect.val()) if productSelect.val() | ||
if url | ||
$.getJSON url, (data) => | ||
$.each data['product_colors'], (index, el) => | ||
colorSelect.append "<option value='#{el.id}'>#{el.name}</option>" | ||
colorSelect.trigger("chosen:updated") | ||
else | ||
colorSelect.trigger("chosen:updated") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
engines/admin_ui/app/assets/stylesheets/admin_ui/pages.css.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
|
||
.pages { | ||
.btn.save { | ||
margin-right:1em; | ||
} | ||
} | ||
|
||
.ibox-content.colors { | ||
height: 280px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
engines/admin_ui/app/views/admin_ui/product_colors/index.html.slim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
- content_for :page_title do | ||
| Colors variants | ||
|
||
= render 'admin_ui/grid/grid_collection_filters', collection_url: product_colors_path | ||
= link_to 'Add new color to product', new_product_color_path, class: 'btn btn-primary' | ||
br | ||
= render 'admin_ui/grid/paginated_collection_grid' |
23 changes: 23 additions & 0 deletions
23
engines/admin_ui/app/views/admin_ui/product_colors/new.html.slim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.pages.wrapper.wrapper-content | ||
= form_for @product_color_value, :url => {:action => "create"}, method: :post, :html => {:class => 'form-horizontal'} do |f| | ||
.ibox.float-e-margins | ||
.ibox-title | ||
h5 Add new color to the product | ||
.ibox-content | ||
.form-group | ||
label.col-sm-2.control-label Product | ||
.col-sm-10 = f.collection_select :product_id, products, :id, :name_with_sku, | ||
{ include_blank: true }, { class: 'chosen-select', data: { selectable_target: '#product_color_value_option_value_id' }} | ||
.form-group | ||
label.col-sm-2.control-label Colors Options | ||
.col-sm-10 = f.collection_select :option_value_id, color_options, :id, :name, { include_blank: true }, { class: 'chosen-select' } | ||
.form-group | ||
label.col-sm-2.control-label Active | ||
.col-sm-10 = f.check_box :active | ||
.form-group | ||
label.col-sm-2.control-label Custom | ||
.col-sm-10 = f.check_box :custom | ||
.form-group | ||
.col-sm-2 | ||
.col-sm-10 | ||
= f.submit 'Create', class: 'btn btn-primary' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Feature: Assign colors to products | ||
|
||
Background: | ||
Given A sample database with valid data | ||
And The example admin is signed in | ||
|
||
@javascript | ||
Scenario: | ||
When I am on the product colors page | ||
And I click on "Add new color to product" link | ||
And I select "Connie" product from chosen select box | ||
And I select "Coral" color from chosen select box | ||
And I click on "Create" button | ||
Then I should see "Color 'coral' for the product 'Connie' successfully created" | ||
|
||
Scenario: | ||
When I am on the product colors page | ||
And I click on "Add new color to product" link | ||
And I select "Connie" product from chosen select box | ||
And I click on "Create" button | ||
Then I should see "can't be blank" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Acceptance | ||
module AdminSteps | ||
step 'The example admin is signed in' do | ||
visit '/login' | ||
fill_in('Email', with: 'admin@example.com') | ||
fill_in('Password', with: '123456') | ||
click_button 'Login' | ||
visit '/fame_admin' | ||
expect(page).to have_text('Welcome to #new Admin') | ||
end | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include Acceptance::AdminSteps, type: :feature | ||
end |
Oops, something went wrong.