supplier menu progress
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
App.MenuController = Ember.ObjectController.extend
|
||||
needs: ['application']
|
||||
product_categories: (-> @store.all('product_category')).property()
|
||||
sorted_product_categories: (-> @get('product_categories').sortBy('position')).property('product_categories.@each', 'product_categories.@each.position')
|
||||
actions:
|
||||
editProductCategory: (product_category)->
|
||||
@modal 'product_category_edit',
|
||||
model: product_category,
|
||||
close: -> product_category.rollback()
|
||||
|
||||
moveProductCategory: (product_category)->
|
||||
@modal 'product_category_move',
|
||||
model: product_category
|
||||
@@ -1,3 +0,0 @@
|
||||
App.MenuController = Ember.ObjectController.extend
|
||||
needs: ['application']
|
||||
product_categories: ~> @store.all('product_category')
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
App.modals.AddSectionController = @App.modals.BaseController.extend
|
||||
alert_message: null
|
||||
section_title: ''
|
||||
section_width: 15
|
||||
section_height: 8
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
@App.modals.BaseController = Ember.ObjectController.extend
|
||||
alert_message: ""
|
||||
title: ~>
|
||||
# return title if directly set by options
|
||||
return @get('modal_options.title') if @get('modal_options.title')
|
||||
# return translated title_path if directly set by controller
|
||||
return t(@title_path) if @title_path
|
||||
# return translated title_path if directly set by options
|
||||
return t(@get('modal_options.title_path')) if @get('modal_options.title_path')
|
||||
# infer title path based on controller name App.modals.AddSectionController => add_section
|
||||
underscored = `this.constructor.toString().substr(11).replace(/Controller$/, '').underscore()`
|
||||
params = {}
|
||||
if model = @get('model')
|
||||
params = model.serialize() if model.serialize
|
||||
@get('modal_options.title') or ttry("modal.#{underscored}.title", params) or underscored.capitalize().replace(/_/, ' ')
|
||||
# find translated title or humanize the controller name
|
||||
ttry("modal.#{underscored}.title", params) or underscored.capitalize().replace(/_/, ' ')
|
||||
actions:
|
||||
close: ->
|
||||
if close = @get('modal_options.close')
|
||||
@@ -24,3 +30,6 @@
|
||||
ok.apply(@)
|
||||
@send 'closeModal' unless @preventClose
|
||||
confirm: -> @send('ok')
|
||||
save: ->
|
||||
@get('model').save()
|
||||
@send 'closeModal' unless @preventClose
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
App.modals.ProductCategoryEditController = App.modals.BaseController.extend
|
||||
title_path: 'product_category.edit.modal.title'
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
App.modals.ProductCategoryMoveController = App.modals.BaseController.extend
|
||||
title_path: 'product_category.move.modal.title'
|
||||
actions:
|
||||
moveBelow: (below_product_category)->
|
||||
position = 0
|
||||
unless below_product_category
|
||||
@set 'model.position', position
|
||||
@get('model').save()
|
||||
position += 1
|
||||
for product_category in @get('product_categories')
|
||||
product_category.set('position', position)
|
||||
product_category.save()
|
||||
if below_product_category and product_category.id is below_product_category.id
|
||||
@set 'model.position', position += 1
|
||||
@get('model').save()
|
||||
|
||||
position += 1
|
||||
@send 'close'
|
||||
# moveBelow: (->
|
||||
# debugger
|
||||
# ).observes('move_below_selection')
|
||||
# change: ->
|
||||
# debugger
|
||||
|
||||
product_categories: (->
|
||||
@store.all('product_category').filter( (pc) => pc.id isnt @get('model.id')).sortBy('position')
|
||||
).property('model.id')
|
||||
|
||||
# setProductCategories: (-> @set 'product_categories', @store.all('product_category')).on('init')
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
App.modals.SectionArrangeTablesController = App.modals.BaseController.extend
|
||||
alert_message: null
|
||||
arrange_type: 'distributed' # can be distributed, by_row or by_column
|
||||
row_count: 2
|
||||
column_count: 2
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Ember.Handlebars.helper 'select-hour', (params..., options)->
|
||||
debugger
|
||||
result = "<select class=\"select-hour\">"
|
||||
result += "<option>#{hour}</option>" for hour in [0..24]
|
||||
result += "</select>"
|
||||
new Handlebars.SafeString result
|
||||
@@ -0,0 +1,5 @@
|
||||
Ember.Handlebars.helper 'select-minute', (params..., options)->
|
||||
result = "<select class=\"select-minute\">"
|
||||
result += "<option>#{minute}</option>" for minute in [0..24]
|
||||
result += "</select>"
|
||||
new Handlebars.SafeString result
|
||||
@@ -2,3 +2,25 @@ attr = DS.attr
|
||||
App.ProductCategory = DS.Model.extend
|
||||
name: attr('string')
|
||||
products: DS.hasMany('product')
|
||||
supplier: DS.belongsTo 'supplier'
|
||||
active_on_sunday: attr('boolean')
|
||||
active_on_monday: attr('boolean')
|
||||
active_on_tuesday: attr('boolean')
|
||||
active_on_wednesday: attr('boolean')
|
||||
active_on_thursday: attr('boolean')
|
||||
active_on_friday: attr('boolean')
|
||||
active_on_saturday: attr('boolean')
|
||||
full_day: attr('boolean')
|
||||
start_from: attr('number')
|
||||
end_on: attr('number')
|
||||
position: attr('number')
|
||||
|
||||
availability_text: Ember.computed 'active_on_sunday', 'active_on_monday', 'active_on_tuesday', 'active_on_wednesday', 'active_on_thursday', 'active_on_friday', 'active_on_saturday', 'full_day', 'start_from', 'end_on', ->
|
||||
days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||
active_days = days.filter (day)=>@get("active_on_#{day}")
|
||||
result = ""
|
||||
if active_days.length < 7
|
||||
result += "<span class=\"day-names\">#{active_days.map((day) -> t("date.day_name.#{day}")).join(", ")}</span> "
|
||||
unless @get('full_day')
|
||||
result += "<span class=\"time-range\">#{day_minutes_to_time @get('start_from')} - #{day_minutes_to_time @get('end_on')}</span>"
|
||||
new Ember.Handlebars.SafeString result
|
||||
|
||||
@@ -13,3 +13,5 @@ App.Supplier = DS.Model.extend
|
||||
iens_profile: attr 'string'
|
||||
lat: attr 'number'
|
||||
lng: attr 'number'
|
||||
week_starts_on_monday: attr 'boolean'
|
||||
product_categories: DS.hasMany 'product_category'
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Ember.Checkbox id=view.switchId checkedBinding="view.value"
|
||||
label for=view.switchId
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
.row.select-minute-of-day
|
||||
.small-5.columns
|
||||
view "select" content=view.hours_list value=view.hour
|
||||
.small-1.columns: span :
|
||||
.small-5.columns.end
|
||||
view "select" content=view.minutes_list value=view.minute
|
||||
@@ -1,7 +1,11 @@
|
||||
h2 Menu
|
||||
each product_category in product_categories
|
||||
each product_category in sorted_product_categories
|
||||
.row: .small-12.columns
|
||||
h3= product_category.name
|
||||
.product_category-header
|
||||
a.move{action "moveProductCategory" product_category} href="#"
|
||||
span.title= product_category.name
|
||||
span.availability= product_category.availability_text
|
||||
a.edit-product-category-button{action "editProductCategory" product_category} href="#"
|
||||
each product in product_category.products
|
||||
.row
|
||||
.small-4.columns= product.name
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
p=t 'product_category.edit.modal.body_header'
|
||||
.form-row
|
||||
.form-label.half=t 'attributes.product_category.name'
|
||||
.form-field.half= input valueBinding="model.name"
|
||||
.row
|
||||
.small-6.columns
|
||||
unless model.supplier.week_starts_on_monday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.sunday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_sunday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.monday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_monday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.tuesday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_tuesday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.wednesday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_wednesday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.thursday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_thursday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.friday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_friday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.saturday'
|
||||
.form-field.half: App.BooleanSwitchView value=model.active_on_saturday
|
||||
if model.supplier.week_starts_on_monday
|
||||
.form-row
|
||||
.form-label.half= t 'date.day_name.sunday'
|
||||
.form-field.half: App.BooleanSwitchView valueBinding=model.active_on_sunday
|
||||
.small-6.columns
|
||||
.row
|
||||
.small-12.columns.text-center: App.BooleanButtonView value=model.full_day reverse=true text_path="product_category.edit.modal.active_between.top"
|
||||
unless model.full_day
|
||||
.row
|
||||
.small-12.columns= view "select-minute-of-day" value=model.start_from
|
||||
.row
|
||||
.small-12.columns.text-center= t 'product_category.edit.modal.active_between.middle'
|
||||
.row
|
||||
.small-12.columns= view "select-minute-of-day" value=model.end_on
|
||||
hr
|
||||
button.confirm-cancel{action "close"}=t 'section.add_tables.modal.close_button'
|
||||
button.confirm-ok.right{action "save"}=t 'section.add_tables.modal.add_button'
|
||||
@@ -0,0 +1,13 @@
|
||||
p=t 'product_category.move.modal.body_header'
|
||||
.row
|
||||
.small-11.small-offset-1.columns
|
||||
a{action "moveBelow"} href="#" = t 'product_category.move.modal.move_to_top'
|
||||
h4=t 'product_category.move.modal.move_below_label'
|
||||
each product_category in product_categories
|
||||
.row.product_category-move-row
|
||||
.small-11.small-offset-1.columns
|
||||
a{action "moveBelow" product_category} href="#"
|
||||
span.title= product_category.name
|
||||
span.availability= product_category.availability_text
|
||||
hr
|
||||
button.confirm-cancel{action "close"}=t 'section.add_tables.modal.close_button'
|
||||
@@ -0,0 +1,17 @@
|
||||
App.BooleanButtonView = Ember.View.extend
|
||||
tagName: 'a'
|
||||
href: '#'
|
||||
classNames: "button"
|
||||
# templateName: "form_elements/boolean_switch"
|
||||
template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
|
||||
classNameBindings: ['rounded:round', 'active:active:disabled']
|
||||
|
||||
text: Ember.computed 'text_path', ->
|
||||
t @text_path
|
||||
|
||||
active: Ember.computed 'value', ->
|
||||
if @reverse then !@get('value') else !!@get('value')
|
||||
|
||||
click: ->
|
||||
@set 'value', !@get('value')
|
||||
# setUniqueId: (->@set 'switchId', "switch-#{Math.round(Math.random()*1000)}").on('init')
|
||||
@@ -0,0 +1,8 @@
|
||||
App.BooleanSwitchView = Ember.View.extend
|
||||
classNames: "switch"
|
||||
templateName: "form_elements/boolean_switch"
|
||||
classNameBindings: ['rounded:round']
|
||||
|
||||
click: ->
|
||||
@set 'value', !@get('value')
|
||||
setUniqueId: (->@set 'switchId', "switch-#{Math.round(Math.random()*1000)}").on('init')
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
App.SelectMinuteOfDayView = Ember.View.extend
|
||||
templateName: "form_elements/select_minute_of_day"
|
||||
classNameBindings: ['rounded:round']
|
||||
hours_list: [0..24]
|
||||
minutes_list: [0..60]
|
||||
hour: Ember.computed 'value', (a,b,c)->
|
||||
if arguments.length > 1
|
||||
@set 'value', 60*b + (@get('minute') || 0)
|
||||
Math.floor (@get('value') || 0)/60
|
||||
minute: Ember.computed 'value', (a,b,c)->
|
||||
if arguments.length > 1
|
||||
@set 'value', 60*(@get('hour')||0) + b
|
||||
Math.floor @get('value')%60
|
||||
Reference in New Issue
Block a user