diff --git a/bookingbug-angular-services-templates.js b/bookingbug-angular-services-templates.js index 1c9efda..4b8db59 100644 --- a/bookingbug-angular-services-templates.js +++ b/bookingbug-angular-services-templates.js @@ -2,6 +2,6 @@ angular.module("BB").run(["$templateCache", function($templateCache) {$templateC $templateCache.put("resource_table_main.html","\n\n \n \n \n \n \n
\n \n \n \n
\n"); $templateCache.put("schedule_cal_main.html","
\n"); $templateCache.put("schedule_edit_form.html","
\n \n\n
\n\n {{ (hasError() && errorMessage(schemaError())) || form.description}}\n
\n"); -$templateCache.put("schedule_edit_main.html","\n \n
\n
\n \n
\n
\n
\n"); +$templateCache.put("schedule_edit_main.html","\n \n
\n
\n \n
\n
\n
\n"); $templateCache.put("schedule_table_main.html","\n\n \n \n \n \n \n
\n \n \n
\n"); $templateCache.put("service_table_main.html","\n\n \n \n \n \n \n
\n
\n \n \n
\n
\n");}]); \ No newline at end of file diff --git a/bookingbug-angular-services.js b/bookingbug-angular-services.js index f1a8134..d1e8db9 100644 --- a/bookingbug-angular-services.js +++ b/bookingbug-angular-services.js @@ -10,8 +10,79 @@ }).call(this); +// $.fullCalendar.Grid.prototype.setElement = function(el) { +// var noEventClick = this.view.opt('noEventClick'); +// var _this = this; + +// this.el = el + +// // attach a handler to the grid's root element. +// this.el.on('mousedown', function(ev) { +// if ( +// (!$(ev.target).is('.fc-event-container *, .fc-more') || noEventClick) && // not an an event element, or "more.." link +// !$(ev.target).closest('.fc-popover').length // not on a popover (like the "more.." events one) +// ) { +// _this.dayMousedown(ev); +// } +// }); + +// // attach event-element-related handlers. in Grid.events +// // same garbage collection note as above. +// this.bindSegHandlers(); + +// this.bindGlobalHandlers(); + +// } + + +// var FC = $.fullCalendar; +// var agendaSelectAcrossWeek +// agendaSelectAcrossWeek = FC.views.agenda['class'].extend({ + +// initialize: function() { +// FC.views.agenda['class'].prototype.initialize.apply(this); +// this.timeGrid.renderSelection = this.renderSelection; +// }, + +// splitRange: function(range) { +// var start = range.start; +// var end = range.end; +// days = moment.duration(end.diff(start)).days() +// return _.map(_.range(days + 1), function(i) { +// day = moment(start).add(i, 'days'); +// return { +// start: day.set({'hour': start.hour(), 'minute': start.minute()}), +// end: moment(day).set({'hour': end.hour(), 'minute': end.minute()}) +// }; +// }) +// }, + +// reportSelection: function(range, ev) { +// _.each(this.splitRange(range), function(r) { +// FC.views.agenda['class'].prototype.reportSelection.apply(this, [r, ev]) +// }, this); +// }, + +// renderSelection: function(range) { +// var ranges = this.view.splitRange(range); +// if (this.view.opt('selectHelper')) { +// _.each(ranges, this.renderRangeHelper, this); +// } +// else { +// segs = _.reduce(ranges, function(s, r) { +// return s.concat(this.rangeToSegs(r)) +// }, [], this); +// this.renderFill('highlight', segs); +// this.view.trigger('selectx', null, range.start, range.end, null); +// } +// } + +// }); + +// $.fullCalendar.views.agendaSelectAcrossWeek = agendaSelectAcrossWeek; + + (function() { - 'use strict'; var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; @@ -69,15 +140,12 @@ }).call(this); (function() { - 'use strict'; - angular.module('BBAdminServices').directive('personTable', ["$log", "ModalForm", "BBModel", function($log, ModalForm, BBModel) { + angular.module('BBAdminServices').directive('personTable', ["AdminCompanyService", "AdminPerson", "$log", "ModalForm", function(AdminCompanyService, AdminPerson, $log, ModalForm) { var controller, link; controller = function($scope) { $scope.fields = ['id', 'name', 'mobile']; $scope.getPeople = function() { - return BBModel.Admin.Person.$query({ - company: $scope.company - }).then(function(people) { + return AdminPerson.query($scope.company).then(function(people) { return $scope.people = people; }); }; @@ -118,7 +186,7 @@ if (scope.company) { return scope.getPeople(); } else { - return BBModel.Admin.Company.$query(attrs).then(function(company) { + return AdminCompanyService.query(attrs).then(function(company) { scope.company = company; return scope.getPeople(); }); @@ -134,8 +202,7 @@ }).call(this); (function() { - 'use strict'; - angular.module('BBAdminServices').directive('resourceTable', ["BBModel", "$log", "ModalForm", function(BBModel, $log, ModalForm) { + angular.module('BBAdminServices').directive('resourceTable', ["AdminCompanyService", "AdminResourceService", "$modal", "$log", "ModalForm", function(AdminCompanyService, AdminResourceService, $modal, $log, ModalForm) { var controller, link; controller = function($scope) { $scope.fields = ['id', 'name']; @@ -144,7 +211,7 @@ params = { company: $scope.company }; - return BBModel.Admin.Resource.$query(params).then(function(resources) { + return AdminResourceService.query(params).then(function(resources) { return $scope.resources = resources; }); }; @@ -188,7 +255,7 @@ if (scope.company) { return scope.getResources(); } else { - return BBModel.Admin.Company.$query(attrs).then(function(company) { + return AdminCompanyService.query(attrs).then(function(company) { scope.company = company; return scope.getResources(); }); @@ -204,7 +271,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdminServices').directive('scheduleCalendar', ["uiCalendarConfig", "ScheduleRules", function(uiCalendarConfig, ScheduleRules) { var controller, link; controller = function($scope, $attrs) { @@ -325,7 +391,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdminServices').directive('scheduleEdit', function() { var link; link = function(scope, element, attrs, ngModel) { @@ -356,8 +421,7 @@ }).call(this); (function() { - 'use strict'; - angular.module('BBAdminServices').directive('scheduleTable', ["BBModel", "$log", "ModalForm", function(BBModel, $log, ModalForm) { + angular.module('BBAdminServices').directive('scheduleTable', ["AdminCompanyService", "AdminScheduleService", "$modal", "$log", "ModalForm", function(AdminCompanyService, AdminScheduleService, $modal, $log, ModalForm) { var controller, link; controller = function($scope) { $scope.fields = ['id', 'name', 'mobile']; @@ -366,7 +430,7 @@ params = { company: $scope.company }; - return BBModel.Admin.Schedule.query(params).then(function(schedules) { + return AdminScheduleService.query(params).then(function(schedules) { return $scope.schedules = schedules; }); }; @@ -401,7 +465,7 @@ if (scope.company) { return scope.getSchedules(); } else { - return BBModel.Admin.Company.query(attrs).then(function(company) { + return AdminCompanyService.query(attrs).then(function(company) { scope.company = company; return scope.getSchedules(); }); @@ -417,7 +481,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdminServices').directive('scheduleWeekdays', ["uiCalendarConfig", "ScheduleRules", function(uiCalendarConfig, ScheduleRules) { var controller, link; controller = function($scope, $attrs) { @@ -535,8 +598,7 @@ }).call(this); (function() { - 'use strict'; - angular.module('BBAdminServices').directive('serviceTable', ["$uibModal", "$log", "ModalForm", "BBModel", function($uibModal, $log, ModalForm, BBModel) { + angular.module('BBAdminServices').directive('serviceTable', ["AdminCompanyService", "AdminServiceService", "$modal", "$log", "ModalForm", function(AdminCompanyService, AdminServiceService, $modal, $log, ModalForm) { var controller, link; controller = function($scope) { $scope.fields = ['id', 'name']; @@ -545,7 +607,7 @@ params = { company: $scope.company }; - return BBModel.Admin.Service.$query(params).then(function(services) { + return AdminServiceService.query(params).then(function(services) { return $scope.services = services; }); }; @@ -588,7 +650,7 @@ if (scope.company) { return scope.getServices(); } else { - return BBModel.Admin.Company.query(attrs).then(function(company) { + return AdminCompanyService.query(attrs).then(function(company) { scope.company = company; return scope.getServices(); }); @@ -613,18 +675,18 @@ * @description * Representation of an Address Object * - * @property {string} address1 First line of the address - * @property {string} address2 Second line of the address - * @property {string} address3 Third line of the address - * @property {string} address4 Fourth line of the address - * @property {string} address5 Fifth line of the address + * @property {string} address1 First line of the address + * @property {string} address2 Second line of the address + * @property {string} address3 Third line of the address + * @property {string} address4 Fourth line of the address + * @property {string} address5 Fifth line of the address * @property {string} postcode The Postcode/Zipcode * @property {string} country The country */ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - angular.module('BB.Models').factory("AdminAddressModel", ["$q", "BBModel", "BaseModel", "AddressModel", function($q, BBModel, BaseModel, AddressModel) { + angular.module('BB.Models').factory("Admin.AddressModel", ["$q", "BBModel", "BaseModel", "AddressModel", function($q, BBModel, BaseModel, AddressModel) { /*** * @ngdoc method @@ -670,7 +732,7 @@ * Representation of an Clinic Object * * @property {string} setTimes Set times for the clinic - * @property {string} setResourcesAndPeople Set resources and people for the clinic + * @property {string} setResourcesAndPeople Set resources and people for the clinic * @property {object} settings Clinic settings * @property {string} resources Clinic resources * @property {integer} resource_ids Clinic resources ids @@ -686,7 +748,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - angular.module('BB.Models').factory("AdminClinicModel", ["$q", "BBModel", "BaseModel", "ClinicModel", function($q, BBModel, BaseModel, ClinicModel) { + angular.module('BB.Models').factory("Admin.ClinicModel", ["$q", "BBModel", "BaseModel", "ClinicModel", function($q, BBModel, BaseModel, ClinicModel) { var Admin_Clinic; return Admin_Clinic = (function(superClass) { extend(Admin_Clinic, superClass); @@ -870,16 +932,48 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - angular.module('BB.Models').factory("AdminPersonModel", ["$q", "AdminPersonService", "BBModel", "BaseModel", "PersonModel", function($q, AdminPersonService, BBModel, BaseModel, PersonModel) { + angular.module('BB.Models').factory("Admin.PersonModel", ["$q", "BBModel", "BaseModel", "PersonModel", "AdminPersonService", function($q, BBModel, BaseModel, PersonModel, AdminPersonService) { var Admin_Person; return Admin_Person = (function(superClass) { extend(Admin_Person, superClass); function Admin_Person(data) { Admin_Person.__super__.constructor.call(this, data); + if (!this.queuing_disabled) { + this.setCurrentCustomer(); + } } + /*** + * @ngdoc method + * @name setCurrentCustomer + * @methodOf BB.Models:AdminPerson + * @description + * Set current customer + * + * @returns {Promise} Returns a promise that rezolve the current customer + */ + + Admin_Person.prototype.setCurrentCustomer = function() { + var defer; + defer = $q.defer(); + if (this.$has('queuer')) { + this.$get('queuer').then((function(_this) { + return function(queuer) { + _this.serving = new BBModel.Admin.Queuer(queuer); + return defer.resolve(_this.serving); + }; + })(this), function(err) { + return defer.reject(err); + }); + } else { + defer.resolve(); + } + return defer.promise; + }; + + /*** * @ngdoc method * @name setAttendance @@ -1110,16 +1204,32 @@ })(this)); }; - Admin_Person.$query = function(params) { - return AdminPersonService.query(params); - }; - Admin_Person.$block = function(company, person, data) { - return AdminPersonService.block(company, person, data); - }; + /*** + * @ngdoc method + * @name query + * @param {Company} company The company model. + * @param {integer=} page Specifies particular page of paginated response. + * @param {integer=} per_page Number of items per page of paginated response. + * @param {string=} filter_by_fields Comma separated list of field, value pairs to filter results by. + * @param {string=} order_by Specifies field to order results by. + * @param {boolean=} order_by_reverse Reverses the ordered results if true. + * @methodOf BB.Models:AdminPerson + * @description + * Gets a filtered collection of people. + * + * @returns {Promise} Returns a promise that resolves to the filtered collection of people. + */ - Admin_Person.$signup = function(user, data) { - return AdminPersonService.signup(user, data); + Admin_Person.query = function(company, page, per_page, filter_by_fields, order_by, order_by_reverse) { + return AdminPersonService.query({ + company: company, + page: page, + per_page: per_page, + filter_by_fields: filter_by_fields, + order_by: order_by, + order_by_reverse: order_by_reverse + }); }; return Admin_Person; @@ -1127,6 +1237,10 @@ })(PersonModel); }]); + angular.module('BB.Models').factory('AdminPerson', ["$injector", function($injector) { + return $injector.get('Admin.PersonModel'); + }]); + }).call(this); (function() { @@ -1150,7 +1264,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - angular.module('BB.Models').factory("AdminResourceModel", ["$q", "AdminResourceService", "BBModel", "BaseModel", "ResourceModel", function($q, AdminResourceService, BBModel, BaseModel, ResourceModel) { + angular.module('BB.Models').factory("Admin.ResourceModel", ["$q", "BBModel", "BaseModel", "ResourceModel", function($q, BBModel, BaseModel, ResourceModel) { var Admin_Resource; return Admin_Resource = (function(superClass) { extend(Admin_Resource, superClass); @@ -1198,14 +1312,6 @@ return this.availability[str] === "Yes"; }; - Admin_Resource.$query = function(params) { - return AdminResourceService.query(params); - }; - - Admin_Resource.$block = function(company, resource, data) { - return block(company, resource, data); - }; - return Admin_Resource; })(ResourceModel); @@ -1232,7 +1338,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - angular.module('BB.Models').factory("AdminScheduleModel", ["$q", "AdminScheduleService", "BBModel", "BaseModel", "ScheduleRules", function($q, AdminScheduleService, BBModel, BaseModel, ScheduleRules) { + angular.module('BB.Models').factory("Admin.ScheduleModel", ["$q", "BBModel", "BaseModel", "ScheduleRules", function($q, BBModel, BaseModel, ScheduleRules) { var Admin_Schedule; return Admin_Schedule = (function(superClass) { extend(Admin_Schedule, superClass); @@ -1263,18 +1369,6 @@ return data; }; - Admin_Schedule.$query = function(params) { - return AdminScheduleService.query(params); - }; - - Admin_Schedule.$delete = function(schedule) { - return AdminScheduleService["delete"](schedule); - }; - - Admin_Schedule.$update = function(schedule) { - return AdminScheduleService.update(schedule); - }; - return Admin_Schedule; })(BaseModel); @@ -1703,7 +1797,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - angular.module('BB.Models').factory("AdminServiceModel", ["$q", "AdminServiceService", "BBModel", "ServiceModel", function($q, AdminServiceService, BBModel, ServiceModel) { + angular.module('BB.Models').factory("Admin.ServiceModel", ["$q", "BBModel", "ServiceModel", function($q, BBModel, ServiceModel) { var Admin_Service; return Admin_Service = (function(superClass) { extend(Admin_Service, superClass); @@ -1712,10 +1806,6 @@ return Admin_Service.__super__.constructor.apply(this, arguments); } - Admin_Service.$query = function(params) { - return AdminServiceService.query(params); - }; - return Admin_Service; })(ServiceModel); @@ -1724,7 +1814,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdmin.Services').factory('AdminAddressService', ["$q", "BBModel", function($q, BBModel) { return { query: function(params) { @@ -1758,7 +1847,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdmin.Services').factory('AdminClinicService', ["$q", "BBModel", "ClinicCollections", "$window", function($q, BBModel, ClinicCollections, $window) { return { query: function(params) { @@ -1863,7 +1951,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdminServices').factory('AdminPersonService', ["$q", "$window", "$rootScope", "halClient", "SlotCollections", "BookingCollections", "BBModel", "LoginService", "$log", function($q, $window, $rootScope, halClient, SlotCollections, BookingCollections, BBModel, LoginService, $log) { return { query: function(params) { @@ -1946,8 +2033,7 @@ }).call(this); (function() { - 'use strict'; - angular.module('BBAdmin.Services').factory('AdminResourceService', ["$q", "UriTemplate", "halClient", "SlotCollections", "BBModel", "BookingCollections", function($q, UriTemplate, halClient, SlotCollections, BBModel, BookingCollections) { + angular.module('BBAdmin.Services').factory('AdminResourceService', ["$q", "UriTemplate", "halClient", "SlotCollections", "BBModel", function($q, UriTemplate, halClient, SlotCollections, BBModel) { return { query: function(params) { var company, defer; @@ -2003,7 +2089,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdmin.Services').factory('AdminScheduleService', ["$q", "BBModel", "ScheduleRules", "BBAssets", function($q, BBModel, ScheduleRules, BBAssets) { return { query: function(params) { @@ -2060,6 +2145,12 @@ }; })(this)); }, + getPeopleScheduleEvents: function(company, start, end) { + return this.getAssetsScheduleEvents(company, start, end); + }, + mapPeopleToScheduleEvents: function(start, end, assets) { + return this.mapAssetsToScheduleEvents(start, end, assets); + }, mapAssetsToScheduleEvents: function(start, end, assets) { var assets_with_schedule; assets_with_schedule = _.filter(assets, function(asset) { @@ -2111,7 +2202,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdmin.Services').factory('AdminServiceService', ["$q", "BBModel", "$log", function($q, BBModel, $log) { return { query: function(params) { @@ -2145,7 +2235,6 @@ }).call(this); (function() { - 'use strict'; angular.module('BBAdminServices').factory("BB.Service.schedule", ["$q", "BBModel", function($q, BBModel) { return { unwrap: function(resource) { diff --git a/bookingbug-angular-services.min.js b/bookingbug-angular-services.min.js index f06bed7..8d13825 100644 --- a/bookingbug-angular-services.min.js +++ b/bookingbug-angular-services.min.js @@ -1,2 +1,2 @@ -(function(){"use strict";angular.module("BBAdminServices",["BB","BBAdmin.Services","BBAdmin.Filters","BBAdmin.Controllers","trNgGrid","ui.calendar"]),angular.module("BBAdminServices").config(["$logProvider",function($logProvider){return $logProvider.debugEnabled(!0)}]),angular.module("BBAdminServicesMockE2E",["BBAdminServices","BBAdminMockE2E"])}).call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;window.Collection.Clinic=function(superClass){function Clinic(){return Clinic.__super__.constructor.apply(this,arguments)}return extend(Clinic,superClass),Clinic.prototype.checkItem=function(item){return Clinic.__super__.checkItem.apply(this,arguments)},Clinic.prototype.matchesParams=function(item){return this.params.start_time&&(this.start_time||(this.start_time=moment(this.params.start_time)),this.start_time.isAfter(item.start_time))?!1:this.params.end_time&&(this.end_time||(this.end_time=moment(this.params.end_time)),this.end_time.isBefore(item.end_time))?!1:this.params.start_date&&(this.start_date||(this.start_date=moment(this.params.start_date)),this.start_date.isAfter(item.start_date))?!1:!this.params.end_date||(this.end_date||(this.end_date=moment(this.params.end_date)),!this.end_date.isBefore(item.end_date))},Clinic}(window.Collection.Base),angular.module("BBAdmin.Services").provider("ClinicCollections",function(){return{$get:function(){return new window.BaseCollections}}})}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("personTable",["$log","ModalForm","BBModel",function($log,ModalForm,BBModel){var controller,link;return controller=function($scope){return $scope.fields=["id","name","mobile"],$scope.getPeople=function(){return BBModel.Admin.Person.$query({company:$scope.company}).then(function(people){return $scope.people=people})},$scope.newPerson=function(){return ModalForm["new"]({company:$scope.company,title:"New Person",new_rel:"new_person",post_rel:"people",success:function(person){return $scope.people.push(person)}})},$scope["delete"]=function(person){return person.$del("self").then(function(){return $scope.people=_.reject($scope.people,person)},function(err){return $log.error("Failed to delete person")})},$scope.edit=function(person){return ModalForm.edit({model:person,title:"Edit Person"})},$scope.schedule=function(person){return person.$get("schedule").then(function(schedule){return ModalForm.edit({model:schedule,title:"Edit Schedule"})})}},link=function(scope,element,attrs){return scope.company?scope.getPeople():BBModel.Admin.Company.$query(attrs).then(function(company){return scope.company=company,scope.getPeople()})},{controller:controller,link:link,templateUrl:"person_table_main.html"}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("resourceTable",["BBModel","$log","ModalForm",function(BBModel,$log,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","name"],$scope.getResources=function(){var params;return params={company:$scope.company},BBModel.Admin.Resource.$query(params).then(function(resources){return $scope.resources=resources})},$scope.newResource=function(){return ModalForm["new"]({company:$scope.company,title:"New Resource",new_rel:"new_resource",post_rel:"resources",size:"lg",success:function(resource){return $scope.resources.push(resource)}})},$scope["delete"]=function(resource){return resource.$del("self").then(function(){return $scope.resources=_.reject($scope.resources,function(p){return p.id===id})},function(err){return $log.error("Failed to delete resource")})},$scope.edit=function(resource){return ModalForm.edit({model:resource,title:"Edit Resource"})},$scope.schedule=function(resource){return resource.$get("schedule").then(function(schedule){return ModalForm.edit({model:schedule,title:"Edit Schedule"})})}},link=function(scope,element,attrs){return scope.company?scope.getResources():BBModel.Admin.Company.$query(attrs).then(function(company){return scope.company=company,scope.getResources()})},{controller:controller,link:link,templateUrl:"resource_table_main.html"}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("scheduleCalendar",["uiCalendarConfig","ScheduleRules",function(uiCalendarConfig,ScheduleRules){var controller,link;return controller=function($scope,$attrs){var options;return $scope.calendarName="scheduleCal",$scope.eventSources=[{events:function(start,end,timezone,callback){return callback($scope.getEvents())}}],$scope.getCalendarEvents=function(start,end){var events;return events=uiCalendarConfig.calendars.scheduleCal.fullCalendar("clientEvents",function(e){return(start.isAfter(e.start)||start.isSame(e.start))&&(end.isBefore(e.end)||end.isSame(e.end))})},options=$scope.setOptions,options||(options={}),$scope.options={calendar:{schedulerLicenseKey:"0598149132-fcs-1443104297",height:options.height||"auto",editable:!1,selectable:!0,defaultView:"agendaWeek",header:{left:"today,prev,next",center:"title",right:"month,agendaWeek"},selectHelper:!1,eventOverlap:!1,lazyFetching:!1,views:{agendaWeek:{duration:{weeks:1},allDaySlot:!1,slotEventOverlap:!1,minTime:options.min_time||"00:00:00",maxTime:options.max_time||"24:00:00"}},select:function(start,end,jsEvent,view){var events;return events=$scope.getCalendarEvents(start,end),events.length>0?$scope.removeRange(start,end):$scope.addRange(start,end)},eventResizeStop:function(event,jsEvent,ui,view){return $scope.addRange(event.start,event.end)},eventDrop:function(event,delta,revertFunc,jsEvent,ui,view){var orig;return event.start.hasTime()?(orig={start:moment(event.start).subtract(delta),end:moment(event.end).subtract(delta)},$scope.removeRange(orig.start,orig.end),$scope.addRange(event.start,event.end)):void 0},eventClick:function(event,jsEvent,view){return $scope.removeRange(event.start,event.end)}}},$scope.render=function(){return uiCalendarConfig.calendars.scheduleCal.fullCalendar("render")}},link=function(scope,element,attrs,ngModel){var scheduleRules;return scheduleRules=function(){return new ScheduleRules(ngModel.$viewValue)},scope.getEvents=function(){return scheduleRules().toEvents()},scope.addRange=function(start,end){return ngModel.$setViewValue(scheduleRules().addRange(start,end)),ngModel.$render()},scope.removeRange=function(start,end){return ngModel.$setViewValue(scheduleRules().removeRange(start,end)),ngModel.$render()},scope.toggleRange=function(start,end){return ngModel.$setViewValue(scheduleRules().toggleRange(start,end)),ngModel.$render()},ngModel.$render=function(){return uiCalendarConfig&&uiCalendarConfig.calendars.scheduleCal?(uiCalendarConfig.calendars.scheduleCal.fullCalendar("refetchEvents"),uiCalendarConfig.calendars.scheduleCal.fullCalendar("unselect")):void 0}},{controller:controller,link:link,templateUrl:"schedule_cal_main.html",require:"ngModel",scope:{render:"=?",setOptions:"=options"}}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("scheduleEdit",function(){var link;return link=function(scope,element,attrs,ngModel){return ngModel.$render=function(){return scope.$$value$$=ngModel.$viewValue},scope.$watch("$$value$$",function(value){return null!=value?ngModel.$setViewValue(value):void 0})},{link:link,templateUrl:"schedule_edit_main.html",require:"ngModel",scope:{options:"="}}}),angular.module("schemaForm").config(["schemaFormProvider","schemaFormDecoratorsProvider","sfPathProvider",function(schemaFormProvider,schemaFormDecoratorsProvider,sfPathProvider){return schemaFormDecoratorsProvider.addMapping("bootstrapDecorator","schedule","schedule_edit_form.html"),schemaFormDecoratorsProvider.createDirective("schedule","schedule_edit_form.html")}])}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("scheduleTable",["BBModel","$log","ModalForm",function(BBModel,$log,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","name","mobile"],$scope.getSchedules=function(){var params;return params={company:$scope.company},BBModel.Admin.Schedule.query(params).then(function(schedules){return $scope.schedules=schedules})},$scope.newSchedule=function(){return ModalForm["new"]({company:$scope.company,title:"New Schedule",new_rel:"new_schedule",post_rel:"schedules",size:"lg",success:function(schedule){return $scope.schedules.push(schedule)}})},$scope["delete"]=function(schedule){return schedule.$del("self").then(function(){return $scope.schedules=_.reject($scope.schedules,schedule)},function(err){return $log.error("Failed to delete schedule")})},$scope.edit=function(schedule){return ModalForm.edit({model:schedule,title:"Edit Schedule",size:"lg"})}},link=function(scope,element,attrs){return scope.company?scope.getSchedules():BBModel.Admin.Company.query(attrs).then(function(company){return scope.company=company,scope.getSchedules()})},{controller:controller,link:link,templateUrl:"schedule_table_main.html"}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("scheduleWeekdays",["uiCalendarConfig","ScheduleRules",function(uiCalendarConfig,ScheduleRules){var controller,link;return controller=function($scope,$attrs){var options;return $scope.calendarName="scheduleWeekdays",$scope.eventSources=[{events:function(start,end,timezone,callback){return callback($scope.getEvents())}}],$scope.getCalendarEvents=function(start,end){var events;return events=uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("clientEvents",function(e){return(start.isAfter(e.start)||start.isSame(e.start))&&(end.isBefore(e.end)||end.isSame(e.end))})},options=$scope.setOptions,options||(options={}),$scope.options={calendar:{schedulerLicenseKey:"0598149132-fcs-1443104297",height:options.height||"auto",editable:!1,selectable:!0,defaultView:"agendaWeek",header:{left:"",center:"title",right:""},selectHelper:!1,eventOverlap:!1,views:{agendaWeek:{duration:{weeks:1},titleFormat:"[]",allDaySlot:!1,columnFormat:"ddd",slotEventOverlap:!1,minTime:options.min_time||"00:00:00",maxTime:options.max_time||"24:00:00"}},select:function(start,end,jsEvent,view){var events;return events=$scope.getCalendarEvents(start,end),events.length>0?$scope.removeRange(start,end):$scope.addRange(start,end)},eventResizeStop:function(event,jsEvent,ui,view){return $scope.addRange(event.start,event.end)},eventDrop:function(event,delta,revertFunc,jsEvent,ui,view){var orig;return event.start.hasTime()?(orig={start:moment(event.start).subtract(delta),end:moment(event.end).subtract(delta)},$scope.removeRange(orig.start,orig.end),$scope.addRange(event.start,event.end)):void 0},eventClick:function(event,jsEvent,view){return $scope.removeRange(event.start,event.end)}}},$scope.render=function(){return uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("render")}},link=function(scope,element,attrs,ngModel){var scheduleRules;return scheduleRules=function(){return new ScheduleRules(ngModel.$viewValue)},scope.getEvents=function(){return scheduleRules().toWeekdayEvents()},scope.addRange=function(start,end){return ngModel.$setViewValue(scheduleRules().addWeekdayRange(start,end)),ngModel.$render()},scope.removeRange=function(start,end){return ngModel.$setViewValue(scheduleRules().removeWeekdayRange(start,end)),ngModel.$render()},ngModel.$render=function(){return uiCalendarConfig&&uiCalendarConfig.calendars.scheduleWeekdays?(uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("refetchEvents"),uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("unselect")):void 0}},{controller:controller,link:link,templateUrl:"schedule_cal_main.html",require:"ngModel",scope:{render:"=?",setOptions:"=options"}}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").directive("serviceTable",["$uibModal","$log","ModalForm","BBModel",function($uibModal,$log,ModalForm,BBModel){var controller,link;return controller=function($scope){return $scope.fields=["id","name"],$scope.getServices=function(){var params;return params={company:$scope.company},BBModel.Admin.Service.$query(params).then(function(services){return $scope.services=services})},$scope.newService=function(){return ModalForm["new"]({company:$scope.company,title:"New Service",new_rel:"new_service",post_rel:"services",success:function(service){return $scope.services.push(service)}})},$scope["delete"]=function(service){return service.$del("self").then(function(){return $scope.services=_.reject($scope.services,service)},function(err){return $log.error("Failed to delete service")})},$scope.edit=function(service){return ModalForm.edit({model:service,title:"Edit Service"})},$scope.newBooking=function(service){return ModalForm.book({model:service,company:$scope.company,title:"New Booking",success:function(booking){return $log.info("Created new booking ",booking)}})}},link=function(scope,element,attrs){return scope.company?scope.getServices():BBModel.Admin.Company.query(attrs).then(function(company){return scope.company=company,scope.getServices()})},{controller:controller,link:link,templateUrl:"service_table_main.html"}}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("AdminAddressModel",["$q","BBModel","BaseModel","AddressModel",function($q,BBModel,BaseModel,AddressModel){var Admin_Address;return Admin_Address=function(superClass){function Admin_Address(){return Admin_Address.__super__.constructor.apply(this,arguments)}return extend(Admin_Address,superClass),Admin_Address.prototype.distanceFrom=function(address,options){var base;return this.dists||(this.dists=[]),(base=this.dists)[address]||(base[address]=Math.round(50*Math.random(),0)),this.dists[address]},Admin_Address}(AddressModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("AdminClinicModel",["$q","BBModel","BaseModel","ClinicModel",function($q,BBModel,BaseModel,ClinicModel){var Admin_Clinic;return Admin_Clinic=function(superClass){function Admin_Clinic(data){var base;Admin_Clinic.__super__.constructor.call(this,data),this.repeat_rule||(this.repeat_rule={}),(base=this.repeat_rule).rules||(base.rules={})}return extend(Admin_Clinic,superClass),Admin_Clinic.prototype.calcRepeatRule=function(){var en,id,ref,ref1,ref2,vals;vals={},vals.name=this.name,vals.start_time=this.start_time.format("HH:mm"),vals.end_time=this.end_time.format("HH:mm"),vals.address_id=this.address_id,vals.resource_ids=[],ref=this.resources;for(id in ref)en=ref[id],en&&vals.resource_ids.push(id);vals.person_ids=[],ref1=this.people;for(id in ref1)en=ref1[id],en&&vals.person_ids.push(id);vals.service_ids=[],ref2=this.services;for(id in ref2)en=ref2[id],en&&vals.service_ids.push(id);return this.repeat_rule.properties=vals,this.repeat_rule},Admin_Clinic.prototype.getPostData=function(){var data,en,id,ref,ref1,ref2;data={},data.name=this.name,data.repeat_rule=this.repeat_rule,data.start_time=this.start_time,data.end_time=this.end_time,data.resource_ids=[],data.update_for_repeat=this.update_for_repeat,ref=this.resources;for(id in ref)en=ref[id],en&&data.resource_ids.push(id);data.person_ids=[],ref1=this.people;for(id in ref1)en=ref1[id],en&&data.person_ids.push(id);data.service_ids=[],ref2=this.services;for(id in ref2)en=ref2[id],en&&data.service_ids.push(id);return this.address&&(data.address_id=this.address.id),this.settings&&(data.settings=this.settings),this.repeat_rule&&this.repeat_rule.rules&&this.repeat_rule.rules.frequency&&(data.repeat_rule=this.calcRepeatRule()),data},Admin_Clinic.prototype.save=function(){return this.person_ids=_.compact(_.map(this.people,function(present,person_id){return present?person_id:void 0})),this.resource_ids=_.compact(_.map(this.resources,function(present,resource_id){return present?resource_id:void 0})),this.service_ids=_.compact(_.map(this.services,function(present,service_id){return present?service_id:void 0})),this.$put("self",{},this).then(function(_this){return function(clinic){return _this.updateModel(clinic),_this.setTimes(),_this.setResourcesAndPeople()}}(this))},Admin_Clinic.prototype.$update=function(data){return data||(data=this),this.$put("self",{},data).then(function(_this){return function(res){return _this.constructor(res)}}(this))},Admin_Clinic}(ClinicModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("AdminPersonModel",["$q","AdminPersonService","BBModel","BaseModel","PersonModel",function($q,AdminPersonService,BBModel,BaseModel,PersonModel){var Admin_Person;return Admin_Person=function(superClass){function Admin_Person(data){Admin_Person.__super__.constructor.call(this,data)}return extend(Admin_Person,superClass),Admin_Person.prototype.setAttendance=function(status){var defer;return defer=$q.defer(),this.$put("attendance",{},{status:status}).then(function(_this){return function(p){return _this.updateModel(p),defer.resolve(_this)}}(this),function(_this){return function(err){return defer.reject(err)}}(this)),defer.promise},Admin_Person.prototype.finishServing=function(){var defer;return defer=$q.defer(),this.$has("finish_serving")?(this.$flush("self"),this.$post("finish_serving").then(function(_this){return function(q){return _this.$get("self").then(function(p){return _this.updateModel(p)}),_this.serving=null,defer.resolve(q)}}(this),function(_this){return function(err){return defer.reject(err)}}(this))):defer.reject("finish_serving link not available"),defer.promise},Admin_Person.prototype.isAvailable=function(start,end){var str;return str=start.format("YYYY-MM-DD")+"-"+end.format("YYYY-MM-DD"),this.availability||(this.availability={}),this.availability[str]?"Yes"===this.availability[str]:(this.availability[str]="-",this.$has("schedule")?this.$get("schedule",{start_date:start.format("YYYY-MM-DD"),end_date:end.format("YYYY-MM-DD")}).then(function(_this){return function(sched){return _this.availability[str]="No",sched&&sched.dates&&sched.dates[start.format("YYYY-MM-DD")]&&"None"!==sched.dates[start.format("YYYY-MM-DD")]?_this.availability[str]="Yes":void 0}}(this)):this.availability[str]="Yes","Yes"===this.availability[str])},Admin_Person.prototype.startServing=function(queuer){var defer,params;return defer=$q.defer(),this.$has("start_serving")?(this.$flush("self"),params={queuer_id:queuer?queuer.id:null},this.$post("start_serving",params).then(function(_this){return function(q){return _this.$get("self").then(function(p){return _this.updateModel(p)}),_this.serving=q,defer.resolve(q)}}(this),function(_this){return function(err){return defer.reject(err)}}(this))):defer.reject("start_serving link not available"),defer.promise},Admin_Person.prototype.getQueuers=function(){var defer;return defer=$q.defer(),this.$has("queuers")?(this.$flush("queuers"),this.$get("queuers").then(function(_this){return function(collection){return collection.$get("queuers").then(function(queuers){var models,q;return models=function(){var i,len,results;for(results=[],i=0,len=queuers.length;len>i;i++)q=queuers[i],results.push(new BBModel.Admin.Queuer(q));return results}(),_this.queuers=models,defer.resolve(models)},function(err){return defer.reject(err)})}}(this),function(_this){return function(err){return defer.reject(err)}}(this))):defer.reject("queuers link not available"),defer.promise},Admin_Person.prototype.getPostData=function(){var data;return data={},data.id=this.id,data.name=this.name,data.extra=this.extra,data.description=this.description,data},Admin_Person.prototype.$update=function(data){return data||(data=this.getPostData()),this.$put("self",{},data).then(function(_this){return function(res){return _this.constructor(res)}}(this))},Admin_Person.$query=function(params){return AdminPersonService.query(params)},Admin_Person.$block=function(company,person,data){return AdminPersonService.block(company,person,data)},Admin_Person.$signup=function(user,data){return AdminPersonService.signup(user,data)},Admin_Person}(PersonModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("AdminResourceModel",["$q","AdminResourceService","BBModel","BaseModel","ResourceModel",function($q,AdminResourceService,BBModel,BaseModel,ResourceModel){var Admin_Resource;return Admin_Resource=function(superClass){function Admin_Resource(){return Admin_Resource.__super__.constructor.apply(this,arguments)}return extend(Admin_Resource,superClass),Admin_Resource.prototype.isAvailable=function(start,end){var str;return str=start.format("YYYY-MM-DD")+"-"+end.format("YYYY-MM-DD"),this.availability||(this.availability={}),this.availability[str]?"Yes"===this.availability[str]:(this.availability[str]="-",this.$has("schedule")?this.$get("schedule",{start_date:start.format("YYYY-MM-DD"),end_date:end.format("YYYY-MM-DD")}).then(function(_this){return function(sched){return _this.availability[str]="No",sched&&sched.dates&&sched.dates[start.format("YYYY-MM-DD")]&&"None"!==sched.dates[start.format("YYYY-MM-DD")]?_this.availability[str]="Yes":void 0}}(this)):this.availability[str]="Yes","Yes"===this.availability[str])},Admin_Resource.$query=function(params){return AdminResourceService.query(params)},Admin_Resource.$block=function(company,resource,data){return block(company,resource,data)},Admin_Resource}(ResourceModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("AdminScheduleModel",["$q","AdminScheduleService","BBModel","BaseModel","ScheduleRules",function($q,AdminScheduleService,BBModel,BaseModel,ScheduleRules){var Admin_Schedule;return Admin_Schedule=function(superClass){function Admin_Schedule(data){Admin_Schedule.__super__.constructor.call(this,data)}return extend(Admin_Schedule,superClass),Admin_Schedule.prototype.getPostData=function(){var data;return data={},data.id=this.id,data.rules=this.rules,data.name=this.name,data.company_id=this.company_id,data.duration=this.duration,data},Admin_Schedule.$query=function(params){return AdminScheduleService.query(params)},Admin_Schedule.$delete=function(schedule){return AdminScheduleService["delete"](schedule)},Admin_Schedule.$update=function(schedule){return AdminScheduleService.update(schedule)},Admin_Schedule}(BaseModel)}])}.call(this),function(){"use strict";var bind=function(fn,me){return function(){return fn.apply(me,arguments)}};angular.module("BB.Models").factory("ScheduleRules",function(){var ScheduleRules;return ScheduleRules=function(){function ScheduleRules(rules){null==rules&&(rules={}),this.removeRangeFromDate=bind(this.removeRangeFromDate,this),this.addRangeToDate=bind(this.addRangeToDate,this),this.rules=rules}return ScheduleRules.prototype.addRange=function(start,end){return this.applyFunctionToDateRange(start,end,"YYYY-MM-DD",this.addRangeToDate)},ScheduleRules.prototype.removeRange=function(start,end){return this.applyFunctionToDateRange(start,end,"YYYY-MM-DD",this.removeRangeFromDate)},ScheduleRules.prototype.addWeekdayRange=function(start,end){return this.applyFunctionToDateRange(start,end,"d",this.addRangeToDate)},ScheduleRules.prototype.removeWeekdayRange=function(start,end){return this.applyFunctionToDateRange(start,end,"d",this.removeRangeFromDate)},ScheduleRules.prototype.addRangeToDate=function(date,range){var ranges;return ranges=this.rules[date]?this.rules[date]:[],this.rules[date]=this.joinRanges(this.insertRange(ranges,range))},ScheduleRules.prototype.removeRangeFromDate=function(date,range){var ranges;return ranges=this.rules[date]?this.rules[date]:[],this.rules[date]=this.joinRanges(this.subtractRange(ranges,range)),""===this.rules[date]?delete this.rules[date]:void 0},ScheduleRules.prototype.applyFunctionToDateRange=function(start,end,format,func){var date,days,end_time,range,results;return days=this.diffInDays(start,end),0===days?(date=start.format(format),range=[start.format("HHmm"),end.format("HHmm")].join("-"),func(date,range)):(end_time=moment(start).endOf("day"),this.applyFunctionToDateRange(start,end_time,format,func),_.each(function(){results=[];for(var j=1;days>=1?days>=j:j>=days;days>=1?j++:j--)results.push(j);return results}.apply(this),function(_this){return function(i){var start_time;return date=moment(start).add(i,"days"),i!==days?(start_time=moment(date).startOf("day"),end_time=moment(date).endOf("day"),_this.applyFunctionToDateRange(start_time,end_time,format,func)):0!==end.hour()||0!==end.minute()?(start_time=moment(end).startOf("day"),_this.applyFunctionToDateRange(start_time,end,format,func)):void 0}}(this))),this.rules},ScheduleRules.prototype.diffInDays=function(start,end){return moment.duration(end.diff(start)).days()},ScheduleRules.prototype.insertRange=function(ranges,range){return ranges.splice(_.sortedIndex(ranges,range),0,range),ranges},ScheduleRules.prototype.subtractRange=function(ranges,range){return _.indexOf(ranges,range,!0)>-1?_.without(ranges,range):_.flatten(_.map(ranges,function(r){return range.slice(0,4)>=r.slice(0,4)&&range.slice(5,9)<=r.slice(5,9)?range.slice(0,4)===r.slice(0,4)?[range.slice(5,9),r.slice(5,9)].join("-"):range.slice(5,9)===r.slice(5,9)?[r.slice(0,4),range.slice(0,4)].join("-"):[[r.slice(0,4),range.slice(0,4)].join("-"),[range.slice(5,9),r.slice(5,9)].join("-")]:r}))},ScheduleRules.prototype.joinRanges=function(ranges){return _.reduce(ranges,function(m,range){return""===m?range:range.slice(0,4)<=m.slice(m.length-4,m.length)?range.slice(5,9)>=m.slice(m.length-4,m.length)?m.slice(0,m.length-4)+range.slice(5,9):m:[m,range].join()},"").split(",")},ScheduleRules.prototype.filterRulesByDates=function(){return _.pick(this.rules,function(value,key){return key.match(/^\d{4}-\d{2}-\d{2}$/)&&"None"!==value})},ScheduleRules.prototype.filterRulesByWeekdays=function(){return _.pick(this.rules,function(value,key){return key.match(/^\d$/)})},ScheduleRules.prototype.formatTime=function(time){return[time.slice(0,2),time.slice(2,4)].join(":")},ScheduleRules.prototype.toEvents=function(d){return d&&"None"!==this.rules[d]?_.map(this.rules[d],function(_this){return function(range){return{start:[d,_this.formatTime(range.split("-")[0])].join("T"),end:[d,_this.formatTime(range.split("-")[1])].join("T")}}}(this)):_.reduce(this.filterRulesByDates(),function(_this){return function(memo,ranges,date){return memo.concat(_.map(ranges,function(range){return{start:[date,_this.formatTime(range.split("-")[0])].join("T"),end:[date,_this.formatTime(range.split("-")[1])].join("T")}}))}}(this),[])},ScheduleRules.prototype.toWeekdayEvents=function(){return _.reduce(this.filterRulesByWeekdays(),function(_this){return function(memo,ranges,day){var date;return date=moment().set("day",day).format("YYYY-MM-DD"),memo.concat(_.map(ranges,function(range){return{start:[date,_this.formatTime(range.split("-")[0])].join("T"),end:[date,_this.formatTime(range.split("-")[1])].join("T")}}))}}(this),[])},ScheduleRules}()})}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("AdminServiceModel",["$q","AdminServiceService","BBModel","ServiceModel",function($q,AdminServiceService,BBModel,ServiceModel){var Admin_Service;return Admin_Service=function(superClass){function Admin_Service(){return Admin_Service.__super__.constructor.apply(this,arguments)}return extend(Admin_Service,superClass),Admin_Service.$query=function(params){return AdminServiceService.query(params)},Admin_Service}(ServiceModel)}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminAddressService",["$q","BBModel",function($q,BBModel){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("addresses").then(function(collection){return collection.$get("addresses").then(function(addresss){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=addresss.length;len>i;i++)s=addresss[i],results.push(new BBModel.Admin.Address(s));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminClinicService",["$q","BBModel","ClinicCollections","$window",function($q,BBModel,ClinicCollections,$window){return{query:function(params){var company,defer,existing;return company=params.company,defer=$q.defer(),params.id?company.$get("clinics",params).then(function(clinic){return clinic=new BBModel.Admin.Clinic(clinic),defer.resolve(clinic)},function(err){return defer.reject(err)}):(existing=ClinicCollections.find(params),existing&&!params.skip_cache?defer.resolve(existing):(params.skip_cache&&(existing&&ClinicCollections["delete"](existing),company.$flush("clinics",params)),company.$get("clinics",params).then(function(collection){return collection.$get("clinics").then(function(clinics){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=clinics.length;len>i;i++)s=clinics[i],results.push(new BBModel.Admin.Clinic(s));return results}(),clinics=new $window.Collection.Clinic(collection,models,params),ClinicCollections.add(clinics),defer.resolve(clinics)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}))),defer.promise},create:function(prms,clinic){var company,deferred;return company=prms.company,deferred=$q.defer(),company.$post("clinics",{},clinic.getPostData()).then(function(_this){return function(clinic){return clinic=new BBModel.Admin.Clinic(clinic),ClinicCollections.checkItems(clinic),deferred.resolve(clinic)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},cancel:function(clinic){var deferred;return deferred=$q.defer(),clinic.$post("cancel",clinic).then(function(_this){return function(clinic){return clinic=new BBModel.Admin.Clinic(clinic),ClinicCollections.deleteItems(clinic),deferred.resolve(clinic)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},update:function(clinic){var deferred;return deferred=$q.defer(),clinic.$put("self",{},clinic.getPostData()).then(function(_this){return function(c){return clinic=new BBModel.Admin.Clinic(c),ClinicCollections.checkItems(clinic),deferred.resolve(clinic)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").factory("AdminPersonService",["$q","$window","$rootScope","halClient","SlotCollections","BookingCollections","BBModel","LoginService","$log",function($q,$window,$rootScope,halClient,SlotCollections,BookingCollections,BBModel,LoginService,$log){ -return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$has("people")?company.$get("people").then(function(collection){return collection.$get("people").then(function(people){var models,p;return models=function(){var i,len,results;for(results=[],i=0,len=people.length;len>i;i++)p=people[i],results.push(new BBModel.Admin.Person(p));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}):($log.warn("company has no people link"),defer.reject("company has no people link")),defer.promise},block:function(company,person,data){var deferred;return deferred=$q.defer(),person.$put("block",{},data).then(function(_this){return function(response){var booking,slot;return response.$href("self").indexOf("bookings")>-1?(booking=new BBModel.Admin.Booking(response),BookingCollections.checkItems(booking),deferred.resolve(booking)):(slot=new BBModel.Admin.Slot(response),SlotCollections.checkItems(slot),deferred.resolve(slot))}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},signup:function(user,data){var defer;return defer=$q.defer(),user.$get("company").then(function(company){var params;return params={},company.$post("people",params,data).then(function(person){return person.$has("administrator")?person.$get("administrator").then(function(user){return LoginService.setLogin(user),defer.resolve(person)}):defer.resolve(person)},function(err){return defer.reject(err)}),defer.promise})}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminResourceService",["$q","UriTemplate","halClient","SlotCollections","BBModel","BookingCollections",function($q,UriTemplate,halClient,SlotCollections,BBModel,BookingCollections){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("resources").then(function(collection){return collection.$get("resources").then(function(resources){var models,r;return models=function(){var i,len,results;for(results=[],i=0,len=resources.length;len>i;i++)r=resources[i],results.push(new BBModel.Admin.Resource(r));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise},block:function(company,resource,data){var deferred;return deferred=$q.defer(),resource.$put("block",{},data).then(function(_this){return function(response){var booking,slot;return response.$href("self").indexOf("bookings")>-1?(booking=new BBModel.Admin.Booking(response),BookingCollections.checkItems(booking),deferred.resolve(booking)):(slot=new BBModel.Admin.Slot(response),SlotCollections.checkItems(slot),deferred.resolve(slot))}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminScheduleService",["$q","BBModel","ScheduleRules","BBAssets",function($q,BBModel,ScheduleRules,BBAssets){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("schedules").then(function(collection){return collection.$get("schedules").then(function(schedules){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=schedules.length;len>i;i++)s=schedules[i],results.push(new BBModel.Admin.Schedule(s));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise},"delete":function(schedule){var deferred;return deferred=$q.defer(),schedule.$del("self").then(function(_this){return function(schedule){return schedule=new BBModel.Admin.Schedule(schedule),deferred.resolve(schedule)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},update:function(schedule){var deferred;return deferred=$q.defer(),schedule.$put("self",{},schedule.getPostData()).then(function(_this){return function(c){return schedule=new BBModel.Admin.Schedule(c),deferred.resolve(schedule)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this))},mapAssetsToScheduleEvents:function(start,end,assets){var assets_with_schedule;return assets_with_schedule=_.filter(assets,function(asset){return asset.$has("schedule")}),_.map(assets_with_schedule,function(asset){var params;return params={start_date:start.format("YYYY-MM-DD"),end_date:end.format("YYYY-MM-DD")},asset.$get("schedule",params).then(function(schedules){var events,rules;return rules=new ScheduleRules(schedules.dates),events=rules.toEvents(),_.each(events,function(e){return e.resourceId=asset.id,e.title=asset.name,e.rendering="background"}),events})})},getAssetsScheduleEvents:function(company,start,end,filtered,requested){var localMethod;return null==filtered&&(filtered=!1),null==requested&&(requested=[]),filtered?$q.all(this.mapAssetsToScheduleEvents(start,end,requested)).then(function(schedules){return _.flatten(schedules)}):(localMethod=this.mapAssetsToScheduleEvents,BBAssets(company).then(function(assets){return $q.all(localMethod(start,end,assets)).then(function(schedules){return _.flatten(schedules)})}))}}}])}.call(this),function(){"use strict";angular.module("BBAdmin.Services").factory("AdminServiceService",["$q","BBModel","$log",function($q,BBModel,$log){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("services").then(function(collection){return collection.$get("services").then(function(services){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=services.length;len>i;i++)s=services[i],results.push(new BBModel.Admin.Service(s));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise}}}])}.call(this),function(){"use strict";angular.module("BBAdminServices").factory("BB.Service.schedule",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Schedule(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.person",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Person(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.people",["$q","BBModel",function($q,BBModel){return{promise:!0,unwrap:function(resource){var deferred;return deferred=$q.defer(),resource.$get("people").then(function(_this){return function(items){var i,j,len,models;for(models=[],j=0,len=items.length;len>j;j++)i=items[j],models.push(new BBModel.Admin.Person(i));return deferred.resolve(models)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}]),angular.module("BBAdminServices").factory("BB.Service.resource",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Resource(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.resources",["$q","BBModel",function($q,BBModel){return{promise:!0,unwrap:function(resource){var deferred;return deferred=$q.defer(),resource.$get("resources").then(function(_this){return function(items){var i,j,len,models;for(models=[],j=0,len=items.length;len>j;j++)i=items[j],models.push(new BBModel.Admin.Resource(i));return deferred.resolve(models)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}]),angular.module("BBAdminServices").factory("BB.Service.service",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Service(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.services",["$q","BBModel",function($q,BBModel){return{promise:!0,unwrap:function(resource){var deferred;return deferred=$q.defer(),resource.$get("services").then(function(_this){return function(items){var i,j,len,models;for(models=[],j=0,len=items.length;len>j;j++)i=items[j],models.push(new BBModel.Admin.Service(i));return deferred.resolve(models)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this); \ No newline at end of file +(function(){"use strict";angular.module("BBAdminServices",["BB","BBAdmin.Services","BBAdmin.Filters","BBAdmin.Controllers","trNgGrid","ui.calendar"]),angular.module("BBAdminServices").config(["$logProvider",function($logProvider){return $logProvider.debugEnabled(!0)}]),angular.module("BBAdminServicesMockE2E",["BBAdminServices","BBAdminMockE2E"])}).call(this),function(){var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;window.Collection.Clinic=function(superClass){function Clinic(){return Clinic.__super__.constructor.apply(this,arguments)}return extend(Clinic,superClass),Clinic.prototype.checkItem=function(item){return Clinic.__super__.checkItem.apply(this,arguments)},Clinic.prototype.matchesParams=function(item){return this.params.start_time&&(this.start_time||(this.start_time=moment(this.params.start_time)),this.start_time.isAfter(item.start_time))?!1:this.params.end_time&&(this.end_time||(this.end_time=moment(this.params.end_time)),this.end_time.isBefore(item.end_time))?!1:this.params.start_date&&(this.start_date||(this.start_date=moment(this.params.start_date)),this.start_date.isAfter(item.start_date))?!1:!this.params.end_date||(this.end_date||(this.end_date=moment(this.params.end_date)),!this.end_date.isBefore(item.end_date))},Clinic}(window.Collection.Base),angular.module("BBAdmin.Services").provider("ClinicCollections",function(){return{$get:function(){return new window.BaseCollections}}})}.call(this),function(){angular.module("BBAdminServices").directive("personTable",["AdminCompanyService","AdminPerson","$log","ModalForm",function(AdminCompanyService,AdminPerson,$log,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","name","mobile"],$scope.getPeople=function(){return AdminPerson.query($scope.company).then(function(people){return $scope.people=people})},$scope.newPerson=function(){return ModalForm["new"]({company:$scope.company,title:"New Person",new_rel:"new_person",post_rel:"people",success:function(person){return $scope.people.push(person)}})},$scope["delete"]=function(person){return person.$del("self").then(function(){return $scope.people=_.reject($scope.people,person)},function(err){return $log.error("Failed to delete person")})},$scope.edit=function(person){return ModalForm.edit({model:person,title:"Edit Person"})},$scope.schedule=function(person){return person.$get("schedule").then(function(schedule){return ModalForm.edit({model:schedule,title:"Edit Schedule"})})}},link=function(scope,element,attrs){return scope.company?scope.getPeople():AdminCompanyService.query(attrs).then(function(company){return scope.company=company,scope.getPeople()})},{controller:controller,link:link,templateUrl:"person_table_main.html"}}])}.call(this),function(){angular.module("BBAdminServices").directive("resourceTable",["AdminCompanyService","AdminResourceService","$modal","$log","ModalForm",function(AdminCompanyService,AdminResourceService,$modal,$log,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","name"],$scope.getResources=function(){var params;return params={company:$scope.company},AdminResourceService.query(params).then(function(resources){return $scope.resources=resources})},$scope.newResource=function(){return ModalForm["new"]({company:$scope.company,title:"New Resource",new_rel:"new_resource",post_rel:"resources",size:"lg",success:function(resource){return $scope.resources.push(resource)}})},$scope["delete"]=function(resource){return resource.$del("self").then(function(){return $scope.resources=_.reject($scope.resources,function(p){return p.id===id})},function(err){return $log.error("Failed to delete resource")})},$scope.edit=function(resource){return ModalForm.edit({model:resource,title:"Edit Resource"})},$scope.schedule=function(resource){return resource.$get("schedule").then(function(schedule){return ModalForm.edit({model:schedule,title:"Edit Schedule"})})}},link=function(scope,element,attrs){return scope.company?scope.getResources():AdminCompanyService.query(attrs).then(function(company){return scope.company=company,scope.getResources()})},{controller:controller,link:link,templateUrl:"resource_table_main.html"}}])}.call(this),function(){angular.module("BBAdminServices").directive("scheduleCalendar",["uiCalendarConfig","ScheduleRules",function(uiCalendarConfig,ScheduleRules){var controller,link;return controller=function($scope,$attrs){var options;return $scope.calendarName="scheduleCal",$scope.eventSources=[{events:function(start,end,timezone,callback){return callback($scope.getEvents())}}],$scope.getCalendarEvents=function(start,end){var events;return events=uiCalendarConfig.calendars.scheduleCal.fullCalendar("clientEvents",function(e){return(start.isAfter(e.start)||start.isSame(e.start))&&(end.isBefore(e.end)||end.isSame(e.end))})},options=$scope.setOptions,options||(options={}),$scope.options={calendar:{schedulerLicenseKey:"0598149132-fcs-1443104297",height:options.height||"auto",editable:!1,selectable:!0,defaultView:"agendaWeek",header:{left:"today,prev,next",center:"title",right:"month,agendaWeek"},selectHelper:!1,eventOverlap:!1,lazyFetching:!1,views:{agendaWeek:{duration:{weeks:1},allDaySlot:!1,slotEventOverlap:!1,minTime:options.min_time||"00:00:00",maxTime:options.max_time||"24:00:00"}},select:function(start,end,jsEvent,view){var events;return events=$scope.getCalendarEvents(start,end),events.length>0?$scope.removeRange(start,end):$scope.addRange(start,end)},eventResizeStop:function(event,jsEvent,ui,view){return $scope.addRange(event.start,event.end)},eventDrop:function(event,delta,revertFunc,jsEvent,ui,view){var orig;return event.start.hasTime()?(orig={start:moment(event.start).subtract(delta),end:moment(event.end).subtract(delta)},$scope.removeRange(orig.start,orig.end),$scope.addRange(event.start,event.end)):void 0},eventClick:function(event,jsEvent,view){return $scope.removeRange(event.start,event.end)}}},$scope.render=function(){return uiCalendarConfig.calendars.scheduleCal.fullCalendar("render")}},link=function(scope,element,attrs,ngModel){var scheduleRules;return scheduleRules=function(){return new ScheduleRules(ngModel.$viewValue)},scope.getEvents=function(){return scheduleRules().toEvents()},scope.addRange=function(start,end){return ngModel.$setViewValue(scheduleRules().addRange(start,end)),ngModel.$render()},scope.removeRange=function(start,end){return ngModel.$setViewValue(scheduleRules().removeRange(start,end)),ngModel.$render()},scope.toggleRange=function(start,end){return ngModel.$setViewValue(scheduleRules().toggleRange(start,end)),ngModel.$render()},ngModel.$render=function(){return uiCalendarConfig&&uiCalendarConfig.calendars.scheduleCal?(uiCalendarConfig.calendars.scheduleCal.fullCalendar("refetchEvents"),uiCalendarConfig.calendars.scheduleCal.fullCalendar("unselect")):void 0}},{controller:controller,link:link,templateUrl:"schedule_cal_main.html",require:"ngModel",scope:{render:"=?",setOptions:"=options"}}}])}.call(this),function(){angular.module("BBAdminServices").directive("scheduleEdit",function(){var link;return link=function(scope,element,attrs,ngModel){return ngModel.$render=function(){return scope.$$value$$=ngModel.$viewValue},scope.$watch("$$value$$",function(value){return null!=value?ngModel.$setViewValue(value):void 0})},{link:link,templateUrl:"schedule_edit_main.html",require:"ngModel",scope:{options:"="}}}),angular.module("schemaForm").config(["schemaFormProvider","schemaFormDecoratorsProvider","sfPathProvider",function(schemaFormProvider,schemaFormDecoratorsProvider,sfPathProvider){return schemaFormDecoratorsProvider.addMapping("bootstrapDecorator","schedule","schedule_edit_form.html"),schemaFormDecoratorsProvider.createDirective("schedule","schedule_edit_form.html")}])}.call(this),function(){angular.module("BBAdminServices").directive("scheduleTable",["AdminCompanyService","AdminScheduleService","$modal","$log","ModalForm",function(AdminCompanyService,AdminScheduleService,$modal,$log,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","name","mobile"],$scope.getSchedules=function(){var params;return params={company:$scope.company},AdminScheduleService.query(params).then(function(schedules){return $scope.schedules=schedules})},$scope.newSchedule=function(){return ModalForm["new"]({company:$scope.company,title:"New Schedule",new_rel:"new_schedule",post_rel:"schedules",size:"lg",success:function(schedule){return $scope.schedules.push(schedule)}})},$scope["delete"]=function(schedule){return schedule.$del("self").then(function(){return $scope.schedules=_.reject($scope.schedules,schedule)},function(err){return $log.error("Failed to delete schedule")})},$scope.edit=function(schedule){return ModalForm.edit({model:schedule,title:"Edit Schedule",size:"lg"})}},link=function(scope,element,attrs){return scope.company?scope.getSchedules():AdminCompanyService.query(attrs).then(function(company){return scope.company=company,scope.getSchedules()})},{controller:controller,link:link,templateUrl:"schedule_table_main.html"}}])}.call(this),function(){angular.module("BBAdminServices").directive("scheduleWeekdays",["uiCalendarConfig","ScheduleRules",function(uiCalendarConfig,ScheduleRules){var controller,link;return controller=function($scope,$attrs){var options;return $scope.calendarName="scheduleWeekdays",$scope.eventSources=[{events:function(start,end,timezone,callback){return callback($scope.getEvents())}}],$scope.getCalendarEvents=function(start,end){var events;return events=uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("clientEvents",function(e){return(start.isAfter(e.start)||start.isSame(e.start))&&(end.isBefore(e.end)||end.isSame(e.end))})},options=$scope.setOptions,options||(options={}),$scope.options={calendar:{schedulerLicenseKey:"0598149132-fcs-1443104297",height:options.height||"auto",editable:!1,selectable:!0,defaultView:"agendaWeek",header:{left:"",center:"title",right:""},selectHelper:!1,eventOverlap:!1,views:{agendaWeek:{duration:{weeks:1},titleFormat:"[]",allDaySlot:!1,columnFormat:"ddd",slotEventOverlap:!1,minTime:options.min_time||"00:00:00",maxTime:options.max_time||"24:00:00"}},select:function(start,end,jsEvent,view){var events;return events=$scope.getCalendarEvents(start,end),events.length>0?$scope.removeRange(start,end):$scope.addRange(start,end)},eventResizeStop:function(event,jsEvent,ui,view){return $scope.addRange(event.start,event.end)},eventDrop:function(event,delta,revertFunc,jsEvent,ui,view){var orig;return event.start.hasTime()?(orig={start:moment(event.start).subtract(delta),end:moment(event.end).subtract(delta)},$scope.removeRange(orig.start,orig.end),$scope.addRange(event.start,event.end)):void 0},eventClick:function(event,jsEvent,view){return $scope.removeRange(event.start,event.end)}}},$scope.render=function(){return uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("render")}},link=function(scope,element,attrs,ngModel){var scheduleRules;return scheduleRules=function(){return new ScheduleRules(ngModel.$viewValue)},scope.getEvents=function(){return scheduleRules().toWeekdayEvents()},scope.addRange=function(start,end){return ngModel.$setViewValue(scheduleRules().addWeekdayRange(start,end)),ngModel.$render()},scope.removeRange=function(start,end){return ngModel.$setViewValue(scheduleRules().removeWeekdayRange(start,end)),ngModel.$render()},ngModel.$render=function(){return uiCalendarConfig&&uiCalendarConfig.calendars.scheduleWeekdays?(uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("refetchEvents"),uiCalendarConfig.calendars.scheduleWeekdays.fullCalendar("unselect")):void 0}},{controller:controller,link:link,templateUrl:"schedule_cal_main.html",require:"ngModel",scope:{render:"=?",setOptions:"=options"}}}])}.call(this),function(){angular.module("BBAdminServices").directive("serviceTable",["AdminCompanyService","AdminServiceService","$modal","$log","ModalForm",function(AdminCompanyService,AdminServiceService,$modal,$log,ModalForm){var controller,link;return controller=function($scope){return $scope.fields=["id","name"],$scope.getServices=function(){var params;return params={company:$scope.company},AdminServiceService.query(params).then(function(services){return $scope.services=services})},$scope.newService=function(){return ModalForm["new"]({company:$scope.company,title:"New Service",new_rel:"new_service",post_rel:"services",success:function(service){return $scope.services.push(service)}})},$scope["delete"]=function(service){return service.$del("self").then(function(){return $scope.services=_.reject($scope.services,service)},function(err){return $log.error("Failed to delete service")})},$scope.edit=function(service){return ModalForm.edit({model:service,title:"Edit Service"})},$scope.newBooking=function(service){return ModalForm.book({model:service,company:$scope.company,title:"New Booking",success:function(booking){return $log.info("Created new booking ",booking)}})}},link=function(scope,element,attrs){return scope.company?scope.getServices():AdminCompanyService.query(attrs).then(function(company){return scope.company=company,scope.getServices()})},{controller:controller,link:link,templateUrl:"service_table_main.html"}}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Admin.AddressModel",["$q","BBModel","BaseModel","AddressModel",function($q,BBModel,BaseModel,AddressModel){var Admin_Address;return Admin_Address=function(superClass){function Admin_Address(){return Admin_Address.__super__.constructor.apply(this,arguments)}return extend(Admin_Address,superClass),Admin_Address.prototype.distanceFrom=function(address,options){var base;return this.dists||(this.dists=[]),(base=this.dists)[address]||(base[address]=Math.round(50*Math.random(),0)),this.dists[address]},Admin_Address}(AddressModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Admin.ClinicModel",["$q","BBModel","BaseModel","ClinicModel",function($q,BBModel,BaseModel,ClinicModel){var Admin_Clinic;return Admin_Clinic=function(superClass){function Admin_Clinic(data){var base;Admin_Clinic.__super__.constructor.call(this,data),this.repeat_rule||(this.repeat_rule={}),(base=this.repeat_rule).rules||(base.rules={})}return extend(Admin_Clinic,superClass),Admin_Clinic.prototype.calcRepeatRule=function(){var en,id,ref,ref1,ref2,vals;vals={},vals.name=this.name,vals.start_time=this.start_time.format("HH:mm"),vals.end_time=this.end_time.format("HH:mm"),vals.address_id=this.address_id,vals.resource_ids=[],ref=this.resources;for(id in ref)en=ref[id],en&&vals.resource_ids.push(id);vals.person_ids=[],ref1=this.people;for(id in ref1)en=ref1[id],en&&vals.person_ids.push(id);vals.service_ids=[],ref2=this.services;for(id in ref2)en=ref2[id],en&&vals.service_ids.push(id);return this.repeat_rule.properties=vals,this.repeat_rule},Admin_Clinic.prototype.getPostData=function(){var data,en,id,ref,ref1,ref2;data={},data.name=this.name,data.repeat_rule=this.repeat_rule,data.start_time=this.start_time,data.end_time=this.end_time,data.resource_ids=[],data.update_for_repeat=this.update_for_repeat,ref=this.resources;for(id in ref)en=ref[id],en&&data.resource_ids.push(id);data.person_ids=[],ref1=this.people;for(id in ref1)en=ref1[id],en&&data.person_ids.push(id);data.service_ids=[],ref2=this.services;for(id in ref2)en=ref2[id],en&&data.service_ids.push(id);return this.address&&(data.address_id=this.address.id),this.settings&&(data.settings=this.settings),this.repeat_rule&&this.repeat_rule.rules&&this.repeat_rule.rules.frequency&&(data.repeat_rule=this.calcRepeatRule()),data},Admin_Clinic.prototype.save=function(){return this.person_ids=_.compact(_.map(this.people,function(present,person_id){return present?person_id:void 0})),this.resource_ids=_.compact(_.map(this.resources,function(present,resource_id){return present?resource_id:void 0})),this.service_ids=_.compact(_.map(this.services,function(present,service_id){return present?service_id:void 0})),this.$put("self",{},this).then(function(_this){return function(clinic){return _this.updateModel(clinic),_this.setTimes(),_this.setResourcesAndPeople()}}(this))},Admin_Clinic.prototype.$update=function(data){return data||(data=this),this.$put("self",{},data).then(function(_this){return function(res){return _this.constructor(res)}}(this))},Admin_Clinic}(ClinicModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Admin.PersonModel",["$q","BBModel","BaseModel","PersonModel","AdminPersonService",function($q,BBModel,BaseModel,PersonModel,AdminPersonService){var Admin_Person;return Admin_Person=function(superClass){function Admin_Person(data){Admin_Person.__super__.constructor.call(this,data),this.queuing_disabled||this.setCurrentCustomer()}return extend(Admin_Person,superClass),Admin_Person.prototype.setCurrentCustomer=function(){var defer;return defer=$q.defer(),this.$has("queuer")?this.$get("queuer").then(function(_this){return function(queuer){return _this.serving=new BBModel.Admin.Queuer(queuer),defer.resolve(_this.serving)}}(this),function(err){return defer.reject(err)}):defer.resolve(),defer.promise},Admin_Person.prototype.setAttendance=function(status){var defer;return defer=$q.defer(),this.$put("attendance",{},{status:status}).then(function(_this){return function(p){return _this.updateModel(p),defer.resolve(_this)}}(this),function(_this){return function(err){return defer.reject(err)}}(this)),defer.promise},Admin_Person.prototype.finishServing=function(){var defer;return defer=$q.defer(),this.$has("finish_serving")?(this.$flush("self"),this.$post("finish_serving").then(function(_this){return function(q){return _this.$get("self").then(function(p){return _this.updateModel(p)}),_this.serving=null,defer.resolve(q)}}(this),function(_this){return function(err){return defer.reject(err)}}(this))):defer.reject("finish_serving link not available"),defer.promise},Admin_Person.prototype.isAvailable=function(start,end){var str;return str=start.format("YYYY-MM-DD")+"-"+end.format("YYYY-MM-DD"),this.availability||(this.availability={}),this.availability[str]?"Yes"===this.availability[str]:(this.availability[str]="-",this.$has("schedule")?this.$get("schedule",{start_date:start.format("YYYY-MM-DD"),end_date:end.format("YYYY-MM-DD")}).then(function(_this){return function(sched){return _this.availability[str]="No",sched&&sched.dates&&sched.dates[start.format("YYYY-MM-DD")]&&"None"!==sched.dates[start.format("YYYY-MM-DD")]?_this.availability[str]="Yes":void 0}}(this)):this.availability[str]="Yes","Yes"===this.availability[str])},Admin_Person.prototype.startServing=function(queuer){var defer,params;return defer=$q.defer(),this.$has("start_serving")?(this.$flush("self"),params={queuer_id:queuer?queuer.id:null},this.$post("start_serving",params).then(function(_this){return function(q){return _this.$get("self").then(function(p){return _this.updateModel(p)}),_this.serving=q,defer.resolve(q)}}(this),function(_this){return function(err){return defer.reject(err)}}(this))):defer.reject("start_serving link not available"),defer.promise},Admin_Person.prototype.getQueuers=function(){var defer;return defer=$q.defer(),this.$has("queuers")?(this.$flush("queuers"),this.$get("queuers").then(function(_this){return function(collection){return collection.$get("queuers").then(function(queuers){var models,q;return models=function(){var i,len,results;for(results=[],i=0,len=queuers.length;len>i;i++)q=queuers[i],results.push(new BBModel.Admin.Queuer(q));return results}(),_this.queuers=models,defer.resolve(models)},function(err){return defer.reject(err)})}}(this),function(_this){return function(err){return defer.reject(err)}}(this))):defer.reject("queuers link not available"),defer.promise},Admin_Person.prototype.getPostData=function(){var data;return data={},data.id=this.id,data.name=this.name,data.extra=this.extra,data.description=this.description,data},Admin_Person.prototype.$update=function(data){return data||(data=this.getPostData()),this.$put("self",{},data).then(function(_this){return function(res){return _this.constructor(res)}}(this))},Admin_Person.query=function(company,page,per_page,filter_by_fields,order_by,order_by_reverse){return AdminPersonService.query({company:company,page:page,per_page:per_page,filter_by_fields:filter_by_fields,order_by:order_by,order_by_reverse:order_by_reverse})},Admin_Person}(PersonModel)}]),angular.module("BB.Models").factory("AdminPerson",["$injector",function($injector){return $injector.get("Admin.PersonModel")}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Admin.ResourceModel",["$q","BBModel","BaseModel","ResourceModel",function($q,BBModel,BaseModel,ResourceModel){var Admin_Resource;return Admin_Resource=function(superClass){function Admin_Resource(){return Admin_Resource.__super__.constructor.apply(this,arguments)}return extend(Admin_Resource,superClass),Admin_Resource.prototype.isAvailable=function(start,end){var str;return str=start.format("YYYY-MM-DD")+"-"+end.format("YYYY-MM-DD"),this.availability||(this.availability={}),this.availability[str]?"Yes"===this.availability[str]:(this.availability[str]="-",this.$has("schedule")?this.$get("schedule",{start_date:start.format("YYYY-MM-DD"),end_date:end.format("YYYY-MM-DD")}).then(function(_this){return function(sched){return _this.availability[str]="No",sched&&sched.dates&&sched.dates[start.format("YYYY-MM-DD")]&&"None"!==sched.dates[start.format("YYYY-MM-DD")]?_this.availability[str]="Yes":void 0}}(this)):this.availability[str]="Yes","Yes"===this.availability[str])},Admin_Resource}(ResourceModel)}])}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Admin.ScheduleModel",["$q","BBModel","BaseModel","ScheduleRules",function($q,BBModel,BaseModel,ScheduleRules){var Admin_Schedule;return Admin_Schedule=function(superClass){function Admin_Schedule(data){Admin_Schedule.__super__.constructor.call(this,data)}return extend(Admin_Schedule,superClass),Admin_Schedule.prototype.getPostData=function(){var data;return data={},data.id=this.id,data.rules=this.rules,data.name=this.name,data.company_id=this.company_id,data.duration=this.duration,data},Admin_Schedule}(BaseModel)}])}.call(this),function(){"use strict";var bind=function(fn,me){return function(){return fn.apply(me,arguments)}};angular.module("BB.Models").factory("ScheduleRules",function(){var ScheduleRules;return ScheduleRules=function(){function ScheduleRules(rules){null==rules&&(rules={}),this.removeRangeFromDate=bind(this.removeRangeFromDate,this),this.addRangeToDate=bind(this.addRangeToDate,this),this.rules=rules}return ScheduleRules.prototype.addRange=function(start,end){return this.applyFunctionToDateRange(start,end,"YYYY-MM-DD",this.addRangeToDate)},ScheduleRules.prototype.removeRange=function(start,end){return this.applyFunctionToDateRange(start,end,"YYYY-MM-DD",this.removeRangeFromDate)},ScheduleRules.prototype.addWeekdayRange=function(start,end){return this.applyFunctionToDateRange(start,end,"d",this.addRangeToDate)},ScheduleRules.prototype.removeWeekdayRange=function(start,end){return this.applyFunctionToDateRange(start,end,"d",this.removeRangeFromDate)},ScheduleRules.prototype.addRangeToDate=function(date,range){var ranges;return ranges=this.rules[date]?this.rules[date]:[],this.rules[date]=this.joinRanges(this.insertRange(ranges,range))},ScheduleRules.prototype.removeRangeFromDate=function(date,range){var ranges;return ranges=this.rules[date]?this.rules[date]:[],this.rules[date]=this.joinRanges(this.subtractRange(ranges,range)),""===this.rules[date]?delete this.rules[date]:void 0},ScheduleRules.prototype.applyFunctionToDateRange=function(start,end,format,func){var date,days,end_time,range,results;return days=this.diffInDays(start,end),0===days?(date=start.format(format),range=[start.format("HHmm"),end.format("HHmm")].join("-"),func(date,range)):(end_time=moment(start).endOf("day"),this.applyFunctionToDateRange(start,end_time,format,func),_.each(function(){results=[];for(var j=1;days>=1?days>=j:j>=days;days>=1?j++:j--)results.push(j);return results}.apply(this),function(_this){return function(i){var start_time;return date=moment(start).add(i,"days"),i!==days?(start_time=moment(date).startOf("day"),end_time=moment(date).endOf("day"),_this.applyFunctionToDateRange(start_time,end_time,format,func)):0!==end.hour()||0!==end.minute()?(start_time=moment(end).startOf("day"),_this.applyFunctionToDateRange(start_time,end,format,func)):void 0}}(this))),this.rules},ScheduleRules.prototype.diffInDays=function(start,end){return moment.duration(end.diff(start)).days()},ScheduleRules.prototype.insertRange=function(ranges,range){return ranges.splice(_.sortedIndex(ranges,range),0,range),ranges},ScheduleRules.prototype.subtractRange=function(ranges,range){return _.indexOf(ranges,range,!0)>-1?_.without(ranges,range):_.flatten(_.map(ranges,function(r){return range.slice(0,4)>=r.slice(0,4)&&range.slice(5,9)<=r.slice(5,9)?range.slice(0,4)===r.slice(0,4)?[range.slice(5,9),r.slice(5,9)].join("-"):range.slice(5,9)===r.slice(5,9)?[r.slice(0,4),range.slice(0,4)].join("-"):[[r.slice(0,4),range.slice(0,4)].join("-"),[range.slice(5,9),r.slice(5,9)].join("-")]:r}))},ScheduleRules.prototype.joinRanges=function(ranges){return _.reduce(ranges,function(m,range){return""===m?range:range.slice(0,4)<=m.slice(m.length-4,m.length)?range.slice(5,9)>=m.slice(m.length-4,m.length)?m.slice(0,m.length-4)+range.slice(5,9):m:[m,range].join()},"").split(",")},ScheduleRules.prototype.filterRulesByDates=function(){return _.pick(this.rules,function(value,key){return key.match(/^\d{4}-\d{2}-\d{2}$/)&&"None"!==value})},ScheduleRules.prototype.filterRulesByWeekdays=function(){return _.pick(this.rules,function(value,key){return key.match(/^\d$/)})},ScheduleRules.prototype.formatTime=function(time){return[time.slice(0,2),time.slice(2,4)].join(":")},ScheduleRules.prototype.toEvents=function(d){return d&&"None"!==this.rules[d]?_.map(this.rules[d],function(_this){return function(range){return{start:[d,_this.formatTime(range.split("-")[0])].join("T"),end:[d,_this.formatTime(range.split("-")[1])].join("T")}}}(this)):_.reduce(this.filterRulesByDates(),function(_this){return function(memo,ranges,date){return memo.concat(_.map(ranges,function(range){return{start:[date,_this.formatTime(range.split("-")[0])].join("T"),end:[date,_this.formatTime(range.split("-")[1])].join("T")}}))}}(this),[])},ScheduleRules.prototype.toWeekdayEvents=function(){return _.reduce(this.filterRulesByWeekdays(),function(_this){return function(memo,ranges,day){var date;return date=moment().set("day",day).format("YYYY-MM-DD"),memo.concat(_.map(ranges,function(range){return{start:[date,_this.formatTime(range.split("-")[0])].join("T"),end:[date,_this.formatTime(range.split("-")[1])].join("T")}}))}}(this),[])},ScheduleRules}()})}.call(this),function(){"use strict";var extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;angular.module("BB.Models").factory("Admin.ServiceModel",["$q","BBModel","ServiceModel",function($q,BBModel,ServiceModel){var Admin_Service;return Admin_Service=function(superClass){function Admin_Service(){return Admin_Service.__super__.constructor.apply(this,arguments)}return extend(Admin_Service,superClass),Admin_Service}(ServiceModel)}])}.call(this),function(){angular.module("BBAdmin.Services").factory("AdminAddressService",["$q","BBModel",function($q,BBModel){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("addresses").then(function(collection){return collection.$get("addresses").then(function(addresss){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=addresss.length;len>i;i++)s=addresss[i],results.push(new BBModel.Admin.Address(s));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise}}}])}.call(this),function(){angular.module("BBAdmin.Services").factory("AdminClinicService",["$q","BBModel","ClinicCollections","$window",function($q,BBModel,ClinicCollections,$window){return{query:function(params){var company,defer,existing;return company=params.company,defer=$q.defer(),params.id?company.$get("clinics",params).then(function(clinic){return clinic=new BBModel.Admin.Clinic(clinic),defer.resolve(clinic)},function(err){return defer.reject(err)}):(existing=ClinicCollections.find(params),existing&&!params.skip_cache?defer.resolve(existing):(params.skip_cache&&(existing&&ClinicCollections["delete"](existing),company.$flush("clinics",params)),company.$get("clinics",params).then(function(collection){return collection.$get("clinics").then(function(clinics){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=clinics.length;len>i;i++)s=clinics[i],results.push(new BBModel.Admin.Clinic(s));return results}(),clinics=new $window.Collection.Clinic(collection,models,params),ClinicCollections.add(clinics),defer.resolve(clinics)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}))),defer.promise},create:function(prms,clinic){var company,deferred;return company=prms.company,deferred=$q.defer(),company.$post("clinics",{},clinic.getPostData()).then(function(_this){return function(clinic){return clinic=new BBModel.Admin.Clinic(clinic),ClinicCollections.checkItems(clinic),deferred.resolve(clinic)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},cancel:function(clinic){var deferred;return deferred=$q.defer(),clinic.$post("cancel",clinic).then(function(_this){return function(clinic){return clinic=new BBModel.Admin.Clinic(clinic),ClinicCollections.deleteItems(clinic),deferred.resolve(clinic)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},update:function(clinic){var deferred;return deferred=$q.defer(),clinic.$put("self",{},clinic.getPostData()).then(function(_this){return function(c){return clinic=new BBModel.Admin.Clinic(c),ClinicCollections.checkItems(clinic),deferred.resolve(clinic)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){angular.module("BBAdminServices").factory("AdminPersonService",["$q","$window","$rootScope","halClient","SlotCollections","BookingCollections","BBModel","LoginService","$log",function($q,$window,$rootScope,halClient,SlotCollections,BookingCollections,BBModel,LoginService,$log){ +return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$has("people")?company.$get("people").then(function(collection){return collection.$get("people").then(function(people){var models,p;return models=function(){var i,len,results;for(results=[],i=0,len=people.length;len>i;i++)p=people[i],results.push(new BBModel.Admin.Person(p));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}):($log.warn("company has no people link"),defer.reject("company has no people link")),defer.promise},block:function(company,person,data){var deferred;return deferred=$q.defer(),person.$put("block",{},data).then(function(_this){return function(response){var booking,slot;return response.$href("self").indexOf("bookings")>-1?(booking=new BBModel.Admin.Booking(response),BookingCollections.checkItems(booking),deferred.resolve(booking)):(slot=new BBModel.Admin.Slot(response),SlotCollections.checkItems(slot),deferred.resolve(slot))}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},signup:function(user,data){var defer;return defer=$q.defer(),user.$get("company").then(function(company){var params;return params={},company.$post("people",params,data).then(function(person){return person.$has("administrator")?person.$get("administrator").then(function(user){return LoginService.setLogin(user),defer.resolve(person)}):defer.resolve(person)},function(err){return defer.reject(err)}),defer.promise})}}}])}.call(this),function(){angular.module("BBAdmin.Services").factory("AdminResourceService",["$q","UriTemplate","halClient","SlotCollections","BBModel",function($q,UriTemplate,halClient,SlotCollections,BBModel){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("resources").then(function(collection){return collection.$get("resources").then(function(resources){var models,r;return models=function(){var i,len,results;for(results=[],i=0,len=resources.length;len>i;i++)r=resources[i],results.push(new BBModel.Admin.Resource(r));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise},block:function(company,resource,data){var deferred;return deferred=$q.defer(),resource.$put("block",{},data).then(function(_this){return function(response){var booking,slot;return response.$href("self").indexOf("bookings")>-1?(booking=new BBModel.Admin.Booking(response),BookingCollections.checkItems(booking),deferred.resolve(booking)):(slot=new BBModel.Admin.Slot(response),SlotCollections.checkItems(slot),deferred.resolve(slot))}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this),function(){angular.module("BBAdmin.Services").factory("AdminScheduleService",["$q","BBModel","ScheduleRules","BBAssets",function($q,BBModel,ScheduleRules,BBAssets){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("schedules").then(function(collection){return collection.$get("schedules").then(function(schedules){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=schedules.length;len>i;i++)s=schedules[i],results.push(new BBModel.Admin.Schedule(s));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise},"delete":function(schedule){var deferred;return deferred=$q.defer(),schedule.$del("self").then(function(_this){return function(schedule){return schedule=new BBModel.Admin.Schedule(schedule),deferred.resolve(schedule)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise},update:function(schedule){var deferred;return deferred=$q.defer(),schedule.$put("self",{},schedule.getPostData()).then(function(_this){return function(c){return schedule=new BBModel.Admin.Schedule(c),deferred.resolve(schedule)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this))},getPeopleScheduleEvents:function(company,start,end){return this.getAssetsScheduleEvents(company,start,end)},mapPeopleToScheduleEvents:function(start,end,assets){return this.mapAssetsToScheduleEvents(start,end,assets)},mapAssetsToScheduleEvents:function(start,end,assets){var assets_with_schedule;return assets_with_schedule=_.filter(assets,function(asset){return asset.$has("schedule")}),_.map(assets_with_schedule,function(asset){var params;return params={start_date:start.format("YYYY-MM-DD"),end_date:end.format("YYYY-MM-DD")},asset.$get("schedule",params).then(function(schedules){var events,rules;return rules=new ScheduleRules(schedules.dates),events=rules.toEvents(),_.each(events,function(e){return e.resourceId=asset.id,e.title=asset.name,e.rendering="background"}),events})})},getAssetsScheduleEvents:function(company,start,end,filtered,requested){var localMethod;return null==filtered&&(filtered=!1),null==requested&&(requested=[]),filtered?$q.all(this.mapAssetsToScheduleEvents(start,end,requested)).then(function(schedules){return _.flatten(schedules)}):(localMethod=this.mapAssetsToScheduleEvents,BBAssets(company).then(function(assets){return $q.all(localMethod(start,end,assets)).then(function(schedules){return _.flatten(schedules)})}))}}}])}.call(this),function(){angular.module("BBAdmin.Services").factory("AdminServiceService",["$q","BBModel","$log",function($q,BBModel,$log){return{query:function(params){var company,defer;return company=params.company,defer=$q.defer(),company.$get("services").then(function(collection){return collection.$get("services").then(function(services){var models,s;return models=function(){var i,len,results;for(results=[],i=0,len=services.length;len>i;i++)s=services[i],results.push(new BBModel.Admin.Service(s));return results}(),defer.resolve(models)},function(err){return defer.reject(err)})},function(err){return defer.reject(err)}),defer.promise}}}])}.call(this),function(){angular.module("BBAdminServices").factory("BB.Service.schedule",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Schedule(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.person",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Person(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.people",["$q","BBModel",function($q,BBModel){return{promise:!0,unwrap:function(resource){var deferred;return deferred=$q.defer(),resource.$get("people").then(function(_this){return function(items){var i,j,len,models;for(models=[],j=0,len=items.length;len>j;j++)i=items[j],models.push(new BBModel.Admin.Person(i));return deferred.resolve(models)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}]),angular.module("BBAdminServices").factory("BB.Service.resource",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Resource(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.resources",["$q","BBModel",function($q,BBModel){return{promise:!0,unwrap:function(resource){var deferred;return deferred=$q.defer(),resource.$get("resources").then(function(_this){return function(items){var i,j,len,models;for(models=[],j=0,len=items.length;len>j;j++)i=items[j],models.push(new BBModel.Admin.Resource(i));return deferred.resolve(models)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}]),angular.module("BBAdminServices").factory("BB.Service.service",["$q","BBModel",function($q,BBModel){return{unwrap:function(resource){return new BBModel.Admin.Service(resource)}}}]),angular.module("BBAdminServices").factory("BB.Service.services",["$q","BBModel",function($q,BBModel){return{promise:!0,unwrap:function(resource){var deferred;return deferred=$q.defer(),resource.$get("services").then(function(_this){return function(items){var i,j,len,models;for(models=[],j=0,len=items.length;len>j;j++)i=items[j],models.push(new BBModel.Admin.Service(i));return deferred.resolve(models)}}(this),function(_this){return function(err){return deferred.reject(err)}}(this)),deferred.promise}}}])}.call(this); \ No newline at end of file diff --git a/bower.json b/bower.json index aff0831..8388da8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bookingbug-angular-services", - "version": "1.4.55", + "version": "1.4.57", "homepage": "https://github.com/BookingBug/bookingbug-angular-services-bower", "authors": [ "Glenn Shoosmith ", @@ -9,8 +9,7 @@ "main": [ "bookingbug-angular-services.js", "bookingbug-angular-services-templates.js", - "bookingbug-angular-services.css", - "src/stylesheets/*" + "bookingbug-angular-services.css" ], "license": "MIT", "ignore": [ @@ -21,8 +20,16 @@ "tests" ], "dependencies": { - "bookingbug-angular-core": "1.4.55", - "bookingbug-angular-admin": "1.4.55", - "angular-ui-calendar": "~1.0.0" + "bookingbug-angular-core": "1.4.57", + "bookingbug-angular-admin": "1.4.57", + "angular-ui-calendar": "~1.0.0", + "fullcalendar": "2.3.1" + }, + "resolutions": { + "fullcalendar": "2.3.1", + "jquery": "~1.11.2", + "angular": "1.2.28", + "bookingbug-angular-core": "master", + "moment": "~2.13.0" } }