To add image field in shop

This commit is contained in:
San Wai Lwin
2018-03-07 12:41:49 +06:30
parent 5cc369114b
commit 9f29bbef5a
6 changed files with 149 additions and 67 deletions

View File

@@ -71,6 +71,6 @@ class Settings::ShopsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def shop_params
params.require(:shop).permit(:name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info)
params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info)
end
end

View File

@@ -1,3 +1,6 @@
class Shop < ApplicationRecord
ShopDetail = Shop.find_by_id(1)
# Shop Image Uploader
mount_uploader :logo, ShopImageUploader
end

View File

@@ -0,0 +1,59 @@
class ShopImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
def root
Rails.root.join 'public/'
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"image/shop_images"
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# def cache_dir
# '/tmp/images'
# end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url(*args)
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process scale: [200, 300]
process :resize_to_fit => [200, 150]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process resize_to_fit: [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

View File

@@ -12,7 +12,7 @@
<%= f.input :unit_price %>
<%= f.input :description %>
<%= f.input :information %>
<%= f.input:taxable %>
<%= f.input :taxable %>
</div>
<label>Product Image</label>

View File

@@ -1,68 +1,86 @@
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<%= simple_form_for([:settings,@settings_shop]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs p-l-10">
<%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%>
<%= f.input :address %>
<%= f.input :city %>
<%= f.input :township %>
<%= f.input :state %>
<%= f.input :phone_no %>
<%= f.input :reservation_no %>
<%= f.input :license %>
<%= f.input :license_data %>
<%= f.input :base_currency %>
<%= f.input :cloud_token %>
<%= f.input :cloud_url %>
<%= f.input :owner_token %>
<%= f.input :id_prefix %>
<%= f.input :is_rounding_adj %>
<%= f.input :quick_sale_summary %>
<%= f.input :calc_tax_order %>
<%= f.input :show_account_info %>
<div class="card">
<div class="body">
<%= simple_form_for([:settings,@settings_shop]) do |f| %>
<%= f.error_notification %>
<div class="form-group p-l-15">
<%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%>
<%= f.input :address %>
<%= f.input :city %>
<%= f.input :township %>
<%= f.input :state %>
<%= f.input :phone_no %>
<%= f.input :reservation_no %>
<%= f.input :license %>
<%= f.input :license_data %>
<%= f.input :base_currency %>
<%= f.input :cloud_token %>
<%= f.input :cloud_url %>
<%= f.input :owner_token %>
<%= f.input :id_prefix %>
<%= f.input :is_rounding_adj %>
<%= f.input :quick_sale_summary %>
<%= f.input :calc_tax_order %>
<%= f.input :show_account_info %>
</div>
</div>
<div class="form-actions">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div>
<% end %>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
<p>
1) address - to write shop's address <br>
2) city - to write city <br>
3) township - to write township <br>
4) state - to write state <br>
5) phone_no - to write shop's phone_no <br>
6) reservation_no - to write shop's reservation_no <br>
7) license - to write license <br>
8) license_data - to write license data <br>
9) base_currency - to write base currency <br>
10)cloud_token - to write cloud token <br>
11)cloud_url - to write cloud url <br>
12)owner_token - to write shop's owner token <br>
13)id_prefix - to write id prefix <br>
14)is_rounding_adj - to check for calculate rounding adj of shop <br>
15)quick_sale_summary - to check for view Quick Sale Summary <br>
16)calc_tax_order - to check for tax calculation of shop <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.shop_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.shop_txt") %> <br>
</p>
<label>Shop Image</label>
<div class="panel padding-10">
<div class="form-group">
<div class="menu-item-img">
<% if f.object.logo? %>
<p><%= f.object.name %></p>
<%= image_tag f.object.logo.url, :class => "img-thumbnail" %>
<% else %>
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
<% end %>
</div>
<%= f.file_field :logo, :class => "img-thumbnail" %>
</div>
</div>
<div class="form-actions p-l-15">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
<p>
1) address - to write shop's address <br>
2) city - to write city <br>
3) township - to write township <br>
4) state - to write state <br>
5) phone_no - to write shop's phone_no <br>
6) reservation_no - to write shop's reservation_no <br>
7) license - to write license <br>
8) license_data - to write license data <br>
9) base_currency - to write base currency <br>
10)cloud_token - to write cloud token <br>
11)cloud_url - to write cloud url <br>
12)owner_token - to write shop's owner token <br>
13)id_prefix - to write id prefix <br>
14)is_rounding_adj - to check for calculate rounding adj of shop <br>
15)quick_sale_summary - to check for view Quick Sale Summary <br>
16)calc_tax_order - to check for tax calculation of shop <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.shop_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.shop_txt") %> <br>
</p>
</div>
</div>
</div>
</div>

View File

@@ -96,8 +96,10 @@
<td><%= @settings_shop.calc_tax_order %></td>
</tr>
<tr>
<td style="width:20%">Shop Image</td>
<td><%= image_tag @settings_shop.logo, :size => '200x200'%></td>
</tr>
<tr>
<td><%= link_to t("views.btn.edit"), edit_settings_shop_path(@settings_shop),:class => 'btn btn-primary btn-sm waves-effect' %>
</td>
</tr>