ios support

This commit is contained in:
2015-03-04 20:48:24 +01:00
parent e02d32156f
commit 3cf8d3c896
22 changed files with 127 additions and 53 deletions
+2 -1
View File
@@ -110,6 +110,8 @@ group :development do
gem 'spring' gem 'spring'
gem 'spring-commands-rspec' gem 'spring-commands-rspec'
gem 'web-console', '~> 2.0.0' gem 'web-console', '~> 2.0.0'
gem 'foreman'
gem 'thin'
end end
group :test do group :test do
@@ -128,7 +130,6 @@ end
# Use unicorn as the app server # Use unicorn as the app server
# gem 'unicorn' # gem 'unicorn'
# gem 'foreman'
# Deploy with Capistrano # Deploy with Capistrano
# gem 'capistrano' # gem 'capistrano'
+13 -2
View File
@@ -1,6 +1,6 @@
GIT GIT
remote: git://github.com/bterkuile/cmtool.git remote: git://github.com/bterkuile/cmtool.git
revision: b0491aa997cca6e791b7352f40e2adf90191a1cd revision: 2b0d4816b82ca202728893d5800f2fc13a17b63b
specs: specs:
cmtool (1.0.0) cmtool (1.0.0)
bourbon bourbon
@@ -138,7 +138,7 @@ GEM
climate_control (0.0.3) climate_control (0.0.3)
activesupport (>= 3.0) activesupport (>= 3.0)
cliver (0.3.2) cliver (0.3.2)
cocaine (0.5.5) cocaine (0.5.7)
climate_control (>= 0.0.3, < 1.0) climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0) coderay (1.1.0)
coffee-rails (4.1.0) coffee-rails (4.1.0)
@@ -157,6 +157,7 @@ GEM
rest-client (~> 1.6.1) rest-client (~> 1.6.1)
crack (0.4.2) crack (0.4.2)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
daemons (1.1.9)
debug_inspector (0.0.2) debug_inspector (0.0.2)
devise (3.4.1) devise (3.4.1)
bcrypt (~> 3.0) bcrypt (~> 3.0)
@@ -168,6 +169,7 @@ GEM
devise-i18n (0.11.3) devise-i18n (0.11.3)
diff-lcs (1.2.5) diff-lcs (1.2.5)
docile (1.1.5) docile (1.1.5)
dotenv (1.0.2)
em-http-request (1.1.2) em-http-request (1.1.2)
addressable (>= 2.3.4) addressable (>= 2.3.4)
cookiejar cookiejar
@@ -226,6 +228,9 @@ GEM
ffi (1.9.6) ffi (1.9.6)
font-awesome-rails (4.3.0.0) font-awesome-rails (4.3.0.0)
railties (>= 3.2, < 5.0) railties (>= 3.2, < 5.0)
foreman (0.77.0)
dotenv (~> 1.0.2)
thor (~> 0.19.1)
foundation-rails (5.5.1.0) foundation-rails (5.5.1.0)
railties (>= 3.1.0) railties (>= 3.1.0)
sass (>= 3.3.0, < 3.5) sass (>= 3.3.0, < 3.5)
@@ -427,6 +432,10 @@ GEM
temple (0.7.5) temple (0.7.5)
test_squad (0.0.1) test_squad (0.0.1)
rails rails
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.4) thread_safe (0.3.4)
tilt (1.4.1) tilt (1.4.1)
@@ -487,6 +496,7 @@ DEPENDENCIES
factory_girl_rails factory_girl_rails
faye faye
font-awesome-rails font-awesome-rails
foreman
foundation-rails foundation-rails
fuubar fuubar
iso_country_codes iso_country_codes
@@ -519,6 +529,7 @@ DEPENDENCIES
spring spring
spring-commands-rspec spring-commands-rspec
test_squad test_squad
thin
turnip turnip
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
web-console (~> 2.0.0) web-console (~> 2.0.0)
+3 -1
View File
@@ -4,4 +4,6 @@
# production: faye: thin start -d -R faye/config.ru -p 9296 # production: faye: thin start -d -R faye/config.ru -p 9296
#counters: bin/drb_counter.rb run -- development #counters: bin/drb_counter.rb run -- development
# production: conters: bin/drb_counter.rb start # production: conters: bin/drb_counter.rb start
server: bundle exec rails s -e production counters: drb_counter/drb_counter.rb development
faye: thin start -R faye/config.ru -p 9296
#server: bundle exec rails s -e production
@@ -6,20 +6,20 @@ App.SectionController = Ember.ObjectController.extend
finishEditable: -> finishEditable: ->
@set('editmode', false) @set('editmode', false)
@get('model').save() @get('model').save()
@get('model.section_elements').forEach (section_element) -> section_element.save() @get('model.section_elements').filterProperty('isDirty').invoke 'save'
@get('model.section_areas').forEach (section_area) -> section_area.save() @get('model.section_areas').filterProperty('isDirty').invoke 'save'
rollbackEditable: -> rollbackEditable: ->
@get('model').rollback() @get('model').rollback()
@get('model.section_elements').forEach (section_element) -> @get('model.section_elements').forEach (section_element) ->
if section_element.get('id') if section_element.get('isNew')
section_element.rollback()
else
section_element.deleteRecord() section_element.deleteRecord()
@get('model.section_areas').forEach (section_area) ->
if section_area.get('id')
section_area.rollback()
else else
section_element.rollback()
@get('model.section_areas').forEach (section_area) ->
if section_area.get('isNew')
section_area.deleteRecord() section_area.deleteRecord()
else
section_area.rollback()
@set('editmode', false) @set('editmode', false)
addSection: -> @modal 'add_section', model: @get('model') addSection: -> @modal 'add_section', model: @get('model')
addTables: -> @modal 'section_add_tables', model: @get('model') addTables: -> @modal 'section_add_tables', model: @get('model')
@@ -28,7 +28,39 @@ DragNDrop.Draggable = Ember.Mixin.create
@set 'targetObject.isDragging', false @set 'targetObject.isDragging', false
@set 'targetObject.controllers.application.isDragging', false @set 'targetObject.controllers.application.isDragging', false
localStorage.removeItem 'draggingView' if localStorage.getItem 'draggingView' localStorage.removeItem 'draggingView' if localStorage.getItem 'draggingView'
touchStart: (ev)->
ev.preventDefault()
target = @$()
return unless target.prop 'draggable'
touch = ev.originalEvent.changedTouches[0]
@touchStartEvent =
left: parseFloat(target.css('left'))
top: parseFloat(target.css('top'))
pageX: touch.pageX
pageY: touch.pageY
touchMove: (ev)->
ev.preventDefault()
target = @$()
return unless target.prop 'draggable'
if ev.originalEvent.changedTouches.length is 1
touch = ev.originalEvent.changedTouches[0]
target.css
left: "#{@touchStartEvent.left + touch.pageX - @touchStartEvent.pageX}px"
top: "#{@touchStartEvent.top + touch.pageY - @touchStartEvent.pageY}px"
touchEnd: (ev)->
ev.preventDefault()
touch = ev.originalEvent.changedTouches[0]
if Math.abs(@touchStartEvent.pageX - touch.pageX) < 2 and Math.abs(@touchStartEvent.pageY - touch.pageY) < 2
# The preventDefaults are preventing the click action to fire, therefore we trigger it ourselves
# But do not trigger when a handle insed the element is clicked
unless $(ev.target).parents('.handles-inside-draggable') or $(ev.target).hasClass('handles-inside-draggable')
@click() if @click
else
$(ev.target).click()
@touchStartEvent = null
this
DragNDrop.Droppable = Ember.Mixin.create DragNDrop.Droppable = Ember.Mixin.create
dragEnter: (e)-> dragEnter: (e)->
if @dragEntered if @dragEntered
@@ -40,6 +72,20 @@ DragNDrop.Droppable = Ember.Mixin.create
# DragNDrop.cancel(e) # DragNDrop.cancel(e)
dragOver: DragNDrop.cancel # don't know why, but crucial for the current way of working with section tables dragOver: DragNDrop.cancel # don't know why, but crucial for the current way of working with section tables
# dragOver: (e)->(e.preventDefault(); false) # dragOver: (e)->(e.preventDefault(); false)
touchEnd: (ev)->
ev.preventDefault()
view = ev.result
return unless view._parentView
target = view.$()
return unless target.prop 'draggable'
newX = parseFloat(target.css('left'))
newY = parseFloat(target.css('top'))
return unless newX? and newY?
position =
left: newX
top: newY
@dropped view, position if @dropped
this
dragLeave: -> dragLeave: ->
if @dragLeft if @dragLeft
@dragLeft() @dragLeft()
@@ -1,6 +1,6 @@
= svg view.content.svg width=view.content.box_width height=view.content.box_height rotation=view.content.rotation = svg view.content.svg width=view.content.box_width height=view.content.box_height rotation=view.content.rotation
if view.showHandles if view.showHandles
.section-element-handles .section-element-handles.handles-inside-draggable
a.rotate-left{action "rotateLeft" view.content bubbles=false}: span.icon a.rotate-left{action "rotateLeft" view.content bubbles=false}: span.icon
a.rotate-right{action "rotateRight" 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 a.remove-section-element{action "removeSectionElement" view.content bubbles=false}: span.icon
@@ -1,6 +1,6 @@
App.SectionElementView = Ember.View.extend DragNDrop.Draggable, App.SectionElementView = Ember.View.extend DragNDrop.Draggable,
templateName: 'section/section-element' templateName: 'section/section-element'
classNames: ['section-element'] classNames: ['section-element-container']
attributeBindings: ['style'] attributeBindings: ['style']
show_handles: false show_handles: false
classNameBindings: [ classNameBindings: [
@@ -1,11 +1,8 @@
App.SectionTablesView = Ember.View.extend DragNDrop.Droppable, App.SectionTablesView = Ember.View.extend DragNDrop.Droppable,
classNames: ['well', 'section-tables-container', 'section-tables-active'] classNames: ['well', 'section-tables-container', 'section-tables-active']
classNameBindings: ['controller.editmode:editing']
templateName: 'section/tables' templateName: 'section/tables'
dpm: 1 dpm: 1
didInsertElement: ->
@$el = $(@get('element'))
height = @$el.width() * @get('controller.model.height') / @get('controller.model.width')
@$el.css('height', height)
dropped: (view, position)-> dropped: (view, position)->
view.positionChange(position, @content) view.positionChange(position, @content)
observeSectionDimensions: (-> observeSectionDimensions: (->
@@ -21,10 +18,9 @@ App.SectionTablesView = Ember.View.extend DragNDrop.Droppable,
dpm = viewport_height / section_height dpm = viewport_height / section_height
@$el.css 'width', dpm * section_width @$el.css 'width', dpm * section_width
@$el.css 'height', dpm * section_height @$el.css 'height', dpm * section_height
console.log "SECTION dpm #{dpm}"
@set 'dpm', dpm @set 'dpm', dpm
).observes('controller.model.height', 'controller.model.width') ).observes('controller.model.height', 'controller.model.width')
tables: (->@get('content')).property('content') tables: (->@get('content')).property('content.@each')
didInsertElement: -> didInsertElement: ->
# the first observable event is triggered without the container having its dimensions # the first observable event is triggered without the container having its dimensions
@get('controller.model').notifyPropertyChange('width').notifyPropertyChange('height') @get('controller.model').notifyPropertyChange('width') #.notifyPropertyChange('height')
@@ -2,17 +2,14 @@
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require jquery-ui/sortable //= require jquery-ui/sortable
//= require jquery.ui.touch-punch // require ./im
// require foundation FOUNDATION 5 JAVASCRIPT IMPLEMENTATIONS AND EMBER ARE NOT COMPATIBLE, FOUNDATION IS TOO SIMPLISTIC AT THE MOMENT AND DESTROYS DOM EVENTS // require foundation FOUNDATION 5 JAVASCRIPT IMPLEMENTATIONS AND EMBER ARE NOT COMPATIBLE, FOUNDATION IS TOO SIMPLISTIC AT THE MOMENT AND DESTROYS DOM EVENTS
//= require js-routes //= require js-routes
//= require moment //= require moment
//= require fullcalendar //= require fullcalendar
//= require translations //= require translations
// require qwaiter
// require ./qsupplier
//= require faye //= require faye
//= require ./base //= require ./base
// require qtip # was used for table actions in section view, now done by EMBER
//= require pickdate //= require pickdate
//= require_directory . //= require_directory .
//= require_self //= require_self
@@ -1,11 +0,0 @@
/*
* jQuery UI Touch Punch 0.2.2
*
* Copyright 2011, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery);
@@ -12,8 +12,6 @@ $side-spacing: 0px
display: inline-block display: inline-block
.location_picker_search .location_picker_search
float: left float: left
.draggable
cursor: move !important
.text-alert .text-alert
color: $alert-color color: $alert-color
.text-warning .text-warning
@@ -6,6 +6,7 @@
margin-right: 10px margin-right: 10px
margin-bottom: 10px margin-bottom: 10px
width: 80px width: 80px
max-height: 120px
border: 2px outset #aaa border: 2px outset #aaa
&:hover &:hover
border-color: $active-color border-color: $active-color
@@ -30,6 +30,10 @@
position: relative position: relative
padding: 0 padding: 0
height: 400px height: 400px
&.editing
background-color: rgba(240, 138, 36, 0.5)
.section-element-container, .section-area-container
cursor: pointer
//background-image: image-url('textures/wood4.jpg') //background-image: image-url('textures/wood4.jpg')
//background-color: rgba(0,0,0,0.4) //background-color: rgba(0,0,0,0.4)
.section-table .section-table
+6 -2
View File
@@ -15,7 +15,6 @@ class ApplicationController < ActionController::Base
private private
def allow_all_origins def allow_all_origins
headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*' headers['Access-Control-Request-Method'] = '*'
@@ -24,7 +23,11 @@ private
end end
def authorize_cmtool def authorize_cmtool
redirect_to '/', alert: t('general.unauthorized') unless current_user.present? && current_user.admin? redirect_to new_administrator_session_path, alert: t('general.unauthorized') unless current_administrator.present?
end
def cmtool_user
current_administrator
end end
def cmtool_locale def cmtool_locale
@@ -65,6 +68,7 @@ private
def after_sign_in_path_for(resource) def after_sign_in_path_for(resource)
case resource case resource
when Employee then supplier_root_path when Employee then supplier_root_path
when Administrator then cmtool.root_path
else root_path else root_path
end end
end end
@@ -6,7 +6,7 @@ module Suppliers
def show def show
[current_supplier].include_relations(sections: :tables, product_categories: :products) [current_supplier].include_relations(sections: :tables, product_categories: :products)
render json: Suppliers::SupplierSerializer.new(current_supplier).as_json render json: current_supplier, serializer: Suppliers::SupplierSerializer #.new(current_supplier).as_json
end end
def update def update
+1 -1
View File
@@ -1,5 +1,5 @@
- model_class = SvgElement - model_class = SvgElement
div.page-header= title :index, model_class - title :index, model_class
- if @svg_elements.any? - if @svg_elements.any?
table.table table.table
thead thead
Regular → Executable
View File
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
Regular → Executable
View File
-4
View File
@@ -1,8 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__) APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot' require_relative '../config/boot'
require 'rails/commands' require 'rails/commands'
+3 -6
View File
@@ -1,7 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin require_relative '../config/boot'
load File.expand_path("../spring", __FILE__) require 'rake'
rescue LoadError Rake.application.run
end
require 'bundler/setup'
load Gem.bin_path('rake', 'rake')
Executable
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end