Add image to product
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 68 B |
@@ -82,6 +82,7 @@ App.ApplicationController = Ember.Controller.extend
|
|||||||
if list.get('join_requests').toArray().length
|
if list.get('join_requests').toArray().length
|
||||||
@transitionToRoute 'join_requests'
|
@transitionToRoute 'join_requests'
|
||||||
callback.call(@) if callback
|
callback.call(@) if callback
|
||||||
|
@transitionToRoute 'active_list' if @currentRouteName is 'index'
|
||||||
error = @ajaxError (emberError)=>
|
error = @ajaxError (emberError)=>
|
||||||
# if jqXHR.status == 404 officially, now assume close list on error
|
# if jqXHR.status == 404 officially, now assume close list on error
|
||||||
#@redirect_to 'index', message: 'the_list_has_been_closed'
|
#@redirect_to 'index', message: 'the_list_has_been_closed'
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
App.ModalProductInfoController = Ember.ObjectController.extend
|
||||||
|
actions:
|
||||||
|
close: ->
|
||||||
|
@get('model.cancel').call(@) if @get('model.cancel')
|
||||||
|
@send 'closeModal'
|
||||||
@@ -29,6 +29,4 @@ App.TableController = Ember.ObjectController.extend
|
|||||||
toggleProductCategory: (product_category)->
|
toggleProductCategory: (product_category)->
|
||||||
product_category.set 'collapsed', not product_category.get('collapsed')
|
product_category.set 'collapsed', not product_category.get('collapsed')
|
||||||
showProductDescription: (product)->
|
showProductDescription: (product)->
|
||||||
@send 'openModal', 'modal_info', Ember.Object.create
|
@send 'openModal', 'modal_product_info', product
|
||||||
title: product.get('name')
|
|
||||||
body: textile(product.get('description'))
|
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ App.Product = DS.Model.extend
|
|||||||
name: attr 'string'
|
name: attr 'string'
|
||||||
price: attr 'number'
|
price: attr 'number'
|
||||||
description: attr 'string'
|
description: attr 'string'
|
||||||
|
image: attr()
|
||||||
product_category: DS.belongsTo('product_category')
|
product_category: DS.belongsTo('product_category')
|
||||||
product_orders: DS.hasMany('product_order')
|
product_orders: DS.hasMany('product_order')
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
modal-dialog action="close"
|
||||||
|
h3.flush--top= name
|
||||||
|
if image
|
||||||
|
.right: img src=image.small alt=""
|
||||||
|
p==description
|
||||||
|
hr
|
||||||
|
button{action "close"}= t 'modal.info.close'
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
.display-panel
|
||||||
|
//TODO: something smart
|
||||||
.display-row
|
.display-row
|
||||||
+grid-row
|
+grid-row
|
||||||
.display-label
|
.display-label
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ module Suppliers
|
|||||||
private
|
private
|
||||||
|
|
||||||
def product_params
|
def product_params
|
||||||
params.require(:product).permit(:name, :code, :price, :description, product_category_ids: [])
|
params.require(:product).permit(:name, :code, :price, :description, :image, product_category_ids: [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Product
|
class Product
|
||||||
include SimplyStored::Couch
|
include SimplyStored::Couch
|
||||||
include ActiveModel::SerializerSupport
|
include ActiveModel::SerializerSupport
|
||||||
|
include Paperclip::Glue
|
||||||
|
|
||||||
property :name
|
property :name
|
||||||
property :code
|
property :code
|
||||||
@@ -26,6 +27,17 @@ class Product
|
|||||||
is_dirty
|
is_dirty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
property :image_file_name
|
||||||
|
property :image_content_type
|
||||||
|
property :image_file_size, :type => Fixnum
|
||||||
|
property :image_updated_at, :type => Time
|
||||||
|
has_attached_file :image,
|
||||||
|
url: '/system/product/:id/images/:style.:extension',
|
||||||
|
styles: {medium: '512x512>', thumb: '128x128>', large: '896x896>', small: '320x320>'},
|
||||||
|
default_url: '/assets/user/blank-pixel.png'
|
||||||
|
validates_attachment :image, content_type: {content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]}
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def persist_product_category_ids
|
def persist_product_category_ids
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
class ProductSerializer < Qwaiter::Serializer
|
class ProductSerializer < Qwaiter::Serializer
|
||||||
embed :ids, include: true
|
embed :ids, include: true
|
||||||
attributes :name, :price, :description
|
attributes :name, :price, :description, :image
|
||||||
|
|
||||||
|
def image
|
||||||
|
if object.image.present?
|
||||||
|
{small: object.image.url(:small)}
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
= form_for [:suppliers, @product] do |f|
|
= form_for [:suppliers, @product] do |f|
|
||||||
= render 'error_messages', target: @product
|
= render 'error_messages', target: @product
|
||||||
.form-row class=(f.object.errors[:name].any? ? 'error' : nil)
|
.form-row class=(f.object.errors[:name].any? ? 'error' : nil)
|
||||||
.form-label
|
.form-label= f.label :name, data: {t: 'attributes.product.name'}
|
||||||
= f.label :name, data: {t: 'attributes.product.name'}
|
.form-field= f.text_field :name
|
||||||
.form-field
|
|
||||||
= f.text_field :name
|
|
||||||
.form-row class=(f.object.errors[:code].any? ? 'error' : nil)
|
.form-row class=(f.object.errors[:code].any? ? 'error' : nil)
|
||||||
.form-label
|
.form-label= f.label :code, data: {t: 'attributes.product.code'}
|
||||||
= f.label :code, data: {t: 'attributes.product.code'}
|
.form-field= f.text_field :code
|
||||||
.form-field
|
|
||||||
= f.text_field :code
|
|
||||||
.form-row class=(f.object.errors[:price].any? ? 'error' : nil)
|
.form-row class=(f.object.errors[:price].any? ? 'error' : nil)
|
||||||
.form-label
|
.form-label= f.label :price, data: {t: 'attributes.product.price'}
|
||||||
= f.label :price, data: {t: 'attributes.product.price'}
|
.form-field= f.text_field :price
|
||||||
.form-field
|
.form-row class=(f.object.errors[:image].any? ? 'error' : nil)
|
||||||
= f.text_field :price
|
.form-label= f.label :image, data: {t: 'attributes.product.image'}
|
||||||
|
.form-field= f.file_field :image
|
||||||
.form-row class=(f.object.errors[:description].any? ? 'error' : nil)
|
.form-row class=(f.object.errors[:description].any? ? 'error' : nil)
|
||||||
.form-label
|
.form-label= f.label :description, data: {t: 'attributes.product.description'}
|
||||||
= f.label :description, data: {t: 'attributes.product.description'}
|
.form-field= f.text_area :description
|
||||||
.form-field
|
|
||||||
= f.text_area :description
|
|
||||||
/= f.input :name
|
/= f.input :name
|
||||||
/= f.input :code
|
/= f.input :code
|
||||||
/= f.input :price
|
/= f.input :price
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
- model_class = Product
|
- model_class = Product
|
||||||
.page-header= title :show, @product
|
.page-header= title :show, @product
|
||||||
|
|
||||||
|
- if @product.image.present?
|
||||||
|
.display-panel= image_tag @product.image.url(:medium)
|
||||||
.display-row
|
.display-row
|
||||||
.display-label
|
.display-label
|
||||||
span data-t='attributes.product.name'
|
span data-t='attributes.product.name'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ en:
|
|||||||
user: Users
|
user: Users
|
||||||
supplier: Restaurants
|
supplier: Restaurants
|
||||||
table: Tables
|
table: Tables
|
||||||
list: Lists
|
list: Lists
|
||||||
product: Products
|
product: Products
|
||||||
order: Orders
|
order: Orders
|
||||||
product_category: Product categories
|
product_category: Product categories
|
||||||
@@ -34,6 +34,7 @@ en:
|
|||||||
code: Code
|
code: Code
|
||||||
price: Price
|
price: Price
|
||||||
created_at: Created
|
created_at: Created
|
||||||
|
image: Image
|
||||||
list:
|
list:
|
||||||
created_at: Created
|
created_at: Created
|
||||||
state: Status
|
state: Status
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ nl:
|
|||||||
code: Code
|
code: Code
|
||||||
price: Prijs
|
price: Prijs
|
||||||
created_at: Aangemaakt
|
created_at: Aangemaakt
|
||||||
|
image: Afbeelding
|
||||||
list:
|
list:
|
||||||
created_at: Aangemaakt
|
created_at: Aangemaakt
|
||||||
state: Status
|
state: Status
|
||||||
|
|||||||
Reference in New Issue
Block a user