Progress commit

This commit is contained in:
2015-03-01 16:04:57 +01:00
parent 9cba5a11ff
commit d172b28850
16 changed files with 106 additions and 24 deletions
@@ -63,7 +63,7 @@ class SvgElementClass
else
results.text(window.compiledJS)
results.removeClass 'error'
window.evaluator = new SnapDsl(window.compiledJS, target: @target)
window.evaluator = new SnapDsl(window.compiledJS, target: @target, width: @box_width.val(), height: @box_height.val())
evaluator.result()
$('.minibutton.run').removeClass 'error'
catch {location, message}
@@ -76,8 +76,8 @@ class SnapDsl
@js_code = code
@options = options
@t = $(options.target)
@width = @t.width()
@height = @t.height()
@width = options.width
@height = options.height
$(options.target).html('')
result: ->
@snap = Snap(@options.target)
@@ -8,12 +8,12 @@ App.SectionController = Ember.ObjectController.extend
@get('model').save()
@get('model.section_elements').forEach (section_element) -> section_element.save()
rollbackEditable: ->
@get('model').rollback().then =>
@get('model.section_elements').forEach (section_element) ->
if section_element.get('id')
section_element.rollback()
else
section_element.deleteRecord()
@get('model').rollback()
@get('model.section_elements').forEach (section_element) ->
if section_element.get('id')
section_element.rollback()
else
section_element.deleteRecord()
@set('editmode', false)
addSection: -> @modal 'add_section', model: @get('model')
addTables: -> @modal 'section_add_tables', model: @get('model')
@@ -36,6 +36,7 @@ App.SectionController = Ember.ObjectController.extend
@modal 'add_section_element',
model: @get('model')
ok: => @send 'makeEditable'
removeSectionElement: (section_element)-> section_element.destroy()
textures: ['wood1', 'wood2']
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
@@ -1,4 +1,5 @@
Ember.Handlebars.helper 'svg', (content, options)->
width = options.hash.width8 || '100%'
height = options.hash.height8 || '100%'
"<svg width='#{width}' height='#{height}' viewBox='0 0 155 310'><g transform=''>#{content}</g></svg>".htmlSafe()
#"<svg width='#{width}' height='#{height}'>#{content}</svg>".htmlSafe()
"<svg width='#{width}' height='#{height}' viewBox='0 0 #{options.hash.width} #{options.hash.height}'><g transform=''>#{content}</g></svg>".htmlSafe()
@@ -94,6 +94,14 @@ App.ApplicationRoute = Ember.Route.extend
markSupplierOpen: ->
return unless supplier = @controllerFor('application').get('supplier')
supplier.open_the_place()
rotateLeft: (record)->
new_rotation = -90 + record.get('rotation')
new_rotation += 360 if new_rotation < 0
record.set 'rotation', new_rotation
rotateRight: (record)->
new_rotation = 90 + record.get('rotation')
new_rotation -= 360 if new_rotation >= 360
record.set 'rotation', new_rotation
events:
list_needs_help: (data) ->
if list = @store.getById('list', data.id)
@@ -20,7 +20,7 @@
li: a{action "addTables"}: span.section-add-tables-icon=t 'section.add_tables.button_label'
li: a{action "arrangeTables"}: span.section-arrange-tables-icon=t 'section.arrange_tables.modal.title'
li: a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}" target="_blank": span.qr-icon=t 'table.print_qr_codes'
li: a{action "addSectionElement"}: span.section-add-section-element-icon= t 'section_element.add_butoon'
li: a{action "addSectionElement"}: span.section-add-section-element-icon= t 'section_element.add_button'
li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
a.section-edit-mode-button{ action "makeEditable" }: span
= view "section-tables" contentBinding="tables"
@@ -1 +1,6 @@
= svg view.content.svg width=view.content.box_width height=view.content.box_height
if view.showHandles
.section-element-handles
a.rotate-left{action "rotateLeft" view.content bubbles=false}: span.icon
a.rotate-right{action "rotateRight" view.content bubbles=false}: span.icon
a.remove-section-element{action "removeSectionElement" view.content bubbles=false}: span.icon
@@ -2,6 +2,7 @@ App.SectionElementView = Ember.View.extend DragNDrop.Draggable,
templateName: 'section/section-element'
classNames: ['section-element']
attributeBindings: ['style']
show_handles: false
classNameBindings: [
'uniqueClass'
]
@@ -32,8 +33,5 @@ App.SectionElementView = Ember.View.extend DragNDrop.Draggable,
@get('content').setProperties
position_x: Math.round(10 * position.left / dpm ) / 10
position_y: Math.round(10 * position.top / dpm ) / 10
click: ->
return unless @get('controller.editmode')
new_rotation = 90 + @get('content.rotation')
new_rotation -= 360 if new_rotation >= 360
@set 'content.rotation', new_rotation
click: -> @toggleProperty('show_handles')
showHandles: Ember.computed.and 'show_handles', 'controller.editmode'
@@ -25,6 +25,7 @@ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() +
window.time_zones = <%= ActiveSupport::TimeZone.all.map{|tz| {name: tz.name, formatted: "GMT#{tz.formatted_offset} #{tz.name}"}}.to_json.html_safe %>;
window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
var path_mapping = {
user_root: '/user',
join_occupied_table: '/user/join_occupied_table',
@@ -25,7 +25,6 @@
# <span data-t="models.table">Tafel</span>
@tspan = (path, vars={}) -> "<span data-t='#{path}' data-t-attributes='#{JSON.stringify(vars)}'>#{t(path, vars)}</span>"
@t = (path, vars={}) ->
#result = undefined
#m = undefined