mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-17 00:41:38 -04:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b9f0169bc | ||
|
|
b7ad63a2e5 | ||
|
|
62310e7a25 |
@@ -1 +0,0 @@
|
|||||||
velocipede
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
ruby-1.9.3-p374
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
||||||
|
# development environment upon cd'ing into the directory
|
||||||
|
|
||||||
|
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
||||||
|
environment_id="ruby-1.9.3-p374@velocipede"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Uncomment following line if you want options to be set only for given project.
|
||||||
|
#
|
||||||
|
# PROJECT_JRUBY_OPTS=( --1.9 )
|
||||||
|
|
||||||
|
#
|
||||||
|
# First we attempt to load the desired environment directly from the environment
|
||||||
|
# file. This is very fast and efficient compared to running through the entire
|
||||||
|
# CLI and selector. If you want feedback on which environment was used then
|
||||||
|
# insert the word 'use' after --create as this triggers verbose mode.
|
||||||
|
#
|
||||||
|
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
||||||
|
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
||||||
|
then
|
||||||
|
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
||||||
|
|
||||||
|
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
||||||
|
then
|
||||||
|
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If the environment file has not yet been created, use the RVM CLI to select.
|
||||||
|
if ! rvm --create use "$environment_id"
|
||||||
|
then
|
||||||
|
echo "Failed to create RVM environment '${environment_id}'."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
||||||
|
# it be automatically loaded. Uncomment the following and adjust the filename if
|
||||||
|
# necessary.
|
||||||
|
#
|
||||||
|
# filename=".gems"
|
||||||
|
# if [[ -s "$filename" ]]
|
||||||
|
# then
|
||||||
|
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# If you use bundler, this might be useful to you:
|
||||||
|
# if command -v bundle && [[ -s Gemfile ]]
|
||||||
|
# then
|
||||||
|
# bundle install
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
@@ -14,9 +14,8 @@ gem 'decent_exposure', '~> 1.0.1'
|
|||||||
gem 'devise', '~> 2.0.4'
|
gem 'devise', '~> 2.0.4'
|
||||||
gem 'haml-rails', '~> 0.3.4'
|
gem 'haml-rails', '~> 0.3.4'
|
||||||
gem 'jquery-rails', '~> 2.0'
|
gem 'jquery-rails', '~> 2.0'
|
||||||
gem 'pg', '~> 0.17.1'
|
gem 'pg'
|
||||||
gem 'will_paginate', '~> 3.0.3'
|
gem 'will_paginate', '~> 3.0.3'
|
||||||
gem 'jbuilder', '~> 2.0.3'
|
|
||||||
|
|
||||||
# Gems used only for assets and not required
|
# Gems used only for assets and not required
|
||||||
# in production environments by default.
|
# in production environments by default.
|
||||||
@@ -31,21 +30,20 @@ group :assets do
|
|||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'rspec-rails', '~> 2.14.0'
|
gem 'rspec-rails', '~> 2.8.1'
|
||||||
gem 'factory_girl_rails', '~> 1.2'
|
gem 'factory_girl_rails', '~> 1.2'
|
||||||
gem 'pry', '~> 0.9.8'
|
gem 'pry', '~> 0.9.8'
|
||||||
gem 'faker', '~> 1.2.0'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'shoulda-matchers', '~> 1.0.0'
|
gem 'shoulda-matchers', '~> 1.0.0'
|
||||||
gem 'capybara', '~> 2.2.1'
|
gem 'capybara', '~> 1.1.2'
|
||||||
gem 'poltergeist', '~> 1.5.0'
|
gem 'turnip', '~> 0.3.0'
|
||||||
gem 'database_cleaner', '~> 1.2.0'
|
gem 'database_cleaner'
|
||||||
gem 'launchy', '~> 2.4.2'
|
gem 'launchy'
|
||||||
gem 'spork', '~> 0.9.2'
|
gem 'spork'
|
||||||
#guard dependency for Mac OS 10
|
#guard dependency for Mac OS 10
|
||||||
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
|
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
|
||||||
gem 'guard-spork', '~> 1.5.1'
|
gem 'guard-spork'
|
||||||
gem 'guard-rspec', '~> 4.2.6'
|
gem 'guard-rspec'
|
||||||
end
|
end
|
||||||
|
|||||||
+83
-96
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: https://github.com/spacemunkay/acts_as_loggable.git
|
remote: https://github.com/spacemunkay/acts_as_loggable.git
|
||||||
revision: 8484dc1f7a58699705c5ffb593ebdf700a9f374a
|
revision: 49e264849ed9018445fb999cacfc55e1e28d7faa
|
||||||
specs:
|
specs:
|
||||||
acts_as_loggable (0.0.7)
|
acts_as_loggable (0.0.7)
|
||||||
activerecord (>= 3.0)
|
activerecord (>= 3.0)
|
||||||
@@ -36,62 +36,60 @@ GEM
|
|||||||
activesupport (3.2.13)
|
activesupport (3.2.13)
|
||||||
i18n (= 0.6.1)
|
i18n (= 0.6.1)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
addressable (2.3.5)
|
addressable (2.3.3)
|
||||||
arel (3.0.3)
|
arel (3.0.2)
|
||||||
bcrypt-ruby (3.1.2)
|
bcrypt-ruby (3.0.1)
|
||||||
bootstrap-will_paginate (0.0.10)
|
bootstrap-will_paginate (0.0.9)
|
||||||
will_paginate
|
will_paginate
|
||||||
builder (3.0.4)
|
builder (3.0.4)
|
||||||
cancan (1.6.10)
|
cancan (1.6.9)
|
||||||
capybara (2.2.1)
|
capybara (1.1.4)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (~> 2.0)
|
selenium-webdriver (~> 2.0)
|
||||||
celluloid (0.15.2)
|
xpath (~> 0.1.4)
|
||||||
timers (~> 1.1.0)
|
childprocess (0.3.9)
|
||||||
childprocess (0.4.0)
|
|
||||||
ffi (~> 1.0, >= 1.0.11)
|
ffi (~> 1.0, >= 1.0.11)
|
||||||
cliver (0.3.2)
|
coderay (1.0.9)
|
||||||
coderay (1.1.0)
|
|
||||||
coffee-rails (3.2.2)
|
coffee-rails (3.2.2)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (~> 3.2.0)
|
railties (~> 3.2.0)
|
||||||
coffee-script (2.2.0)
|
coffee-script (2.2.0)
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.7.0)
|
coffee-script-source (1.6.2)
|
||||||
commonjs (0.2.7)
|
commonjs (0.2.6)
|
||||||
database_cleaner (1.2.0)
|
database_cleaner (0.9.1)
|
||||||
decent_exposure (1.0.2)
|
decent_exposure (1.0.2)
|
||||||
devise (2.0.6)
|
devise (2.0.5)
|
||||||
bcrypt-ruby (~> 3.0)
|
bcrypt-ruby (~> 3.0)
|
||||||
orm_adapter (~> 0.0.3)
|
orm_adapter (~> 0.0.3)
|
||||||
railties (~> 3.1)
|
railties (~> 3.1)
|
||||||
warden (~> 1.1.1)
|
warden (~> 1.1.1)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.1.3)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.0.2)
|
execjs (1.4.0)
|
||||||
|
multi_json (~> 1.0)
|
||||||
factory_girl (2.6.4)
|
factory_girl (2.6.4)
|
||||||
activesupport (>= 2.3.9)
|
activesupport (>= 2.3.9)
|
||||||
factory_girl_rails (1.7.0)
|
factory_girl_rails (1.7.0)
|
||||||
factory_girl (~> 2.6.0)
|
factory_girl (~> 2.6.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
faker (1.2.0)
|
ffi (1.6.0)
|
||||||
i18n (~> 0.5)
|
|
||||||
ffi (1.9.3)
|
|
||||||
formatador (0.2.4)
|
formatador (0.2.4)
|
||||||
guard (2.4.0)
|
gherkin (2.11.6)
|
||||||
|
json (>= 1.7.6)
|
||||||
|
guard (1.7.0)
|
||||||
formatador (>= 0.2.4)
|
formatador (>= 0.2.4)
|
||||||
listen (~> 2.1)
|
listen (>= 0.6.0)
|
||||||
lumberjack (~> 1.0)
|
lumberjack (>= 1.0.2)
|
||||||
pry (>= 0.9.12)
|
pry (>= 0.9.10)
|
||||||
thor (>= 0.18.1)
|
thor (>= 0.14.6)
|
||||||
guard-rspec (4.2.6)
|
guard-rspec (1.2.1)
|
||||||
guard (~> 2.1)
|
guard (>= 1.1)
|
||||||
rspec (>= 2.14, < 4.0)
|
guard-spork (1.5.0)
|
||||||
guard-spork (1.5.1)
|
|
||||||
childprocess (>= 0.2.3)
|
childprocess (>= 0.2.3)
|
||||||
guard (>= 1.1)
|
guard (>= 1.1)
|
||||||
spork (>= 0.8.4)
|
spork (>= 0.8.4)
|
||||||
@@ -101,17 +99,14 @@ GEM
|
|||||||
activesupport (>= 3.1, < 4.1)
|
activesupport (>= 3.1, < 4.1)
|
||||||
haml (~> 3.1)
|
haml (~> 3.1)
|
||||||
railties (>= 3.1, < 4.1)
|
railties (>= 3.1, < 4.1)
|
||||||
hike (1.2.3)
|
hike (1.2.1)
|
||||||
i18n (0.6.1)
|
i18n (0.6.1)
|
||||||
jbuilder (2.0.3)
|
|
||||||
activesupport (>= 3.0.0)
|
|
||||||
multi_json (>= 1.2.0)
|
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
jquery-rails (2.3.0)
|
jquery-rails (2.2.1)
|
||||||
railties (>= 3.0, < 5.0)
|
railties (>= 3.0, < 5.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
json (1.8.1)
|
json (1.7.7)
|
||||||
launchy (2.4.2)
|
launchy (2.2.0)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
less (2.2.2)
|
less (2.2.2)
|
||||||
commonjs (~> 0.2.6)
|
commonjs (~> 0.2.6)
|
||||||
@@ -119,18 +114,15 @@ GEM
|
|||||||
actionpack (>= 3.1)
|
actionpack (>= 3.1)
|
||||||
less (~> 2.2.0)
|
less (~> 2.2.0)
|
||||||
libv8 (3.3.10.4)
|
libv8 (3.3.10.4)
|
||||||
listen (2.4.1)
|
listen (0.7.3)
|
||||||
celluloid (>= 0.15.2)
|
lumberjack (1.0.3)
|
||||||
rb-fsevent (>= 0.9.3)
|
mail (2.5.3)
|
||||||
rb-inotify (>= 0.9)
|
i18n (>= 0.4.0)
|
||||||
lumberjack (1.0.4)
|
|
||||||
mail (2.5.4)
|
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
method_source (0.8.2)
|
method_source (0.8.1)
|
||||||
mime-types (1.25.1)
|
mime-types (1.22)
|
||||||
mini_portile (0.5.2)
|
multi_json (1.7.9)
|
||||||
multi_json (1.8.4)
|
|
||||||
netzke-basepack (0.8.4)
|
netzke-basepack (0.8.4)
|
||||||
netzke-core (~> 0.8.2)
|
netzke-core (~> 0.8.2)
|
||||||
netzke-cancan (0.8.2)
|
netzke-cancan (0.8.2)
|
||||||
@@ -139,18 +131,12 @@ GEM
|
|||||||
netzke-core (0.8.4)
|
netzke-core (0.8.4)
|
||||||
execjs
|
execjs
|
||||||
uglifier
|
uglifier
|
||||||
nokogiri (1.6.1)
|
nokogiri (1.5.9)
|
||||||
mini_portile (~> 0.5.0)
|
|
||||||
orm_adapter (0.0.7)
|
orm_adapter (0.0.7)
|
||||||
pg (0.17.1)
|
pg (0.15.1)
|
||||||
poltergeist (1.5.0)
|
|
||||||
capybara (~> 2.1)
|
|
||||||
cliver (~> 0.3.1)
|
|
||||||
multi_json (~> 1.0)
|
|
||||||
websocket-driver (>= 0.2.0)
|
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
pry (0.9.12.6)
|
pry (0.9.12)
|
||||||
coderay (~> 1.0)
|
coderay (~> 1.0.5)
|
||||||
method_source (~> 0.8)
|
method_source (~> 0.8)
|
||||||
slop (~> 3.4)
|
slop (~> 3.4)
|
||||||
rack (1.4.5)
|
rack (1.4.5)
|
||||||
@@ -175,30 +161,31 @@ GEM
|
|||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (>= 0.14.6, < 2.0)
|
thor (>= 0.14.6, < 2.0)
|
||||||
rake (10.1.1)
|
rake (10.0.4)
|
||||||
rb-fsevent (0.9.4)
|
rb-fsevent (0.9.3)
|
||||||
rb-inotify (0.9.3)
|
|
||||||
ffi (>= 0.5.0)
|
|
||||||
rdoc (3.12.2)
|
rdoc (3.12.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
rspec (2.14.1)
|
rspec (2.8.0)
|
||||||
rspec-core (~> 2.14.0)
|
rspec-core (~> 2.8.0)
|
||||||
rspec-expectations (~> 2.14.0)
|
rspec-expectations (~> 2.8.0)
|
||||||
rspec-mocks (~> 2.14.0)
|
rspec-mocks (~> 2.8.0)
|
||||||
rspec-core (2.14.7)
|
rspec-core (2.8.0)
|
||||||
rspec-expectations (2.14.5)
|
rspec-expectations (2.8.0)
|
||||||
diff-lcs (>= 1.1.3, < 2.0)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-mocks (2.14.5)
|
rspec-mocks (2.8.0)
|
||||||
rspec-rails (2.14.1)
|
rspec-rails (2.8.1)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activemodel (>= 3.0)
|
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
rspec-core (~> 2.14.0)
|
rspec (~> 2.8.0)
|
||||||
rspec-expectations (~> 2.14.0)
|
rubyzip (0.9.9)
|
||||||
rspec-mocks (~> 2.14.0)
|
selenium-webdriver (2.31.0)
|
||||||
|
childprocess (>= 0.2.5)
|
||||||
|
multi_json (~> 1.0)
|
||||||
|
rubyzip
|
||||||
|
websocket (~> 1.0.4)
|
||||||
shoulda-matchers (1.0.0)
|
shoulda-matchers (1.0.0)
|
||||||
slop (3.4.7)
|
slop (3.4.4)
|
||||||
spork (0.9.2)
|
spork (0.9.2)
|
||||||
sprockets (2.2.2)
|
sprockets (2.2.2)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
@@ -208,25 +195,27 @@ GEM
|
|||||||
therubyracer (0.10.2)
|
therubyracer (0.10.2)
|
||||||
libv8 (~> 3.3.10)
|
libv8 (~> 3.3.10)
|
||||||
thor (0.18.1)
|
thor (0.18.1)
|
||||||
tilt (1.4.1)
|
tilt (1.3.6)
|
||||||
timers (1.1.0)
|
treetop (1.4.12)
|
||||||
treetop (1.4.15)
|
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
|
turnip (0.3.1)
|
||||||
|
gherkin (>= 2.5)
|
||||||
|
rspec (~> 2.0)
|
||||||
twitter-bootstrap-rails (2.0.9)
|
twitter-bootstrap-rails (2.0.9)
|
||||||
actionpack (>= 3.1)
|
actionpack (>= 3.1)
|
||||||
less-rails (~> 2.2.2)
|
less-rails (~> 2.2.2)
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
therubyracer (~> 0.10.1)
|
therubyracer (~> 0.10.1)
|
||||||
tzinfo (0.3.38)
|
tzinfo (0.3.37)
|
||||||
uglifier (2.4.0)
|
uglifier (2.1.2)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
json (>= 1.8.0)
|
multi_json (~> 1.0, >= 1.0.2)
|
||||||
warden (1.1.1)
|
warden (1.1.1)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
websocket-driver (0.3.2)
|
websocket (1.0.7)
|
||||||
will_paginate (3.0.5)
|
will_paginate (3.0.4)
|
||||||
xpath (2.0.0)
|
xpath (0.1.4)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
@@ -236,30 +225,28 @@ DEPENDENCIES
|
|||||||
acts_as_loggable!
|
acts_as_loggable!
|
||||||
bootstrap-will_paginate (~> 0.0.6)
|
bootstrap-will_paginate (~> 0.0.6)
|
||||||
cancan
|
cancan
|
||||||
capybara (~> 2.2.1)
|
capybara (~> 1.1.2)
|
||||||
coffee-rails (~> 3.2.1)
|
coffee-rails (~> 3.2.1)
|
||||||
database_cleaner (~> 1.2.0)
|
database_cleaner
|
||||||
decent_exposure (~> 1.0.1)
|
decent_exposure (~> 1.0.1)
|
||||||
devise (~> 2.0.4)
|
devise (~> 2.0.4)
|
||||||
factory_girl_rails (~> 1.2)
|
factory_girl_rails (~> 1.2)
|
||||||
faker (~> 1.2.0)
|
guard-rspec
|
||||||
guard-rspec (~> 4.2.6)
|
guard-spork
|
||||||
guard-spork (~> 1.5.1)
|
|
||||||
haml-rails (~> 0.3.4)
|
haml-rails (~> 0.3.4)
|
||||||
jbuilder (~> 2.0.3)
|
|
||||||
jquery-rails (~> 2.0)
|
jquery-rails (~> 2.0)
|
||||||
launchy (~> 2.4.2)
|
launchy
|
||||||
netzke-basepack (~> 0.8.0)
|
netzke-basepack (~> 0.8.0)
|
||||||
netzke-cancan
|
netzke-cancan
|
||||||
netzke-core (~> 0.8.0)
|
netzke-core (~> 0.8.0)
|
||||||
pg (~> 0.17.1)
|
pg
|
||||||
poltergeist (~> 1.5.0)
|
|
||||||
pry (~> 0.9.8)
|
pry (~> 0.9.8)
|
||||||
rails (= 3.2.13)
|
rails (= 3.2.13)
|
||||||
rb-fsevent
|
rb-fsevent
|
||||||
rspec-rails (~> 2.14.0)
|
rspec-rails (~> 2.8.1)
|
||||||
shoulda-matchers (~> 1.0.0)
|
shoulda-matchers (~> 1.0.0)
|
||||||
spork (~> 0.9.2)
|
spork
|
||||||
|
turnip (~> 0.3.0)
|
||||||
twitter-bootstrap-rails (~> 2.0.3)
|
twitter-bootstrap-rails (~> 2.0.3)
|
||||||
uglifier (>= 1.0.3)
|
uglifier (>= 1.0.3)
|
||||||
will_paginate (~> 3.0.3)
|
will_paginate (~> 3.0.3)
|
||||||
|
|||||||
@@ -1,25 +1,3 @@
|
|||||||
# About
|
|
||||||
A web application for bicycle collectives to track bicycles, bicycle work history, volunteer hours, volunteer work history, and volunteers currently in the shop.
|
|
||||||
|
|
||||||
See an overview video of what it looks like and how it works here: https://www.youtube.com/watch?v=0-JjM6d9nK4.
|
|
||||||
|
|
||||||
## Instructions/Guides
|
|
||||||
|
|
||||||
### Adding a User
|
|
||||||
To add a user, a user must sign themselves up from the initial login screen. An admin can later log in to grant that user admin privileges afterward, if desired.
|
|
||||||
|
|
||||||
### Adding a Bike
|
|
||||||
How to add a bike to the database: https://www.youtube.com/watch?v=1IchWUdMQ90.
|
|
||||||
|
|
||||||
## Views
|
|
||||||
The app has two different views. One for "core" volunteers which I consider admins, and another for "customer" volunteers which I consider users. Because of the Netzke/ExtJS framework I used, the current UI is non-intuitive and I feel like is only adequate for admins who can take the time to learn the system. I'm in the process of designing a simpler mobile friendly UI with the essential functionality that's intended for users.
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
Currently, at the Velocipede collective we have it running on a computer in the shop on the local network. The reason for this, is so that it's only accessible from within the shop. I'm weighing out different methods for ensuring that users can only log in from within the shop (and not from home), such as a shop password that only admins can see and would make visible from within the physical bike shop. I also don't have to worry about security issues while the app is in development. In the future, I'd like to see the app hosted much like http://freehub.bikekitchen.org/.
|
|
||||||
|
|
||||||
## Ideas
|
|
||||||
At Velocipede, with a mobile friendly UI for users, I'm hoping we can get donations of old, unused smart phones, connected via local wifi, that can be used as stations to log a volunteer's work and hours. They can be secured by gluing cables into the earphone jacks to deter theft if necessary. This might be another way that the collective can promote reuse of materials.
|
|
||||||
|
|
||||||
# Developer Setup
|
# Developer Setup
|
||||||
|
|
||||||
1. use rvm
|
1. use rvm
|
||||||
@@ -27,8 +5,6 @@ At Velocipede, with a mobile friendly UI for users, I'm hoping we can get donati
|
|||||||
1. `gem install bundler`
|
1. `gem install bundler`
|
||||||
1. `bundle`
|
1. `bundle`
|
||||||
1. Install Postgres (Mac OSX instructions below)
|
1. Install Postgres (Mac OSX instructions below)
|
||||||
1. Copy over DB config: `cp config/database.yml.example config/database.yml`
|
|
||||||
1. Update config with your database (velocipede), user (velocipede), and password.
|
|
||||||
1. `rake db:create db:migrate`
|
1. `rake db:create db:migrate`
|
||||||
1. `rake db:seed`
|
1. `rake db:seed`
|
||||||
1. Download extJS 4.1 (A version of 4.1 is hosted here: http://my.jasondenney.com/extjs-4.1.1.zip) Latest versions at http://www.sencha.com/products/extjs. Unzip and place where ever you like.
|
1. Download extJS 4.1 (A version of 4.1 is hosted here: http://my.jasondenney.com/extjs-4.1.1.zip) Latest versions at http://www.sencha.com/products/extjs. Unzip and place where ever you like.
|
||||||
@@ -43,11 +19,8 @@ At Velocipede, with a mobile friendly UI for users, I'm hoping we can get donati
|
|||||||
1. Start Postgres `pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start`
|
1. Start Postgres `pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start`
|
||||||
1. Create your PG user `createuser -d -P velocipede`
|
1. Create your PG user `createuser -d -P velocipede`
|
||||||
1. Create your database `createdb -U velocipede --owner=velocipede velocipede`
|
1. Create your database `createdb -U velocipede --owner=velocipede velocipede`
|
||||||
|
1. Copy over DB config: `cp config/database.yml.example config/database.yml`
|
||||||
# Testing
|
1. Update config with your database (velocipede), user (velocipede), and password.
|
||||||
|
|
||||||
1. Install phantomjs `brew install phantomjs`
|
|
||||||
1. Run tests with `rspec`
|
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
Add icons
|
Add icons
|
||||||
|
|||||||
@@ -12,8 +12,4 @@
|
|||||||
//
|
//
|
||||||
//= require jquery
|
//= require jquery
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require twitter/bootstrap/bootstrap-button
|
//= require custom_netzke_helpers
|
||||||
//= require twitter/bootstrap/bootstrap-modal
|
|
||||||
//= require utils
|
|
||||||
//= require bootstrap-datepicker
|
|
||||||
//= require bootstrap-timepicker
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
$('.btn').button();
|
|
||||||
|
|
||||||
$("#add_bike_submit").click(function(){
|
|
||||||
|
|
||||||
json_data = { bikes: [{
|
|
||||||
serial_number: $("#serial_number").val(),
|
|
||||||
bike_brand_id: parseInt($("#bike_brand_id").val()),
|
|
||||||
shop_id: parseInt($("#shop_id").val()),
|
|
||||||
model: $("#model").val(),
|
|
||||||
bike_style_id: parseInt($('input[name=bike_style]:checked').val()),
|
|
||||||
seat_tube_height: parseFloat($("#seat_tube_height").val()),
|
|
||||||
bike_condition_id: parseInt($('input[name=bike_condition]:checked').val()),
|
|
||||||
bike_purpose_id: 1,
|
|
||||||
bike_wheel_size_id: parseInt($("#bike_wheel_size_id").val()),
|
|
||||||
}]};
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: $("#add_bike_submit").data("url"),
|
|
||||||
type: "POST",
|
|
||||||
data: JSON.stringify(json_data),
|
|
||||||
contentType: 'application/json',
|
|
||||||
dataType: "json",
|
|
||||||
success: function(data, status, xhr){
|
|
||||||
window.location = data.bikes[0].id + "?add_bike=1";
|
|
||||||
},
|
|
||||||
error: function(data, status ){
|
|
||||||
displayFormErrors(data.responseJSON);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
-474
@@ -1,474 +0,0 @@
|
|||||||
/* =========================================================
|
|
||||||
* bootstrap-datepicker.js
|
|
||||||
* http://www.eyecon.ro/bootstrap-datepicker
|
|
||||||
* =========================================================
|
|
||||||
* Copyright 2012 Stefan Petre
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ========================================================= */
|
|
||||||
|
|
||||||
!function( $ ) {
|
|
||||||
|
|
||||||
// Picker object
|
|
||||||
|
|
||||||
var Datepicker = function(element, options){
|
|
||||||
this.element = $(element);
|
|
||||||
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
|
|
||||||
this.picker = $(DPGlobal.template)
|
|
||||||
.appendTo('body')
|
|
||||||
.on({
|
|
||||||
click: $.proxy(this.click, this)//,
|
|
||||||
//mousedown: $.proxy(this.mousedown, this)
|
|
||||||
});
|
|
||||||
this.isInput = this.element.is('input');
|
|
||||||
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
|
|
||||||
|
|
||||||
if (this.isInput) {
|
|
||||||
this.element.on({
|
|
||||||
focus: $.proxy(this.show, this),
|
|
||||||
//blur: $.proxy(this.hide, this),
|
|
||||||
keyup: $.proxy(this.update, this)
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (this.component){
|
|
||||||
this.component.on('click', $.proxy(this.show, this));
|
|
||||||
} else {
|
|
||||||
this.element.on('click', $.proxy(this.show, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0;
|
|
||||||
if (typeof this.minViewMode === 'string') {
|
|
||||||
switch (this.minViewMode) {
|
|
||||||
case 'months':
|
|
||||||
this.minViewMode = 1;
|
|
||||||
break;
|
|
||||||
case 'years':
|
|
||||||
this.minViewMode = 2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.minViewMode = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.viewMode = options.viewMode||this.element.data('date-viewmode')||0;
|
|
||||||
if (typeof this.viewMode === 'string') {
|
|
||||||
switch (this.viewMode) {
|
|
||||||
case 'months':
|
|
||||||
this.viewMode = 1;
|
|
||||||
break;
|
|
||||||
case 'years':
|
|
||||||
this.viewMode = 2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.viewMode = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.startViewMode = this.viewMode;
|
|
||||||
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
|
|
||||||
this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
|
|
||||||
this.onRender = options.onRender;
|
|
||||||
this.fillDow();
|
|
||||||
this.fillMonths();
|
|
||||||
this.update();
|
|
||||||
this.showMode();
|
|
||||||
};
|
|
||||||
|
|
||||||
Datepicker.prototype = {
|
|
||||||
constructor: Datepicker,
|
|
||||||
|
|
||||||
show: function(e) {
|
|
||||||
this.picker.show();
|
|
||||||
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
|
||||||
this.place();
|
|
||||||
$(window).on('resize', $.proxy(this.place, this));
|
|
||||||
if (e ) {
|
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
if (!this.isInput) {
|
|
||||||
}
|
|
||||||
var that = this;
|
|
||||||
$(document).on('mousedown', function(ev){
|
|
||||||
if ($(ev.target).closest('.datepicker').length == 0) {
|
|
||||||
that.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.element.trigger({
|
|
||||||
type: 'show',
|
|
||||||
date: this.date
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
hide: function(){
|
|
||||||
this.picker.hide();
|
|
||||||
$(window).off('resize', this.place);
|
|
||||||
this.viewMode = this.startViewMode;
|
|
||||||
this.showMode();
|
|
||||||
if (!this.isInput) {
|
|
||||||
$(document).off('mousedown', this.hide);
|
|
||||||
}
|
|
||||||
//this.set();
|
|
||||||
this.element.trigger({
|
|
||||||
type: 'hide',
|
|
||||||
date: this.date
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
set: function() {
|
|
||||||
var formated = DPGlobal.formatDate(this.date, this.format);
|
|
||||||
if (!this.isInput) {
|
|
||||||
if (this.component){
|
|
||||||
this.element.find('input').prop('value', formated);
|
|
||||||
}
|
|
||||||
this.element.data('date', formated);
|
|
||||||
} else {
|
|
||||||
this.element.prop('value', formated);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setValue: function(newDate) {
|
|
||||||
if (typeof newDate === 'string') {
|
|
||||||
this.date = DPGlobal.parseDate(newDate, this.format);
|
|
||||||
} else {
|
|
||||||
this.date = new Date(newDate);
|
|
||||||
}
|
|
||||||
this.set();
|
|
||||||
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
|
|
||||||
this.fill();
|
|
||||||
},
|
|
||||||
|
|
||||||
place: function(){
|
|
||||||
var offset = this.component ? this.component.offset() : this.element.offset();
|
|
||||||
this.picker.css({
|
|
||||||
top: offset.top + this.height,
|
|
||||||
left: offset.left
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
update: function(newDate){
|
|
||||||
this.date = DPGlobal.parseDate(
|
|
||||||
typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')),
|
|
||||||
this.format
|
|
||||||
);
|
|
||||||
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
|
|
||||||
this.fill();
|
|
||||||
},
|
|
||||||
|
|
||||||
fillDow: function(){
|
|
||||||
var dowCnt = this.weekStart;
|
|
||||||
var html = '<tr>';
|
|
||||||
while (dowCnt < this.weekStart + 7) {
|
|
||||||
html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>';
|
|
||||||
}
|
|
||||||
html += '</tr>';
|
|
||||||
this.picker.find('.datepicker-days thead').append(html);
|
|
||||||
},
|
|
||||||
|
|
||||||
fillMonths: function(){
|
|
||||||
var html = '';
|
|
||||||
var i = 0
|
|
||||||
while (i < 12) {
|
|
||||||
html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
|
|
||||||
}
|
|
||||||
this.picker.find('.datepicker-months td').append(html);
|
|
||||||
},
|
|
||||||
|
|
||||||
fill: function() {
|
|
||||||
var d = new Date(this.viewDate),
|
|
||||||
year = d.getFullYear(),
|
|
||||||
month = d.getMonth(),
|
|
||||||
currentDate = this.date.valueOf();
|
|
||||||
this.picker.find('.datepicker-days th:eq(1)')
|
|
||||||
.text(DPGlobal.dates.months[month]+' '+year);
|
|
||||||
var prevMonth = new Date(year, month-1, 28,0,0,0,0),
|
|
||||||
day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
|
|
||||||
prevMonth.setDate(day);
|
|
||||||
prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
|
|
||||||
var nextMonth = new Date(prevMonth);
|
|
||||||
nextMonth.setDate(nextMonth.getDate() + 42);
|
|
||||||
nextMonth = nextMonth.valueOf();
|
|
||||||
var html = [];
|
|
||||||
var clsName,
|
|
||||||
prevY,
|
|
||||||
prevM;
|
|
||||||
while(prevMonth.valueOf() < nextMonth) {
|
|
||||||
if (prevMonth.getDay() === this.weekStart) {
|
|
||||||
html.push('<tr>');
|
|
||||||
}
|
|
||||||
clsName = this.onRender(prevMonth);
|
|
||||||
prevY = prevMonth.getFullYear();
|
|
||||||
prevM = prevMonth.getMonth();
|
|
||||||
if ((prevM < month && prevY === year) || prevY < year) {
|
|
||||||
clsName += ' old';
|
|
||||||
} else if ((prevM > month && prevY === year) || prevY > year) {
|
|
||||||
clsName += ' new';
|
|
||||||
}
|
|
||||||
if (prevMonth.valueOf() === currentDate) {
|
|
||||||
clsName += ' active';
|
|
||||||
}
|
|
||||||
html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>');
|
|
||||||
if (prevMonth.getDay() === this.weekEnd) {
|
|
||||||
html.push('</tr>');
|
|
||||||
}
|
|
||||||
prevMonth.setDate(prevMonth.getDate()+1);
|
|
||||||
}
|
|
||||||
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
|
||||||
var currentYear = this.date.getFullYear();
|
|
||||||
|
|
||||||
var months = this.picker.find('.datepicker-months')
|
|
||||||
.find('th:eq(1)')
|
|
||||||
.text(year)
|
|
||||||
.end()
|
|
||||||
.find('span').removeClass('active');
|
|
||||||
if (currentYear === year) {
|
|
||||||
months.eq(this.date.getMonth()).addClass('active');
|
|
||||||
}
|
|
||||||
|
|
||||||
html = '';
|
|
||||||
year = parseInt(year/10, 10) * 10;
|
|
||||||
var yearCont = this.picker.find('.datepicker-years')
|
|
||||||
.find('th:eq(1)')
|
|
||||||
.text(year + '-' + (year + 9))
|
|
||||||
.end()
|
|
||||||
.find('td');
|
|
||||||
year -= 1;
|
|
||||||
for (var i = -1; i < 11; i++) {
|
|
||||||
html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>';
|
|
||||||
year += 1;
|
|
||||||
}
|
|
||||||
yearCont.html(html);
|
|
||||||
},
|
|
||||||
|
|
||||||
click: function(e) {
|
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
var target = $(e.target).closest('span, td, th');
|
|
||||||
if (target.length === 1) {
|
|
||||||
switch(target[0].nodeName.toLowerCase()) {
|
|
||||||
case 'th':
|
|
||||||
switch(target[0].className) {
|
|
||||||
case 'switch':
|
|
||||||
this.showMode(1);
|
|
||||||
break;
|
|
||||||
case 'prev':
|
|
||||||
case 'next':
|
|
||||||
this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
|
|
||||||
this.viewDate,
|
|
||||||
this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
|
|
||||||
DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1)
|
|
||||||
);
|
|
||||||
this.fill();
|
|
||||||
this.set();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'span':
|
|
||||||
if (target.is('.month')) {
|
|
||||||
var month = target.parent().find('span').index(target);
|
|
||||||
this.viewDate.setMonth(month);
|
|
||||||
} else {
|
|
||||||
var year = parseInt(target.text(), 10)||0;
|
|
||||||
this.viewDate.setFullYear(year);
|
|
||||||
}
|
|
||||||
if (this.viewMode !== 0) {
|
|
||||||
this.date = new Date(this.viewDate);
|
|
||||||
this.element.trigger({
|
|
||||||
type: 'changeDate',
|
|
||||||
date: this.date,
|
|
||||||
viewMode: DPGlobal.modes[this.viewMode].clsName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.showMode(-1);
|
|
||||||
this.fill();
|
|
||||||
this.set();
|
|
||||||
break;
|
|
||||||
case 'td':
|
|
||||||
if (target.is('.day') && !target.is('.disabled')){
|
|
||||||
var day = parseInt(target.text(), 10)||1;
|
|
||||||
var month = this.viewDate.getMonth();
|
|
||||||
if (target.is('.old')) {
|
|
||||||
month -= 1;
|
|
||||||
} else if (target.is('.new')) {
|
|
||||||
month += 1;
|
|
||||||
}
|
|
||||||
var year = this.viewDate.getFullYear();
|
|
||||||
this.date = new Date(year, month, day,0,0,0,0);
|
|
||||||
this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0);
|
|
||||||
this.fill();
|
|
||||||
this.set();
|
|
||||||
this.element.trigger({
|
|
||||||
type: 'changeDate',
|
|
||||||
date: this.date,
|
|
||||||
viewMode: DPGlobal.modes[this.viewMode].clsName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mousedown: function(e){
|
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
},
|
|
||||||
|
|
||||||
showMode: function(dir) {
|
|
||||||
if (dir) {
|
|
||||||
this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
|
|
||||||
}
|
|
||||||
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.datepicker = function ( option, val ) {
|
|
||||||
return this.each(function () {
|
|
||||||
var $this = $(this),
|
|
||||||
data = $this.data('datepicker'),
|
|
||||||
options = typeof option === 'object' && option;
|
|
||||||
if (!data) {
|
|
||||||
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
|
|
||||||
}
|
|
||||||
if (typeof option === 'string') data[option](val);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.datepicker.defaults = {
|
|
||||||
onRender: function(date) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.fn.datepicker.Constructor = Datepicker;
|
|
||||||
|
|
||||||
var DPGlobal = {
|
|
||||||
modes: [
|
|
||||||
{
|
|
||||||
clsName: 'days',
|
|
||||||
navFnc: 'Month',
|
|
||||||
navStep: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
clsName: 'months',
|
|
||||||
navFnc: 'FullYear',
|
|
||||||
navStep: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
clsName: 'years',
|
|
||||||
navFnc: 'FullYear',
|
|
||||||
navStep: 10
|
|
||||||
}],
|
|
||||||
dates:{
|
|
||||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
|
||||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
|
||||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
|
||||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
|
||||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
||||||
},
|
|
||||||
isLeapYear: function (year) {
|
|
||||||
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
|
||||||
},
|
|
||||||
getDaysInMonth: function (year, month) {
|
|
||||||
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
|
||||||
},
|
|
||||||
parseFormat: function(format){
|
|
||||||
var separator = format.match(/[.\/\-\s].*?/),
|
|
||||||
parts = format.split(/\W+/);
|
|
||||||
if (!separator || !parts || parts.length === 0){
|
|
||||||
throw new Error("Invalid date format.");
|
|
||||||
}
|
|
||||||
return {separator: separator, parts: parts};
|
|
||||||
},
|
|
||||||
parseDate: function(date, format) {
|
|
||||||
var parts = date.split(format.separator),
|
|
||||||
date = new Date(),
|
|
||||||
val;
|
|
||||||
date.setHours(0);
|
|
||||||
date.setMinutes(0);
|
|
||||||
date.setSeconds(0);
|
|
||||||
date.setMilliseconds(0);
|
|
||||||
if (parts.length === format.parts.length) {
|
|
||||||
var year = date.getFullYear(), day = date.getDate(), month = date.getMonth();
|
|
||||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
|
||||||
val = parseInt(parts[i], 10)||1;
|
|
||||||
switch(format.parts[i]) {
|
|
||||||
case 'dd':
|
|
||||||
case 'd':
|
|
||||||
day = val;
|
|
||||||
date.setDate(val);
|
|
||||||
break;
|
|
||||||
case 'mm':
|
|
||||||
case 'm':
|
|
||||||
month = val - 1;
|
|
||||||
date.setMonth(val - 1);
|
|
||||||
break;
|
|
||||||
case 'yy':
|
|
||||||
year = 2000 + val;
|
|
||||||
date.setFullYear(2000 + val);
|
|
||||||
break;
|
|
||||||
case 'yyyy':
|
|
||||||
year = val;
|
|
||||||
date.setFullYear(val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
date = new Date(year, month, day, 0 ,0 ,0);
|
|
||||||
}
|
|
||||||
return date;
|
|
||||||
},
|
|
||||||
formatDate: function(date, format){
|
|
||||||
var val = {
|
|
||||||
d: date.getDate(),
|
|
||||||
m: date.getMonth() + 1,
|
|
||||||
yy: date.getFullYear().toString().substring(2),
|
|
||||||
yyyy: date.getFullYear()
|
|
||||||
};
|
|
||||||
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
|
||||||
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
|
||||||
var date = [];
|
|
||||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
|
||||||
date.push(val[format.parts[i]]);
|
|
||||||
}
|
|
||||||
return date.join(format.separator);
|
|
||||||
},
|
|
||||||
headTemplate: '<thead>'+
|
|
||||||
'<tr>'+
|
|
||||||
'<th class="prev">‹</th>'+
|
|
||||||
'<th colspan="5" class="switch"></th>'+
|
|
||||||
'<th class="next">›</th>'+
|
|
||||||
'</tr>'+
|
|
||||||
'</thead>',
|
|
||||||
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
|
|
||||||
};
|
|
||||||
DPGlobal.template = '<div class="datepicker dropdown-menu">'+
|
|
||||||
'<div class="datepicker-days">'+
|
|
||||||
'<table class=" table-condensed">'+
|
|
||||||
DPGlobal.headTemplate+
|
|
||||||
'<tbody></tbody>'+
|
|
||||||
'</table>'+
|
|
||||||
'</div>'+
|
|
||||||
'<div class="datepicker-months">'+
|
|
||||||
'<table class="table-condensed">'+
|
|
||||||
DPGlobal.headTemplate+
|
|
||||||
DPGlobal.contTemplate+
|
|
||||||
'</table>'+
|
|
||||||
'</div>'+
|
|
||||||
'<div class="datepicker-years">'+
|
|
||||||
'<table class="table-condensed">'+
|
|
||||||
DPGlobal.headTemplate+
|
|
||||||
DPGlobal.contTemplate+
|
|
||||||
'</table>'+
|
|
||||||
'</div>'+
|
|
||||||
'</div>';
|
|
||||||
|
|
||||||
}( window.jQuery );
|
|
||||||
-1097
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,150 @@
|
|||||||
|
//when signed out, or session expires forward to sign in page
|
||||||
|
Ext.Ajax.on('requestexception', function(conn, response, options) {
|
||||||
|
if (response.status === 401) { window.location = '/users/sign_in'; }
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
Ext.define('Ext.ux.form.field.ColorCombo', {
|
||||||
|
extend:'Ext.form.FieldContainer',
|
||||||
|
mixins:{
|
||||||
|
field:'Ext.form.field.Field'
|
||||||
|
},
|
||||||
|
alias: 'widget.xcolorcombo',
|
||||||
|
|
||||||
|
//configurables
|
||||||
|
combineErrors: true,
|
||||||
|
msgTarget: 'under',
|
||||||
|
layout: 'hbox',
|
||||||
|
readOnly: false,
|
||||||
|
|
||||||
|
// properties
|
||||||
|
colorValue: null,
|
||||||
|
/**
|
||||||
|
* @property dateField
|
||||||
|
* @type Ext.form.field.Date
|
||||||
|
*/
|
||||||
|
colorField: null,
|
||||||
|
|
||||||
|
initComponent: function(){
|
||||||
|
var me = this
|
||||||
|
,i = 0
|
||||||
|
,key
|
||||||
|
,tab;
|
||||||
|
|
||||||
|
me.items = me.items || [];
|
||||||
|
|
||||||
|
me.colorField = Ext.create('Ext.form.field.Trigger', {
|
||||||
|
flex:1,
|
||||||
|
isFormField:false, //exclude from field query's
|
||||||
|
submitValue:false,
|
||||||
|
readOnly: me.readOnly,
|
||||||
|
onTriggerClick: function() {
|
||||||
|
//show renders, so put first
|
||||||
|
me.picker.show();
|
||||||
|
me.picker.alignTo(me.colorField.inputEl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
me.items.push(me.colorField);
|
||||||
|
|
||||||
|
me.picker = Ext.create('Ext.picker.Color', {
|
||||||
|
renderTo: document.body,
|
||||||
|
floating: true,
|
||||||
|
hidden: true,
|
||||||
|
style: {
|
||||||
|
backgroundColor: "#fff"
|
||||||
|
},
|
||||||
|
listeners: {
|
||||||
|
scope:this,
|
||||||
|
select: function(field, value, opts){
|
||||||
|
me.setValue(value);
|
||||||
|
me.picker.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
me.items.push(me.picker);
|
||||||
|
|
||||||
|
for (; i < me.items.length; i++) {
|
||||||
|
me.items[i].on('focus', Ext.bind(me.onItemFocus, me));
|
||||||
|
me.items[i].on('blur', Ext.bind(me.onItemBlur, me));
|
||||||
|
me.items[i].on('specialkey', function(field, event){
|
||||||
|
key = event.getKey();
|
||||||
|
tab = key == event.TAB;
|
||||||
|
|
||||||
|
if (tab && me.focussedItem == me.dateField) {
|
||||||
|
event.stopEvent();
|
||||||
|
me.timeField.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
me.fireEvent('specialkey', field, event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
me.callParent();
|
||||||
|
|
||||||
|
// this dummy is necessary because Ext.Editor will not check whether an inputEl is present or not
|
||||||
|
this.inputEl = {
|
||||||
|
dom: document.createElement('div'),
|
||||||
|
swallowEvent:function(){}
|
||||||
|
};
|
||||||
|
|
||||||
|
me.initField();
|
||||||
|
},
|
||||||
|
focus:function(){
|
||||||
|
this.callParent(arguments);
|
||||||
|
this.colorField.focus();
|
||||||
|
var me = this;
|
||||||
|
},
|
||||||
|
|
||||||
|
onItemFocus:function(item){
|
||||||
|
if (this.blurTask){
|
||||||
|
this.blurTask.cancel();
|
||||||
|
}
|
||||||
|
this.focussedItem = item;
|
||||||
|
},
|
||||||
|
|
||||||
|
onItemBlur:function(item, e){
|
||||||
|
var me = this;
|
||||||
|
if (item != me.focussedItem){ return; }
|
||||||
|
// 100ms to focus a new item that belongs to us, otherwise we will assume the user left the field
|
||||||
|
me.blurTask = new Ext.util.DelayedTask(function(){
|
||||||
|
me.picker.hide();
|
||||||
|
me.fireEvent('blur', me, e);
|
||||||
|
});
|
||||||
|
me.blurTask.delay(100);
|
||||||
|
},
|
||||||
|
|
||||||
|
getValue: function(){
|
||||||
|
var value = null
|
||||||
|
,color = this.colorField.getSubmitValue();
|
||||||
|
|
||||||
|
if (color){
|
||||||
|
value = this.colorField.getValue();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
|
getSubmitValue: function(){
|
||||||
|
// var value = this.getValue();
|
||||||
|
// return value ? Ext.Date.format(value, this.dateTimeFormat) : null;
|
||||||
|
|
||||||
|
var me = this
|
||||||
|
,value = me.getValue();
|
||||||
|
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
|
setValue: function(value){
|
||||||
|
this.colorField.setValue(value);
|
||||||
|
},
|
||||||
|
// Bug? A field-mixin submits the data from getValue, not getSubmitValue
|
||||||
|
getSubmitData: function(){
|
||||||
|
var me = this
|
||||||
|
,data = null;
|
||||||
|
|
||||||
|
if (!me.disabled && me.submitValue && !me.isFileUpload()) {
|
||||||
|
data = {};
|
||||||
|
data[me.getName()] = '' + me.getSubmitValue();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#checkin_menu").show();
|
$("#checkin_menu").show();
|
||||||
$("#checkin").click( function(e){
|
$("#checkin").click( function(e){
|
||||||
var username = $("#user_username").val();
|
var username = $("#user_email").val();
|
||||||
var password = $("#user_password").val();
|
var password = $("#user_password").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -13,7 +13,7 @@ $(document).ready(function(){
|
|||||||
complete: function() { },
|
complete: function() { },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
alert("Checked IN!");
|
alert("Checked IN!");
|
||||||
$("#user_username").val('');
|
$("#user_email").val('');
|
||||||
$("#user_password").val('');
|
$("#user_password").val('');
|
||||||
},
|
},
|
||||||
error: function(data,textStatus) {
|
error: function(data,textStatus) {
|
||||||
@@ -22,7 +22,7 @@ $(document).ready(function(){
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
$("#checkout").click( function(e){
|
$("#checkout").click( function(e){
|
||||||
var username = $("#user_username").val();
|
var username = $("#user_email").val();
|
||||||
var password = $("#user_password").val();
|
var password = $("#user_password").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@@ -34,8 +34,7 @@ $(document).ready(function(){
|
|||||||
complete: function() { },
|
complete: function() { },
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
alert("Checked OUT!");
|
alert("Checked OUT!");
|
||||||
|
$("#user_email").val('');
|
||||||
$("#user_username").val('');
|
|
||||||
$("#user_password").val('');
|
$("#user_password").val('');
|
||||||
},
|
},
|
||||||
error: function(data,textStatus) {
|
error: function(data,textStatus) {
|
||||||
|
|||||||
@@ -1,379 +0,0 @@
|
|||||||
//when signed out, or session expires forward to sign in page
|
|
||||||
Ext.Ajax.on('requestexception', function(conn, response, options) {
|
|
||||||
if (response.status === 401) { window.location = '/users/sign_in'; }
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
//Override default netzke time entry field
|
|
||||||
Ext.define('Ext.ux.form.field.DateTime', {
|
|
||||||
extend:'Ext.form.FieldContainer',
|
|
||||||
mixins:{
|
|
||||||
field:'Ext.form.field.Field'
|
|
||||||
},
|
|
||||||
alias: 'widget.xdatetime',
|
|
||||||
|
|
||||||
//configurables
|
|
||||||
|
|
||||||
combineErrors: true,
|
|
||||||
msgTarget: 'under',
|
|
||||||
layout: 'hbox',
|
|
||||||
readOnly: false,
|
|
||||||
|
|
||||||
dateFormat: 'Y-m-d',
|
|
||||||
dateSubmitFormat: 'Y-m-d',
|
|
||||||
timeFormat: 'H:i:s',
|
|
||||||
timeSubmitFormat: 'H:i:s',
|
|
||||||
submitFormat: 'c',
|
|
||||||
dateConfig:{},
|
|
||||||
timeConfig:{},
|
|
||||||
|
|
||||||
|
|
||||||
// properties
|
|
||||||
|
|
||||||
dateValue: null, // Holds the actual date
|
|
||||||
|
|
||||||
dateField: null,
|
|
||||||
|
|
||||||
hourField: null,
|
|
||||||
minuteField: null,
|
|
||||||
ampmField: null,
|
|
||||||
|
|
||||||
initComponent: function(){
|
|
||||||
var me = this
|
|
||||||
,i = 0
|
|
||||||
,key
|
|
||||||
,tab;
|
|
||||||
|
|
||||||
me.items = me.items || [];
|
|
||||||
|
|
||||||
me.dateField = Ext.create('Ext.form.field.Date', Ext.apply({
|
|
||||||
format:me.dateFormat,
|
|
||||||
flex:1,
|
|
||||||
isFormField:false, //exclude from field query's
|
|
||||||
submitValue:false,
|
|
||||||
submitFormat: me.dateSubmitFormat,
|
|
||||||
readOnly: me.readOnly
|
|
||||||
}, me.dateConfig));
|
|
||||||
me.items.push(me.dateField);
|
|
||||||
|
|
||||||
me.hourField = Ext.create('Ext.form.field.Number', {
|
|
||||||
maxWidth: 25,
|
|
||||||
allowBlank: false,
|
|
||||||
allowOnlyWhitespace: false,
|
|
||||||
blankText: "Hour cannot be blank.",
|
|
||||||
allowDecimals: false,
|
|
||||||
maxValue: 12,
|
|
||||||
minValue: 1,
|
|
||||||
maxLength: 2,
|
|
||||||
enforceMaxLength: 2,
|
|
||||||
hideTrigger: true,
|
|
||||||
submitValue:false,
|
|
||||||
flex:1,
|
|
||||||
fieldStyle: "text-align:right;",
|
|
||||||
isFormField:false, //exclude from field query's
|
|
||||||
});
|
|
||||||
me.items.push(me.hourField);
|
|
||||||
|
|
||||||
me.colon = Ext.create('Ext.draw.Text', {
|
|
||||||
text: ':',
|
|
||||||
padding: '3 3 0 3'
|
|
||||||
});
|
|
||||||
me.items.push(me.colon);
|
|
||||||
|
|
||||||
me.minuteField = Ext.create('Ext.form.field.Text', {
|
|
||||||
maxWidth: 30,
|
|
||||||
allowBlank: false,
|
|
||||||
allowOnlyWhitespace: false,
|
|
||||||
blankText: "Minutes cannot be blank.",
|
|
||||||
regex: /[012345]\d/,
|
|
||||||
maxLength: 2,
|
|
||||||
enforceMaxLength: 2,
|
|
||||||
submitValue:false,
|
|
||||||
flex:1,
|
|
||||||
isFormField:false, //exclude from field query's
|
|
||||||
});
|
|
||||||
me.items.push(me.minuteField);
|
|
||||||
|
|
||||||
|
|
||||||
me.ampmField = Ext.create('Ext.form.ComboBox', {
|
|
||||||
maxWidth: 45,
|
|
||||||
value: 'PM',
|
|
||||||
store: ['AM', 'PM'],
|
|
||||||
forceSelection: true,
|
|
||||||
flex:1,
|
|
||||||
editable: false
|
|
||||||
});
|
|
||||||
|
|
||||||
me.items.push(me.ampmField);
|
|
||||||
|
|
||||||
for (; i < me.items.length; i++) {
|
|
||||||
me.items[i].on('focus', Ext.bind(me.onItemFocus, me));
|
|
||||||
me.items[i].on('blur', Ext.bind(me.onItemBlur, me));
|
|
||||||
me.items[i].on('specialkey', function(field, event){
|
|
||||||
key = event.getKey();
|
|
||||||
tab = key == event.TAB;
|
|
||||||
|
|
||||||
if (tab && me.focussedItem == me.dateField) {
|
|
||||||
event.stopEvent();
|
|
||||||
me.timeField.focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
me.fireEvent('specialkey', field, event);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
me.callParent();
|
|
||||||
|
|
||||||
// this dummy is necessary because Ext.Editor will not check whether an inputEl is present or not
|
|
||||||
this.inputEl = {
|
|
||||||
dom: document.createElement('div'),
|
|
||||||
swallowEvent:function(){}
|
|
||||||
};
|
|
||||||
|
|
||||||
me.initField();
|
|
||||||
},
|
|
||||||
|
|
||||||
focus:function(){
|
|
||||||
this.callParent(arguments);
|
|
||||||
this.dateField.focus();
|
|
||||||
},
|
|
||||||
|
|
||||||
onItemFocus:function(item){
|
|
||||||
if (this.blurTask){
|
|
||||||
this.blurTask.cancel();
|
|
||||||
}
|
|
||||||
this.focussedItem = item;
|
|
||||||
},
|
|
||||||
|
|
||||||
onItemBlur:function(item, e){
|
|
||||||
var me = this;
|
|
||||||
if (item != me.focussedItem){ return; }
|
|
||||||
// 100ms to focus a new item that belongs to us, otherwise we will assume the user left the field
|
|
||||||
me.blurTask = new Ext.util.DelayedTask(function(){
|
|
||||||
me.fireEvent('blur', me, e);
|
|
||||||
});
|
|
||||||
me.blurTask.delay(100);
|
|
||||||
},
|
|
||||||
|
|
||||||
getValue: function(){
|
|
||||||
var value = null
|
|
||||||
,date = this.dateField.getSubmitValue()
|
|
||||||
,time = null
|
|
||||||
,format;
|
|
||||||
|
|
||||||
hour = this.hourField.getValue();
|
|
||||||
minute = this.minuteField.getValue();
|
|
||||||
ampm = this.ampmField.getValue();
|
|
||||||
time = Ext.Date.parse(hour + " " + minute + " " + ampm, 'g i A');
|
|
||||||
time = Ext.Date.format(time, this.timeSubmitFormat);
|
|
||||||
|
|
||||||
if (date){
|
|
||||||
if (time){
|
|
||||||
format = this.getFormat();
|
|
||||||
value = Ext.Date.parse(date + ' ' + time, format);
|
|
||||||
} else {
|
|
||||||
value = this.dateField.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
getSubmitValue: function(){
|
|
||||||
// var value = this.getValue();
|
|
||||||
// return value ? Ext.Date.format(value, this.dateTimeFormat) : null;
|
|
||||||
|
|
||||||
var me = this
|
|
||||||
,format = me.getFormat()
|
|
||||||
,value = me.getValue();
|
|
||||||
console.log(value);
|
|
||||||
console.log(format);
|
|
||||||
console.log("formatted: " + Ext.Date.format(value, this.submitFormat));
|
|
||||||
return value ? Ext.Date.format(value, this.submitFormat) : null;
|
|
||||||
},
|
|
||||||
|
|
||||||
setValue: function(value){
|
|
||||||
if (Ext.isString(value) || Ext.isDate(value)){
|
|
||||||
|
|
||||||
if( Ext.isDate(value)){
|
|
||||||
dt = value;
|
|
||||||
}else{
|
|
||||||
dt = new Date(value);
|
|
||||||
value = Ext.Date.parse(value, this.getFormat()); //this.dateTimeFormat
|
|
||||||
}
|
|
||||||
this.dateField.setValue(value);
|
|
||||||
|
|
||||||
hour = Ext.Date.format(dt, 'g');
|
|
||||||
minute = Ext.Date.format(dt, 'i');
|
|
||||||
ampm = Ext.Date.format(dt, 'A');
|
|
||||||
|
|
||||||
this.hourField.setValue(hour);
|
|
||||||
this.minuteField.setRawValue(minute);
|
|
||||||
this.ampmField.setValue(ampm);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getFormat: function(){
|
|
||||||
value = (this.dateField.submitFormat || this.dateField.format) + " " + (this.timeSubmitFormat || this.timeFormat);
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Bug? A field-mixin submits the data from getValue, not getSubmitValue
|
|
||||||
getSubmitData: function(){
|
|
||||||
var me = this
|
|
||||||
,data = null;
|
|
||||||
|
|
||||||
if (!me.disabled && me.submitValue && !me.isFileUpload()) {
|
|
||||||
data = {};
|
|
||||||
data[me.getName()] = '' + me.getSubmitValue();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ext.define('Ext.ux.form.field.ColorCombo', {
|
|
||||||
extend:'Ext.form.FieldContainer',
|
|
||||||
mixins:{
|
|
||||||
field:'Ext.form.field.Field'
|
|
||||||
},
|
|
||||||
alias: 'widget.xcolorcombo',
|
|
||||||
|
|
||||||
//configurables
|
|
||||||
combineErrors: true,
|
|
||||||
msgTarget: 'under',
|
|
||||||
layout: 'hbox',
|
|
||||||
readOnly: false,
|
|
||||||
|
|
||||||
// properties
|
|
||||||
colorValue: null,
|
|
||||||
/**
|
|
||||||
* @property dateField
|
|
||||||
* @type Ext.form.field.Date
|
|
||||||
*/
|
|
||||||
colorField: null,
|
|
||||||
|
|
||||||
initComponent: function(){
|
|
||||||
var me = this
|
|
||||||
,i = 0
|
|
||||||
,key
|
|
||||||
,tab;
|
|
||||||
|
|
||||||
me.items = me.items || [];
|
|
||||||
|
|
||||||
me.colorField = Ext.create('Ext.form.field.Trigger', {
|
|
||||||
flex:1,
|
|
||||||
isFormField:false, //exclude from field query's
|
|
||||||
submitValue:false,
|
|
||||||
readOnly: me.readOnly,
|
|
||||||
onTriggerClick: function() {
|
|
||||||
//show renders, so put first
|
|
||||||
me.picker.show();
|
|
||||||
me.picker.alignTo(me.colorField.inputEl);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
me.items.push(me.colorField);
|
|
||||||
|
|
||||||
me.picker = Ext.create('Ext.picker.Color', {
|
|
||||||
renderTo: document.body,
|
|
||||||
floating: true,
|
|
||||||
hidden: true,
|
|
||||||
style: {
|
|
||||||
backgroundColor: "#fff"
|
|
||||||
},
|
|
||||||
listeners: {
|
|
||||||
scope:this,
|
|
||||||
select: function(field, value, opts){
|
|
||||||
me.setValue(value);
|
|
||||||
me.picker.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
me.items.push(me.picker);
|
|
||||||
|
|
||||||
for (; i < me.items.length; i++) {
|
|
||||||
me.items[i].on('focus', Ext.bind(me.onItemFocus, me));
|
|
||||||
me.items[i].on('blur', Ext.bind(me.onItemBlur, me));
|
|
||||||
me.items[i].on('specialkey', function(field, event){
|
|
||||||
key = event.getKey();
|
|
||||||
tab = key == event.TAB;
|
|
||||||
|
|
||||||
if (tab && me.focussedItem == me.dateField) {
|
|
||||||
event.stopEvent();
|
|
||||||
me.timeField.focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
me.fireEvent('specialkey', field, event);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
me.callParent();
|
|
||||||
|
|
||||||
// this dummy is necessary because Ext.Editor will not check whether an inputEl is present or not
|
|
||||||
this.inputEl = {
|
|
||||||
dom: document.createElement('div'),
|
|
||||||
swallowEvent:function(){}
|
|
||||||
};
|
|
||||||
|
|
||||||
me.initField();
|
|
||||||
},
|
|
||||||
focus:function(){
|
|
||||||
this.callParent(arguments);
|
|
||||||
this.colorField.focus();
|
|
||||||
var me = this;
|
|
||||||
},
|
|
||||||
|
|
||||||
onItemFocus:function(item){
|
|
||||||
if (this.blurTask){
|
|
||||||
this.blurTask.cancel();
|
|
||||||
}
|
|
||||||
this.focussedItem = item;
|
|
||||||
},
|
|
||||||
|
|
||||||
onItemBlur:function(item, e){
|
|
||||||
var me = this;
|
|
||||||
if (item != me.focussedItem){ return; }
|
|
||||||
// 100ms to focus a new item that belongs to us, otherwise we will assume the user left the field
|
|
||||||
me.blurTask = new Ext.util.DelayedTask(function(){
|
|
||||||
me.picker.hide();
|
|
||||||
me.fireEvent('blur', me, e);
|
|
||||||
});
|
|
||||||
me.blurTask.delay(100);
|
|
||||||
},
|
|
||||||
|
|
||||||
getValue: function(){
|
|
||||||
var value = null
|
|
||||||
,color = this.colorField.getSubmitValue();
|
|
||||||
|
|
||||||
if (color){
|
|
||||||
value = this.colorField.getValue();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
getSubmitValue: function(){
|
|
||||||
// var value = this.getValue();
|
|
||||||
// return value ? Ext.Date.format(value, this.dateTimeFormat) : null;
|
|
||||||
|
|
||||||
var me = this
|
|
||||||
,value = me.getValue();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
setValue: function(value){
|
|
||||||
this.colorField.setValue(value);
|
|
||||||
},
|
|
||||||
// Bug? A field-mixin submits the data from getValue, not getSubmitValue
|
|
||||||
getSubmitData: function(){
|
|
||||||
var me = this
|
|
||||||
,data = null;
|
|
||||||
|
|
||||||
if (!me.disabled && me.submitValue && !me.isFileUpload()) {
|
|
||||||
data = {};
|
|
||||||
data[me.getName()] = '' + me.getSubmitValue();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
$("#index_logout").click(function(){
|
|
||||||
$.ajax({
|
|
||||||
type: "DELETE",
|
|
||||||
url: $("#index_logout").data("url"),
|
|
||||||
complete: function(){
|
|
||||||
window.location.href="/";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
$(".task_list_task").click(function(){
|
|
||||||
$("#update_tasks_submit").removeClass("disabled");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#update_tasks_submit").click(function(){
|
|
||||||
|
|
||||||
tasks = [];
|
|
||||||
$(".task_list_task").each(function(){
|
|
||||||
tasks.push({
|
|
||||||
id: parseInt($(this).data("id")),
|
|
||||||
done: $(this).is(":checked")
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
json_data = { tasks: tasks };
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: $("#update_tasks_submit").data("url"),
|
|
||||||
type: "PUT",
|
|
||||||
data: JSON.stringify(json_data),
|
|
||||||
contentType: 'application/json',
|
|
||||||
dataType: "json",
|
|
||||||
success: function(data, status, xhr){
|
|
||||||
//should re-render via JS, but for now reload
|
|
||||||
location.reload();
|
|
||||||
},
|
|
||||||
error: function(data, status ){
|
|
||||||
alert("An error occured updating tasks");
|
|
||||||
//displayFormErrors(data.responseJSON);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
$(document).ready(function(){
|
|
||||||
|
|
||||||
var currentdate = new Date();
|
|
||||||
$("#date_id").datepicker().on('changeDate', function(ev){
|
|
||||||
$("#date_id").datepicker('hide');
|
|
||||||
});
|
|
||||||
$("#date_id").datepicker('setValue', currentdate);
|
|
||||||
|
|
||||||
$("#start_time_id").timepicker();
|
|
||||||
$("#end_time_id").timepicker();
|
|
||||||
|
|
||||||
$("#add_time_entry_submit").click(function(){
|
|
||||||
date = $("#date_id").val();
|
|
||||||
start_date = new Date(date + " " + $("#start_time_id").val());
|
|
||||||
end_date = new Date(date + " " + $("#end_time_id").val());
|
|
||||||
|
|
||||||
forward = $("#add_time_entry_submit").data("forward");
|
|
||||||
|
|
||||||
// If a bike is selected, forward to the bike
|
|
||||||
// checklist.
|
|
||||||
bike_id = parseInt($("#bike_id").val());
|
|
||||||
if( bike_id > 0 ){
|
|
||||||
forward = "/task_lists/" + bike_id + "/edit";
|
|
||||||
}
|
|
||||||
|
|
||||||
json_data = { time_entries: [{
|
|
||||||
start_date: start_date.toISOString(),
|
|
||||||
end_date: end_date.toISOString(),
|
|
||||||
log_action_id: parseInt($('input[name=action_id]:checked').val()),
|
|
||||||
bike_id: bike_id,
|
|
||||||
description: $("#description_id").val(),
|
|
||||||
}]};
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: $("#add_time_entry_submit").data("url"),
|
|
||||||
type: "POST",
|
|
||||||
data: JSON.stringify(json_data),
|
|
||||||
contentType: 'application/json',
|
|
||||||
dataType: "json",
|
|
||||||
success: function(data, status, xhr){
|
|
||||||
window.location = forward;
|
|
||||||
},
|
|
||||||
error: function(data, status ){
|
|
||||||
displayFormErrors(data.responseJSON);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".work_entry-delete-btn").click(function(){
|
|
||||||
row = $(this).closest("tr");
|
|
||||||
entry_id = row.data("id");
|
|
||||||
start_date = row.data("start_date");
|
|
||||||
duration = row.data("duration");
|
|
||||||
description = row.data("description");
|
|
||||||
$("#work_entry_start_date").html(start_date);
|
|
||||||
$("#work_entry_duration").html(duration);
|
|
||||||
$("#work_entry_description").html(description);
|
|
||||||
$("#confirmation_delete").data("entry_id", entry_id);
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#confirmation_delete").click(function(){
|
|
||||||
entry_id = $(this).data("entry_id");
|
|
||||||
url = $("#confirmation_delete").data("url") + entry_id;
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
type: "delete",
|
|
||||||
contentType: 'application/json',
|
|
||||||
success: function(data, status, xhr){
|
|
||||||
location.reload();
|
|
||||||
},
|
|
||||||
error: function(data, status ){
|
|
||||||
displayFormErrors(data.responseJSON);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
function displayFormErrors(data){
|
|
||||||
if( data.errors != undefined ){
|
|
||||||
$.each( data.errors, function( field, errorMsg) {
|
|
||||||
$("#"+field).parents(".control-group").addClass("error");
|
|
||||||
$("#"+field).siblings(".help-block").html(errorMsg);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,5 @@
|
|||||||
* compiled file, but it's generally better to create a new file per style scope.
|
* compiled file, but it's generally better to create a new file per style scope.
|
||||||
*
|
*
|
||||||
*= require_self
|
*= require_self
|
||||||
*= require datepicker
|
*= require_tree .
|
||||||
*= require bootstrap-timepicker
|
|
||||||
*= require bootstrap_and_overrides
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
-146
@@ -1,146 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Timepicker Component for Twitter Bootstrap
|
|
||||||
*
|
|
||||||
* Copyright 2013 Joris de Wit
|
|
||||||
*
|
|
||||||
* Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
.bootstrap-timepicker {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu {
|
|
||||||
left: auto;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:before {
|
|
||||||
left: auto;
|
|
||||||
right: 12px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:after {
|
|
||||||
left: auto;
|
|
||||||
right: 13px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker .add-on {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker .add-on i {
|
|
||||||
display: inline-block;
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.dropdown-menu {
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.dropdown-menu.open {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.dropdown-menu:before {
|
|
||||||
border-bottom: 7px solid rgba(0, 0, 0, 0.2);
|
|
||||||
border-left: 7px solid transparent;
|
|
||||||
border-right: 7px solid transparent;
|
|
||||||
content: "";
|
|
||||||
display: inline-block;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.dropdown-menu:after {
|
|
||||||
border-bottom: 6px solid #FFFFFF;
|
|
||||||
border-left: 6px solid transparent;
|
|
||||||
border-right: 6px solid transparent;
|
|
||||||
content: "";
|
|
||||||
display: inline-block;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-left:before {
|
|
||||||
left: 6px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-left:after {
|
|
||||||
left: 7px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-right:before {
|
|
||||||
right: 6px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-right:after {
|
|
||||||
right: 7px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-top:before {
|
|
||||||
top: -7px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-top:after {
|
|
||||||
top: -6px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-bottom:before {
|
|
||||||
bottom: -7px;
|
|
||||||
border-bottom: 0;
|
|
||||||
border-top: 7px solid #999;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget.timepicker-orient-bottom:after {
|
|
||||||
bottom: -6px;
|
|
||||||
border-bottom: 0;
|
|
||||||
border-top: 6px solid #ffffff;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget a.btn,
|
|
||||||
.bootstrap-timepicker-widget input {
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table {
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td {
|
|
||||||
text-align: center;
|
|
||||||
height: 30px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 2px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td:not(.separator) {
|
|
||||||
min-width: 30px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td span {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td a {
|
|
||||||
border: 1px transparent solid;
|
|
||||||
width: 100%;
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0;
|
|
||||||
padding: 8px 0;
|
|
||||||
outline: 0;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td a:hover {
|
|
||||||
text-decoration: none;
|
|
||||||
background-color: #eee;
|
|
||||||
-webkit-border-radius: 4px;
|
|
||||||
-moz-border-radius: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
border-color: #ddd;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td a i {
|
|
||||||
margin-top: 2px;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget table td input {
|
|
||||||
width: 25px;
|
|
||||||
margin: 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker-widget .modal-content {
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
@media (min-width: 767px) {
|
|
||||||
.bootstrap-timepicker-widget.modal {
|
|
||||||
width: 200px;
|
|
||||||
margin-left: -100px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
.bootstrap-timepicker {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.bootstrap-timepicker .dropdown-menu {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +1,10 @@
|
|||||||
@import "twitter/bootstrap/bootstrap";
|
@import "twitter/bootstrap/bootstrap";
|
||||||
body {
|
|
||||||
padding-top: 60px;
|
|
||||||
padding-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@import "twitter/bootstrap/responsive";
|
@import "twitter/bootstrap/responsive";
|
||||||
|
|
||||||
// Set the correct sprite paths
|
// Set the correct sprite paths
|
||||||
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
|
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
|
||||||
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
|
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
|
||||||
|
|
||||||
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
|
|
||||||
// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not
|
|
||||||
// have the proper paths. So for now we use the absolute path.
|
|
||||||
@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
|
|
||||||
@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
|
|
||||||
@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
|
|
||||||
@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
|
|
||||||
|
|
||||||
// Font Awesome
|
|
||||||
@import "fontawesome";
|
|
||||||
|
|
||||||
// Your custom LESS stylesheets goes here
|
// Your custom LESS stylesheets goes here
|
||||||
//
|
//
|
||||||
// Since bootstrap was imported above you have access to its mixins which
|
// Since bootstrap was imported above you have access to its mixins which
|
||||||
@@ -31,17 +15,3 @@ body {
|
|||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
// @linkColor: #ff0000;
|
// @linkColor: #ff0000;
|
||||||
|
|
||||||
[data-toggle="buttons-radio"] > .btn > input[type="radio"],
|
|
||||||
[data-toggle="buttons"] > .btn > input[type="checkbox"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inline-block {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-group.error .btn-group > .btn {
|
|
||||||
color: #b94a48;
|
|
||||||
border-color: #b94a48;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,182 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Datepicker for Bootstrap
|
|
||||||
*
|
|
||||||
* Copyright 2012 Stefan Petre
|
|
||||||
* Licensed under the Apache License v2.0
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
.datepicker {
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
padding: 4px;
|
|
||||||
margin-top: 1px;
|
|
||||||
-webkit-border-radius: 4px;
|
|
||||||
-moz-border-radius: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
/*.dow {
|
|
||||||
border-top: 1px solid #ddd !important;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
.datepicker:before {
|
|
||||||
content: '';
|
|
||||||
display: inline-block;
|
|
||||||
border-left: 7px solid transparent;
|
|
||||||
border-right: 7px solid transparent;
|
|
||||||
border-bottom: 7px solid #ccc;
|
|
||||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
|
||||||
position: absolute;
|
|
||||||
top: -7px;
|
|
||||||
left: 6px;
|
|
||||||
}
|
|
||||||
.datepicker:after {
|
|
||||||
content: '';
|
|
||||||
display: inline-block;
|
|
||||||
border-left: 6px solid transparent;
|
|
||||||
border-right: 6px solid transparent;
|
|
||||||
border-bottom: 6px solid #ffffff;
|
|
||||||
position: absolute;
|
|
||||||
top: -6px;
|
|
||||||
left: 7px;
|
|
||||||
}
|
|
||||||
.datepicker > div {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.datepicker table {
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.datepicker td,
|
|
||||||
.datepicker th {
|
|
||||||
text-align: center;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
-webkit-border-radius: 4px;
|
|
||||||
-moz-border-radius: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.datepicker td.day:hover {
|
|
||||||
background: #eeeeee;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.datepicker td.day.disabled {
|
|
||||||
color: #eeeeee;
|
|
||||||
}
|
|
||||||
.datepicker td.old,
|
|
||||||
.datepicker td.new {
|
|
||||||
color: #999999;
|
|
||||||
}
|
|
||||||
.datepicker td.active,
|
|
||||||
.datepicker td.active:hover {
|
|
||||||
color: #ffffff;
|
|
||||||
background-color: #006dcc;
|
|
||||||
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
|
||||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
|
||||||
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
|
||||||
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
|
||||||
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
|
|
||||||
background-repeat: repeat-x;
|
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
|
|
||||||
border-color: #0044cc #0044cc #002a80;
|
|
||||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
|
||||||
*background-color: #0044cc;
|
|
||||||
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
|
|
||||||
|
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
|
||||||
color: #fff;
|
|
||||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
|
||||||
}
|
|
||||||
.datepicker td.active:hover,
|
|
||||||
.datepicker td.active:hover:hover,
|
|
||||||
.datepicker td.active:focus,
|
|
||||||
.datepicker td.active:hover:focus,
|
|
||||||
.datepicker td.active:active,
|
|
||||||
.datepicker td.active:hover:active,
|
|
||||||
.datepicker td.active.active,
|
|
||||||
.datepicker td.active:hover.active,
|
|
||||||
.datepicker td.active.disabled,
|
|
||||||
.datepicker td.active:hover.disabled,
|
|
||||||
.datepicker td.active[disabled],
|
|
||||||
.datepicker td.active:hover[disabled] {
|
|
||||||
color: #ffffff;
|
|
||||||
background-color: #0044cc;
|
|
||||||
*background-color: #003bb3;
|
|
||||||
}
|
|
||||||
.datepicker td.active:active,
|
|
||||||
.datepicker td.active:hover:active,
|
|
||||||
.datepicker td.active.active,
|
|
||||||
.datepicker td.active:hover.active {
|
|
||||||
background-color: #003399 \9;
|
|
||||||
}
|
|
||||||
.datepicker td span {
|
|
||||||
display: block;
|
|
||||||
width: 47px;
|
|
||||||
height: 54px;
|
|
||||||
line-height: 54px;
|
|
||||||
float: left;
|
|
||||||
margin: 2px;
|
|
||||||
cursor: pointer;
|
|
||||||
-webkit-border-radius: 4px;
|
|
||||||
-moz-border-radius: 4px;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.datepicker td span:hover {
|
|
||||||
background: #eeeeee;
|
|
||||||
}
|
|
||||||
.datepicker td span.active {
|
|
||||||
color: #ffffff;
|
|
||||||
background-color: #006dcc;
|
|
||||||
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
|
||||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
|
||||||
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
|
||||||
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
|
||||||
background-image: linear-gradient(to bottom, #0088cc, #0044cc);
|
|
||||||
background-repeat: repeat-x;
|
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
|
|
||||||
border-color: #0044cc #0044cc #002a80;
|
|
||||||
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
|
||||||
*background-color: #0044cc;
|
|
||||||
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
|
|
||||||
|
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
|
||||||
color: #fff;
|
|
||||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
|
||||||
}
|
|
||||||
.datepicker td span.active:hover,
|
|
||||||
.datepicker td span.active:focus,
|
|
||||||
.datepicker td span.active:active,
|
|
||||||
.datepicker td span.active.active,
|
|
||||||
.datepicker td span.active.disabled,
|
|
||||||
.datepicker td span.active[disabled] {
|
|
||||||
color: #ffffff;
|
|
||||||
background-color: #0044cc;
|
|
||||||
*background-color: #003bb3;
|
|
||||||
}
|
|
||||||
.datepicker td span.active:active,
|
|
||||||
.datepicker td span.active.active {
|
|
||||||
background-color: #003399 \9;
|
|
||||||
}
|
|
||||||
.datepicker td span.old {
|
|
||||||
color: #999999;
|
|
||||||
}
|
|
||||||
.datepicker th.switch {
|
|
||||||
width: 145px;
|
|
||||||
}
|
|
||||||
.datepicker th.next,
|
|
||||||
.datepicker th.prev {
|
|
||||||
font-size: 21px;
|
|
||||||
}
|
|
||||||
.datepicker thead tr:first-child th {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.datepicker thead tr:first-child th:hover {
|
|
||||||
background: #eeeeee;
|
|
||||||
}
|
|
||||||
.input-append.date .add-on i,
|
|
||||||
.input-prepend.date .add-on i {
|
|
||||||
display: block;
|
|
||||||
cursor: pointer;
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,11 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
|||||||
|
|
||||||
#all users
|
#all users
|
||||||
# (had to use hash for borders to get the title to display properly)
|
# (had to use hash for borders to get the title to display properly)
|
||||||
@@app_tab_panel_items = [ :bikes_border ]
|
@@app_tab_panel_items = [ :bikes_border,
|
||||||
|
{ layout: :fit,
|
||||||
|
wrappedComponent: :brands_and_models_border,
|
||||||
|
title: "Brands/Models"}
|
||||||
|
]
|
||||||
|
|
||||||
#for users only
|
#for users only
|
||||||
if not controller.current_user.role?(:admin)
|
if not controller.current_user.role?(:admin)
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ class BikeBrands < Netzke::Basepack::Grid
|
|||||||
super
|
super
|
||||||
c.model = "BikeBrand"
|
c.model = "BikeBrand"
|
||||||
c.title = "Brands"
|
c.title = "Brands"
|
||||||
c.force_fit = true
|
|
||||||
|
|
||||||
c.prohibit_update = true if cannot? :update, BikeBrand
|
c.prohibit_update = true if cannot? :update, BikeBrand
|
||||||
c.prohibit_create = true if cannot? :create, BikeBrand
|
c.prohibit_create = true if cannot? :create, BikeBrand
|
||||||
c.prohibit_delete = true if cannot? :delete, BikeBrand
|
c.prohibit_delete = true if cannot? :delete, BikeBrand
|
||||||
end
|
end
|
||||||
|
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ class BikeLogs < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.model = "ActsAsLoggable::Log"
|
c.model = "ActsAsLoggable::Log"
|
||||||
c.title = "Bike History"
|
c.title = "Bike History"
|
||||||
c.force_fit = true
|
|
||||||
c.data_store = {auto_load: false}
|
c.data_store = {auto_load: false}
|
||||||
c.scope = lambda { |rel| rel.where(:loggable_type => 'Bike',:loggable_id => session[:selected_bike_id]);}
|
c.scope = lambda { |rel| rel.where(:loggable_type => 'Bike',:loggable_id => session[:selected_bike_id]);}
|
||||||
c.strong_default_attrs = {
|
c.strong_default_attrs = {
|
||||||
@@ -19,9 +18,9 @@ class BikeLogs < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.columns = [
|
c.columns = [
|
||||||
{ :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db) },
|
{ :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db) },
|
||||||
{ :name => :end_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db) },
|
{ :name => :end_date, :hidden => true, :default_value => Time.now.to_formatted_s(:db) },
|
||||||
:description,
|
:description,
|
||||||
{ :name => :bike_action__action, :text => 'Action', :default_value => ::ActsAsLoggable::BikeAction.first.id},
|
{ :name => :bike_action__action, :text => 'Action'},
|
||||||
{ :name => :logged_by, :getter => lambda{ |rec|
|
{ :name => :logged_by, :getter => lambda{ |rec|
|
||||||
user = User.find_by_id(rec.logger_id)
|
user = User.find_by_id(rec.logger_id)
|
||||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||||
@@ -48,7 +47,7 @@ class BikeLogs < Netzke::Basepack::Grid
|
|||||||
{ :name => :start_date},
|
{ :name => :start_date},
|
||||||
{ :name => :description},
|
{ :name => :description},
|
||||||
#had to hack acts_as_loggable/log.rb to get this to work
|
#had to hack acts_as_loggable/log.rb to get this to work
|
||||||
{ :name => :bike_action__action, :field_label => 'Action', :min_chars => 1 }
|
{ :name => :bike_action__action, :field_label => 'Action'}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class BikeLogsAndTasksAccordian < Netzke::Basepack::Accordion
|
||||||
|
component :bike_logs
|
||||||
|
component :tasks
|
||||||
|
|
||||||
|
def configure(c)
|
||||||
|
c.prevent_header = true
|
||||||
|
c.items = [ :bike_logs, :tasks ]
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
class BikeLowerTabs < Netzke::Basepack::TabPanel
|
|
||||||
component :bike_logs
|
|
||||||
component :tasks
|
|
||||||
component :brands_and_models_border
|
|
||||||
|
|
||||||
def configure(c)
|
|
||||||
c.prevent_header = true
|
|
||||||
c.items = [ :bike_logs, :tasks,
|
|
||||||
{netzke_component: :brands_and_models_border, title: "Brands and Models"} ]
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -4,7 +4,6 @@ class BikeModels < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.model = "BikeModel"
|
c.model = "BikeModel"
|
||||||
c.title = "Models"
|
c.title = "Models"
|
||||||
c.force_fit = true
|
|
||||||
c.data_store = {auto_load: false}
|
c.data_store = {auto_load: false}
|
||||||
c.scope = lambda { |rel| rel.where(:bike_brand_id => session[:selected_bike_brand_id]);}
|
c.scope = lambda { |rel| rel.where(:bike_brand_id => session[:selected_bike_brand_id]);}
|
||||||
c.strong_default_attrs = {
|
c.strong_default_attrs = {
|
||||||
|
|||||||
+11
-17
@@ -2,12 +2,11 @@ class Bikes < Netzke::Basepack::Grid
|
|||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
c.model = "Bike"
|
c.model = "Bike"
|
||||||
c.force_fit = true
|
|
||||||
|
|
||||||
# columns with :id set, have :min_chars set in init_component
|
# columns with :id set, have :min_chars set in init_component
|
||||||
# See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering
|
# See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering
|
||||||
c.columns = [
|
c.columns = [
|
||||||
{ :name => :shop_id, :text => 'Shop ID', :default_value => Bike.last.id.to_i + 1},
|
{ :name => :shop_id, :text => 'Shop ID'},
|
||||||
:serial_number,
|
:serial_number,
|
||||||
{ :id => :bike_brand__brand, :name => :bike_brand__brand, :text => 'Brand'},
|
{ :id => :bike_brand__brand, :name => :bike_brand__brand, :text => 'Brand'},
|
||||||
{ :name => :model, :text => 'Model',
|
{ :name => :model, :text => 'Model',
|
||||||
@@ -20,25 +19,20 @@ class Bikes < Netzke::Basepack::Grid
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
#needs to have type :action or else won't work in grid, because... netzke
|
#needs to have type :action or else won't work in grid, because... netzke
|
||||||
{ :name => "color", :text => "Frame Color", :type => :action, :editor => { :xtype => "xcolorcombo"}, :renderer => :color_block,
|
{ :name => "color", :text => "Frame Color", :type => :action, :editor => { :xtype => "xcolorcombo"}, :renderer => :color_block},
|
||||||
:default_value => '000000'},
|
{ :id => :bike_style__style, :name => :bike_style__style, :text => 'Style' },
|
||||||
{ :id => :bike_style__style, :name => :bike_style__style, :text => 'Style', :default_value => BikeStyle.first.id},
|
|
||||||
{ :name => :seat_tube_height, :text => 'Seat Tube (in)'},
|
{ :name => :seat_tube_height, :text => 'Seat Tube (in)'},
|
||||||
{ :name => :top_tube_length, :text => 'Top Tube (in)'},
|
{ :name => :top_tube_length, :text => 'Top Tube (in)'},
|
||||||
{ :name => :bike_wheel_size__display_string, :text => 'Wheel Size'},
|
{ :name => :wheel_size, :text => 'Wheel Size (in)'},
|
||||||
:value,
|
:value,
|
||||||
{ :id => :bike_condition__condition, :name => :bike_condition__condition, :text => 'Condition', :default_value => BikeCondition.first.id},
|
{ :id => :bike_condition__condition, :name => :bike_condition__condition, :text => 'Condition'},
|
||||||
{ :id => :bike_purpose__purpose, :name => :bike_purpose__purpose, :text => 'Purpose', :default_value => BikePurpose.first.id},
|
{ :id => :bike_purpose__purpose, :name => :bike_purpose__purpose, :text => 'Purpose'},
|
||||||
{ :name => :owner, :getter => lambda { |rec|
|
{ :name => :owner, :getter => lambda { |rec|
|
||||||
user = rec.owner
|
user = rec.owner
|
||||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
# Default the sorting to ASC on shop_id
|
|
||||||
c.data_store.sorters = [{ property: 'shop_id', direction: 'ASC' }]
|
|
||||||
|
|
||||||
@bike = Bike.all
|
@bike = Bike.all
|
||||||
c.prohibit_update = true if cannot? :update, @bike
|
c.prohibit_update = true if cannot? :update, @bike
|
||||||
c.prohibit_create = true if cannot? :create, @bike
|
c.prohibit_create = true if cannot? :create, @bike
|
||||||
@@ -47,18 +41,18 @@ class Bikes < Netzke::Basepack::Grid
|
|||||||
def default_fields_for_forms
|
def default_fields_for_forms
|
||||||
# :field_label MUST be defined in order for search to work
|
# :field_label MUST be defined in order for search to work
|
||||||
[
|
[
|
||||||
{ :name => :bike_brand__brand, :field_label => 'Brand', :min_chars => 1 },
|
{ :name => :bike_brand__brand, :field_label => 'Brand' },
|
||||||
{ :name => :model, :field_label => 'Model'},
|
{ :name => :model, :field_label => 'Model'},
|
||||||
{ :name => :shop_id, :field_label => 'Shop ID'},
|
{ :name => :shop_id, :field_label => 'Shop ID'},
|
||||||
{ :name => :serial_number, :field_label => 'Serial Number'},
|
{ :name => :serial_number, :field_label => 'Serial Number'},
|
||||||
{ :name => "color", :xtype => "xcolorcombo"},
|
{ :name => "color", :xtype => "xcolorcombo"},
|
||||||
{ :name => :bike_style__style, :field_label => 'Style', :min_chars => 1},
|
{ :name => :bike_style__style, :field_label => 'Style' },
|
||||||
{ :name => :seat_tube_height, :field_label => 'Seat Tube (in)'},
|
{ :name => :seat_tube_height, :field_label => 'Seat Tube (in)'},
|
||||||
{ :name => :top_tube_length, :field_label => 'Top Tube (in)'},
|
{ :name => :top_tube_length, :field_label => 'Top Tube (in)'},
|
||||||
{ :name => :bike_wheel_size__display_string, :field_label => 'Wheel Size'},
|
{ :name => :wheel_size, :field_label => 'Wheel Size (in)'},
|
||||||
{ :name => :value, :field_label => 'Value'},
|
{ :name => :value, :field_label => 'Value'},
|
||||||
{ :name => :bike_condition__condition, :field_label => 'Condition', :min_chars => 1},
|
{ :name => :bike_condition__condition, :field_label => 'Condition'},
|
||||||
{ :name => :bike_purpose__purpose, :field_label => 'Purpose', :min_chars => 1}
|
{ :name => :bike_purpose__purpose, :field_label => 'Purpose'}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// calling superclass's initComponent
|
// calling superclass's initComponent
|
||||||
this.callParent();
|
this.callParent();
|
||||||
|
|
||||||
|
// something...
|
||||||
//due to Netzke bug, :min_chars attribute doesn't work
|
//due to Netzke bug, :min_chars attribute doesn't work
|
||||||
var min_char_columns = [
|
var min_char_columns = [
|
||||||
"bike_brand__brand",
|
"bike_brand__brand",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class BikesBorder < Netzke::Base
|
|||||||
# Remember regions collapse state and size
|
# Remember regions collapse state and size
|
||||||
include Netzke::Basepack::ItemPersistence
|
include Netzke::Basepack::ItemPersistence
|
||||||
component :bikes
|
component :bikes
|
||||||
component :bike_lower_tabs
|
component :bike_logs_and_tasks_accordian
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
@@ -10,7 +10,7 @@ class BikesBorder < Netzke::Base
|
|||||||
c.title = "Bikes"
|
c.title = "Bikes"
|
||||||
c.items = [
|
c.items = [
|
||||||
{ netzke_component: :bikes, region: :center, split: true },
|
{ netzke_component: :bikes, region: :center, split: true },
|
||||||
{ netzke_component: :bike_lower_tabs, region: :south, height: 300, split: true}
|
{ netzke_component: :bike_logs_and_tasks_accordian, region: :south, height: 300, split: true}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,30 +5,14 @@
|
|||||||
|
|
||||||
// setting the 'rowclick' event
|
// setting the 'rowclick' event
|
||||||
var view = this.getComponent('bikes').getView();
|
var view = this.getComponent('bikes').getView();
|
||||||
|
|
||||||
//disable until a bike is clicked
|
|
||||||
var bike_logs_comp = this.queryById('bike_logs');
|
|
||||||
if( bike_logs_comp){
|
|
||||||
bike_logs_comp.disable();
|
|
||||||
}
|
|
||||||
var bike_tasks_comp = this.queryById('tasks');
|
|
||||||
if( bike_tasks_comp ){
|
|
||||||
bike_tasks_comp.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
view.on('itemclick', function(view, record){
|
view.on('itemclick', function(view, record){
|
||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
this.selectBike({bike_id: record.get('id')});
|
this.selectBike({bike_id: record.get('id')});
|
||||||
// query for these components again, can change if not visible because of accordian
|
if( this.queryById('bike_logs') ){
|
||||||
var bike_logs_comp = this.queryById('bike_logs');
|
this.queryById('bike_logs').getStore().load();
|
||||||
var bike_tasks_comp = this.queryById('tasks');
|
|
||||||
if( bike_logs_comp ){
|
|
||||||
bike_logs_comp.getStore().load();
|
|
||||||
bike_logs_comp.enable();
|
|
||||||
}
|
}
|
||||||
if( bike_tasks_comp ){
|
if( this.queryById('tasks') ){
|
||||||
bike_tasks_comp.getStore().load();
|
this.queryById('tasks').getStore().load();
|
||||||
bike_tasks_comp.enable();
|
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ class CheckIns < Netzke::Basepack::Grid
|
|||||||
super
|
super
|
||||||
c.header = false
|
c.header = false
|
||||||
c.model = "ActsAsLoggable::Log"
|
c.model = "ActsAsLoggable::Log"
|
||||||
c.force_fit = true
|
|
||||||
c.scope = lambda { |rel| rel.where(:log_action_type => ::ActsAsLoggable::UserAction).
|
c.scope = lambda { |rel| rel.where(:log_action_type => ::ActsAsLoggable::UserAction).
|
||||||
where(:loggable_type => "User").
|
where(:loggable_type => "User").
|
||||||
where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")).
|
where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")).
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
class Customers < Netzke::Basepack::Grid
|
class Customers < Netzke::Basepack::Grid
|
||||||
def configure(c)
|
def configure(c)
|
||||||
c.model = "Customer"
|
c.model = "Customer"
|
||||||
c.force_fit = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
this.callParent();
|
this.callParent();
|
||||||
this.getView().on('itemclick', function(view, record){
|
this.getView().on('itemclick', function(view, record){
|
||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
|
console.log("user: " + record.get('id') );
|
||||||
this.selectCustomer({customer_id: record.get('id'), customer_type: 'Customer'});
|
this.selectCustomer({customer_id: record.get('id'), customer_type: 'Customer'});
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ class Logs < Netzke::Basepack::Grid
|
|||||||
super
|
super
|
||||||
c.header = false
|
c.header = false
|
||||||
c.model = "ActsAsLoggable::Log"
|
c.model = "ActsAsLoggable::Log"
|
||||||
c.force_fit = true
|
|
||||||
c.columns = [
|
c.columns = [
|
||||||
:loggable_id,
|
:loggable_id,
|
||||||
:loggable_type,
|
:loggable_type,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ class Tasks < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.header = false
|
c.header = false
|
||||||
c.model = "Task"
|
c.model = "Task"
|
||||||
c.force_fit = true
|
|
||||||
c.scope = lambda{ |rel|
|
c.scope = lambda{ |rel|
|
||||||
if session[:selected_bike_id]
|
if session[:selected_bike_id]
|
||||||
rel.where(:task_list_id => Bike.find_by_id(session[:selected_bike_id]).task_list.id)
|
rel.where(:task_list_id => Bike.find_by_id(session[:selected_bike_id]).task_list.id)
|
||||||
@@ -22,21 +21,20 @@ class Tasks < Netzke::Basepack::Grid
|
|||||||
:task_list_id => task_list_id
|
:task_list_id => task_list_id
|
||||||
}
|
}
|
||||||
c.columns = [
|
c.columns = [
|
||||||
:done,
|
|
||||||
:task,
|
:task,
|
||||||
:notes
|
:notes,
|
||||||
|
:done
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_fields_for_forms
|
def default_fields_for_forms
|
||||||
bike = Bike.find_by_id(session[:selected_bike_id])
|
fields = []
|
||||||
bike = "Select a Bike First!" if bike.nil?
|
fields << { :no_binding => true, :xtype => 'displayfield', :fieldLabel => "No Bike Selected", :value => "Select a Bike First!"}
|
||||||
[
|
fields.concat( [
|
||||||
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Bike Selected", :value => "#{bike.to_s}"},
|
|
||||||
:done,
|
|
||||||
:task,
|
:task,
|
||||||
:notes,
|
:notes,
|
||||||
]
|
:done
|
||||||
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ class TransactionLogs < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.model = "ActsAsLoggable::Log"
|
c.model = "ActsAsLoggable::Log"
|
||||||
c.title = "Transaction Payments"
|
c.title = "Transaction Payments"
|
||||||
c.force_fit = true
|
|
||||||
c.data_store = {auto_load: false}
|
c.data_store = {auto_load: false}
|
||||||
c.scope = lambda { |rel| rel.where(:loggable_type => 'Transaction',:loggable_id => session[:selected_transaction_id]);}
|
c.scope = lambda { |rel| rel.where(:loggable_type => 'Transaction',:loggable_id => session[:selected_transaction_id]);}
|
||||||
c.strong_default_attrs = {
|
c.strong_default_attrs = {
|
||||||
@@ -21,7 +20,7 @@ class TransactionLogs < Netzke::Basepack::Grid
|
|||||||
c.columns = [
|
c.columns = [
|
||||||
{ :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db), :text => 'Date' },
|
{ :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db), :text => 'Date' },
|
||||||
{ :name => :description, :text => "Amount"} ,
|
{ :name => :description, :text => "Amount"} ,
|
||||||
{ :name => :transaction_action__action, :text => 'Method', :default_value => ::ActsAsLoggable::TransactionAction.first.id},
|
{ :name => :transaction_action__action, :text => 'Method'},
|
||||||
{ :name => :logged_by, :getter => lambda{ |rec|
|
{ :name => :logged_by, :getter => lambda{ |rec|
|
||||||
user = User.find_by_id(rec.logger_id)
|
user = User.find_by_id(rec.logger_id)
|
||||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||||
@@ -50,7 +49,7 @@ class TransactionLogs < Netzke::Basepack::Grid
|
|||||||
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Payment for:", :value => "#{item.to_s}"},
|
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Payment for:", :value => "#{item.to_s}"},
|
||||||
{ :name => :description, :xtype => 'numberfield', :field_label => 'Amount'},
|
{ :name => :description, :xtype => 'numberfield', :field_label => 'Amount'},
|
||||||
#had to hack acts_as_loggable/log.rb to get this to work
|
#had to hack acts_as_loggable/log.rb to get this to work
|
||||||
{ :name => :transaction_action__action, :field_label => 'Payment Method', :min_chars => 1}
|
{ :name => :transaction_action__action, :field_label => 'Payment Method'}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ class Transactions < Netzke::Basepack::Grid
|
|||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
c.model = "Transaction"
|
c.model = "Transaction"
|
||||||
c.force_fit = true
|
|
||||||
c.strong_default_attrs = {
|
c.strong_default_attrs = {
|
||||||
:vendor_id => controller.current_user.id,
|
:vendor_id => controller.current_user.id,
|
||||||
:customer_id => session[:selected_customer_id],
|
:customer_id => session[:selected_customer_id],
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class TransactionsBorder < Netzke::Base
|
|||||||
component :transactions
|
component :transactions
|
||||||
component :transaction_logs
|
component :transaction_logs
|
||||||
#users and customers components are required for the transactions form
|
#users and customers components are required for the transactions form
|
||||||
component :users_and_customers_lower_tabs
|
component :users_and_customers_accordian
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
@@ -13,7 +13,7 @@ class TransactionsBorder < Netzke::Base
|
|||||||
c.items = [
|
c.items = [
|
||||||
{ netzke_component: :transactions, region: :center, height: 300, split: true },
|
{ netzke_component: :transactions, region: :center, height: 300, split: true },
|
||||||
{ netzke_component: :transaction_logs, region: :east, width: 300, split: true },
|
{ netzke_component: :transaction_logs, region: :east, width: 300, split: true },
|
||||||
{ netzke_component: :users_and_customers_lower_tabs, region: :south, height: 300, split: true }
|
{ netzke_component: :users_and_customers_accordian, region: :south, height: 300, split: true }
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,10 @@
|
|||||||
|
|
||||||
// setting the 'rowclick' event
|
// setting the 'rowclick' event
|
||||||
var view = this.getComponent('transactions').getView();
|
var view = this.getComponent('transactions').getView();
|
||||||
|
|
||||||
if( this.queryById('transaction_logs')){
|
|
||||||
this.queryById('transaction_logs').disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
view.on('itemclick', function(view, record){
|
view.on('itemclick', function(view, record){
|
||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
this.selectTransaction({transaction_id: record.get('id')});
|
this.selectTransaction({transaction_id: record.get('id')});
|
||||||
this.getComponent('transaction_logs').getStore().load();
|
this.getComponent('transaction_logs').getStore().load();
|
||||||
|
|
||||||
if( this.queryById('transaction_logs')){
|
|
||||||
this.queryById('transaction_logs').enable();
|
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
class UserAndProfilesLowerTabs < Netzke::Basepack::TabPanel
|
|
||||||
component :user_profiles
|
|
||||||
component :user_logs
|
|
||||||
component :user_stats
|
|
||||||
|
|
||||||
def configure(c)
|
|
||||||
c.prevent_header = true
|
|
||||||
c.items = [ :user_logs,
|
|
||||||
{ netzke_component: :user_profiles, title: "User Profiles" },
|
|
||||||
{ netzke_component: :user_stats, title: "User Stats" }]
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
class UserLogs < Netzke::Basepack::Grid
|
class UserLogs < Netzke::Basepack::Grid
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
|
|
||||||
@@ -34,7 +33,6 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.model = "ActsAsLoggable::Log"
|
c.model = "ActsAsLoggable::Log"
|
||||||
c.title = "User Timesheet"
|
c.title = "User Timesheet"
|
||||||
c.force_fit = true
|
|
||||||
c.data_store = user_log_data_store
|
c.data_store = user_log_data_store
|
||||||
c.scope = user_log_scope
|
c.scope = user_log_scope
|
||||||
c.strong_default_attrs = user_log_strong_default_attrs
|
c.strong_default_attrs = user_log_strong_default_attrs
|
||||||
@@ -53,23 +51,10 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_fields_for_forms
|
# Overriding the defautl add in form
|
||||||
#figure out a better way to do this
|
def preconfigure_record_window(c)
|
||||||
bike_store = Bike.all.map { |b| [b.id, b.shop_id] }
|
super
|
||||||
current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user
|
c.form_config.klass = UserLogsAddItem
|
||||||
bike_id = current_user.bike.nil? ? nil : current_user.bike.id
|
|
||||||
[
|
|
||||||
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Log for:", :value => "#{current_user.to_s}"},
|
|
||||||
{ :name => :start_date},
|
|
||||||
{ :name => :end_date},
|
|
||||||
{ :name => :description},
|
|
||||||
#had to hack acts_as_loggable/log.rb to get this to work
|
|
||||||
{ :name => :user_action__action, :field_label => 'Action', :min_chars => 1},
|
|
||||||
{ :name => :for_bike, :checkboxName => :copy_log, :inputValue => true, :title => "Copy description to a Bike's History?", :xtype => 'fieldset', :checkboxToggle => true, :collapsed => true, :items => [
|
|
||||||
{:xtype => 'combo', :no_binding => true, :name => :copy_id, :title => 'Bike', :fieldLabel => 'Bike', :store => bike_store, :value => bike_id}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
@@ -77,4 +62,8 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
[ :apply, :add_in_form, :search ]
|
[ :apply, :add_in_form, :search ]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
js_configure do |c|
|
||||||
|
c.mixin :init_component
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -2,12 +2,48 @@
|
|||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
// calling superclass's initComponent
|
// calling superclass's initComponent
|
||||||
this.callParent();
|
this.callParent();
|
||||||
|
// TESTTING
|
||||||
//due to Netzke bug, :min_chars attribute doesn't work
|
//due to Netzke bug, :min_chars attribute doesn't work
|
||||||
var min_char_columns = [
|
var min_char_columns = [
|
||||||
"user_action__purpose"]
|
"user_action__purpose"
|
||||||
Ext.each(min_char_columns, function(column, index) {
|
];
|
||||||
Ext.ComponentManager.get(column).editor.minChars = 1;
|
|
||||||
});
|
// Ext.each(min_char_columns, function(column, index) {
|
||||||
|
// Ext.ComponentManager.get(column).editor.minChars = 1;
|
||||||
|
// });
|
||||||
|
|
||||||
|
var view = this.getView();
|
||||||
|
|
||||||
|
view.on('itemclick', function(view, record){
|
||||||
|
console.log('clicking ');
|
||||||
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
|
// console.log('Old record', record);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
view.on('itemupdate', function(record, index, node){
|
||||||
|
console.log('Updating item');
|
||||||
|
// if('end_date' in record.data.modified){
|
||||||
|
// console.log('start', record.data.start_date);
|
||||||
|
// console.log('end', record.data.end_date);
|
||||||
|
// }else if('start_date' in record.data.modified){
|
||||||
|
|
||||||
|
// }
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// var hoursInput = Ext.getCmp('user_logs_add_form_hours-inputEl');
|
||||||
|
|
||||||
|
// console.log(hoursInput);
|
||||||
|
|
||||||
|
// hoursInput.on('change', function(field, newValue, oldValue){
|
||||||
|
// console.log('Hours changing...', newValue);
|
||||||
|
// });
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
addNewItem: function(e){
|
||||||
|
e.fireEvent('click', {});
|
||||||
|
console.log(e);
|
||||||
|
console.log('Adding new item');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# The User Log Add Item Form
|
||||||
|
class UserLogsAddItem < Netzke::Basepack::Form
|
||||||
|
def configure(c)
|
||||||
|
super
|
||||||
|
c.model = 'ActsAsLoggable::Log'
|
||||||
|
|
||||||
|
#figure out a better way to do this
|
||||||
|
bike_store = Bike.all.map { |b| [b.id, b.shop_id] }
|
||||||
|
current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user
|
||||||
|
bike_id = current_user.bike.nil? ? nil : current_user.bike.id
|
||||||
|
c.items = [
|
||||||
|
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Log for:", :value => "#{current_user.to_s}"},
|
||||||
|
{ :id => :user_logs_add_form_start, :name => :start_date},
|
||||||
|
{ :id => :user_logs_add_form_time, :no_binding => true, :name => :time, :xtype => 'field', :fieldLabel => "Time:", :value => 0 },
|
||||||
|
{ :id => :user_logs_add_form_units, :xtype => 'combo', :no_binding => true, :name => :units, :fieldLabel => 'Units', :store => ['Mins', 'Hrs'], :value => 'Mins' },
|
||||||
|
{ :id => :user_logs_add_form_end, :name => :end_date, :hidden => true },
|
||||||
|
{ :name => :description},
|
||||||
|
#had to hack acts_as_loggable/log.rb to get this to work
|
||||||
|
{ :name => :user_action__action, :field_label => 'Action'},
|
||||||
|
{ :name => :for_bike, :checkboxName => :copy_log, :inputValue => true,
|
||||||
|
:title => "Copy description to a Bike's History?", :xtype => 'fieldset', :checkboxToggle => true, :collapsed => true, :items => [
|
||||||
|
{:xtype => 'combo', :no_binding => true, :name => :copy_id, :title => 'Bike', :fieldLabel => 'Bike', :store => bike_store, :value => bike_id}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
js_configure do |c|
|
||||||
|
c.mixin :init_component
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
{
|
||||||
|
initComponent: function(){
|
||||||
|
// calling superclass's initComponent
|
||||||
|
this.callParent();
|
||||||
|
|
||||||
|
var panel = this;
|
||||||
|
var theForm = this.getForm();
|
||||||
|
var startInput = Ext.getCmp('user_logs_add_form_start');
|
||||||
|
var timeInput = Ext.getCmp('user_logs_add_form_time');
|
||||||
|
var unitsInput = Ext.getCmp('user_logs_add_form_units');
|
||||||
|
var endInput = Ext.getCmp('user_logs_add_form_end');
|
||||||
|
var startdate = startInput.items.items[0];
|
||||||
|
var starttime = startInput.items.items[1];
|
||||||
|
var enddate = endInput.items.items[0];
|
||||||
|
var endtime = endInput.items.items[1];
|
||||||
|
|
||||||
|
startdate.on('change', function(e){
|
||||||
|
var hours = timeInput.getValue();
|
||||||
|
var startTime = starttime.getValue();
|
||||||
|
|
||||||
|
if('Mins' === unitsInput.getValue()){
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.MINUTE, parseInt(hours));
|
||||||
|
}else{
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.HOUR, parseInt(hours));
|
||||||
|
}
|
||||||
|
|
||||||
|
endtime.setValue(calculatedEndTime);
|
||||||
|
enddate.setValue(calculatedEndTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
starttime.on('change', function(e){
|
||||||
|
var hours = timeInput.getValue();
|
||||||
|
var startTime = starttime.getValue();
|
||||||
|
|
||||||
|
if('Mins' === unitsInput.getValue()){
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.MINUTE, parseInt(hours));
|
||||||
|
}else{
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.HOUR, parseInt(hours));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
endtime.setValue(calculatedEndTime);
|
||||||
|
enddate.setValue(calculatedEndTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
timeInput.on('change', function(e){
|
||||||
|
var hours = timeInput.getValue();
|
||||||
|
var startTime = starttime.getValue();
|
||||||
|
|
||||||
|
if('Mins' === unitsInput.getValue()){
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.MINUTE, parseInt(hours));
|
||||||
|
}else{
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.HOUR, parseInt(hours));
|
||||||
|
}
|
||||||
|
|
||||||
|
endtime.setValue(calculatedEndTime);
|
||||||
|
enddate.setValue(calculatedEndTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
unitsInput.on('change', function(e){
|
||||||
|
var hours = timeInput.getValue();
|
||||||
|
var startTime = starttime.getValue();
|
||||||
|
|
||||||
|
if('Mins' === unitsInput.getValue()){
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.MINUTE, parseInt(hours));
|
||||||
|
}else{
|
||||||
|
var calculatedEndTime = Ext.Date.add(new Date(startTime), Ext.Date.HOUR, parseInt(hours));
|
||||||
|
}
|
||||||
|
|
||||||
|
endtime.setValue(calculatedEndTime);
|
||||||
|
enddate.setValue(calculatedEndTime);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@ class UserProfiles < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.model = "UserProfile"
|
c.model = "UserProfile"
|
||||||
c.title = "Profile"
|
c.title = "Profile"
|
||||||
c.force_fit = true
|
|
||||||
c.data_store = user_profiles_data_store
|
c.data_store = user_profiles_data_store
|
||||||
c.scope = user_profiles_scope
|
c.scope = user_profiles_scope
|
||||||
c.strong_default_attrs = user_profile_strong_default_attrs
|
c.strong_default_attrs = user_profile_strong_default_attrs
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ class UserRoleJoins < Netzke::Basepack::Grid
|
|||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
c.model = "UserRoleJoin"
|
c.model = "UserRoleJoin"
|
||||||
c.force_fit = true
|
|
||||||
c.header = false
|
c.header = false
|
||||||
c.title = "User Roles"
|
c.title = "User Roles"
|
||||||
c.data_store.sorters = [{ :property => :user__username, :direction => :ASC}]
|
c.data_store.sorters = [{ :property => :user__username, :direction => :ASC}]
|
||||||
@@ -11,9 +10,9 @@ class UserRoleJoins < Netzke::Basepack::Grid
|
|||||||
{ :name => :name, :getter => lambda{ |rec|
|
{ :name => :name, :getter => lambda{ |rec|
|
||||||
user = User.find_by_id(rec.user_id)
|
user = User.find_by_id(rec.user_id)
|
||||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{ :name => :role__role, :text => "Role", :default_value => Role.exists? ? Role.first.id : nil},
|
{ :name => :role__role, :text => "Role"},
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:ends ]
|
:ends ]
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class UserStats < Netzke::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
def user
|
def user
|
||||||
User.find_by_id(session[:selected_user_id]) || controller.current_user
|
controller.current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ class UserTransactions < Netzke::Basepack::Grid
|
|||||||
|
|
||||||
c.model = "Transaction"
|
c.model = "Transaction"
|
||||||
c.title = "Transactions"
|
c.title = "Transactions"
|
||||||
c.force_fit = true
|
|
||||||
c.scope = lambda { |rel| rel.where(:customer_id => controller.current_user.id, :customer_type => 'User');}
|
c.scope = lambda { |rel| rel.where(:customer_id => controller.current_user.id, :customer_type => 'User');}
|
||||||
c.data_store = { auto_load: true }
|
c.data_store = { auto_load: true }
|
||||||
c.columns = [
|
c.columns = [
|
||||||
|
|||||||
@@ -5,18 +5,10 @@
|
|||||||
|
|
||||||
// setting the 'rowclick' event
|
// setting the 'rowclick' event
|
||||||
var view = this.getComponent('user_transactions').getView();
|
var view = this.getComponent('user_transactions').getView();
|
||||||
|
|
||||||
if( this.queryById('transaction_logs')){
|
|
||||||
this.queryById('transaction_logs').disable();
|
|
||||||
}
|
|
||||||
view.on('itemclick', function(view, record){
|
view.on('itemclick', function(view, record){
|
||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
this.selectTransaction({transaction_id: record.get('id')});
|
this.selectTransaction({transaction_id: record.get('id')});
|
||||||
this.getComponent('transaction_logs').getStore().load();
|
this.getComponent('transaction_logs').getStore().load();
|
||||||
|
|
||||||
if( this.queryById('transaction_logs')){
|
|
||||||
this.queryById('transaction_logs').enable();
|
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,13 @@ class Users < Netzke::Basepack::Grid
|
|||||||
super
|
super
|
||||||
c.header = false
|
c.header = false
|
||||||
c.model = "User"
|
c.model = "User"
|
||||||
c.force_fit = true
|
|
||||||
|
|
||||||
c.columns = [
|
c.columns = [
|
||||||
{ :name => :username, :read_only => true },
|
{ :name => :username, :read_only => true },
|
||||||
:first_name,
|
:first_name,
|
||||||
:last_name,
|
:last_name,
|
||||||
:email,
|
:email,
|
||||||
{ :text => "Bike - Shop ID", :id => :bike__shop_id, :name => :bike__shop_id, :default_value => Bike.exists? ? Bike.first.id : nil }
|
{ :id => :bike__shop_id, :name => :bike__shop_id}
|
||||||
]
|
]
|
||||||
|
|
||||||
c.columns << :reset if can? :manage, User
|
c.columns << :reset if can? :manage, User
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
Ext.Msg.alert("Success", "New Password: "+data.password);
|
Ext.Msg.alert("Success", "New Password: "+data.password);
|
||||||
},
|
},
|
||||||
error: function(data,textStatus) {
|
error: function(data,textStatus) {
|
||||||
Ext.Msg.alert( "Error", JSON.parse(data.responseText)["errors"][0]);
|
Ext.Msg.alert( "Error", JSON.parse(data.responseText)["error"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
class UsersAndCustomersLowerTabs < Netzke::Basepack::TabPanel
|
class UsersAndCustomersAccordian < Netzke::Basepack::Accordion
|
||||||
component :customers
|
component :customers
|
||||||
component :users
|
component :users
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
c.prevent_header = true
|
c.prevent_header = true
|
||||||
c.items = [ :users, :customers ]
|
c.items = [ :customers, :users ]
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2,14 +2,16 @@ class UsersAndProfilesBorder < Netzke::Base
|
|||||||
# Remember regions collapse state and size
|
# Remember regions collapse state and size
|
||||||
include Netzke::Basepack::ItemPersistence
|
include Netzke::Basepack::ItemPersistence
|
||||||
component :users
|
component :users
|
||||||
component :user_and_profiles_lower_tabs
|
component :user_profiles
|
||||||
|
component :user_logs
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
c.header = false
|
c.header = false
|
||||||
c.items = [
|
c.items = [
|
||||||
{ netzke_component: :users, header: "Users", region: :center, width: 350, split: true },
|
{ netzke_component: :users, header: "Users", region: :center, width: 350, split: true },
|
||||||
{ netzke_component: :user_and_profiles_lower_tabs, region: :south, height: 300, split: true}
|
{ netzke_component: :user_profiles, region: :south, height: 150, split: true},
|
||||||
|
{ netzke_component: :user_logs, region: :east, split: true}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,48 +2,18 @@
|
|||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
// calling superclass's initComponent
|
// calling superclass's initComponent
|
||||||
this.callParent();
|
this.callParent();
|
||||||
var stats = this.queryById('user_stats');
|
var stats = this.getComponent('user_stats');
|
||||||
if (stats != undefined){
|
if (stats != undefined){
|
||||||
stats.updateStats();
|
stats.updateStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this.queryById('user_profiles')){
|
|
||||||
this.queryById('user_profiles').disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( this.queryById('user_logs')){
|
|
||||||
this.queryById('user_logs').disable();
|
|
||||||
//update user stats
|
|
||||||
var store = this.queryById('user_logs').getStore()
|
|
||||||
store.on('load', function (store, records, operation, success){
|
|
||||||
if( this.queryById('user_stats') ){
|
|
||||||
this.queryById('user_stats').updateStats();
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
}
|
|
||||||
if( this.queryById('user_stats') ){
|
|
||||||
this.queryById('user_stats').disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting the 'rowclick' event
|
// setting the 'rowclick' event
|
||||||
var view = this.getComponent('users').getView();
|
var view = this.getComponent('users').getView();
|
||||||
view.on('itemclick', function(view, record){
|
view.on('itemclick', function(view, record){
|
||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
this.selectUser({user_id: record.get('id')});
|
this.selectUser({user_id: record.get('id')});
|
||||||
|
this.getComponent('user_profiles').getStore().load();
|
||||||
if( this.queryById('user_profiles')){
|
this.getComponent('user_logs').getStore().load();
|
||||||
this.queryById('user_profiles').getStore().load();
|
|
||||||
this.queryById('user_profiles').enable();
|
|
||||||
}
|
|
||||||
if( this.queryById('user_logs')){
|
|
||||||
this.queryById('user_logs').getStore().load();
|
|
||||||
this.queryById('user_logs').enable();
|
|
||||||
}
|
|
||||||
if( this.queryById('user_stats') ){
|
|
||||||
this.queryById('user_stats').updateStats();
|
|
||||||
this.queryById('user_stats').enable();
|
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ class Api::V1::BaseController < ActionController::Base
|
|||||||
private
|
private
|
||||||
def authenticate_user
|
def authenticate_user
|
||||||
if params[:username]
|
if params[:username]
|
||||||
user = User.find_for_database_authentication( :username => params[:username] )
|
user = User.find_for_database_authentication( :email => params[:username] )
|
||||||
@current_user = user if user && user.valid_password?( params[:password] )
|
@current_user = user if user && user.valid_password?( params[:password] )
|
||||||
|
|
||||||
if @current_user.nil?
|
if @current_user.nil?
|
||||||
msg = "Username/Password/Token invalid"
|
msg = "Username/Password/Token invalid"
|
||||||
render :json => {:error => msg }, :status => 401 and return
|
render :json => {:error => msg }, :status => 403 and return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
authenticate_user!
|
authenticate_user!
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
class Api::V1::BikesController < Api::V1::BaseController
|
|
||||||
CANNOT_MANAGE = "You do not have permission to manage bikes."
|
|
||||||
EXPECTED_BIKE = "Expected bike in submitted data"
|
|
||||||
NOT_FOUND = "The bike could not be found."
|
|
||||||
|
|
||||||
before_filter :check_bike_permission, except: :show
|
|
||||||
|
|
||||||
def create
|
|
||||||
if params[:bikes] && bike = params[:bikes].first
|
|
||||||
@bike = Bike.new(bike)
|
|
||||||
if !@bike.save
|
|
||||||
render json: { errors: @bike.errors }, status: 422 and return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
render json: { errors: [EXPECTED_BIKE]}, status: 422 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
@bike = Bike.find_by_id(params[:id])
|
|
||||||
if @bike.nil?
|
|
||||||
render json: { errors: [NOT_FOUND] }, status: 404 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def check_bike_permission
|
|
||||||
if cannot? :manage, Bike
|
|
||||||
render json: { errors: [CANNOT_MANAGE]}, status: 403 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
class Api::V1::TaskListsController < Api::V1::BaseController
|
|
||||||
CANNOT_MANAGE = "You do not have permission to manage this task list."
|
|
||||||
NOT_FOUND = "The task list could not be found."
|
|
||||||
|
|
||||||
before_filter :get_task_list
|
|
||||||
before_filter :check_task_list_permission, except: :show
|
|
||||||
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def get_task_list
|
|
||||||
@task_list = TaskList.find_by_id(params[:id])
|
|
||||||
if @task_list.nil?
|
|
||||||
render json: { errors: [NOT_FOUND] }, status: 404 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_task_list_permission
|
|
||||||
if cannot? :manage, Bike and @task_list.item != current_user.bike
|
|
||||||
render json: { errors: [CANNOT_MANAGE]}, status: 403 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
class Api::V1::TasksController < Api::V1::BaseController
|
|
||||||
EXPECTED_TASKS = "Expected a list of tasks in submitted data."
|
|
||||||
CANNOT_MANAGE = "You do not have permission to manage this task."
|
|
||||||
NOT_FOUND = "The task could not be found."
|
|
||||||
|
|
||||||
before_filter :validate_params
|
|
||||||
before_filter :get_tasks
|
|
||||||
before_filter :check_task_permission, except: :show
|
|
||||||
|
|
||||||
def update
|
|
||||||
errors = []
|
|
||||||
@tasks.each do |task_hash|
|
|
||||||
task = task_hash[:record]
|
|
||||||
attrs = task_hash[:new_attributes]
|
|
||||||
task.update_attributes(attrs)
|
|
||||||
if !task.errors.empty?
|
|
||||||
errors << { id: task.id, errors: task.errors }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !errors.empty?
|
|
||||||
render json: { errors: errors }, status: 422 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def validate_params
|
|
||||||
if params[:tasks].nil? and not params[:tasks].kind_of?(Array)
|
|
||||||
render json: { errors: [EXPECTED_TASKS]}, status: 422 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_tasks
|
|
||||||
@tasks = []
|
|
||||||
errors = []
|
|
||||||
|
|
||||||
params[:tasks].each do |task|
|
|
||||||
t = Task.find_by_id(task[:id])
|
|
||||||
if t.nil?
|
|
||||||
errors << { id: task[:id], error: NOT_FOUND }
|
|
||||||
else
|
|
||||||
@tasks << { record: t, new_attributes: task }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !errors.empty?
|
|
||||||
render json: { errors: errors }, status: 404 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_task_permission
|
|
||||||
errors = []
|
|
||||||
@tasks.each do |task_hash|
|
|
||||||
task = task_hash[:record]
|
|
||||||
if task.task_list.item != current_user.bike
|
|
||||||
errors << { id: task[:id], error: CANNOT_MANAGE }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if cannot? :manage, Bike and !errors.empty?
|
|
||||||
render json: { errors: errors}, status: 403 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
class Api::V1::TimeEntriesController < Api::V1::BaseController
|
|
||||||
EXPECTED_TIME_ENTRY = "Expected time entry in submitted data"
|
|
||||||
NOT_FOUND = "Time entry not found"
|
|
||||||
|
|
||||||
def create
|
|
||||||
if params[:time_entries] && time_entry = params[:time_entries].first
|
|
||||||
time_entry.merge!({ loggable_id: current_user.id,
|
|
||||||
logger_id: current_user.id })
|
|
||||||
bike_id = time_entry[:bike_id].to_i
|
|
||||||
|
|
||||||
@time_entry = TimeEntry.new(time_entry.except(:bike_id))
|
|
||||||
|
|
||||||
if bike_id > 0
|
|
||||||
@time_entry.copy_to_bike_history(bike_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
if !@time_entry.save
|
|
||||||
render json: { errors: @time_entry.errors }, status: 422 and return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
render json: { errors: [EXPECTED_TIME_ENTRY]}, status: 422 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete
|
|
||||||
if time_entry = TimeEntry.find_by_id(params[:id])
|
|
||||||
time_entry.delete
|
|
||||||
render nothing: true, status: 204 and return
|
|
||||||
else
|
|
||||||
render json: { errors: [NOT_FOUND]}, status: 404 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,27 +1,21 @@
|
|||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
class Api::V1::UsersController < Api::V1::BaseController
|
class Api::V1::UsersController < Api::V1::BaseController
|
||||||
CANNOT_MANAGE = "You do not have the permission to manager users"
|
|
||||||
NOT_FOUND = "User not found"
|
|
||||||
NOT_ALLOWED = "Not allowed to reset your own password in this fashion"
|
|
||||||
PASS_LENGTH = 8
|
|
||||||
|
|
||||||
def password_reset
|
def password_reset
|
||||||
if can? :manage, User
|
if can? :manage, User
|
||||||
user = User.find_by_id(params[:user_id])
|
user = User.find_by_id(params[:user_id])
|
||||||
render :json => { "errors" => [NOT_FOUND]}, :status => 404 and return if user.nil?
|
render :json => { "error" => "User not found"}, :status => 404 and return if user.nil?
|
||||||
render :json => { "errors" => [NOT_ALLOWED]}, :status => 403 and return if user.id == current_user.id
|
render :json => { "error" => "Not allowed to reset your own password in this fashion."}, :status => 403 and return if user.id == current_user.id
|
||||||
|
|
||||||
new_pass = SecureRandom.hex[0,PASS_LENGTH]
|
new_pass = SecureRandom.hex[0,8]
|
||||||
user.password = new_pass
|
user.password = new_pass
|
||||||
user.save
|
user.save
|
||||||
render :json => { "password" => new_pass}, :status => 200 and return
|
render :json => { "password" => new_pass}, :status => 200 and return
|
||||||
else
|
else
|
||||||
render :json => { "errors" => [CANNOT_MANAGE]}, :status => 403 and return
|
render :json => { "error" => "You do not have the permission"}, :status => 403 and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
=begin Is this here by accident? Commenting out for now (1/30/14)
|
|
||||||
def checkout
|
def checkout
|
||||||
#must use @current_user since user may not have signed in
|
#must use @current_user since user may not have signed in
|
||||||
if !@current_user.checked_in?
|
if !@current_user.checked_in?
|
||||||
@@ -31,5 +25,4 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||||||
render :nothing => true, :status => 204 and return
|
render :nothing => true, :status => 204 and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
=end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
class BikesController < AuthenticatedController
|
|
||||||
|
|
||||||
def new
|
|
||||||
@brands = BikeBrand.all.map{ |b| [b.brand, b.id] }
|
|
||||||
@brands.unshift( ["Select a brand", -1] )
|
|
||||||
@wheel_sizes = BikeWheelSize.all.map{ |w| [w.display_string, w.id] }
|
|
||||||
@wheel_sizes.unshift( ["Select a wheel size", -1] )
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
@bike = Bike.find_by_id(params[:id])
|
|
||||||
@task_list_id = @bike.task_list.id
|
|
||||||
@show_add_bike = true if params[:add_bike]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
class PanelController < ApplicationController
|
|
||||||
|
|
||||||
def index
|
|
||||||
render :inline => "<%=netzke :app_view, :layout => true %>", :layout => "netzke"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
class SiteController < ApplicationController
|
class SiteController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@bike = current_user.bike
|
render :inline => "<%= netzke :app_view, :layout => true %>", :layout => "application"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
class TaskListsController < AuthenticatedController
|
|
||||||
def edit
|
|
||||||
@task_list = TaskList.find_by_id(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
class TimeEntriesController < AuthenticatedController
|
|
||||||
|
|
||||||
def new
|
|
||||||
@bikes = Bike.all.map{ |b| [b.to_s , b.id] }
|
|
||||||
if bike = current_user.bike
|
|
||||||
@bikes.unshift( [bike.to_s, bike.id] )
|
|
||||||
end
|
|
||||||
@bikes.unshift( ["Non-bike work", -1] )
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
|
||||||
@user_time_entries = TimeEntry.where(loggable_id: current_user.id)
|
|
||||||
@credits_available = current_user.total_credits
|
|
||||||
@hours_worked = current_user.total_hours
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+13
-14
@@ -1,7 +1,7 @@
|
|||||||
class Bike < ActiveRecord::Base
|
class Bike < ActiveRecord::Base
|
||||||
acts_as_loggable
|
acts_as_loggable
|
||||||
attr_accessible :shop_id, :serial_number, :bike_brand_id, :model, :color, :bike_style_id, :seat_tube_height,
|
attr_accessible :shop_id, :serial_number, :bike_brand_id, :model, :color, :bike_style_id, :seat_tube_height,
|
||||||
:top_tube_length, :bike_wheel_size_id, :value, :bike_condition_id, :bike_purpose_id
|
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_purpose_id
|
||||||
|
|
||||||
has_many :transactions
|
has_many :transactions
|
||||||
|
|
||||||
@@ -11,18 +11,21 @@ class Bike < ActiveRecord::Base
|
|||||||
belongs_to :bike_style
|
belongs_to :bike_style
|
||||||
belongs_to :bike_condition
|
belongs_to :bike_condition
|
||||||
belongs_to :bike_purpose
|
belongs_to :bike_purpose
|
||||||
belongs_to :bike_wheel_size
|
|
||||||
|
|
||||||
validates :shop_id, :presence => true, :uniqueness => true, :numericality => { :only_integer => true }
|
default_scope order('shop_id ASC')
|
||||||
|
|
||||||
|
validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 }
|
||||||
validates :serial_number, :length => { :minimum => 3 }
|
validates :serial_number, :length => { :minimum => 3 }
|
||||||
validates :model, :length => { :maximum => 50 }
|
validates :model, :length => { :maximum => 50 }
|
||||||
validates :bike_brand_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid brand" }
|
validates :bike_brand_id, :presence => true
|
||||||
#validates :color, :presence => true
|
validates :color, :presence => true
|
||||||
validates :bike_style_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid style" }
|
validates :bike_style_id, :presence => true
|
||||||
validates :seat_tube_height, :presence => true, :numericality => true
|
validates :seat_tube_height, :presence => true
|
||||||
validates :bike_wheel_size_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid wheel size" }
|
validates :top_tube_length, :presence => true
|
||||||
validates :bike_condition_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid condition" }
|
validates :wheel_size, :presence => true
|
||||||
validates :bike_purpose_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid purpose" }
|
#validates :value, :presence => true
|
||||||
|
validates :bike_condition_id, :presence => true
|
||||||
|
validates :bike_purpose_id, :presence => true
|
||||||
|
|
||||||
self.per_page = 15
|
self.per_page = 15
|
||||||
|
|
||||||
@@ -44,10 +47,6 @@ class Bike < ActiveRecord::Base
|
|||||||
self.bike_purpose
|
self.bike_purpose
|
||||||
end
|
end
|
||||||
|
|
||||||
def wheel_size
|
|
||||||
self.bike_wheel_size
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"#{brand} - #{model} - #{style}"
|
"#{brand} - #{model} - #{style}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
class BikeWheelSize < ActiveRecord::Base
|
|
||||||
belongs_to :bike
|
|
||||||
|
|
||||||
def display_string
|
|
||||||
result = []
|
|
||||||
result << "#{twmm}-#{rdmm}" unless twmm.blank? and rdmm.blank?
|
|
||||||
result << "#{rdin}x#{twin}" unless rdin.blank? and twin.blank?
|
|
||||||
result << "#{rdfr}x#{twfr}" unless rdfr.blank? and twfr.blank?
|
|
||||||
result << description unless description.blank?
|
|
||||||
result.join(" | ")
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
|
||||||
"#{twmm}-#{rdmm} #{rdin}x#{twin} #{rdfr}x#{twfr} '#{description}' #{tire_common_score}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
class Task < ActiveRecord::Base
|
class Task < ActiveRecord::Base
|
||||||
attr_accessible :task, :notes, :done, :task_list_id
|
attr_accessible :task, :notes, :done
|
||||||
|
|
||||||
belongs_to :task_list
|
belongs_to :task_list
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class TaskList < ActiveRecord::Base
|
|||||||
attr_accessible :item_id, :item_type, :name
|
attr_accessible :item_id, :item_type, :name
|
||||||
|
|
||||||
belongs_to :item, :polymorphic => true
|
belongs_to :item, :polymorphic => true
|
||||||
has_many :tasks, order: "id ASC"
|
has_many :tasks
|
||||||
|
|
||||||
after_save :create_default_bike_tasks
|
after_save :create_default_bike_tasks
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
class TimeEntry < ActsAsLoggable::Log
|
|
||||||
default_scope where( loggable_type: "User",
|
|
||||||
logger_type: "User",
|
|
||||||
log_action_type: "ActsAsLoggable::UserAction").where("log_action_id != 4").order("start_date DESC")
|
|
||||||
|
|
||||||
def copy_to_bike_history(bike_id)
|
|
||||||
self.assign_attributes({
|
|
||||||
copy_log: true,
|
|
||||||
copy_type: 'Bike',
|
|
||||||
copy_id: bike_id,
|
|
||||||
copy_action_type: 'ActsAsLoggable::BikeAction',
|
|
||||||
copy_action_id: 4
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
def duration
|
|
||||||
end_date - start_date
|
|
||||||
end
|
|
||||||
|
|
||||||
def duration_in_hours
|
|
||||||
(duration / 1.hour).round(2)
|
|
||||||
end
|
|
||||||
|
|
||||||
def type
|
|
||||||
log_action.try(:action)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+21
-29
@@ -47,12 +47,11 @@ class User < ActiveRecord::Base
|
|||||||
### TODO methods below probably belong somewhere else
|
### TODO methods below probably belong somewhere else
|
||||||
|
|
||||||
def completed_build_bikes
|
def completed_build_bikes
|
||||||
#default BUILDBIKE/CLASS ID is 5
|
purpose_id = BikePurpose.find_by_purpose("BUILDBIKE").id
|
||||||
purpose_id = 5
|
|
||||||
Bike.find_by_sql("
|
Bike.find_by_sql("
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM bikes
|
FROM bikes
|
||||||
INNER JOIN(
|
INNER JOIN(
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM transactions
|
FROM transactions
|
||||||
WHERE customer_id = #{self.id}
|
WHERE customer_id = #{self.id}
|
||||||
@@ -65,16 +64,15 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def total_credits_spent
|
def total_credits_spent
|
||||||
log_action_id = 1 #TIME
|
log_action = ::ActsAsLoggable::TransactionAction.find_by_action("TIME")
|
||||||
transaction_logs.
|
transaction_logs.
|
||||||
where( "log_action_id = ? AND log_action_type = ?",
|
where( "log_action_id = ? AND log_action_type = ?",
|
||||||
log_action_id, ::ActsAsLoggable::TransactionAction.to_s).
|
log_action.id, log_action.class.to_s).
|
||||||
sum{ |r| r.description.to_i }.round(2)
|
sum{ |r| r.description.to_i }.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_earned_credits
|
def total_earned_credits
|
||||||
volunteer_id = 1
|
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||||
staff_id = 3
|
|
||||||
|
|
||||||
# Find the first credit conversion which has a created_at date before the
|
# Find the first credit conversion which has a created_at date before the
|
||||||
# log's created_at date and join it to the log's row so we can calculate
|
# log's created_at date and join it to the log's row so we can calculate
|
||||||
@@ -83,7 +81,7 @@ class User < ActiveRecord::Base
|
|||||||
#
|
#
|
||||||
# The DISTINCT ON, and ORDER BY are important to getting the
|
# The DISTINCT ON, and ORDER BY are important to getting the
|
||||||
# single conversion rate that applies to the respective log.
|
# single conversion rate that applies to the respective log.
|
||||||
::ActsAsLoggable::Log.find_by_sql(["
|
::ActsAsLoggable::Log.find_by_sql("
|
||||||
SELECT DISTINCT ON (logs.created_at) start_date, end_date,
|
SELECT DISTINCT ON (logs.created_at) start_date, end_date,
|
||||||
conversion.conversion, conversion.created_at
|
conversion.conversion, conversion.created_at
|
||||||
FROM logs
|
FROM logs
|
||||||
@@ -91,26 +89,23 @@ class User < ActiveRecord::Base
|
|||||||
SELECT conversion, created_at
|
SELECT conversion, created_at
|
||||||
FROM credit_conversions
|
FROM credit_conversions
|
||||||
) AS conversion ON logs.created_at > conversion.created_at
|
) AS conversion ON logs.created_at > conversion.created_at
|
||||||
WHERE logs.loggable_id = :id
|
WHERE logs.loggable_id = #{self.id}
|
||||||
AND logs.loggable_type = 'User'
|
AND logs.loggable_type = 'User'
|
||||||
AND (log_action_id IN (:credit_actions) AND log_action_type = :log_action_type)
|
AND (log_action_id != #{log_action.id} AND log_action_type = '#{log_action.class.to_s}')
|
||||||
ORDER BY logs.created_at, conversion.created_at DESC",
|
ORDER BY logs.created_at, conversion.created_at DESC").
|
||||||
{id: self.id,
|
|
||||||
credit_actions: [volunteer_id, staff_id],
|
|
||||||
log_action_type: ::ActsAsLoggable::UserAction.to_s}]).
|
|
||||||
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
|
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_hours
|
def total_hours
|
||||||
log_action_id = 4 #CHECKIN
|
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_month_hours
|
def current_month_hours
|
||||||
log_action_id = 4 #CHECKIN
|
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||||
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
|
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
|
||||||
current_month_range = (Time.now.beginning_of_month..Time.now.end_of_month)
|
current_month_range = (Time.now.beginning_of_month..Time.now.end_of_month)
|
||||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s)
|
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s)
|
||||||
.where( :start_date => current_month_range)
|
.where( :start_date => current_month_range)
|
||||||
.where( :end_date => current_month_range)
|
.where( :end_date => current_month_range)
|
||||||
.sum { |l| (l.end_date - l.start_date)/3600 }
|
.sum { |l| (l.end_date - l.start_date)/3600 }
|
||||||
@@ -118,31 +113,28 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def checked_in?
|
def checked_in?
|
||||||
#default CHECKIN log action is id, yea yea should be a constant
|
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||||
log_action_id = 4
|
checked = logs.where( log_action_id: log_action.id).
|
||||||
checked = logs.where( log_action_id: log_action_id).
|
|
||||||
where("start_date >= ?", Time.zone.now.beginning_of_day).
|
where("start_date >= ?", Time.zone.now.beginning_of_day).
|
||||||
where("start_date = end_date")
|
where("start_date = end_date")
|
||||||
!checked.empty?
|
!checked.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def checkin
|
def checkin
|
||||||
#default CHECKIN log action is id, yea yea should be a constant
|
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||||
log_action_id = 4
|
|
||||||
time = Time.now
|
time = Time.now
|
||||||
logs.create( logger_id: self.id,
|
logs.create( logger_id: self.id,
|
||||||
logger_type: self.class.to_s,
|
logger_type: self.class.to_s,
|
||||||
start_date: time,
|
start_date: time,
|
||||||
end_date: time,
|
end_date: time,
|
||||||
log_action_id: log_action_id,
|
log_action_id: log_action.id,
|
||||||
log_action_type: ::ActsAsLoggable::UserAction.to_s)
|
log_action_type: log_action.class.to_s)
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
def checkout
|
def checkout
|
||||||
#default CHECKIN log action is id, yea yea should be a constant
|
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
||||||
log_action_id = 4
|
checked = logs.where( log_action_id: log_action.id).
|
||||||
checked = logs.where( log_action_id: log_action_id).
|
|
||||||
where("start_date >= ?", Time.zone.now.beginning_of_day).
|
where("start_date >= ?", Time.zone.now.beginning_of_day).
|
||||||
where("start_date = end_date").first
|
where("start_date = end_date").first
|
||||||
checked.end_date = Time.now
|
checked.end_date = Time.now
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
json.bikes [@bike] do |bike|
|
|
||||||
json.array! bike
|
|
||||||
json.set! :href, api_bike_path(bike)
|
|
||||||
end
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
json.bikes [@bike] do |bike|
|
|
||||||
json.array! bike
|
|
||||||
end
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
json.task_lists [@task_list] do |tl|
|
|
||||||
json.array! tl
|
|
||||||
json.links do
|
|
||||||
json.bike do
|
|
||||||
json.href api_bike_path(tl.item)
|
|
||||||
json.id tl.item_id
|
|
||||||
end
|
|
||||||
json.tasks tl.tasks do |task|
|
|
||||||
json.id task.id
|
|
||||||
json.done task.done
|
|
||||||
json.notes task.notes
|
|
||||||
json.task task.task
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
json.tasks [@tasks.map{|x| x[:record]}] do |task|
|
|
||||||
json.array! task
|
|
||||||
end
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
json.time_entries [@time_entry] do |time_entry|
|
|
||||||
json.array! time_entry
|
|
||||||
#json.set! :href, api_time_entry_path(time_entry)
|
|
||||||
end
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
%a{ class: "btn btn-default btn-lg", href: root_path}
|
|
||||||
%span{ class:"icon-home"}
|
|
||||||
%h2 Add Bike
|
|
||||||
|
|
||||||
%p
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "shop_id", placeholder: "Shop ID", type: "number", min:0, class: "input-lg" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
= select_tag(:bike_brand_id, options_for_select(@brands))
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "model", placeholder: "Model", type: "text", class: "input-lg" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "serial_number", placeholder: "Serial Number", type: "text", class: "input-lg" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
.btn-group{ "data-toggle" => "buttons-radio"}
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_style", value: 3} RD
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_style", value: 1} MTN
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_style", value: 2} HYB
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_style", value: 4} OTHER
|
|
||||||
%input{ id: "bike_style_id", type: "hidden"}
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
= select_tag(:bike_wheel_size_id, options_for_select(@wheel_sizes), id: :bike_wheel_size_id)
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
.btn-group{ "data-toggle" => "buttons-radio"}
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_condition", value: 2} Poor
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_condition", value: 3} Fair
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_condition", value: 4} Good
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "bike_condition", value: 5} Excellent
|
|
||||||
%input{ id: "bike_condition_id", type: "hidden"}
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "seat_tube_height", placeholder: "Seat Tube (cm)", type: "number", min: 0, max: 100, class: "input-lg" }
|
|
||||||
.help-block
|
|
||||||
-# Commenting this out until description is added to Bike
|
|
||||||
%p
|
|
||||||
%input{id: "bike_description", placeholder: "Short description", type: "text", class: "input-lg" }
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "add_bike_submit", value: "Add Bike", type: "button", class: "btn btn-lg btn-block btn-primary", "data-url" => "#{api_create_bike_path}"}
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
- if @show_add_bike
|
|
||||||
%p
|
|
||||||
%a{class: "btn btn-lg btn-block btn-info", href: new_bike_path} Add Another Bike?
|
|
||||||
|
|
||||||
%a{ class: "btn btn-default btn-lg", href: root_path}
|
|
||||||
%span{ class:"icon-home"}
|
|
||||||
%h2 #{@bike.shop_id}: #{@bike.bike_brand}
|
|
||||||
%h2 #{@bike.model}
|
|
||||||
|
|
||||||
%dl.dl-horizontal
|
|
||||||
%dt Type
|
|
||||||
%dd #{@bike.bike_style}
|
|
||||||
%dt Wheel Size
|
|
||||||
%dd #{@bike.bike_wheel_size.display_string}
|
|
||||||
%dt Condition
|
|
||||||
%dd #{@bike.bike_condition}
|
|
||||||
%dt Seat Tube (cm)
|
|
||||||
%dd #{@bike.seat_tube_height}
|
|
||||||
%dt Purpose
|
|
||||||
%dd #{@bike.bike_purpose}
|
|
||||||
- if !@bike.value.nil?
|
|
||||||
%dt Value
|
|
||||||
%dd #{@bike.value}
|
|
||||||
- if !@bike.color.nil?
|
|
||||||
%dt Color
|
|
||||||
%dd{ style: "width: 50px; background-color: ##{@bike.color}; border: black; border-width: 1px; border-style: solid;"} #{@bike.color}
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary", href: edit_task_list_path(@task_list_id) } View Checklist
|
|
||||||
@@ -1,28 +1,21 @@
|
|||||||
<%- if controller_name != 'sessions' %>
|
<%- if controller_name != 'sessions' %>
|
||||||
<p>
|
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||||
<%= link_to "Sign in", new_session_path(resource_name), class: "btn btn-block btn-default" %><br />
|
|
||||||
</p>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||||
<p>
|
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||||
<%= link_to "Sign up", new_registration_path(resource_name), class: "btn btn-block btn-default" %><br />
|
|
||||||
</p>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
||||||
<p>
|
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||||
<%= link_to "Forgot your password?", new_password_path(resource_name), class: "btn btn-block btn-default" %><br />
|
|
||||||
</p>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||||
<p>
|
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: "btn btn-block btn-default" %><br />
|
|
||||||
</p>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||||
|
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%- if devise_mapping.omniauthable? %>
|
<%- if devise_mapping.omniauthable? %>
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
<%= stylesheet_link_tag "bootstrap_and_overrides", :media => "all" %>
|
|
||||||
|
|
||||||
<h2>Forgot your password?</h2>
|
<h2>Forgot your password?</h2>
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||||
<%= devise_error_messages! %>
|
<%= devise_error_messages! %>
|
||||||
|
|
||||||
<div class="form-group">
|
<div><%= f.label :email %><br />
|
||||||
<%= f.email_field :email, placeholder: "Email", class: "form-control input-lg" %>
|
<%= f.email_field :email %></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div><%= f.submit "Reset Password", class:"btn btn-lg btn-primary"%></div>
|
<div><%= f.submit "Send me reset password instructions" %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "links" %>
|
<%= render "links" %>
|
||||||
|
|||||||
@@ -1,14 +1,25 @@
|
|||||||
%p
|
%fieldset
|
||||||
%fieldset
|
.control-group
|
||||||
.form-group
|
= f.label :addrStreet1, :class => "control-label"
|
||||||
= f.text_field :addrStreet1, placeholder: "Street Address Line 1", :class => "form-control input-lg"
|
.controls
|
||||||
.form-group
|
= f.text_field :addrStreet1, :class => "control-label"
|
||||||
= f.text_field :addrStreet2, placeholder: "Street Address Line 2",:class => "form-control input-lg"
|
.control-group
|
||||||
.form-group
|
= f.label :addrStreet2, :class => "control-label"
|
||||||
= f.text_field :addrCity, placeholder: "City", :class => "form-control input-lg"
|
.controls
|
||||||
.form-group
|
= f.text_field :addrStreet2, :class => "control-label"
|
||||||
= f.text_field :addrState, placeholder: "State Abbreviation", :class => "form-control input-lg"
|
.control-group
|
||||||
.form-group
|
= f.label :addrCity, :class => "control-label"
|
||||||
= f.text_field :addrZip, placeholder: "Zip Code", :class => "form-control input-lg"
|
.controls
|
||||||
.form-group
|
= f.text_field :addrCity, :class => "control-label"
|
||||||
= f.text_field :phone, placeholder: "Phone", :class => "form-control input-lg"
|
.control-group
|
||||||
|
= f.label :addrState, :class => "control-label"
|
||||||
|
.controls
|
||||||
|
= f.text_field :addrState, :class => "control-label"
|
||||||
|
.control-group
|
||||||
|
= f.label :addrZip, :class => "control-label"
|
||||||
|
.controls
|
||||||
|
= f.text_field :addrZip, :class => "control-label"
|
||||||
|
.control-group
|
||||||
|
= f.label :phone, :class => "control-label"
|
||||||
|
.controls
|
||||||
|
= f.text_field :phone, :class => "control-label"
|
||||||
|
|||||||
@@ -1,23 +1,36 @@
|
|||||||
= stylesheet_link_tag "bootstrap_and_overrides", :media => "all"
|
= stylesheet_link_tag "bootstrap_and_overrides", :media => "all"
|
||||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form-horizontal"}) do |f|
|
||||||
= devise_error_messages!
|
= devise_error_messages!
|
||||||
.controls
|
.controls
|
||||||
%h2 Sign up
|
%h2 Sign up
|
||||||
.form-group
|
.control-group
|
||||||
= f.text_field :username, placeholder: "Username", :class => "form-control input-lg"
|
= f.label :username, :class => "control-label"
|
||||||
.form-group
|
.controls
|
||||||
= f.text_field :first_name, placeholder: "First Name", :class => "form-control input-lg"
|
= f.text_field :username
|
||||||
.form-group
|
.control-group
|
||||||
= f.text_field :last_name, placeholder: "Last Name", :class => "form-control input-lg"
|
= f.label :first_name, :class => "control-label"
|
||||||
.form-group
|
.controls
|
||||||
= f.email_field :email, placeholder: "E-mail", :class => "form-control input-lg"
|
= f.text_field :first_name
|
||||||
|
.control-group
|
||||||
|
= f.label :last_name, :class => "control-label"
|
||||||
|
.controls
|
||||||
|
= f.text_field :last_name
|
||||||
|
.control-group
|
||||||
|
= f.label :email, :class => "control-label"
|
||||||
|
.controls
|
||||||
|
= f.email_field :email
|
||||||
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
|
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
|
||||||
= f.fields_for :user_profiles, profile_builder do |builder|
|
= f.fields_for :user_profiles, profile_builder do |builder|
|
||||||
= render 'user_profile_fields', f: builder
|
= render 'user_profile_fields', f: builder
|
||||||
.form-group
|
.control-group
|
||||||
= f.password_field :password, placeholder: "Password", :class => "form-control input-lg"
|
= f.label :password, :class => "control-label"
|
||||||
.form-group
|
.controls
|
||||||
= f.password_field :password_confirmation, placeholder: "Password Confirmation", :class => "form-control input-lg"
|
= f.password_field :password
|
||||||
.form-group
|
.control-group
|
||||||
= f.submit "Sign up", class:"btn btn-lg btn-primary"
|
= f.label :password_confirmation, :class => "control-label"
|
||||||
|
.controls
|
||||||
|
= f.password_field :password_confirmation
|
||||||
|
.control-group
|
||||||
|
.controls
|
||||||
|
= f.submit "Sign up"
|
||||||
= render "links"
|
= render "links"
|
||||||
|
|||||||
@@ -5,44 +5,34 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||||
<div class="form-group">
|
<div><%= f.label :username%><br />
|
||||||
<%= f.text_field :username, placeholder: "Username", class: "form-control input-lg"%>
|
<%= f.text_field :username%></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div><%= f.label :password %><br />
|
||||||
<%= f.password_field :password, placeholder: "Password", class: "form-control input-lg" %>
|
<%= f.password_field :password %></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<% if devise_mapping.rememberable? -%>
|
<% if devise_mapping.rememberable? -%>
|
||||||
<label>
|
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
||||||
<%= f.check_box :remember_me %> Remember Me
|
|
||||||
</label>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div><%= f.submit "Sign in" %></div>
|
||||||
<p>
|
|
||||||
<%= f.submit "Sign in", class:"btn btn-lg btn-primary" %>
|
<div id="checkin_menu"style="display:none;">
|
||||||
</p>
|
<input id="checkin" name="checkin" type="button" value="CHECK IN">
|
||||||
<p> Or quickly... </p>
|
<input id="checkout" name="checkout" type="button" value="CHECK OUT">
|
||||||
<div class="btn-group">
|
|
||||||
<input id="checkin" name="checkin" type="button" value="CHECK IN" class="btn btn-lg btn-success">
|
|
||||||
<input id="checkout" name="checkout" type="button" value="CHECK OUT" class="btn btn-lg btn-danger">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<%= render "links" %>
|
<%= render "links" %>
|
||||||
|
|
||||||
<% if Rails.env.development? %>
|
<% if Rails.env.development? %>
|
||||||
<p>
|
|
||||||
<% User.all.each do |user| %>
|
<% User.all.each do |user| %>
|
||||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||||
<%= f.hidden_field :username, :value => user.username%>
|
<%= f.hidden_field :username, :value => user.username%></div>
|
||||||
<%= f.hidden_field :password, :value => 'password' %>
|
<%= f.hidden_field :password, :value => 'password' %></div>
|
||||||
<%= f.submit "Sign in as #{user.username}", class:"btn btn-info" %>
|
<div><%= f.submit "Sign in as #{user.username}" %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,18 +2,14 @@
|
|||||||
%html{:lang => "en"}
|
%html{:lang => "en"}
|
||||||
%head
|
%head
|
||||||
%meta{:charset => "utf-8"}/
|
%meta{:charset => "utf-8"}/
|
||||||
%meta{ name: "viewport", content: "width=device-width", "initial-scale" => "1.0"}
|
|
||||||
%title= content_for?(:title) ? yield(:title) : "Velocipede"
|
%title= content_for?(:title) ? yield(:title) : "Velocipede"
|
||||||
|
= load_netzke
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
= stylesheet_link_tag "bootstrap_and_overrides", "datepicker", "bootstrap-timepicker", :media => "all"
|
|
||||||
/[if lt IE 9]
|
/[if lt IE 9]
|
||||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||||
:css
|
:css
|
||||||
body {
|
body {
|
||||||
padding-top: 5px;
|
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||||
}
|
|
||||||
.x-boundlist-item {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%body
|
%body
|
||||||
@@ -25,11 +21,11 @@
|
|||||||
- if flash[:alert]
|
- if flash[:alert]
|
||||||
%p{:class => 'alert'}= flash[:alert]
|
%p{:class => 'alert'}= flash[:alert]
|
||||||
.row
|
.row
|
||||||
.span12
|
.span13
|
||||||
= yield
|
= yield
|
||||||
|
|
||||||
%footer
|
%footer
|
||||||
%p © BikeShed #{Time.now.year}
|
%p © Velocipede 2013
|
||||||
|
|
||||||
= javascript_include_tag "application"
|
= javascript_include_tag "application"
|
||||||
= javascript_include_tag params[:controller]
|
= javascript_include_tag params[:controller]
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
!!! 5
|
|
||||||
%html{:lang => "en"}
|
|
||||||
%head
|
|
||||||
%meta{:charset => "utf-8"}/
|
|
||||||
%title= content_for?(:title) ? yield(:title) : "Velocipede"
|
|
||||||
= load_netzke
|
|
||||||
= csrf_meta_tags
|
|
||||||
%body
|
|
||||||
= yield
|
|
||||||
= javascript_include_tag "application"
|
|
||||||
= javascript_include_tag params[:controller]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
= stylesheet_link_tag "bootstrap_and_overrides", :media => "all"
|
|
||||||
%h2 Dashboard
|
|
||||||
|
|
||||||
%p
|
|
||||||
%p
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary", href: new_time_entry_path} Add Time Entry
|
|
||||||
%p
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary", href: time_entries_path} View Timesheet
|
|
||||||
%p
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary", href: new_bike_path} Add Bike
|
|
||||||
|
|
||||||
- if !@bike.nil?
|
|
||||||
%p
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary", href: bike_path(@bike)} View Your Bike
|
|
||||||
|
|
||||||
|
|
||||||
%p
|
|
||||||
%p
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary hidden-xs", href: admin_index_path} Admin View
|
|
||||||
%p
|
|
||||||
%input{id: "index_logout", value: "Logout", type: "button", class: "btn btn-lg btn-block btn-danger", "data-url" => destroy_user_session_path }
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
%a{ class: "btn btn-default btn-lg", href: root_path}
|
|
||||||
%span{ class:"icon-home"}
|
|
||||||
%h2 Task List
|
|
||||||
%h3
|
|
||||||
%a{ href: bike_path(@task_list.item)}#{@task_list.item.shop_id} #{@task_list.item.bike_brand}
|
|
||||||
%h4 #{@task_list.item.model}
|
|
||||||
|
|
||||||
%p
|
|
||||||
.control-group
|
|
||||||
- @task_list.tasks.each do |task|
|
|
||||||
.controls
|
|
||||||
%input{class: "task_list_task", type: "checkbox", "data-id" => task.id, checked: task.done}
|
|
||||||
#{task.task}
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "update_tasks_submit", value: "Save Changes", type: "button", class: "btn btn-lg btn-block btn-primary disabled", "data-url" => "#{api_update_task_path}"}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
%a{ class: "btn btn-default btn-lg", href: root_path}
|
|
||||||
%span{ class:"icon-home"}
|
|
||||||
%h2 Your Timesheet
|
|
||||||
|
|
||||||
%dl.dl-horizontal
|
|
||||||
%dd
|
|
||||||
%span.badge #{@hours_worked}
|
|
||||||
Total Hours Worked
|
|
||||||
%dd
|
|
||||||
%span.badge #{@credits_available}
|
|
||||||
Total Credits Available
|
|
||||||
|
|
||||||
%table.table
|
|
||||||
%tbody
|
|
||||||
- @user_time_entries.each do |entry|
|
|
||||||
%tr{ "data-id" => entry.id, "data-description" => entry.description,
|
|
||||||
"data-duration" => entry.duration_in_hours,
|
|
||||||
"data-start_date" => entry.start_date.to_date.to_formatted_s(:rfc822)}
|
|
||||||
%td #{entry.start_date.to_date.to_formatted_s(:rfc822)}
|
|
||||||
%td #{entry.duration_in_hours}
|
|
||||||
%td #{entry.type}
|
|
||||||
%td #{truncate(entry.description)}
|
|
||||||
%td
|
|
||||||
%button{ class: "btn icon-remove btn-danger work_entry-delete-btn", role: "button", "data-toggle" => "modal", "data-target" => "#confirmation" }
|
|
||||||
|
|
||||||
%a{class: "btn btn-lg btn-block btn-primary", href: new_time_entry_path } Add Time Entry
|
|
||||||
|
|
||||||
.modal{ id: "confirmation", class: "hide", role: "dialog", "aria-labelledby" => "confirmation_title", "aria-hidden" => "true", tabindex: -1 }
|
|
||||||
.modal-header
|
|
||||||
%button{ class: "close", "data-dismiss" => "modal", "aria-hidden" => "true"}x
|
|
||||||
%h4{ id: "confirmation_title" } Are you sure you want to delete?
|
|
||||||
.modal-body
|
|
||||||
%div{ id: "work_entry_start_date" }
|
|
||||||
Start Date
|
|
||||||
%div{ id: "work_entry_duration" }
|
|
||||||
Duration
|
|
||||||
%div{ id: "work_entry_description" }
|
|
||||||
Description
|
|
||||||
.modal-footer
|
|
||||||
%button{ class: "btn", "data-dismiss" => "modal", "aria-hidden" => "true"} Close
|
|
||||||
%button{ id: "confirmation_delete", class: "btn btn-primary", "data-url" => "api/v1/time_entries/" } Delete
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
%a{ class: "btn btn-default btn-lg", href: root_path}
|
|
||||||
%span{ class:"icon-home"}
|
|
||||||
%h2 Add Time Entry
|
|
||||||
|
|
||||||
%p
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "date_id", placeholder: "Date", type: "text", class: "datepicker input-small" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls{ class: "bootstrap-timepicker"}
|
|
||||||
%label Start
|
|
||||||
%input{id: "start_time_id", placeholder: "Time ID", type: "text", class: "input-small" }
|
|
||||||
.hidden{ id: "start_date" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%label End
|
|
||||||
%input{id: "end_time_id", placeholder: "Time ID", type: "text", class: "input-small" }
|
|
||||||
.hidden{ id: "end_date" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
.btn-group{ "data-toggle" => "buttons-radio"}
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "action_id", value: 1} Volunteer
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "action_id", value: 2} Personal
|
|
||||||
%label{ class: "btn btn-default"}
|
|
||||||
%input{ type: "radio", name: "action_id", value: 3} Staff
|
|
||||||
.hidden{ id: "log_action_id" }
|
|
||||||
.help-block
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%label
|
|
||||||
= select_tag(:bike_id, options_for_select(@bikes))
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%textarea{id: "description_id", placeholder: "Work description", class: "input-lg" }
|
|
||||||
.control-group
|
|
||||||
.controls
|
|
||||||
%input{id: "add_time_entry_submit", value: "Add Time Entry", type: "button", class: "btn btn-lg btn-block btn-primary", "data-url" => "#{api_create_time_entry_path}", "data-forward" => "#{"."}"}
|
|
||||||
@@ -10,7 +10,7 @@ development:
|
|||||||
# Do not set this db to the same as development or production.
|
# Do not set this db to the same as development or production.
|
||||||
test:
|
test:
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
database: velocipede_test
|
database: velocipede
|
||||||
username: velocipede
|
username: velocipede
|
||||||
password:
|
password:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
|
|||||||
@@ -222,12 +222,11 @@ Devise.setup do |config|
|
|||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Rails.env.test?
|
#Check in the user if they sign in. (Devise uses Warden)
|
||||||
#Check in the user if they sign in. (Devise uses Warden)
|
Warden::Manager.after_set_user do |user,auth,opts|
|
||||||
Warden::Manager.after_set_user do |user,auth,opts|
|
# this essentially gets called after every netzke request, but alas,
|
||||||
# this essentially gets called after every netzke request, but alas,
|
# only using the after_authenticaion callback doesn't get fired after
|
||||||
# only using the after_authenticaion callback doesn't get fired after
|
# user creation.
|
||||||
# user creation.
|
user.checkin unless user.checked_in?
|
||||||
user.checkin unless user.checked_in?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+3
-24
@@ -4,34 +4,13 @@ Velocipede::Application.routes.draw do
|
|||||||
netzke
|
netzke
|
||||||
|
|
||||||
root :to => 'site#index'
|
root :to => 'site#index'
|
||||||
get 'admin/index', to: 'panel#index', as: "admin_index"
|
|
||||||
|
|
||||||
get 'bikes/new', to: 'bikes#new', as: "new_bike"
|
|
||||||
get 'bikes/:id', to: 'bikes#show', as: "bike"
|
|
||||||
|
|
||||||
get 'task_lists/:id/edit' => "task_lists#edit", as: "edit_task_list"
|
|
||||||
|
|
||||||
get 'time_entries' => "time_entries#index", as: "time_entries"
|
|
||||||
get 'time_entries/new' => "time_entries#new", as: "new_time_entry"
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# API Routes
|
# API Routes
|
||||||
scope 'api', :module => :api, defaults: {format: :json} do
|
scope 'api', :module => :api do
|
||||||
scope 'v1', :module => :v1 do
|
scope 'v1', :module => :v1 do
|
||||||
post 'checkin' => "logs#checkin", :as => "api_checkin"
|
post 'checkin' => "logs#checkin", :as => "api_checkin"
|
||||||
post 'checkout' => "logs#checkout", :as => "api_checkout"
|
post 'checkout' => "logs#checkout", :as => "api_checkout"
|
||||||
|
post 'reset' => "users#password_reset", :as => "api_password_reset"
|
||||||
post 'reset' => "users#password_reset", :as => "api_password_reset"
|
|
||||||
|
|
||||||
get 'bikes/:id' => "bikes#show", as: "api_bike"
|
|
||||||
post 'bikes/create' => "bikes#create", as: "api_create_bike"
|
|
||||||
|
|
||||||
get 'task_lists/:id' => "task_lists#show", as: "api_task_list"
|
|
||||||
|
|
||||||
put 'tasks/update' => "tasks#update", as: "api_update_task"
|
|
||||||
|
|
||||||
post 'time_entries/create' => "time_entries#create", as: "api_create_time_entry"
|
|
||||||
delete 'time_entries/:id' => "time_entries#delete", as: "api_delete_time_entry"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ class AddModelToBike < ActiveRecord::Migration
|
|||||||
add_column :bikes, :model, :string
|
add_column :bikes, :model, :string
|
||||||
change_column :bikes, :bike_model_id, :integer, :null => true
|
change_column :bikes, :bike_model_id, :integer, :null => true
|
||||||
Bike.all.each do |bike|
|
Bike.all.each do |bike|
|
||||||
bike.update_attribute(:model, BikeModel.find_by_id(bike['bike_model_id']).model )
|
bike.model = BikeModel.find_by_id(bike.bike_model_id).model
|
||||||
|
bike.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
class ChangeBikeShopId < ActiveRecord::Migration
|
|
||||||
# We don't use change_column because we have arbitrary strings we
|
|
||||||
# need to strip the characters from to make the integer values
|
|
||||||
def up
|
|
||||||
bikes = Bike.all
|
|
||||||
remove_column :bikes, :shop_id
|
|
||||||
add_column :bikes, :shop_id, :integer, :unique => true
|
|
||||||
|
|
||||||
# deconflict shop ids
|
|
||||||
bikes.each do |bike|
|
|
||||||
new_id = bike.shop_id.gsub(/[^\d]/, '').to_i rescue 1
|
|
||||||
while bikes.map(&:shop_id).include? new_id
|
|
||||||
new_id += 1
|
|
||||||
end
|
|
||||||
bike.update_attribute(:shop_id, new_id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
change_column :bikes, :shop_id, :string
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
class CreateBikeWheelSizes < ActiveRecord::Migration
|
|
||||||
def up
|
|
||||||
create_table(:bike_wheel_sizes) do |t|
|
|
||||||
t.integer :twmm
|
|
||||||
t.integer :rdmm
|
|
||||||
t.string :twin
|
|
||||||
t.string :rdin
|
|
||||||
t.string :twfr
|
|
||||||
t.string :rdfr
|
|
||||||
t.string :description
|
|
||||||
t.string :tire_common_score
|
|
||||||
end
|
|
||||||
|
|
||||||
#create the default undetermined wheel size record
|
|
||||||
BikeWheelSize.create( twmm: 0, rdmm: 0, rdin: 0, twin: 0, rdfr: 0, twfr: 0, description: "UNDETERMINED", tire_common_score: 0)
|
|
||||||
ActiveRecord::Base.connection.execute(IO.read(File.join(Rails.root, "db", "seed", "sql", "common_wheel_sizes.sql")))
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
drop_table :bike_wheel_sizes
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
class AlterBikeWheelToId < ActiveRecord::Migration
|
|
||||||
def up
|
|
||||||
add_column :bikes, :bike_wheel_size_id, :integer
|
|
||||||
|
|
||||||
undetermined_id = BikeWheelSize.find_by_rdin("0")
|
|
||||||
Bike.find_each do |bike|
|
|
||||||
wheel_size = BikeWheelSize.find_by_rdin(bike['wheel_size'].to_s)
|
|
||||||
|
|
||||||
if wheel_size.nil?
|
|
||||||
wheel_size_id = undetermined_id
|
|
||||||
else
|
|
||||||
wheel_size_id = wheel_size.id
|
|
||||||
end
|
|
||||||
bike.update_attribute(:bike_wheel_size_id, wheel_size_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
remove_column :bikes, :wheel_size
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
|
|
||||||
add_column :bikes, :wheel_size, :integer
|
|
||||||
|
|
||||||
Bike.find_each do |bike|
|
|
||||||
wheel_size = BikeWheelSize.find_by_id(bike['bike_wheel_size_id'])
|
|
||||||
bike.update_attribute(:wheel_size, wheel_size["rdin"].to_i)
|
|
||||||
end
|
|
||||||
|
|
||||||
remove_column :bikes, :bike_wheel_size_id
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
class AddTimezonesToLogs < ActiveRecord::Migration
|
|
||||||
def up
|
|
||||||
change_table :logs do |t|
|
|
||||||
t.change :start_date, :timestamptz
|
|
||||||
t.change :end_date, :timestamptz
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
change_table :logs do |t|
|
|
||||||
t.change :start_date, :timestamp
|
|
||||||
t.change :end_date, :timestamp
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+11
-20
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140504154355) do
|
ActiveRecord::Schema.define(:version => 20130902201853) do
|
||||||
|
|
||||||
create_table "bike_actions", :force => true do |t|
|
create_table "bike_actions", :force => true do |t|
|
||||||
t.string "action", :limit => 128, :null => false
|
t.string "action", :limit => 128, :null => false
|
||||||
@@ -46,35 +46,26 @@ ActiveRecord::Schema.define(:version => 20140504154355) do
|
|||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "bike_wheel_sizes", :force => true do |t|
|
|
||||||
t.integer "twmm"
|
|
||||||
t.integer "rdmm"
|
|
||||||
t.string "twin"
|
|
||||||
t.string "rdin"
|
|
||||||
t.string "twfr"
|
|
||||||
t.string "rdfr"
|
|
||||||
t.string "description"
|
|
||||||
t.string "tire_common_score"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "bikes", :force => true do |t|
|
create_table "bikes", :force => true do |t|
|
||||||
t.string "serial_number"
|
t.string "serial_number"
|
||||||
t.integer "bike_brand_id", :null => false
|
t.integer "bike_brand_id", :null => false
|
||||||
t.integer "bike_model_id"
|
t.integer "bike_model_id"
|
||||||
t.string "color"
|
t.string "color"
|
||||||
t.integer "bike_style_id", :null => false
|
t.integer "bike_style_id", :null => false
|
||||||
t.float "seat_tube_height"
|
t.float "seat_tube_height"
|
||||||
t.float "top_tube_length"
|
t.float "top_tube_length"
|
||||||
|
t.integer "wheel_size"
|
||||||
t.float "value"
|
t.float "value"
|
||||||
t.integer "bike_condition_id", :null => false
|
t.integer "bike_condition_id", :null => false
|
||||||
t.integer "bike_purpose_id", :null => false
|
t.integer "bike_purpose_id", :null => false
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.string "shop_id"
|
||||||
t.string "model"
|
t.string "model"
|
||||||
t.integer "shop_id"
|
|
||||||
t.integer "bike_wheel_size_id"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "bikes", ["shop_id"], :name => "index_bikes_on_shop_id", :unique => true
|
||||||
|
|
||||||
create_table "credit_conversions", :force => true do |t|
|
create_table "credit_conversions", :force => true do |t|
|
||||||
t.integer "conversion", :default => 1
|
t.integer "conversion", :default => 1
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user