voltar 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/fonts/FontAwesome.otf +0 -0
  6. data/app/assets/fonts/Simple-Line-Icons.eot +0 -0
  7. data/app/assets/fonts/Simple-Line-Icons.svg +1369 -0
  8. data/app/assets/fonts/Simple-Line-Icons.ttf +0 -0
  9. data/app/assets/fonts/Simple-Line-Icons.woff +0 -0
  10. data/app/assets/fonts/fontawesome-webfont.eot +0 -0
  11. data/app/assets/fonts/fontawesome-webfont.svg +520 -0
  12. data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  13. data/app/assets/fonts/fontawesome-webfont.woff +0 -0
  14. data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  15. data/app/assets/fonts/glyphicons-halflings-regular.svg +229 -0
  16. data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  17. data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  18. data/app/assets/fonts/sourcesanspro/sourcesanspro-bold.woff +0 -0
  19. data/app/assets/fonts/sourcesanspro/sourcesanspro-light.woff +0 -0
  20. data/app/assets/fonts/sourcesanspro/sourcesanspro.woff +0 -0
  21. data/app/assets/javascripts/voltar/app.js +203 -0
  22. data/app/assets/javascripts/voltar/application.js +33 -0
  23. data/app/assets/javascripts/voltar/controllers/app_ctrl.js.erb +673 -0
  24. data/app/assets/javascripts/voltar/directives/app_directives.js +345 -0
  25. data/app/assets/javascripts/voltar/factories/app_services.js +255 -0
  26. data/app/assets/javascripts/voltar/stripe.js.coffee +2 -0
  27. data/app/assets/stylesheets/voltar/app.css +4990 -0
  28. data/app/assets/stylesheets/voltar/application.css +23 -0
  29. data/app/assets/stylesheets/voltar/voltar.css.scss +93 -0
  30. data/app/controllers/voltar/application_controller.rb +4 -0
  31. data/app/controllers/voltar/dashboard_controller.rb +11 -0
  32. data/app/helpers/voltar/application_helper.rb +4 -0
  33. data/app/views/layouts/voltar/application.html.erb +40 -0
  34. data/app/views/voltar/account/_billing.html.erb +552 -0
  35. data/app/views/voltar/account/_locations.html.erb +135 -0
  36. data/app/views/voltar/account/_managers.html +134 -0
  37. data/app/views/voltar/account/_password.html.erb +57 -0
  38. data/app/views/voltar/account/_profile.html.erb +84 -0
  39. data/app/views/voltar/dashboard/index.html.erb +0 -0
  40. data/app/views/voltar/inventory/_delete_dialog.html.erb +16 -0
  41. data/app/views/voltar/inventory/_edit.html.erb +244 -0
  42. data/app/views/voltar/inventory/_index.html.erb +160 -0
  43. data/app/views/voltar/inventory/_mark_as_sold_dialog.html.erb +26 -0
  44. data/app/views/voltar/shared/_keen_js.html.haml +11 -0
  45. data/app/views/voltar/shared/_voltar_app.html.erb +83 -0
  46. data/app/views/voltar/shared/_voltar_aside.html.erb +71 -0
  47. data/app/views/voltar/shared/_voltar_footer.html.erb +13 -0
  48. data/app/views/voltar/shared/_voltar_header.html.erb +156 -0
  49. data/app/views/voltar/shared/app/_country_province_select.html +19 -0
  50. data/app/views/voltar/shared/app/_dashboard.html.erb +243 -0
  51. data/app/views/voltar/shared/app/_notifications.html.erb +13 -0
  52. data/app/views/voltar/shared/app/_spinner.html.erb +8 -0
  53. data/config/routes.rb +4 -0
  54. data/lib/tasks/voltar_tasks.rake +4 -0
  55. data/lib/voltar.rb +5 -0
  56. data/lib/voltar/engine.rb +15 -0
  57. data/lib/voltar/version.rb +3 -0
  58. data/test/dummy/README.rdoc +28 -0
  59. data/test/dummy/Rakefile +6 -0
  60. data/test/dummy/app/assets/javascripts/application.js +13 -0
  61. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  62. data/test/dummy/app/controllers/application_controller.rb +5 -0
  63. data/test/dummy/app/helpers/application_helper.rb +2 -0
  64. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  65. data/test/dummy/bin/bundle +3 -0
  66. data/test/dummy/bin/rails +4 -0
  67. data/test/dummy/bin/rake +4 -0
  68. data/test/dummy/bin/setup +29 -0
  69. data/test/dummy/config.ru +4 -0
  70. data/test/dummy/config/application.rb +26 -0
  71. data/test/dummy/config/boot.rb +5 -0
  72. data/test/dummy/config/database.yml +25 -0
  73. data/test/dummy/config/environment.rb +5 -0
  74. data/test/dummy/config/environments/development.rb +41 -0
  75. data/test/dummy/config/environments/production.rb +76 -0
  76. data/test/dummy/config/environments/test.rb +39 -0
  77. data/test/dummy/config/initializers/assets.rb +11 -0
  78. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  79. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  80. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  81. data/test/dummy/config/initializers/inflections.rb +16 -0
  82. data/test/dummy/config/initializers/mime_types.rb +4 -0
  83. data/test/dummy/config/initializers/session_store.rb +3 -0
  84. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  85. data/test/dummy/config/locales/en.yml +23 -0
  86. data/test/dummy/config/routes.rb +4 -0
  87. data/test/dummy/config/secrets.yml +22 -0
  88. data/test/dummy/log/development.log +0 -0
  89. data/test/dummy/public/404.html +67 -0
  90. data/test/dummy/public/422.html +67 -0
  91. data/test/dummy/public/500.html +66 -0
  92. data/test/dummy/public/favicon.ico +0 -0
  93. data/test/integration/navigation_test.rb +10 -0
  94. data/test/test_helper.rb +15 -0
  95. data/test/voltar_test.rb +7 -0
  96. data/vendor/assets/images/voltar/a0.jpg +0 -0
  97. data/vendor/assets/images/voltar/a1.jpg +0 -0
  98. data/vendor/assets/images/voltar/a10.jpg +0 -0
  99. data/vendor/assets/images/voltar/a2.jpg +0 -0
  100. data/vendor/assets/images/voltar/a3.jpg +0 -0
  101. data/vendor/assets/images/voltar/a4.jpg +0 -0
  102. data/vendor/assets/images/voltar/a5.jpg +0 -0
  103. data/vendor/assets/images/voltar/a6.jpg +0 -0
  104. data/vendor/assets/images/voltar/a7.jpg +0 -0
  105. data/vendor/assets/images/voltar/a8.jpg +0 -0
  106. data/vendor/assets/images/voltar/a9.jpg +0 -0
  107. data/vendor/assets/images/voltar/b0.jpg +0 -0
  108. data/vendor/assets/images/voltar/b1.jpg +0 -0
  109. data/vendor/assets/images/voltar/b2.jpg +0 -0
  110. data/vendor/assets/images/voltar/b3.jpg +0 -0
  111. data/vendor/assets/images/voltar/b4.jpg +0 -0
  112. data/vendor/assets/images/voltar/b5.jpg +0 -0
  113. data/vendor/assets/images/voltar/c0.jpg +0 -0
  114. data/vendor/assets/images/voltar/c1.jpg +0 -0
  115. data/vendor/assets/images/voltar/c2.jpg +0 -0
  116. data/vendor/assets/images/voltar/c3.jpg +0 -0
  117. data/vendor/assets/images/voltar/c4.jpg +0 -0
  118. data/vendor/assets/images/voltar/c5.jpg +0 -0
  119. data/vendor/assets/images/voltar/chosen-sprite.png +0 -0
  120. data/vendor/assets/images/voltar/chosen-sprite@2x.png +0 -0
  121. data/vendor/assets/images/voltar/logo.png +0 -0
  122. data/vendor/assets/images/voltar/p0.jpg +0 -0
  123. data/vendor/assets/javascripts/voltar/angular-animate.js +1689 -0
  124. data/vendor/assets/javascripts/voltar/angular-contenteditable.js +98 -0
  125. data/vendor/assets/javascripts/voltar/angular-cookies.js +206 -0
  126. data/vendor/assets/javascripts/voltar/angular-sanitize.js +647 -0
  127. data/vendor/assets/javascripts/voltar/angular-ui-router.js +3658 -0
  128. data/vendor/assets/javascripts/voltar/angular.js +22024 -0
  129. data/vendor/assets/javascripts/voltar/chosen.jquery.min.js +2 -0
  130. data/vendor/assets/javascripts/voltar/easypiechart/jquery.easy-pie-chart.js +209 -0
  131. data/vendor/assets/javascripts/voltar/flot/jquery.flot.min.js +29 -0
  132. data/vendor/assets/javascripts/voltar/flot/jquery.flot.orderBars.js +187 -0
  133. data/vendor/assets/javascripts/voltar/flot/jquery.flot.pie.min.js +56 -0
  134. data/vendor/assets/javascripts/voltar/flot/jquery.flot.resize.js +60 -0
  135. data/vendor/assets/javascripts/voltar/flot/jquery.flot.spline.js +212 -0
  136. data/vendor/assets/javascripts/voltar/flot/jquery.flot.tooltip.min.js +12 -0
  137. data/vendor/assets/javascripts/voltar/jquery.min.js +5 -0
  138. data/vendor/assets/javascripts/voltar/moment.js +2856 -0
  139. data/vendor/assets/javascripts/voltar/ngStorage.js +103 -0
  140. data/vendor/assets/javascripts/voltar/ocLazyLoad.js +906 -0
  141. data/vendor/assets/javascripts/voltar/smart-table.min.js +1 -0
  142. data/vendor/assets/javascripts/voltar/sparkline/jquery.sparkline.min.js +2 -0
  143. data/vendor/assets/javascripts/voltar/toaster.js +185 -0
  144. data/vendor/assets/javascripts/voltar/ui-bootstrap-tpls.js +4116 -0
  145. data/vendor/assets/javascripts/voltar/ui-jq.js +86 -0
  146. data/vendor/assets/javascripts/voltar/ui-load.js +93 -0
  147. data/vendor/assets/javascripts/voltar/ui-validate.js +119 -0
  148. data/vendor/assets/stylesheets/voltar/animate.css +1098 -0
  149. data/vendor/assets/stylesheets/voltar/bootstrap.css +6202 -0
  150. data/vendor/assets/stylesheets/voltar/chosen.css +399 -0
  151. data/vendor/assets/stylesheets/voltar/font-awesome.min.css +4 -0
  152. data/vendor/assets/stylesheets/voltar/font.css +18 -0
  153. data/vendor/assets/stylesheets/voltar/simple-line-icons.css +526 -0
  154. data/vendor/assets/stylesheets/voltar/toaster.css +213 -0
  155. metadata +333 -0
@@ -0,0 +1,345 @@
1
+ 'use strict';
2
+
3
+ /* Directives */
4
+ // All the directives rely on jQuery.
5
+
6
+ angular.module('voltar.directives', ['ui.load'])
7
+ .directive('uiModule', ['MODULE_CONFIG','uiLoad', '$compile', function(MODULE_CONFIG, uiLoad, $compile) {
8
+ return {
9
+ restrict: 'A',
10
+ compile: function (el, attrs) {
11
+ var contents = el.contents().clone();
12
+ return function(scope, el, attrs){
13
+ el.contents().remove();
14
+ uiLoad.load(MODULE_CONFIG[attrs.uiModule])
15
+ .then(function(){
16
+ $compile(contents)(scope, function(clonedElement, scope) {
17
+ el.append(clonedElement);
18
+ });
19
+ });
20
+ }
21
+ }
22
+ };
23
+ }])
24
+ .directive('uiShift', ['$timeout', function($timeout) {
25
+ return {
26
+ restrict: 'A',
27
+ link: function(scope, el, attr) {
28
+ // get the $prev or $parent of this el
29
+ var _el = $(el),
30
+ _window = $(window),
31
+ prev = _el.prev(),
32
+ parent,
33
+ width = _window.width()
34
+ ;
35
+
36
+ !prev.length && (parent = _el.parent());
37
+
38
+ function sm(){
39
+ $timeout(function () {
40
+ var method = attr.uiShift;
41
+ var target = attr.target;
42
+ _el.hasClass('in') || _el[method](target).addClass('in');
43
+ });
44
+ }
45
+
46
+ function md(){
47
+ parent && parent['prepend'](el);
48
+ !parent && _el['insertAfter'](prev);
49
+ _el.removeClass('in');
50
+ }
51
+
52
+ (width < 768 && sm()) || md();
53
+
54
+ _window.resize(function() {
55
+ if(width !== _window.width()){
56
+ $timeout(function(){
57
+ (_window.width() < 768 && sm()) || md();
58
+ width = _window.width();
59
+ });
60
+ }
61
+ });
62
+ }
63
+ };
64
+ }])
65
+ .directive('uiToggleClass', ['$timeout', '$document', function($timeout, $document) {
66
+ return {
67
+ restrict: 'AC',
68
+ link: function(scope, el, attr) {
69
+ el.on('click', function(e) {
70
+ e.preventDefault();
71
+ var classes = attr.uiToggleClass.split(','),
72
+ targets = (attr.target && attr.target.split(',')) || Array(el),
73
+ key = 0;
74
+ angular.forEach(classes, function( _class ) {
75
+ var target = targets[(targets.length && key)];
76
+ ( _class.indexOf( '*' ) !== -1 ) && magic(_class, target);
77
+ $( target ).toggleClass(_class);
78
+ key ++;
79
+ });
80
+ $(el).toggleClass('active');
81
+
82
+ function magic(_class, target){
83
+ var patt = new RegExp( '\\s' +
84
+ _class.
85
+ replace( /\*/g, '[A-Za-z0-9-_]+' ).
86
+ split( ' ' ).
87
+ join( '\\s|\\s' ) +
88
+ '\\s', 'g' );
89
+ var cn = ' ' + $(target)[0].className + ' ';
90
+ while ( patt.test( cn ) ) {
91
+ cn = cn.replace( patt, ' ' );
92
+ }
93
+ $(target)[0].className = $.trim( cn );
94
+ }
95
+ });
96
+ }
97
+ };
98
+ }])
99
+ .directive('uiNav', ['$timeout', function($timeout) {
100
+ return {
101
+ restrict: 'AC',
102
+ link: function(scope, el, attr) {
103
+ var _window = $(window),
104
+ _mb = 768,
105
+ wrap = $('.app-aside'),
106
+ next,
107
+ backdrop = '.dropdown-backdrop';
108
+ // unfolded
109
+ el.on('click', 'a', function(e) {
110
+ next && next.trigger('mouseleave.nav');
111
+ var _this = $(this);
112
+ _this.parent().siblings( ".active" ).toggleClass('active');
113
+ _this.next().is('ul') && _this.parent().toggleClass('active') && e.preventDefault();
114
+ // mobile
115
+ _this.next().is('ul') || ( ( _window.width() < _mb ) && $('.app-aside').removeClass('show off-screen') );
116
+ });
117
+
118
+ // folded & fixed
119
+ el.on('mouseenter', 'a', function(e){
120
+ next && next.trigger('mouseleave.nav');
121
+ $('> .nav', wrap).remove();
122
+ if ( !$('.app-aside-fixed.app-aside-folded').length || ( _window.width() < _mb ) || $('.app-aside-dock').length) return;
123
+ var _this = $(e.target)
124
+ , top
125
+ , w_h = $(window).height()
126
+ , offset = 50
127
+ , min = 150;
128
+
129
+ !_this.is('a') && (_this = _this.closest('a'));
130
+ if( _this.next().is('ul') ){
131
+ next = _this.next();
132
+ }else{
133
+ return;
134
+ }
135
+
136
+ _this.parent().addClass('active');
137
+ top = _this.parent().position().top + offset;
138
+ next.css('top', top);
139
+ if( top + next.height() > w_h ){
140
+ next.css('bottom', 0);
141
+ }
142
+ if(top + min > w_h){
143
+ next.css('bottom', w_h - top - offset).css('top', 'auto');
144
+ }
145
+ next.appendTo(wrap);
146
+
147
+ next.on('mouseleave.nav', function(e){
148
+ $(backdrop).remove();
149
+ next.appendTo(_this.parent());
150
+ next.off('mouseleave.nav').css('top', 'auto').css('bottom', 'auto');
151
+ _this.parent().removeClass('active');
152
+ });
153
+
154
+ $('.smart').length && $('<div class="dropdown-backdrop"/>').insertAfter('.app-aside').on('click', function(next){
155
+ next && next.trigger('mouseleave.nav');
156
+ });
157
+
158
+ });
159
+
160
+ wrap.on('mouseleave', function(e){
161
+ next && next.trigger('mouseleave.nav');
162
+ $('> .nav', wrap).remove();
163
+ });
164
+ }
165
+ };
166
+ }])
167
+ .directive('uiScroll', ['$location', '$anchorScroll', function($location, $anchorScroll) {
168
+ return {
169
+ restrict: 'AC',
170
+ link: function(scope, el, attr) {
171
+ el.on('click', function(e) {
172
+ $location.hash(attr.uiScroll);
173
+ $anchorScroll();
174
+ });
175
+ }
176
+ };
177
+ }])
178
+ .directive('uiFullscreen', ['uiLoad', function(uiLoad) {
179
+ return {
180
+ restrict: 'AC',
181
+ template:'<i class="fa fa-expand fa-fw text"></i><i class="fa fa-compress fa-fw text-active"></i>',
182
+ link: function(scope, el, attr) {
183
+ el.addClass('hide');
184
+ uiLoad.load('js/libs/screenfull.min.js').then(function(){
185
+ if (screenfull.enabled) {
186
+ el.removeClass('hide');
187
+ }
188
+ el.on('click', function(){
189
+ var target;
190
+ attr.target && ( target = $(attr.target)[0] );
191
+ el.toggleClass('active');
192
+ screenfull.toggle(target);
193
+ });
194
+ });
195
+ }
196
+ };
197
+ }])
198
+ .directive('uiButterbar', ['$rootScope', '$anchorScroll', function($rootScope, $anchorScroll) {
199
+ return {
200
+ restrict: 'AC',
201
+ template:'<span class="bar"></span>',
202
+ link: function(scope, el, attrs) {
203
+ el.addClass('butterbar hide');
204
+ scope.$on('$stateChangeStart', function(event) {
205
+ $anchorScroll();
206
+ el.removeClass('hide').addClass('active');
207
+ });
208
+ scope.$on('$stateChangeSuccess', function( event, toState, toParams, fromState ) {
209
+ event.targetScope.$watch('$viewContentLoaded', function(){
210
+ el.addClass('hide').removeClass('active');
211
+ })
212
+ });
213
+ }
214
+ };
215
+ }])
216
+ .directive('setNgAnimate', ['$animate', function ($animate) {
217
+ return {
218
+ link: function ($scope, $element, $attrs) {
219
+ $scope.$watch( function() {
220
+ return $scope.$eval($attrs.setNgAnimate, $scope);
221
+ }, function(valnew, valold){
222
+ $animate.enabled(!!valnew, $element);
223
+ });
224
+ }
225
+ };
226
+ }])
227
+ .directive('uiFocus', function($timeout, $parse) {
228
+ return {
229
+ link: function(scope, element, attrs) {
230
+ var model = $parse(attrs.uiFocus);
231
+ scope.$watch(model, function(value) {
232
+ if(value === true) {
233
+ $timeout(function() {
234
+ element[0].focus();
235
+ });
236
+ }
237
+ });
238
+ element.bind('blur', function() {
239
+ scope.$apply(model.assign(scope, false));
240
+ });
241
+ }
242
+ };
243
+ })
244
+ .directive('countryProvinceSelect', ['$rootScope', function($rootScope) {
245
+ return {
246
+ scope: {
247
+ resource: '='
248
+ },
249
+ restrict: 'E',
250
+ templateUrl: 'countryProvinceSelect.html',
251
+ link: function($scope, elem, attrs) {
252
+
253
+ },
254
+ controller: function($scope, Country, Province) {
255
+
256
+ Province.all()
257
+ .success(function(success) {
258
+ $scope.provinces = success;
259
+ })
260
+
261
+ Country.all()
262
+ .success(function(success) {
263
+ $scope.countries = success;
264
+ })
265
+ .error(function(error) {
266
+ //
267
+ })
268
+
269
+ $scope.updateStates = function(countryId) {
270
+ Province.get(countryId)
271
+ .success(function(success) {
272
+ $scope.provinces = success
273
+ })
274
+ .error(function(error) {
275
+ //
276
+ })
277
+ }
278
+
279
+ }
280
+ };
281
+ }])
282
+ .directive('ngThumb', ['$window', function($window) {
283
+ var helper = {
284
+ support: !!($window.FileReader && $window.CanvasRenderingContext2D),
285
+ isFile: function(item) {
286
+ return angular.isObject(item) && item instanceof $window.File;
287
+ },
288
+ isImage: function(file) {
289
+ var type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
290
+ return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
291
+ }
292
+ };
293
+
294
+ return {
295
+ restrict: 'A',
296
+ template: "<canvas class='opaque no-radius'/>",
297
+ link: function(scope, element, attributes) {
298
+ if (!helper.support) return;
299
+
300
+ var params = scope.$eval(attributes.ngThumb);
301
+
302
+ if (!helper.isFile(params.file)) return;
303
+ if (!helper.isImage(params.file)) return;
304
+
305
+ var canvas = element.find('canvas');
306
+ var reader = new FileReader();
307
+
308
+ reader.onload = onLoadFile;
309
+ reader.readAsDataURL(params.file);
310
+
311
+ function onLoadFile(event) {
312
+ var img = new Image();
313
+ img.onload = onLoadImage;
314
+ img.src = event.target.result;
315
+ }
316
+
317
+ function onLoadImage() {
318
+ var width = params.width || this.width / this.height * params.height;
319
+ var height = params.height || this.height / this.width * params.width;
320
+ canvas.attr({ width: width, height: height });
321
+ canvas[0].getContext('2d').drawImage(this, 0, 0, width, height);
322
+ }
323
+ }
324
+ };
325
+ }])
326
+ .directive('ngToggleClick', ['$window', function($window) {
327
+
328
+ return {
329
+ // name: '',
330
+ // priority: 1,
331
+ // terminal: true,
332
+ // scope: {}, // {} = isolate, true = child, false/undefined = no change
333
+ // controller: function($scope, $element, $attrs, $transclude) {},
334
+ // require: 'ngModel', // Array = multiple requires, ? = optional, ^ = check parent elements
335
+ restrict: 'A', // E = Element, A = Attribute, C = Class, M = Comment
336
+ template: '',
337
+ // templateUrl: '',
338
+ // replace: true,
339
+ // transclude: true,
340
+ // compile: function(tElement, tAttrs, function transclude(function(scope, cloneLinkingFn){ return function linking(scope, elm, attrs){}})),
341
+ link: function($scope, iElm, iAttrs, controller) {
342
+ $(iAttrs.ngToggleClick).trigger('click');
343
+ }
344
+ };
345
+ }]);
@@ -0,0 +1,255 @@
1
+ angular.module('voltar.services', [])
2
+ .value('apiBaseUrl', '/api/v1/')
3
+ .factory('YearRange', function() {
4
+
5
+ var service = {};
6
+
7
+ service.generate = function() {
8
+ d = new Date();
9
+ start = d.getFullYear() - 73;
10
+ end = d.getFullYear() + 2
11
+ var arr = [];
12
+ while(start <= end){
13
+ arr.push(start++);
14
+ }
15
+ return arr;
16
+ }
17
+
18
+ return service;
19
+
20
+ })
21
+
22
+ .factory('Inventory', function($http, apiBaseUrl) {
23
+
24
+ var service = {};
25
+
26
+ service.all = function(search) {
27
+ return $http.get(apiBaseUrl + 'inventories.json?' + $.param(search))
28
+ }
29
+
30
+ service.get = function(id) {
31
+ return $http.get(apiBaseUrl + 'inventories/' + id + '.json')
32
+ }
33
+
34
+ service.update = function(inventory) {
35
+ return $http.put(apiBaseUrl + 'inventories/' + inventory.id + '.json', { inventory: inventory })
36
+ }
37
+
38
+ service.save = function(inventory) {
39
+ return $http.post(apiBaseUrl + 'inventories.json', { inventory: inventory })
40
+ }
41
+
42
+ service.destroy = function(inventoryId) {
43
+ return $http.delete(apiBaseUrl + 'inventories/' + inventoryId + '.json')
44
+ }
45
+
46
+ service.prioritize = function(busIds) {
47
+ return $http.post(apiBaseUrl + 'inventories/prioritize_buses.json', { bus_ids: busIds })
48
+ }
49
+
50
+ return service;
51
+
52
+ })
53
+
54
+ // BusType
55
+ .factory('BusType', function($http, apiBaseUrl) {
56
+
57
+ var service = {};
58
+
59
+ service.all = function() {
60
+ return $http.get(apiBaseUrl + 'bus_types.json');
61
+ }
62
+
63
+ service.body_makes = function(bus_type_id) {
64
+ return $http.get(apiBaseUrl + 'bus_types/' + bus_type_id + '.json')
65
+ }
66
+
67
+ return service;
68
+
69
+ })
70
+
71
+ .factory('Dealer', function($http, apiBaseUrl) {
72
+
73
+ var service = {};
74
+
75
+ service.get = function() {
76
+ return $http.get(apiBaseUrl + 'dealer.json')
77
+ }
78
+
79
+ service.update = function(data) {
80
+ return $http.put(apiBaseUrl + 'dealer.json', { dealer: data } )
81
+ }
82
+
83
+ return service;
84
+
85
+ })
86
+
87
+ // country service
88
+ .factory('Country', function($http, apiBaseUrl) {
89
+
90
+ var service = {};
91
+
92
+ service.all = function() {
93
+ return $http.get(apiBaseUrl + 'countries.json');
94
+ }
95
+
96
+ return service;
97
+
98
+ })
99
+
100
+ // state province factory service
101
+ .factory('Province', function($http, apiBaseUrl) {
102
+
103
+ var service = {};
104
+
105
+ service.get = function(countryId) {
106
+ return $http.get(apiBaseUrl + 'countries/' + countryId + '/states.json');
107
+ }
108
+
109
+ service.all = function() {
110
+ return $http.get(apiBaseUrl + 'states.json');
111
+ }
112
+
113
+ return service;
114
+
115
+ })
116
+
117
+ // Password
118
+ .factory('Password', function($http, apiBaseUrl) {
119
+
120
+ var service = {}
121
+
122
+ service.update = function(data) {
123
+ return $http.put(apiBaseUrl + 'password', { dealer: data } );
124
+ }
125
+
126
+ return service;
127
+
128
+ })
129
+
130
+
131
+ // Manager/User
132
+ .factory('Manager', function($http, apiBaseUrl) {
133
+
134
+ var service = {};
135
+
136
+ service.all = function() {
137
+ return $http.get(apiBaseUrl + 'managers.json');
138
+ }
139
+
140
+ service.new = function() {
141
+ return $http.get(apiBaseUrl + 'managers/new.json');
142
+ }
143
+
144
+ service.save = function(data) {
145
+ return $http.post(apiBaseUrl + 'managers.json', { dealer: data} )
146
+ }
147
+
148
+ service.update = function(id, data) {
149
+ return $http.put(apiBaseUrl + 'managers/' + id + '.json', { dealer: data})
150
+ }
151
+
152
+ service.delete = function(id) {
153
+ return $http.delete(apiBaseUrl + 'managers/' + id + '.json')
154
+ }
155
+
156
+ service.persist = function(data) {
157
+ if (data.id) {
158
+ return service.update(data.id, data);
159
+ } else {
160
+ return service.save(data);
161
+ }
162
+ }
163
+
164
+ return service;
165
+ })
166
+
167
+ // Location
168
+ .factory('Location', ['$http', 'apiBaseUrl', function($http, apiBaseUrl) {
169
+
170
+ var service = {};
171
+
172
+ service.all = function() {
173
+ return $http.get(apiBaseUrl + 'locations.json');
174
+ }
175
+
176
+ service.create = function(location) {
177
+ return $http.post(apiBaseUrl + 'locations.json', { location: location } )
178
+ }
179
+
180
+ service.update = function(location) {
181
+ return $http.put(apiBaseUrl + 'locations/' + location.id + '.json', { location: location } )
182
+ }
183
+
184
+ service.persist = function(location) {
185
+ if (location.id) {
186
+ return service.update(location);
187
+ } else {
188
+ return service.create(location);
189
+ }
190
+ }
191
+
192
+ return service;
193
+
194
+ }])
195
+
196
+ // Invoice factory
197
+ .factory('Invoice', ['$http', 'apiBaseUrl', function($http, apiBaseUrl) {
198
+
199
+ var service = {};
200
+
201
+ service.all = function() {
202
+ return $http.get(apiBaseUrl + 'invoices.json');
203
+ }
204
+
205
+ return service;
206
+
207
+ }])
208
+
209
+
210
+ // Credit Cards
211
+ .factory('CreditCard', ['$http', 'apiBaseUrl', function($http, apiBaseUrl) {
212
+
213
+ var service = {};
214
+
215
+ service.update = function(card) {
216
+ return $http.put(apiBaseUrl + 'dealer/credit_cards/' + card.id + '.json', { credit_card: card })
217
+ }
218
+
219
+ service.create = function(card) {
220
+ return $http.post(apiBaseUrl + 'dealer/credit_cards.json', { credit_card: card})
221
+ }
222
+
223
+ service.makePrimary = function(card) {
224
+ return $http.put(apiBaseUrl + 'dealer/credit_cards/' + card.id + '/make_default.json')
225
+ }
226
+
227
+ return service;
228
+ }])
229
+
230
+
231
+ // Plan service
232
+ .factory('Plan', ['$http', 'apiBaseUrl', function($http, apiBaseUrl) {
233
+
234
+ var service = {};
235
+
236
+ service.switchPlan = function(planName) {
237
+ return $http.put(apiBaseUrl + 'dealer/switch_plan.json', { plan: planName })
238
+ }
239
+
240
+ return service;
241
+
242
+ }])
243
+
244
+
245
+ // Analytics service
246
+ .factory('Analytics', ['$http', 'apiBaseUrl', function($http, apiBaseUrl) {
247
+
248
+ var service = {};
249
+
250
+ service.busTypes = function() {
251
+ return $http.get(apiBaseUrl + 'analytics/bus_types.json');
252
+ }
253
+
254
+ return service;
255
+ }])