Base progress
This commit is contained in:
@@ -14,7 +14,7 @@ gem 'slim-rails'
|
||||
# in production environments by default.
|
||||
#gem 'active_model_serializers', '~> 0.10.0.rc2' # explicitly outside assets
|
||||
#gem 'active_model_serializers', github: 'rails-api/active_model_serializers' # explicitly outside assets
|
||||
gem 'active_model_serializers', '0.9.3' # explicitly outside assets
|
||||
#gem 'active_model_serializers', '0.9.3' # explicitly outside assets
|
||||
#gem 'jsonapi-serializers', github: 'bterkuile/jsonapi-serializers'
|
||||
gem 'jsonapi-serializers', path: '/home/benjamin/development/rails/components/jsonapi-serializers'
|
||||
group :assets do
|
||||
@@ -36,7 +36,9 @@ group :assets do
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
|
||||
gem 'ember-rails'
|
||||
#gem 'ember-rails'
|
||||
gem 'ember-rails', path: '/home/benjamin/development/rails/components/ember-rails'
|
||||
|
||||
#gem 'ember-source', '~> 1.13.9'
|
||||
#gem 'emblem-rails'
|
||||
gem 'ember-validations-rails'
|
||||
|
||||
+25
-23
@@ -38,6 +38,17 @@ GIT
|
||||
couch_potato (>= 0.2.15)
|
||||
rest-client (>= 1.4.2)
|
||||
|
||||
PATH
|
||||
remote: /home/benjamin/development/rails/components/ember-rails
|
||||
specs:
|
||||
ember-rails (0.19.2)
|
||||
active-model-adapter-source (>= 1.13.0)
|
||||
ember-data-source (>= 1.13.0)
|
||||
ember-handlebars-template (>= 0.1.1, < 1.0)
|
||||
ember-source (>= 1.8.0)
|
||||
jquery-rails (>= 1.0.17)
|
||||
railties (>= 3.1)
|
||||
|
||||
PATH
|
||||
remote: /home/benjamin/development/rails/components/jsonapi-serializers
|
||||
specs:
|
||||
@@ -74,8 +85,6 @@ GEM
|
||||
activemodel (>= 3.0.2, < 5.0)
|
||||
activesupport (>= 3.0.2, < 5.0)
|
||||
active_decorator (0.5.3)
|
||||
active_model_serializers (0.9.3)
|
||||
activemodel (>= 3.2)
|
||||
activejob (4.2.4)
|
||||
activesupport (= 4.2.4)
|
||||
globalid (>= 0.3.0)
|
||||
@@ -189,15 +198,7 @@ GEM
|
||||
ember-handlebars-template (0.4.1)
|
||||
barber (>= 0.9.0)
|
||||
sprockets (>= 3.3, < 3.4)
|
||||
ember-rails (0.19.2)
|
||||
active-model-adapter-source (>= 1.13.0)
|
||||
active_model_serializers
|
||||
ember-data-source (>= 1.13.0)
|
||||
ember-handlebars-template (>= 0.1.1, < 1.0)
|
||||
ember-source (>= 1.8.0)
|
||||
jquery-rails (>= 1.0.17)
|
||||
railties (>= 3.1)
|
||||
ember-source (2.0.0)
|
||||
ember-source (2.0.2)
|
||||
ember-validations-rails (1.0.0)
|
||||
railties
|
||||
erubis (2.7.0)
|
||||
@@ -237,7 +238,7 @@ GEM
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
hashie (3.4.2)
|
||||
hitimes (1.2.2)
|
||||
hitimes (1.2.3)
|
||||
http-cookie (1.0.2)
|
||||
domain_name (~> 0.5)
|
||||
http_parser.rb (0.6.0)
|
||||
@@ -249,7 +250,7 @@ GEM
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (5.0.5)
|
||||
railties (>= 3.2.16)
|
||||
js-routes (1.1.0)
|
||||
js-routes (1.1.2)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (1.8.3)
|
||||
@@ -267,14 +268,15 @@ GEM
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.6.1)
|
||||
mini_magick (4.3.1)
|
||||
mime-types (2.6.2)
|
||||
mimemagic (0.3.0)
|
||||
mini_magick (4.3.3)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.8.0)
|
||||
multi_json (1.11.2)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
naught (1.0.0)
|
||||
naught (1.1.0)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.9.2)
|
||||
@@ -299,11 +301,12 @@ GEM
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
orm_adapter (0.5.0)
|
||||
paperclip (4.2.4)
|
||||
paperclip (4.3.1)
|
||||
activemodel (>= 3.2.0)
|
||||
activesupport (>= 3.2.0)
|
||||
cocaine (~> 0.5.5)
|
||||
mime-types
|
||||
mimemagic (= 0.3.0)
|
||||
pickadate-rails (3.5.6.0)
|
||||
railties (>= 3.1.0)
|
||||
pry (0.10.1)
|
||||
@@ -330,7 +333,7 @@ GEM
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.4)
|
||||
sprockets-rails
|
||||
rails-assets-ember-qunit (0.4.10)
|
||||
rails-assets-ember-qunit (0.4.11)
|
||||
rails-assets-qunit (1.19.0)
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
@@ -409,12 +412,12 @@ GEM
|
||||
railties (>= 3.1, < 5.0)
|
||||
slim (~> 3.0)
|
||||
slop (3.6.0)
|
||||
spring (1.3.6)
|
||||
spring (1.4.0)
|
||||
spring-commands-rspec (1.0.4)
|
||||
spring (>= 0.9.1)
|
||||
sprockets (3.3.4)
|
||||
rack (~> 1.0)
|
||||
sprockets-rails (2.3.2)
|
||||
sprockets-rails (2.3.3)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
@@ -435,7 +438,7 @@ GEM
|
||||
tilt (2.0.1)
|
||||
timers (4.0.4)
|
||||
hitimes
|
||||
tinymce-rails (4.2.4)
|
||||
tinymce-rails (4.2.5)
|
||||
railties (>= 3.1.1)
|
||||
turnip (1.3.1)
|
||||
gherkin (>= 2.5)
|
||||
@@ -472,7 +475,6 @@ DEPENDENCIES
|
||||
ace-rails-ap
|
||||
active_attr
|
||||
active_decorator
|
||||
active_model_serializers (= 0.9.3)
|
||||
airbrussh
|
||||
bourbon
|
||||
cancancan
|
||||
@@ -489,7 +491,7 @@ DEPENDENCIES
|
||||
devise-i18n
|
||||
devise_simply_stored!
|
||||
ember-emblem-template!
|
||||
ember-rails
|
||||
ember-rails!
|
||||
ember-validations-rails
|
||||
factory_girl_rails
|
||||
faye
|
||||
|
||||
@@ -6,6 +6,7 @@ App.ApplicationAdapter = DS.JSONAPIAdapter.extend
|
||||
namespace: 'supplier'
|
||||
pathForType: (type)->
|
||||
type.underscore().pluralize()
|
||||
# Code for createRecord and updateRecord taken from ember data v2.0.0 restadapter
|
||||
createRecord: (store, type, snapshot)->
|
||||
data = {}
|
||||
#var serializer = store.serializerFor(type.modelName);
|
||||
@@ -15,6 +16,12 @@ App.ApplicationAdapter = DS.JSONAPIAdapter.extend
|
||||
serializer.serializeIntoHash data, type, snapshot, includeId: true
|
||||
|
||||
@ajax url, "POST", data: data
|
||||
#debugger
|
||||
#Ember.get(snapshot.record, 'store').serializerFor('creation').serialize(snapshot)
|
||||
#3
|
||||
|
||||
updateRecord: (store, type, snapshot)->
|
||||
data = {}
|
||||
#var serializer = store.serializerFor(type.modelName);
|
||||
serializer = Ember.get(snapshot.record, 'store').serializerFor('creation')
|
||||
id = snapshot.id
|
||||
url = @buildURL(type.modelName, id, snapshot, 'updateRecord')
|
||||
serializer.serializeIntoHash data, type, snapshot, includeId: true
|
||||
@ajax url, "PUT", data: data
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
App.ScheduleView = Ember.Component.extend
|
||||
event_changed: (event)->
|
||||
@get('globals.current_employee').store.findRecord('employee-shift', event.id).then (employee_shift)->
|
||||
if employee_shift = @get('globals.current_employee').store.peekRecord('employee-shift', event.id)
|
||||
return unless event.start and event.end
|
||||
employee_shift.set 'start_from', event.start
|
||||
employee_shift.set 'end_on', event.end
|
||||
employee_shift.save()
|
||||
@@ -13,7 +14,9 @@ App.ScheduleView = Ember.Component.extend
|
||||
save: -> callbacks.save.call(@, employee_shift) if callbacks.save
|
||||
destroy_callback: -> callbacks.destroy.call(@, employee_shift) if callbacks.destroy
|
||||
classNames: ['schedule-view']
|
||||
didInsertElement: ->
|
||||
|
||||
didRender: -> @drawCalendar()
|
||||
drawCalendar: ->
|
||||
placeholder = @$('#schedule-placeholder')
|
||||
events = @get('globals.current_supplier.employee_shifts').filter((employee_shift) -> employee_shift.get('employee.active') ).map( (employee_shift)->employee_shift.get('calendar_event') )
|
||||
editable = !!@get('globals.current_employee.manager')
|
||||
@@ -45,7 +48,7 @@ App.ScheduleView = Ember.Component.extend
|
||||
destroy: (shift)->
|
||||
placeholder.fullCalendar('removeEvents', [event.id])
|
||||
timeFormat: 'H(:mm)'
|
||||
axisFormat: 'H:mm'
|
||||
slotLabelFormat: 'H:mm'
|
||||
lang: moment.locale()
|
||||
if editable
|
||||
fullCalendarOptions.select = (start, end, jsEvent, view) =>
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
td.actions
|
||||
if (can "manage" "tables")
|
||||
a.table-edit{ action 'editTable' table }: span
|
||||
a.table-destroy{ action 'destroyTable' table }: span
|
||||
unless table.list
|
||||
a.table-destroy{ action 'destroyTable' table }: span
|
||||
.form-actions
|
||||
if (can "manage" "tables")
|
||||
a.form-action-new.new-table-button{action "newTable"}= t 'table.new_button'
|
||||
|
||||
@@ -58,16 +58,20 @@ private
|
||||
I18n.locale = params[:locale].presence.try(:to_sym) || Rails.configuration.i18n.default_locale
|
||||
end
|
||||
|
||||
#def _render_with_renderer_json(resource, options)
|
||||
#serializer = build_json_serializer(resource, options)
|
||||
|
||||
#binding.pry
|
||||
#if serializer
|
||||
#super(serializer, options)
|
||||
#else
|
||||
#super
|
||||
#end
|
||||
#end
|
||||
def _render_with_renderer_json(resource, options)
|
||||
return super if resource.is_a?(Hash)
|
||||
options[:serializer] ||= begin
|
||||
if resource.is_a?(SimplyStored::Couch)
|
||||
#infer based on controller path replacing actual controller part with resouce part /lists/:id/table
|
||||
"#{self.class.name.deconstantize}::#{resource.class.name.demodulize}Serializer".constantize
|
||||
else
|
||||
# infer based on controller path
|
||||
"#{controller_path.classify}Serializer".constantize
|
||||
end
|
||||
end
|
||||
options[:is_collection] = params[:id].blank? unless options.has_key?(:is_collection)
|
||||
JSONAPI::Serializer.serialize(resource, options).to_json
|
||||
end
|
||||
|
||||
def layout_by_resource(*args)
|
||||
#if devise_controller?
|
||||
|
||||
@@ -5,25 +5,27 @@ module Suppliers
|
||||
@employee_shifts.include_relations(:employee, :supplier)
|
||||
# Only select shifts from currently linked and employees
|
||||
@employee_shifts.select! do |shift|
|
||||
current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
return false unless current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
|
||||
true
|
||||
end
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shifts, serializer: Suppliers::EmployeeShiftSerializer, is_collection: true, include: %w[employee])
|
||||
render json: @employee_shifts, include: %w[employee]
|
||||
end
|
||||
def create
|
||||
@employee_shift.supplier = current_supplier
|
||||
@employee_shift.save
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer, include: %w[employee])
|
||||
render json: @employee_shift, include: %w[employee]
|
||||
end
|
||||
|
||||
def update
|
||||
@employee_shift.update employee_shift_params
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer)
|
||||
render json: @employee_shift
|
||||
end
|
||||
|
||||
def destroy
|
||||
head :forbidden and return unless @employee_shift.supplier_id == current_supplier.id
|
||||
@employee_shift.destroy
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -8,13 +8,13 @@ module Suppliers
|
||||
# GET /employees.json
|
||||
def index
|
||||
@employees = current_supplier.employees
|
||||
render json: JSONAPI::Serializer.serialize(@employees, serializer: Suppliers::EmployeeSerializer, is_collection: true)
|
||||
render json: @employees
|
||||
end
|
||||
|
||||
# GET /employees/1
|
||||
# GET /employees/1.json
|
||||
def show
|
||||
render json: JSONAPI::Serializer.serialize(@employee, serializer: Suppliers::EmployeeSerializer)
|
||||
render json: @employee
|
||||
end
|
||||
|
||||
# POST /employees
|
||||
@@ -37,7 +37,7 @@ module Suppliers
|
||||
end
|
||||
|
||||
if valid
|
||||
render json: @employee, serializer: Suppliers::EmployeeSerializer, status: :created
|
||||
render json: @employee
|
||||
else
|
||||
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -47,12 +47,10 @@ module Suppliers
|
||||
# PUT /employees/1.json
|
||||
def update
|
||||
#current_supplier.settings_for(@employee).update!(employee_params)
|
||||
respond_to do |format|
|
||||
if @employee.update_attributes(employee_params)
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.json { render json: {errors: @employee.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
if @employee.update_attributes(employee_params)
|
||||
render json: @employee
|
||||
else
|
||||
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,10 +59,7 @@ module Suppliers
|
||||
def destroy
|
||||
head :forbidden and return if @employee == current_employee # do not remove self at the moment
|
||||
current_supplier.remove_employee @employee
|
||||
|
||||
respond_to do |format|
|
||||
format.json { head :no_content }
|
||||
end
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -21,12 +21,12 @@ module Suppliers
|
||||
end
|
||||
@lists.include_relation(:table, :users, orders: {user: nil, product_orders: :product})
|
||||
|
||||
render json: JSONAPI::Serializer.serialize(@lists, serializer: Suppliers::ListSerializer, is_collection: true, include: %w[
|
||||
render json: @lists, include: %w[
|
||||
orders
|
||||
orders.user
|
||||
orders.product_orders
|
||||
users
|
||||
])
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
@@ -52,14 +52,14 @@ module Suppliers
|
||||
@lists = List.for_supplier_created_at current_supplier, @start_time..@end_time
|
||||
@lists.include_relation(:table) # for number
|
||||
|
||||
render json: JSONAPI::Serializer.serialize(@lists, serializer: Suppliers::ListSerializer, is_collection: true, include: %w[table])
|
||||
render json: @lists, include: %w[table]
|
||||
end
|
||||
|
||||
# GET /lists/1
|
||||
# GET /lists/1.json
|
||||
def show
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Suppliers::ListSerializer)
|
||||
render json: @list
|
||||
end
|
||||
|
||||
# GET /lists/1/extra_info
|
||||
@@ -115,26 +115,26 @@ module Suppliers
|
||||
def destroy
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@list.destroy
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
# POST /supplier/lists/1/close
|
||||
def close
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list.close!
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /supplier/lists/1/mark_helped
|
||||
def mark_helped
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list.mark_helped!
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
def remove_needs_payment
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list.remove_needs_payment!
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -8,11 +8,7 @@ module Suppliers
|
||||
else
|
||||
@orders = Order.for_supplier(current_supplier, page: params[:page], per_page: params['per_page'] || 25)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @orders }
|
||||
end
|
||||
render json: @orders
|
||||
end
|
||||
|
||||
def cancel
|
||||
@@ -23,22 +19,21 @@ module Suppliers
|
||||
|
||||
def show
|
||||
@order = current_supplier.find_order(params[:id])
|
||||
respond_to do |format|
|
||||
format.json { render json: @order }
|
||||
end
|
||||
render json: @order
|
||||
end
|
||||
|
||||
# POST /orders/1/mark_in_process
|
||||
def mark_in_process
|
||||
@order = Order.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@order.is_being_processed!
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /orders/1/is_delivered
|
||||
def mark_delivered
|
||||
@order = Order.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@order.is_delivered!
|
||||
render nothing: true
|
||||
head :no_content
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,11 +3,11 @@ module Suppliers
|
||||
prepend_before_action :find_page, only: [:show]
|
||||
def index
|
||||
@pages = Page.all_for_suppliers(locale: params[:locale])
|
||||
render json: JSONAPI::Serializer.serialize(@pages, serializer: Suppliers::PageSerializer, is_collection: true)
|
||||
render json: @pages
|
||||
end
|
||||
|
||||
def show
|
||||
render json: JSONAPI::Serializer.serialize(@page, serializer: Suppliers::PageSerializer)
|
||||
render json: @page
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -106,11 +106,7 @@ module Suppliers
|
||||
def destroy
|
||||
@product_category = ProductCategory.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@product_category.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suppliers_product_categories_url, notice: t('action.destroy.successfull', model: ProductCategory.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /supplier/product_categories/sort
|
||||
|
||||
@@ -54,7 +54,7 @@ module Suppliers
|
||||
#@product_variant = ProductVariant.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@product_variant = ProductVariant.find(params[:id])
|
||||
@product_variant.destroy
|
||||
render json: {}
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -81,11 +81,7 @@ module Suppliers
|
||||
def destroy
|
||||
#@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@product.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suppliers_products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) }
|
||||
format.json { head :ok }
|
||||
end
|
||||
head :no_content
|
||||
end
|
||||
|
||||
def preview_products
|
||||
|
||||
@@ -2,13 +2,13 @@ module Suppliers
|
||||
class SectionAreasController < Suppliers::ApplicationController
|
||||
def index
|
||||
@section_areas = SectionArea.for_supplier(current_supplier)
|
||||
render json: JSONAPI::Serializer.serialize(@section_areas, serializer: Suppliers::SectionAreaSerializer, is_collection: true)
|
||||
render json: @section_areas
|
||||
end
|
||||
|
||||
def create
|
||||
@section_area.supplier = current_supplier
|
||||
if @section_area.save
|
||||
render json: JSONAPI::Serializer.serialize(@section_area, serializer: Suppliers::SectionAreaSerializer)
|
||||
render json: @section_area
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -16,7 +16,7 @@ module Suppliers
|
||||
|
||||
def update
|
||||
if @section_area.update_attributes section_area_params
|
||||
render json: JSONAPI::Serializer.serialize(@section_area, serializer: Suppliers::SectionAreaSerializer)
|
||||
render json: @section_area
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -24,7 +24,7 @@ module Suppliers
|
||||
|
||||
def destroy
|
||||
@section_area.destroy
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,13 +2,13 @@ module Suppliers
|
||||
class SectionElementsController < Suppliers::ApplicationController
|
||||
def index
|
||||
@section_elements = SectionElement.for_supplier(current_supplier)
|
||||
render json: JSONAPI::Serializer.serialize(@section_elements, serializer: Suppliers::SectionElementSerializer, is_collection: true)
|
||||
render json: @section_elements
|
||||
end
|
||||
|
||||
def create
|
||||
@section_element.supplier = current_supplier
|
||||
if @section_element.save
|
||||
render json: JSONAPI::Serializer.serialize(@section_element, serializer: Suppliers::SectionElementSerializer)
|
||||
render json: @section_element
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -16,15 +16,15 @@ module Suppliers
|
||||
|
||||
def update
|
||||
if @section_element.update_attributes section_element_params
|
||||
render json: JSONAPI::Serializer.serialize(@section_element, serializer: Suppliers::SectionElementSerializer)
|
||||
render json: @section_element
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@section_element.destroy()
|
||||
head :ok
|
||||
@section_element.destroy
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -17,7 +17,7 @@ module Suppliers
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
render json: JSONAPI::Serializer.serialize(@sections, serializer: Suppliers::ExtendedSectionSerializer, is_collection: true)
|
||||
render json: @sections
|
||||
end
|
||||
|
||||
# GET /sections/1
|
||||
@@ -25,11 +25,7 @@ module Suppliers
|
||||
def show
|
||||
@section = Section.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@tables = @section.tables_with_active_list_id
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render action: 'tables_view' }# show.html.erb
|
||||
format.json { render json: @section }
|
||||
end
|
||||
render json: @section
|
||||
end
|
||||
|
||||
# GET /sections/new
|
||||
@@ -37,11 +33,7 @@ module Suppliers
|
||||
def new
|
||||
@section = Section.new
|
||||
@section.supplier = current_supplier
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @section }
|
||||
end
|
||||
render json: @section
|
||||
end
|
||||
|
||||
# GET /sections/1/edit
|
||||
@@ -56,7 +48,7 @@ module Suppliers
|
||||
@section.supplier = current_supplier
|
||||
|
||||
if @section.save
|
||||
render json: @section, serializer: Suppliers::SectionSerializer, status: :created
|
||||
render json: @section
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -68,7 +60,7 @@ module Suppliers
|
||||
@section = Section.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
if @section.update_attributes(section_params)
|
||||
head :ok
|
||||
render json: @section
|
||||
else
|
||||
render json: {errors: @section.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -80,7 +72,7 @@ module Suppliers
|
||||
@section = Section.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@section.destroy
|
||||
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# GET /sections/1/manage_tables
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module Suppliers
|
||||
class SuppliersController < Suppliers::ApplicationController
|
||||
def index
|
||||
render json: {}
|
||||
|
||||
end
|
||||
|
||||
@@ -15,7 +16,7 @@ module Suppliers
|
||||
#product_categories.products
|
||||
#product_categories.products.product_variants
|
||||
#]) #.new(current_supplier).as_json
|
||||
render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer, include: %w[
|
||||
render json: current_supplier, include: %w[
|
||||
sections
|
||||
sections.tables
|
||||
sections.section_areas
|
||||
@@ -23,13 +24,13 @@ module Suppliers
|
||||
product_categories
|
||||
product_categories.products
|
||||
product_categories.products.product_variants
|
||||
])
|
||||
]
|
||||
end
|
||||
|
||||
def update
|
||||
@supplier = current_supplier
|
||||
current_supplier.update_attributes(supplier_params)
|
||||
render json: JSONAPI::Serializer.serialize( current_supplier, serializer: Suppliers::SupplierSerializer)
|
||||
render json: current_supplier
|
||||
end
|
||||
|
||||
def switch_to
|
||||
|
||||
@@ -2,7 +2,7 @@ module Suppliers
|
||||
class SvgElementsController < Suppliers::ApplicationController
|
||||
def index
|
||||
@svg_elements = SvgElement.active
|
||||
render json: JSONAPI::Serializer.serialize(@svg_elements, serializer: Suppliers::SvgElementSerializer)
|
||||
render json: @svg_elements
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ module Suppliers
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@table.destroy
|
||||
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
def qr_codes
|
||||
|
||||
@@ -8,12 +8,13 @@ module Users
|
||||
#lists.reject!{|l| l.id == params[:exclude_list]} if params[:exclude_list].present?
|
||||
#lists.reject!{|l| l.id == current_user.active_list_id } if current_user && current_user.active_list_id.present? # see spec Loading lists and switching to the order products view works, lists loading may unlink active list orders
|
||||
lists.include_relation(:users, :supplier)
|
||||
render json: JSONAPI::Serializer.serialize(lists, serializer: Users::ListSerializer, include: %w[supplier users], is_collection: true, meta: {total_pages: lists.total_pages, page: lists.current_page}) #, root: :lists
|
||||
render json: lists, include: %w[supplier users], meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||
end
|
||||
|
||||
#EMBER
|
||||
def current
|
||||
@list = current_user.active_list
|
||||
params[:id] = @list.id # serializer determines collection or not based on the presence of this
|
||||
show
|
||||
end
|
||||
|
||||
@@ -21,13 +22,13 @@ module Users
|
||||
list = List.find(params[:id])
|
||||
render json: {}, status: :not_found and return unless list.present?
|
||||
@table = list.table
|
||||
render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer)
|
||||
render json: @table
|
||||
end
|
||||
|
||||
def show
|
||||
@list ||= List.find(params[:id]) if params[:id]
|
||||
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users join_requests join_requests.user])
|
||||
render json: @list, include: %w[supplier users join_requests join_requests.user]
|
||||
end
|
||||
|
||||
# POST /user/list_needs_payment.json
|
||||
@@ -35,7 +36,7 @@ module Users
|
||||
@list = active_list
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless @list.try(:id).to_s == params[:id]
|
||||
@list.needs_payment!
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer)
|
||||
render json: @list
|
||||
end
|
||||
|
||||
# POST /user/lists/:id/move_table.json?table_id=....
|
||||
@@ -80,7 +81,7 @@ module Users
|
||||
def reject_join_request
|
||||
render js: '' and return unless params[:user_id].present?
|
||||
active_list && active_list.reject_join_request_for_user!(params[:user_id])
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /user/approve_join_request?user_id=1
|
||||
@@ -88,7 +89,7 @@ module Users
|
||||
render js: '' and return unless params[:user_id].present?
|
||||
@user = User.find(params[:user_id])
|
||||
active_list && active_list.approve_join_request_for_user!(@user)
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module Users
|
||||
@list = List.find(params[:list_id])
|
||||
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
|
||||
orders = @list.orders.include_relation(:product_orders)
|
||||
render json: JSONAPI::Serializer.serialize(orders, serializer: Users::OrderSerializer, include: %w[list user product_orders product_orders.order], is_collection: true)
|
||||
render json: orders, include: %w[list user product_orders product_orders.order]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,14 +2,10 @@ module Users
|
||||
class ProductCategoriesController < Users::ApplicationController
|
||||
#EMBER
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {} and return unless params[:table_id].present?
|
||||
table = Table.find(params[:table_id])
|
||||
product_categories = table.supplier.product_categories.include_relation('products') # not yet implemented for many to many
|
||||
render json: product_categories #, serializer: ProductCategorySerializer
|
||||
end
|
||||
end
|
||||
render json: {} and return unless params[:table_id].present?
|
||||
table = Table.find(params[:table_id])
|
||||
product_categories = table.supplier.product_categories.include_relation('products') # not yet implemented for many to many
|
||||
render json: product_categories #, serializer: ProductCategorySerializer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,13 +10,11 @@ module Users
|
||||
table = Table.find(params[:id])
|
||||
supplier = table.supplier
|
||||
supplier.product_categories.include_relations(products: :product_variants)
|
||||
render json: JSONAPI::Serializer.serialize(supplier, serializer: Users::SupplierSerializer, include: %w[
|
||||
render json: supplier, include: %w[
|
||||
product_categories
|
||||
product_categories.products
|
||||
product_categories.supplier
|
||||
product_categories.products.product_variants
|
||||
product_categories.products.product_variants.product
|
||||
])
|
||||
]
|
||||
end
|
||||
|
||||
# POST /tables/:id/needs_help.json
|
||||
@@ -25,7 +23,7 @@ module Users
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless active_list.present?
|
||||
active_list.needs_help!
|
||||
#render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer)
|
||||
render json: {}
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /user/tables/:id/join
|
||||
@@ -35,7 +33,7 @@ module Users
|
||||
if @list = @table.active_list
|
||||
@list.send_table_join_request_for_user! current_user
|
||||
end
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# GET /user/table_info.json
|
||||
@@ -61,15 +59,18 @@ module Users
|
||||
end
|
||||
|
||||
# Used by the user Ember app
|
||||
# NOTE: ordering on a table always creates a new list or failes if the conditions for creating a new
|
||||
# list are not met. To order on an already open list send the request to the lists controller
|
||||
# POST /user/tables/:id/order_products
|
||||
def order_products
|
||||
table = Table.find(params[:id])
|
||||
res = {}
|
||||
res[:active_list_present] = true if active_list.present?
|
||||
res[:occupied] = table.occupied?
|
||||
res[:reserved] = table.reserved?
|
||||
res[:supplier_closed] = table.supplier.closed?
|
||||
res[:no_product_orders] = true unless product_orders = new_order_product_orders.presence
|
||||
unless res[:occupied] or res[:supplier_closed] or res[:no_product_orders]
|
||||
unless res[:occupied] or res[:supplier_closed] or res[:no_product_orders] or res[:active_list_present]
|
||||
# Create new list
|
||||
list = List.from_table( table, current_user )
|
||||
res[:active_list_id] = list.id # used to set the active list in the app
|
||||
|
||||
@@ -8,6 +8,9 @@ class EmployeeShift
|
||||
belongs_to :supplier
|
||||
belongs_to :employee
|
||||
|
||||
validates :start_from, presence: true
|
||||
validates :end_on, presence: true
|
||||
|
||||
view :for_supplier_view, type: :custom, map_function: %|function(doc){
|
||||
if(doc.ruby_class == 'EmployeeShift' && doc.start_from && doc.end_on){
|
||||
emit([doc.supplier_id, doc.end_on], 1)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class ListSerializer < Qwaiter::Serializer
|
||||
# user ids for facebook pictures
|
||||
#embed :ids
|
||||
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_id, :closed_at #, :has_active_orders
|
||||
|
||||
#def has_active_orders
|
||||
#object.has_active_orders?
|
||||
#end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class SectionSerializer < Qwaiter::Serializer
|
||||
attributes :title, :path, :width, :height
|
||||
has_many :tables
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class SupplierTableSerializer < Qwaiter::Serializer
|
||||
self.root = :table
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help
|
||||
has_one :supplier, serializer: Suppliers::SupplierSerializer
|
||||
end
|
||||
@@ -1,17 +0,0 @@
|
||||
class TableSerializer < Qwaiter::Serializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied #, :alist_id
|
||||
|
||||
#def list_id
|
||||
#object.active_list_id || object.active_list.try(:id)
|
||||
#end
|
||||
|
||||
#def list
|
||||
#object.active_list
|
||||
#end
|
||||
|
||||
def list
|
||||
object.active_list
|
||||
end
|
||||
|
||||
has_one :list, key: :active_list_id
|
||||
end
|
||||
@@ -1,34 +0,0 @@
|
||||
#class ListExtendedSerializer
|
||||
#render json: {
|
||||
#list: list.serialized_with_status_join_requests_and_supplier_counters.merge(order_ids: list.orders.map(&:id)),
|
||||
#}
|
||||
#.merge(ActiveModel::ArraySerializer.new(list.supplier.product_categories, each_serializer: ProductCategorySerializer, root: :product_categories).as_json)
|
||||
#.merge(ActiveModel::ArraySerializer.new(list.orders, each_serializer: OrderSerializer, root: :orders).as_json)
|
||||
#end
|
||||
=begin
|
||||
class UserExtendedListSerializer < Qwaiter::Serializer
|
||||
# user ids for facebook pictures
|
||||
self.root = :list
|
||||
attributes :extended_version, :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price,
|
||||
:table_id, :table_number, :section_id, :user_ids, :supplier_id, :closed_at, :cached_supplier_name
|
||||
#:supplier_orders_in_process_count, :supplier_orders_placed_count
|
||||
|
||||
def has_active_orders
|
||||
object.has_active_orders?
|
||||
end
|
||||
|
||||
def cached_supplier_name
|
||||
object.supplier.name
|
||||
end
|
||||
has_many :orders
|
||||
#has_many :product_categories
|
||||
has_one :table, serializer: Users::TableSerializer # this one add a lot of stuff
|
||||
has_many :join_requests, serializer: JoinRequestSerializer
|
||||
has_many :users, serializer: Users::UserSerializer
|
||||
#has_one :supplier # added by other resource
|
||||
|
||||
def extended_version
|
||||
true
|
||||
end
|
||||
end
|
||||
=end
|
||||
@@ -1,10 +0,0 @@
|
||||
class UserExtendedSupplierSerializer < Qwaiter::Serializer
|
||||
self.root = :supplier
|
||||
attributes :extended_version, :open, :name, :orders_in_process_count, :orders_placed_count
|
||||
has_many :product_categories
|
||||
#has_many :products only product in category!!!!!!
|
||||
|
||||
def extended_version
|
||||
true
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class UserExtendedTableSerializer < Qwaiter::Serializer
|
||||
self.root = :table
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :needs_help
|
||||
has_one :supplier, serializer: UserExtendedSupplierSerializer
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
class Waiter::SectionSerializer < Qwaiter::Serializer
|
||||
root 'section'
|
||||
attributes :title, :path, :width, :height
|
||||
class Waiter::SectionSerializer
|
||||
include Qwaiter::WaiterBaseSerializer
|
||||
attributes :title, :width, :height
|
||||
has_many :tables, serializer: Waiter::TableSerializer
|
||||
has_one :supplier, serializer: Waiter::SupplierSerializer
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Waiter::SupplierSerializer < Qwaiter::Serializer
|
||||
root 'supplier'
|
||||
class Waiter::SupplierSerializer
|
||||
include Qwaiter::WaiterBaseSerializer
|
||||
attributes :open, :name, :lat, :lng, :time_zone, :address, :house_number, :house_number_addition, :postal_code, :city, :country,
|
||||
:facebook_promotion_url, :iens_profile, :week_starts_on_monday, :orders_in_process_count, :orders_placed_count
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class Waiter::TableSerializer < Qwaiter::Serializer
|
||||
class Waiter::TableSerializer
|
||||
include Qwaiter::WaiterBaseSerializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help
|
||||
end
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
config.embed = :ids
|
||||
config.embed_in_root = true
|
||||
#config.adapter = :json_api
|
||||
end
|
||||
#ActiveModel::Serializer.setup do |config|
|
||||
#config.embed = :ids
|
||||
#config.embed_in_root = true
|
||||
##config.adapter = :json_api
|
||||
#end
|
||||
#module ActiveModel::SerializerSupport
|
||||
# def read_attribute_for_serialization(attr)
|
||||
# public_send attr
|
||||
# end
|
||||
#end
|
||||
module ActiveModel::SerializerSupport
|
||||
#only because it is used
|
||||
end
|
||||
|
||||
=begin
|
||||
class Qwaiter::JsonAdapter < ActiveModel::Serializer::Adapter::JsonApi
|
||||
|
||||
@@ -7,6 +7,7 @@ module Qwaiter
|
||||
autoload :UserBaseSerializer
|
||||
autoload :SupplierBaseSerializer
|
||||
autoload :EmployeeBaseSerializer
|
||||
autoload :WaiterBaseSerializer
|
||||
autoload :Counter
|
||||
autoload :Broadcaster
|
||||
autoload :Couchbase
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
=begin
|
||||
module Qwaiter
|
||||
class Serializer < ActiveModel::Serializer
|
||||
def self.root=(val)
|
||||
@@ -34,6 +35,7 @@ module Qwaiter
|
||||
end
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
||||
# require 'active_model/array_serializer'
|
||||
# module ActiveModel
|
||||
|
||||
@@ -3,8 +3,8 @@ module Qwaiter::SupplierBaseSerializer
|
||||
include JSONAPI::Serializer
|
||||
included do
|
||||
class_attribute :related_link_for_attributes
|
||||
attribute :created_at
|
||||
attribute :updated_at
|
||||
timestamp_attribute :created_at
|
||||
timestamp_attribute :updated_at
|
||||
end
|
||||
|
||||
def base_url
|
||||
@@ -25,6 +25,7 @@ module Qwaiter::SupplierBaseSerializer
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def relationship_self_link(attribute_name)
|
||||
end
|
||||
|
||||
@@ -35,6 +36,13 @@ module Qwaiter::SupplierBaseSerializer
|
||||
end
|
||||
end
|
||||
|
||||
def timestamp_attribute(attr)
|
||||
attribute attr do
|
||||
return unless timestamp = object.public_send(attr)
|
||||
timestamp.iso8601
|
||||
end
|
||||
end
|
||||
|
||||
def related_link_for(*attributes)
|
||||
self.related_link_for_attributes = attributes
|
||||
end
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
module Qwaiter::WaiterBaseSerializer
|
||||
extend ActiveSupport::Concern
|
||||
include JSONAPI::Serializer
|
||||
included do
|
||||
class_attribute :related_link_for_attributes
|
||||
timestamp_attribute :created_at
|
||||
timestamp_attribute :updated_at
|
||||
end
|
||||
|
||||
def base_url
|
||||
nil
|
||||
end
|
||||
|
||||
def format_name(attribute_name)
|
||||
attribute_name.to_s.dasherize
|
||||
end
|
||||
|
||||
def unformat_name(attribute_name)
|
||||
attribute_name.to_s.underscore
|
||||
end
|
||||
|
||||
#alias_method :default_relationship_related_link, :relationship_related_link
|
||||
def relationship_related_link(attribute_name)
|
||||
#super if related_link_for_attributes.include?(attribute_name)
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def relationship_self_link(attribute_name)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def attributes(*attrs)
|
||||
attrs.each do |attr|
|
||||
attribute attr
|
||||
end
|
||||
end
|
||||
|
||||
def timestamp_attribute(attr)
|
||||
attribute attr do
|
||||
return unless timestamp = object.public_send(attr)
|
||||
timestamp.iso8601
|
||||
end
|
||||
end
|
||||
|
||||
def related_link_for(*attributes)
|
||||
self.related_link_for_attributes = attributes
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,7 @@ step 'there is a confirmed and open supplier' do
|
||||
@supplier_password = 'secret1'
|
||||
@employee_password = @supplier_password
|
||||
@employee = create :employee, email: 'supplier@mozo.bar', password: @supplier_password
|
||||
binding.pry
|
||||
@supplier = build :supplier, open: true
|
||||
@supplier.add_manager @employee
|
||||
@section = create :section, title: 'Room', supplier: @supplier, width: 8, height: 8
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
step "the user is on the active list page" do
|
||||
visit "/user#/active_list"
|
||||
user_visit "active-list"
|
||||
end
|
||||
|
||||
step "the user should see the order in the active list view" do
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "persistance" do
|
||||
let(:db){CouchPotato.database.couchrest_database}
|
||||
let(:db_uri){ File.join(db.host, db.name)}
|
||||
describe "database format" do
|
||||
it "persists with proper ruby class" do
|
||||
employee = create :employee
|
||||
response = Net::HTTP.get URI(File.join(db_uri, employee.id))
|
||||
response.should include %|"ruby_class":"Employee"|
|
||||
response.should_not include %|"id":|
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -21,6 +21,11 @@ module Features
|
||||
submit_form
|
||||
end
|
||||
|
||||
def user_visit(path)
|
||||
#visit File.join("http://localhost:3/")
|
||||
visit File.join("/user#", path)
|
||||
end
|
||||
|
||||
def login_employee_as(email)
|
||||
visit "/employees/sign_in"
|
||||
fill_in "employee_email", with: email
|
||||
|
||||
+169
-77
@@ -1,7 +1,7 @@
|
||||
/*!
|
||||
* FullCalendar v2.2.7 Stylesheet
|
||||
* Docs & License: http://arshaw.com/fullcalendar/
|
||||
* (c) 2013 Adam Shaw
|
||||
* FullCalendar v2.4.0 Stylesheet
|
||||
* Docs & License: http://fullcalendar.io/
|
||||
* (c) 2015 Adam Shaw
|
||||
*/
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ body .fc { /* extra precedence to overcome jqui */
|
||||
|
||||
.fc-unthemed th,
|
||||
.fc-unthemed td,
|
||||
.fc-unthemed hr,
|
||||
.fc-unthemed thead,
|
||||
.fc-unthemed tbody,
|
||||
.fc-unthemed .fc-divider,
|
||||
.fc-unthemed .fc-row,
|
||||
.fc-unthemed .fc-popover {
|
||||
border-color: #ddd;
|
||||
@@ -36,7 +36,7 @@ body .fc { /* extra precedence to overcome jqui */
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.fc-unthemed hr,
|
||||
.fc-unthemed .fc-divider,
|
||||
.fc-unthemed .fc-popover .fc-header {
|
||||
background: #eee;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ body .fc { /* extra precedence to overcome jqui */
|
||||
|
||||
.fc-nonbusiness { /* default look for non-business-hours areas */
|
||||
/* will inherit .fc-bgevent's styles */
|
||||
background: #ccc;
|
||||
background: #d7d7d7;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,32 +72,88 @@ body .fc { /* extra precedence to overcome jqui */
|
||||
|
||||
.fc-icon {
|
||||
display: inline-block;
|
||||
font-size: 2em;
|
||||
line-height: .5em;
|
||||
height: .5em; /* will make the total height 1em */
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
line-height: 1em;
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
|
||||
/* don't allow browser text-selection */
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/*
|
||||
Acceptable font-family overrides for individual icons:
|
||||
"Arial", sans-serif
|
||||
"Times New Roman", serif
|
||||
|
||||
NOTE: use percentage font sizes or else old IE chokes
|
||||
*/
|
||||
|
||||
.fc-icon:after {
|
||||
position: relative;
|
||||
margin: 0 -1em; /* ensures character will be centered, regardless of width */
|
||||
}
|
||||
|
||||
.fc-icon-left-single-arrow:after {
|
||||
content: "\02039";
|
||||
font-weight: bold;
|
||||
font-size: 200%;
|
||||
top: -7%;
|
||||
left: 3%;
|
||||
}
|
||||
|
||||
.fc-icon-right-single-arrow:after {
|
||||
content: "\0203A";
|
||||
font-weight: bold;
|
||||
font-size: 200%;
|
||||
top: -7%;
|
||||
left: -3%;
|
||||
}
|
||||
|
||||
.fc-icon-left-double-arrow:after {
|
||||
content: "\000AB";
|
||||
font-size: 160%;
|
||||
top: -7%;
|
||||
}
|
||||
|
||||
.fc-icon-right-double-arrow:after {
|
||||
content: "\000BB";
|
||||
font-size: 160%;
|
||||
top: -7%;
|
||||
}
|
||||
|
||||
.fc-icon-left-triangle:after {
|
||||
content: "\25C4";
|
||||
font-size: 125%;
|
||||
top: 3%;
|
||||
left: -2%;
|
||||
}
|
||||
|
||||
.fc-icon-right-triangle:after {
|
||||
content: "\25BA";
|
||||
font-size: 125%;
|
||||
top: 3%;
|
||||
left: 2%;
|
||||
}
|
||||
|
||||
.fc-icon-down-triangle:after {
|
||||
content: "\25BC";
|
||||
font-size: 125%;
|
||||
top: 2%;
|
||||
}
|
||||
|
||||
.fc-icon-x:after {
|
||||
content: "\000D7";
|
||||
font-size: 200%;
|
||||
top: 6%;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,8 +198,9 @@ body .fc { /* extra precedence to overcome jqui */
|
||||
|
||||
.fc button .fc-icon { /* non-theme */
|
||||
position: relative;
|
||||
top: .05em; /* seems to be a good adjustment across browsers */
|
||||
margin: 0 .1em;
|
||||
top: -0.05em; /* seems to be a good adjustment across browsers */
|
||||
margin: 0 .2em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -230,7 +287,7 @@ previous button's border...
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,.15);
|
||||
}
|
||||
|
||||
.fc-popover .fc-header {
|
||||
.fc-popover .fc-header { /* TODO: be more consistent with fc-head/fc-body */
|
||||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
@@ -260,8 +317,8 @@ previous button's border...
|
||||
}
|
||||
|
||||
.fc-unthemed .fc-popover .fc-header .fc-close {
|
||||
font-size: 25px;
|
||||
margin-top: 4px;
|
||||
font-size: .9em;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* jqui themed */
|
||||
@@ -274,11 +331,15 @@ previous button's border...
|
||||
/* Misc Reusable Components
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc hr {
|
||||
.fc-divider {
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
hr.fc-divider {
|
||||
height: 0;
|
||||
margin: 0;
|
||||
padding: 0 0 2px; /* height is unreliable across browsers, so use padding */
|
||||
border-style: solid;
|
||||
border-width: 1px 0;
|
||||
}
|
||||
|
||||
@@ -474,6 +535,79 @@ temporary rendered events).
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.fc-event .fc-bg { /* the generic .fc-bg already does position */
|
||||
z-index: 1;
|
||||
background: #fff;
|
||||
opacity: .25;
|
||||
filter: alpha(opacity=25); /* for IE */
|
||||
}
|
||||
|
||||
.fc-event .fc-content {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.fc-event .fc-resizer {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
|
||||
/* Horizontal Events
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* events that are continuing to/from another week. kill rounded corners and butt up against edge */
|
||||
|
||||
.fc-ltr .fc-h-event.fc-not-start,
|
||||
.fc-rtl .fc-h-event.fc-not-end {
|
||||
margin-left: 0;
|
||||
border-left-width: 0;
|
||||
padding-left: 1px; /* replace the border with padding */
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.fc-ltr .fc-h-event.fc-not-end,
|
||||
.fc-rtl .fc-h-event.fc-not-start {
|
||||
margin-right: 0;
|
||||
border-right-width: 0;
|
||||
padding-right: 1px; /* replace the border with padding */
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
/* resizer */
|
||||
|
||||
.fc-h-event .fc-resizer { /* positioned it to overcome the event's borders */
|
||||
top: -1px;
|
||||
bottom: -1px;
|
||||
left: -1px;
|
||||
right: -1px;
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
/* left resizer */
|
||||
.fc-ltr .fc-h-event .fc-start-resizer,
|
||||
.fc-ltr .fc-h-event .fc-start-resizer:before,
|
||||
.fc-ltr .fc-h-event .fc-start-resizer:after,
|
||||
.fc-rtl .fc-h-event .fc-end-resizer,
|
||||
.fc-rtl .fc-h-event .fc-end-resizer:before,
|
||||
.fc-rtl .fc-h-event .fc-end-resizer:after {
|
||||
right: auto; /* ignore the right and only use the left */
|
||||
cursor: w-resize;
|
||||
}
|
||||
|
||||
/* right resizer */
|
||||
.fc-ltr .fc-h-event .fc-end-resizer,
|
||||
.fc-ltr .fc-h-event .fc-end-resizer:before,
|
||||
.fc-ltr .fc-h-event .fc-end-resizer:after,
|
||||
.fc-rtl .fc-h-event .fc-start-resizer,
|
||||
.fc-rtl .fc-h-event .fc-start-resizer:before,
|
||||
.fc-rtl .fc-h-event .fc-start-resizer:after {
|
||||
left: auto; /* ignore the left and only use the right */
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
|
||||
/* DayGrid events
|
||||
----------------------------------------------------------------------------------------------------
|
||||
@@ -486,27 +620,8 @@ be a descendant of the grid when it is being dragged.
|
||||
padding: 0 1px;
|
||||
}
|
||||
|
||||
/* events that are continuing to/from another week. kill rounded corners and butt up against edge */
|
||||
|
||||
.fc-ltr .fc-day-grid-event.fc-not-start,
|
||||
.fc-rtl .fc-day-grid-event.fc-not-end {
|
||||
margin-left: 0;
|
||||
border-left-width: 0;
|
||||
padding-left: 1px; /* replace the border with padding */
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.fc-ltr .fc-day-grid-event.fc-not-end,
|
||||
.fc-rtl .fc-day-grid-event.fc-not-start {
|
||||
margin-right: 0;
|
||||
border-right-width: 0;
|
||||
padding-right: 1px; /* replace the border with padding */
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.fc-day-grid-event > .fc-content { /* force events to be one-line tall */
|
||||
.fc-day-grid-event .fc-content { /* force events to be one-line tall */
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -515,23 +630,10 @@ be a descendant of the grid when it is being dragged.
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* resize handle (outside of fc-content, so can go outside of bounds) */
|
||||
|
||||
.fc-day-grid-event .fc-resizer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
.fc-ltr .fc-day-grid-event .fc-resizer {
|
||||
right: -3px;
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.fc-rtl .fc-day-grid-event .fc-resizer {
|
||||
.fc-day-grid-event .fc-resizer { /* enlarge the default hit area */
|
||||
left: -3px;
|
||||
cursor: w-resize;
|
||||
right: -3px;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
|
||||
@@ -663,7 +765,7 @@ a.fc-more:hover {
|
||||
padding-bottom: 1em; /* ensure a space at bottom of cell for user selecting/clicking */
|
||||
}
|
||||
|
||||
.fc-basic-view tbody .fc-row {
|
||||
.fc-basic-view .fc-body .fc-row {
|
||||
min-height: 4em; /* ensure that all rows are at least this tall */
|
||||
}
|
||||
|
||||
@@ -814,16 +916,16 @@ a.fc-more:hover {
|
||||
/* TimeGrid Slats (lines that run horizontally)
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-slats td {
|
||||
.fc-time-grid .fc-slats td {
|
||||
height: 1.5em;
|
||||
border-bottom: 0; /* each cell is responsible for its top border */
|
||||
}
|
||||
|
||||
.fc-slats .fc-minor td {
|
||||
.fc-time-grid .fc-slats .fc-minor td {
|
||||
border-top-style: dotted;
|
||||
}
|
||||
|
||||
.fc-slats .ui-widget-content { /* for jqui theme */
|
||||
.fc-time-grid .fc-slats .ui-widget-content { /* for jqui theme */
|
||||
background: none; /* see through to fc-bg */
|
||||
}
|
||||
|
||||
@@ -872,13 +974,10 @@ a.fc-more:hover {
|
||||
}
|
||||
|
||||
|
||||
/* TimeGrid Event Styling
|
||||
----------------------------------------------------------------------------------------------------
|
||||
We use the full "fc-time-grid-event" class instead of using descendants because the event won't
|
||||
be a descendant of the grid when it is being dragged.
|
||||
*/
|
||||
/* Generic Vertical Event
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-time-grid-event.fc-not-start { /* events that are continuing from another day */
|
||||
.fc-v-event.fc-not-start { /* events that are continuing from another day */
|
||||
/* replace space made by the top border with padding */
|
||||
border-top-width: 0;
|
||||
padding-top: 1px;
|
||||
@@ -888,7 +987,7 @@ be a descendant of the grid when it is being dragged.
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
|
||||
.fc-time-grid-event.fc-not-end {
|
||||
.fc-v-event.fc-not-end {
|
||||
/* replace space made by the top border with padding */
|
||||
border-bottom-width: 0;
|
||||
padding-bottom: 1px;
|
||||
@@ -898,15 +997,17 @@ be a descendant of the grid when it is being dragged.
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
|
||||
/* TimeGrid Event Styling
|
||||
----------------------------------------------------------------------------------------------------
|
||||
We use the full "fc-time-grid-event" class instead of using descendants because the event won't
|
||||
be a descendant of the grid when it is being dragged.
|
||||
*/
|
||||
|
||||
.fc-time-grid-event {
|
||||
overflow: hidden; /* don't let the bg flow over rounded corners */
|
||||
}
|
||||
|
||||
.fc-time-grid-event > .fc-content { /* contains the time and title, but no bg and resizer */
|
||||
position: relative;
|
||||
z-index: 2; /* above the bg */
|
||||
}
|
||||
|
||||
.fc-time-grid-event .fc-time,
|
||||
.fc-time-grid-event .fc-title {
|
||||
padding: 0 1px;
|
||||
@@ -917,13 +1018,6 @@ be a descendant of the grid when it is being dragged.
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.fc-time-grid-event .fc-bg {
|
||||
z-index: 1;
|
||||
background: #fff;
|
||||
opacity: .25;
|
||||
filter: alpha(opacity=25); /* for IE */
|
||||
}
|
||||
|
||||
/* short mode, where time and title are on the same line */
|
||||
|
||||
.fc-time-grid-event.fc-short .fc-content {
|
||||
@@ -958,8 +1052,6 @@ be a descendant of the grid when it is being dragged.
|
||||
/* resizer */
|
||||
|
||||
.fc-time-grid-event .fc-resizer {
|
||||
position: absolute;
|
||||
z-index: 3; /* above content */
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
|
||||
+2859
-1502
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+202
@@ -0,0 +1,202 @@
|
||||
/*!
|
||||
* FullCalendar v2.4.0 Print Stylesheet
|
||||
* Docs & License: http://fullcalendar.io/
|
||||
* (c) 2015 Adam Shaw
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include this stylesheet on your page to get a more printer-friendly calendar.
|
||||
* When including this stylesheet, use the media='print' attribute of the <link> tag.
|
||||
* Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
|
||||
*/
|
||||
|
||||
.fc {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
|
||||
/* Global Event Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-event {
|
||||
background: #fff !important;
|
||||
color: #000 !important;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
.fc-event .fc-resizer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/* Table & Day-Row Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
th,
|
||||
td,
|
||||
hr,
|
||||
thead,
|
||||
tbody,
|
||||
.fc-row {
|
||||
border-color: #ccc !important;
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
/* kill the overlaid, absolutely-positioned common components */
|
||||
.fc-bg,
|
||||
.fc-bgevent-skeleton,
|
||||
.fc-highlight-skeleton,
|
||||
.fc-helper-skeleton {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* don't force a min-height on rows (for DayGrid) */
|
||||
.fc tbody .fc-row {
|
||||
height: auto !important; /* undo height that JS set in distributeHeight */
|
||||
min-height: 0 !important; /* undo the min-height from each view's specific stylesheet */
|
||||
}
|
||||
|
||||
.fc tbody .fc-row .fc-content-skeleton {
|
||||
position: static; /* undo .fc-rigid */
|
||||
padding-bottom: 0 !important; /* use a more border-friendly method for this... */
|
||||
}
|
||||
|
||||
.fc tbody .fc-row .fc-content-skeleton tbody tr:last-child td { /* only works in newer browsers */
|
||||
padding-bottom: 1em; /* ...gives space within the skeleton. also ensures min height in a way */
|
||||
}
|
||||
|
||||
.fc tbody .fc-row .fc-content-skeleton table {
|
||||
/* provides a min-height for the row, but only effective for IE, which exaggerates this value,
|
||||
making it look more like 3em. for other browers, it will already be this tall */
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
|
||||
/* Undo month-view event limiting. Display all events and hide the "more" links
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-more-cell,
|
||||
.fc-more {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.fc tr.fc-limited {
|
||||
display: table-row !important;
|
||||
}
|
||||
|
||||
.fc td.fc-limited {
|
||||
display: table-cell !important;
|
||||
}
|
||||
|
||||
.fc-popover {
|
||||
display: none; /* never display the "more.." popover in print mode */
|
||||
}
|
||||
|
||||
|
||||
/* TimeGrid Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* undo the min-height 100% trick used to fill the container's height */
|
||||
.fc-time-grid {
|
||||
min-height: 0 !important;
|
||||
}
|
||||
|
||||
/* don't display the side axis at all ("all-day" and time cells) */
|
||||
.fc-agenda-view .fc-axis {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* don't display the horizontal lines */
|
||||
.fc-slats,
|
||||
.fc-time-grid hr { /* this hr is used when height is underused and needs to be filled */
|
||||
display: none !important; /* important overrides inline declaration */
|
||||
}
|
||||
|
||||
/* let the container that holds the events be naturally positioned and create real height */
|
||||
.fc-time-grid .fc-content-skeleton {
|
||||
position: static;
|
||||
}
|
||||
|
||||
/* in case there are no events, we still want some height */
|
||||
.fc-time-grid .fc-content-skeleton table {
|
||||
height: 4em;
|
||||
}
|
||||
|
||||
/* kill the horizontal spacing made by the event container. event margins will be done below */
|
||||
.fc-time-grid .fc-event-container {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
/* TimeGrid *Event* Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* naturally position events, vertically stacking them */
|
||||
.fc-time-grid .fc-event {
|
||||
position: static !important;
|
||||
margin: 3px 2px !important;
|
||||
}
|
||||
|
||||
/* for events that continue to a future day, give the bottom border back */
|
||||
.fc-time-grid .fc-event.fc-not-end {
|
||||
border-bottom-width: 1px !important;
|
||||
}
|
||||
|
||||
/* indicate the event continues via "..." text */
|
||||
.fc-time-grid .fc-event.fc-not-end:after {
|
||||
content: "...";
|
||||
}
|
||||
|
||||
/* for events that are continuations from previous days, give the top border back */
|
||||
.fc-time-grid .fc-event.fc-not-start {
|
||||
border-top-width: 1px !important;
|
||||
}
|
||||
|
||||
/* indicate the event is a continuation via "..." text */
|
||||
.fc-time-grid .fc-event.fc-not-start:before {
|
||||
content: "...";
|
||||
}
|
||||
|
||||
/* time */
|
||||
|
||||
/* undo a previous declaration and let the time text span to a second line */
|
||||
.fc-time-grid .fc-event .fc-time {
|
||||
white-space: normal !important;
|
||||
}
|
||||
|
||||
/* hide the the time that is normally displayed... */
|
||||
.fc-time-grid .fc-event .fc-time span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ...replace it with a more verbose version (includes AM/PM) stored in an html attribute */
|
||||
.fc-time-grid .fc-event .fc-time:after {
|
||||
content: attr(data-full);
|
||||
}
|
||||
|
||||
|
||||
/* Vertical Scroller & Containers
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* kill the scrollbars and allow natural height */
|
||||
.fc-scroller,
|
||||
.fc-day-grid-container, /* these divs might be assigned height, which we need to cleared */
|
||||
.fc-time-grid-container { /* */
|
||||
overflow: visible !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
/* kill the horizontal border/padding used to compensate for scrollbars */
|
||||
.fc-row {
|
||||
border: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
/* Button Controls
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-button-group,
|
||||
.fc button {
|
||||
display: none; /* don't display any button-related controls */
|
||||
}
|
||||
Vendored
+180
@@ -0,0 +1,180 @@
|
||||
/*!
|
||||
* FullCalendar v2.4.0 Google Calendar Plugin
|
||||
* Docs & License: http://fullcalendar.io/
|
||||
* (c) 2015 Adam Shaw
|
||||
*/
|
||||
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([ 'jquery' ], factory);
|
||||
}
|
||||
else if (typeof exports === 'object') { // Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
else {
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function($) {
|
||||
|
||||
|
||||
var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
|
||||
var fc = $.fullCalendar;
|
||||
var applyAll = fc.applyAll;
|
||||
|
||||
|
||||
fc.sourceNormalizers.push(function(sourceOptions) {
|
||||
var googleCalendarId = sourceOptions.googleCalendarId;
|
||||
var url = sourceOptions.url;
|
||||
var match;
|
||||
|
||||
// if the Google Calendar ID hasn't been explicitly defined
|
||||
if (!googleCalendarId && url) {
|
||||
|
||||
// detect if the ID was specified as a single string.
|
||||
// will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
|
||||
if (/^[^\/]+@([^\/\.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
|
||||
googleCalendarId = url;
|
||||
}
|
||||
// try to scrape it out of a V1 or V3 API feed URL
|
||||
else if (
|
||||
(match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^\/]*)/.exec(url)) ||
|
||||
(match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^\/]*)/.exec(url))
|
||||
) {
|
||||
googleCalendarId = decodeURIComponent(match[1]);
|
||||
}
|
||||
|
||||
if (googleCalendarId) {
|
||||
sourceOptions.googleCalendarId = googleCalendarId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (googleCalendarId) { // is this a Google Calendar?
|
||||
|
||||
// make each Google Calendar source uneditable by default
|
||||
if (sourceOptions.editable == null) {
|
||||
sourceOptions.editable = false;
|
||||
}
|
||||
|
||||
// We want removeEventSource to work, but it won't know about the googleCalendarId primitive.
|
||||
// Shoehorn it into the url, which will function as the unique primitive. Won't cause side effects.
|
||||
// This hack is obsolete since 2.2.3, but keep it so this plugin file is compatible with old versions.
|
||||
sourceOptions.url = googleCalendarId;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
fc.sourceFetchers.push(function(sourceOptions, start, end, timezone) {
|
||||
if (sourceOptions.googleCalendarId) {
|
||||
return transformOptions(sourceOptions, start, end, timezone, this); // `this` is the calendar
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function transformOptions(sourceOptions, start, end, timezone, calendar) {
|
||||
var url = API_BASE + '/' + encodeURIComponent(sourceOptions.googleCalendarId) + '/events?callback=?'; // jsonp
|
||||
var apiKey = sourceOptions.googleCalendarApiKey || calendar.options.googleCalendarApiKey;
|
||||
var success = sourceOptions.success;
|
||||
var data;
|
||||
var timezoneArg; // populated when a specific timezone. escaped to Google's liking
|
||||
|
||||
function reportError(message, apiErrorObjs) {
|
||||
var errorObjs = apiErrorObjs || [ { message: message } ]; // to be passed into error handlers
|
||||
|
||||
// call error handlers
|
||||
(sourceOptions.googleCalendarError || $.noop).apply(calendar, errorObjs);
|
||||
(calendar.options.googleCalendarError || $.noop).apply(calendar, errorObjs);
|
||||
|
||||
// print error to debug console
|
||||
fc.warn.apply(null, [ message ].concat(apiErrorObjs || []));
|
||||
}
|
||||
|
||||
if (!apiKey) {
|
||||
reportError("Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/");
|
||||
return {}; // an empty source to use instead. won't fetch anything.
|
||||
}
|
||||
|
||||
// The API expects an ISO8601 datetime with a time and timezone part.
|
||||
// Since the calendar's timezone offset isn't always known, request the date in UTC and pad it by a day on each
|
||||
// side, guaranteeing we will receive all events in the desired range, albeit a superset.
|
||||
// .utc() will set a zone and give it a 00:00:00 time.
|
||||
if (!start.hasZone()) {
|
||||
start = start.clone().utc().add(-1, 'day');
|
||||
}
|
||||
if (!end.hasZone()) {
|
||||
end = end.clone().utc().add(1, 'day');
|
||||
}
|
||||
|
||||
// when sending timezone names to Google, only accepts underscores, not spaces
|
||||
if (timezone && timezone != 'local') {
|
||||
timezoneArg = timezone.replace(' ', '_');
|
||||
}
|
||||
|
||||
data = $.extend({}, sourceOptions.data || {}, {
|
||||
key: apiKey,
|
||||
timeMin: start.format(),
|
||||
timeMax: end.format(),
|
||||
timeZone: timezoneArg,
|
||||
singleEvents: true,
|
||||
maxResults: 9999
|
||||
});
|
||||
|
||||
return $.extend({}, sourceOptions, {
|
||||
googleCalendarId: null, // prevents source-normalizing from happening again
|
||||
url: url,
|
||||
data: data,
|
||||
startParam: false, // `false` omits this parameter. we already included it above
|
||||
endParam: false, // same
|
||||
timezoneParam: false, // same
|
||||
success: function(data) {
|
||||
var events = [];
|
||||
var successArgs;
|
||||
var successRes;
|
||||
|
||||
if (data.error) {
|
||||
reportError('Google Calendar API: ' + data.error.message, data.error.errors);
|
||||
}
|
||||
else if (data.items) {
|
||||
$.each(data.items, function(i, entry) {
|
||||
var url = entry.htmlLink;
|
||||
|
||||
// make the URLs for each event show times in the correct timezone
|
||||
if (timezoneArg) {
|
||||
url = injectQsComponent(url, 'ctz=' + timezoneArg);
|
||||
}
|
||||
|
||||
events.push({
|
||||
id: entry.id,
|
||||
title: entry.summary,
|
||||
start: entry.start.dateTime || entry.start.date, // try timed. will fall back to all-day
|
||||
end: entry.end.dateTime || entry.end.date, // same
|
||||
url: url,
|
||||
location: entry.location,
|
||||
description: entry.description
|
||||
});
|
||||
});
|
||||
|
||||
// call the success handler(s) and allow it to return a new events array
|
||||
successArgs = [ events ].concat(Array.prototype.slice.call(arguments, 1)); // forward other jq args
|
||||
successRes = applyAll(success, this, successArgs);
|
||||
if ($.isArray(successRes)) {
|
||||
return successRes;
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Injects a string like "arg=value" into the querystring of a URL
|
||||
function injectQsComponent(url, component) {
|
||||
// inject it after the querystring but before the fragment
|
||||
return url.replace(/(\?.*?)?(#|$)/, function(whole, qs, hash) {
|
||||
return (qs ? qs + '&' : '?') + component + hash;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
+4
File diff suppressed because one or more lines are too long
+20
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2015 Adam Shaw
|
||||
|
||||
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.
|
||||
Reference in New Issue
Block a user