commit 32c9f9be04a081a43c5dc83a1799b2c93c885ec5 Author: Harry Bomrah Date: Fri Jan 20 17:02:50 2017 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de5d954 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/db/*.sqlite3-journal +test/dummy/log/*.log +test/dummy/tmp/ +test/dummy/.sass-cache diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..20cb895 --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +source 'https://rubygems.org' + +# Declare your gem's dependencies in property_hire.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use a debugger +# gem 'byebug', group: [:development, :test] + diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..d33f7d5 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2017 Harry Bomrah + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..cb63caf --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += PropertyHire + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..69bdc0e --- /dev/null +++ b/Rakefile @@ -0,0 +1,37 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'PropertyHire' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + +load 'rails/tasks/statistics.rake' + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task default: :test diff --git a/app/assets/images/property_hire/.keep b/app/assets/images/property_hire/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/property_hire/application.js b/app/assets/javascripts/property_hire/application.js new file mode 100644 index 0000000..8913b40 --- /dev/null +++ b/app/assets/javascripts/property_hire/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/app/assets/javascripts/property_hire_calendar_frontend.js b/app/assets/javascripts/property_hire_calendar_frontend.js new file mode 100644 index 0000000..8fb74a1 --- /dev/null +++ b/app/assets/javascripts/property_hire_calendar_frontend.js @@ -0,0 +1,597 @@ +var Calendar = function(dom,property_id){ + + c = this; + this.title = $("#current_title"); + this.calendar = $(dom); + this.nextBtn = $("#next_month_btn"); + this.prevBtn = $("#prev_month_btn"); + this.todayBtn = $("#today_btn"); + this.modeBtns = $(".calendar_mode button"); + this.refreshBtn = $("#refresh_btn"); + this.dialog = new EventDialog(c); + this.loading = $('#calendar-loading'); + this.agenda_space = $("#calendar_agenda"); + this.currentView = "month"; + this.property_id = property_id; + this.navigation = $("#navigation"); + this.rangeSelection = $("#range_selection"); + var agendaView = new AgendaView(c); + var loadeventsonviewchange = false; + this.initialize = function(){ + var date = new Date(); + var d = date.getDate(); + var m = date.getMonth(); + var y = date.getFullYear(); + var dview = (c.currentView == "agenda" ? "month" : c.currentView); + c.calendar.fullCalendar({ + editable: false, + selectable: false, + events: "/xhr/property_hires/get_bookings?property_id="+c.property_id, + header: false, + default: dview, + height: $("body").height() - 141, + loading: function(bool) { + if (bool) c.loading.css("left",($(window).width()/2 - 60) + "px").show(); + else c.loading.hide(); + }, + windowResize : function(view){ + view.setHeight($("body").height() - 141); + c.calendar.fullCalendar("refetchEvents"); + }, + viewDisplay: function(view) { + c.title.html(view.title); + }, + eventClick: function(calEvent, e, view) { + c.dialog.dismiss(); + c.dialog.inflate(calEvent); + c.dialog.show({"x":e.originalEvent.clientX,"y":e.originalEvent.clientY}); + } + }); + + c.nextBtn.click(function(){ + c.dialog.dismiss(); + c.calendar.fullCalendar('next'); + }); + c.prevBtn.click(function(){ + c.dialog.dismiss(); + c.calendar.fullCalendar('prev'); + }); + c.todayBtn.click(function(){ + c.dialog.dismiss(); + c.calendar.fullCalendar('today'); + }); + c.modeBtns.click(function(){ + c.dialog.dismiss(); + toggleViews($(this).data("mode")); + }); + c.refreshBtn.click(function(){ + c.dialog.dismiss(); + if(c.currentView == "agenda") + agendaView.refresh(); + else + c.calendar.fullCalendar("refetchEvents"); + }); + + var toggleViews = function(view){ + c.modeBtns.removeClass("active"); + c.modeBtns.each(function(){ + if ($(this).data("mode") == view) + $(this).addClass("active"); + }) + if(view != "agenda"){ + if(c.currentView == "agenda"){ + // $("#sec1").addClass("span3").removeClass("span7"); + $("#sec2").show(); + // $("#sec3").addClass("span4").removeClass("span5"); + agendaView.hide(); + } + c.calendar.fullCalendar('changeView',view); + }else{ + // $("#sec1").addClass("span7").removeClass("span3"); + $("#sec2").hide(); + // $("#sec3").addClass("span5").removeClass("span4"); + agendaView.inflate(); + } + c.currentView = view; + if(loadeventsonviewchange){ + c.calendar.fullCalendar("refetchEvents"); + loadeventsonviewchange = false; + } + } + if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;} + + } + + this.renderEvent = function(eventStick){ + if(eventStick.recurring == true) + c.calendar.fullCalendar("refetchEvents"); + else + c.calendar.fullCalendar("renderEvent",eventStick); + } + + + $(document).ready(function() { + c.initialize(); + }); +} + +var EventDialog = function(calendar,event){ + _t = this; + var event_quick_view = null; + var template = ""; + var _this_event = null; + var month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"]; + this.inflate = function(_event){ + if(!_event) throw new UserException("EventStick can't be null!"); + _this_event = _event; + var start_time = "", + end_time = "", + time_string = null; + + if(_event.allDay) { + start_time = $.fullCalendar.formatDate(_event._start,"MMM dd, yyyy"); + if(_event._end) + end_time = $.fullCalendar.formatDate(_event._end,"MMM dd, yyyy"); + time_string = (_event._start === _event._end || !_event._end ? "

" + start_time + "

" : " " + start_time + " " + end_time + ""); + } else { + var sh = _event._start.getHours() > 12 ? _event._start.getHours() - 12 : _event._start.getHours(), + eh = _event._end.getHours() > 12 ? _event._end.getHours() - 12 : _event._end.getHours(), + sm = _event._start.getMinutes() < 10 ? '0' + _event._start.getMinutes() : _event._start.getMinutes(), + em = _event._end.getMinutes() < 10 ? '0' + _event._end.getMinutes() : _event._end.getMinutes(), + stime = _event._start.getHours() > 12 ? sh + ':' + sm + " PM" : sh + ':' + sm + " AM", + etime = _event._end.getHours() > 12 ? eh + ':' + em + " PM" : eh + ':' + em + " AM", + same = (_event._start.getDate() == _event._end.getDate() && _event._start.getMonth() == _event._end.getMonth() && _event._start.getFullYear() == _event._end.getFullYear()); + start_time = month_names[_event._start.getMonth()] + " " + _event._start.getDate() + ", " + _event._start.getFullYear(); + end_time = month_names[_event._end.getMonth()] + " " + _event._end.getDate() + ", " + _event._end.getFullYear(); + + time_string = (same ? "

" + start_time + "

" + stime + " " + etime : "

" + start_time + "" + stime + "

" + end_time + "" + etime + "

"); + } + event_quick_view = $(''); + template = '