faalis 1.0.0.alpha1 → 1.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -10
  3. data/Rakefile +6 -2
  4. data/app/assets/javascripts/faalis/angular-manifest.js +3 -0
  5. data/app/assets/javascripts/faalis/application.js +0 -1
  6. data/app/assets/javascripts/faalis/dashboard/app.js +20 -6
  7. data/app/assets/javascripts/faalis/dashboard/application.js.erb +5 -1
  8. data/app/assets/javascripts/faalis/dashboard/controllers/group.js.coffee +42 -0
  9. data/app/assets/javascripts/faalis/dashboard/functions.js.erb +20 -0
  10. data/app/assets/javascripts/faalis/dashboard/init.js +1 -1
  11. data/app/assets/javascripts/faalis/dashboard/lib/button.js.coffee +17 -0
  12. data/app/assets/javascripts/faalis/dashboard/lib/controllers.js.coffee +11 -0
  13. data/app/assets/javascripts/faalis/dashboard/lib/controllers/base_controller.js.coffee +14 -0
  14. data/app/assets/javascripts/faalis/dashboard/lib/controllers/generic_add_controller.js.coffee +33 -0
  15. data/app/assets/javascripts/faalis/dashboard/lib/controllers/generic_index_controller.js.coffee +85 -0
  16. data/app/assets/javascripts/faalis/dashboard/lib/fields/base.js.coffee +6 -0
  17. data/app/assets/javascripts/faalis/dashboard/lib/fields/has_many_field.js.coffee +4 -0
  18. data/app/assets/javascripts/faalis/dashboard/lib/fields/string_field.js.coffee +2 -0
  19. data/app/assets/javascripts/faalis/dashboard/lib/resource.js.coffee +147 -0
  20. data/app/assets/javascripts/faalis/dashboard/modules/auth/auth.js +5 -3
  21. data/app/assets/javascripts/faalis/dashboard/modules/auth/profile.js +6 -5
  22. data/app/assets/javascripts/faalis/dashboard/modules/auth/user.js +12 -10
  23. data/app/assets/javascripts/faalis/dashboard/modules/conversations.js +2 -1
  24. data/app/assets/javascripts/faalis/dashboard/modules/fields/#image.js# +43 -0
  25. data/app/assets/javascripts/faalis/dashboard/modules/fields/date.js +51 -0
  26. data/app/assets/javascripts/faalis/dashboard/modules/fields/datetime.js +26 -15
  27. data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +3 -1
  28. data/app/assets/javascripts/faalis/dashboard/modules/fields/file.js +43 -0
  29. data/app/assets/javascripts/faalis/dashboard/modules/fields/image.js +33 -46
  30. data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +7 -4
  31. data/app/assets/javascripts/faalis/dashboard/modules/fields/tag.js +5 -11
  32. data/app/assets/javascripts/faalis/dashboard/modules/fields/time.js +34 -122
  33. data/app/assets/javascripts/faalis/dashboard/modules/logs.js +5 -4
  34. data/app/assets/javascripts/faalis/dashboard/modules/permissions.js.coffee +38 -0
  35. data/app/assets/javascripts/faalis/dashboard/resources/group_resource.js.coffee +8 -0
  36. data/app/assets/javascripts/faalis/dashboard/resources/permission_resource.js.coffee +6 -0
  37. data/app/assets/javascripts/faalis/dashboard/services/api.js.coffee +73 -0
  38. data/app/assets/javascripts/faalis/dashboard/services/resource_factory.js.coffee +48 -0
  39. data/app/assets/javascripts/faalis/dashboard/services/user.js.coffee +4 -0
  40. data/app/assets/javascripts/faalis/dashboard/variables.js.erb +5 -0
  41. data/app/assets/javascripts/faalis/{locales → locale}/en.json +0 -0
  42. data/app/assets/javascripts/faalis/{locales → locale}/fa.json +0 -0
  43. data/app/assets/javascripts/faalis/{locales → locale}/translations.fa.js +0 -0
  44. data/app/controllers/faalis/api/v1/groups_controller.rb +53 -57
  45. data/app/controllers/faalis/api/v1/permissions_controller.rb +29 -12
  46. data/app/controllers/faalis/api_controller.rb +19 -12
  47. data/app/controllers/faalis/application_controller.rb +8 -7
  48. data/app/controllers/faalis/dashboard_controller.rb +5 -11
  49. data/app/models/faalis/{user → concerns/user}/auth_definitions.rb +6 -1
  50. data/app/models/faalis/{user → concerns/user}/mongoid_fields.rb +8 -2
  51. data/app/models/faalis/concerns/user/permission.rb +24 -0
  52. data/app/models/faalis/concerns/user/user_roles.rb +20 -0
  53. data/app/models/faalis/group.rb +13 -15
  54. data/app/models/faalis/permission.rb +15 -1
  55. data/app/models/faalis/user.rb +44 -20
  56. data/app/policies/faalis/admin_only_policy.rb +66 -0
  57. data/app/policies/faalis/application_policy.rb +40 -0
  58. data/app/policies/faalis/group_policy.rb +8 -0
  59. data/app/policies/faalis/user_policy.rb +9 -0
  60. data/app/views/{angularjs_templates → angular}/auth/groups/details.html +0 -0
  61. data/app/views/{angularjs_templates → angular}/auth/groups/index.html +0 -0
  62. data/app/views/{angularjs_templates → angular}/auth/groups/new.html +0 -0
  63. data/app/views/{angularjs_templates → angular}/auth/index.html +0 -0
  64. data/app/views/{angularjs_templates → angular}/auth/profile/edit.html +0 -0
  65. data/app/views/{angularjs_templates → angular}/auth/users/details.html +0 -0
  66. data/app/views/{angularjs_templates → angular}/auth/users/index.html +0 -0
  67. data/app/views/{angularjs_templates → angular}/auth/users/new.html +0 -0
  68. data/app/views/{angularjs_templates → angular}/conversations/details.html +0 -0
  69. data/app/views/{angularjs_templates → angular}/conversations/index.html +0 -0
  70. data/app/views/{angularjs_templates → angular}/conversations/new.html +0 -0
  71. data/app/views/{angularjs_templates → angular}/conversations/show.html +0 -0
  72. data/app/views/{angularjs_templates → angular}/conversations/show_details.html +0 -0
  73. data/app/views/angular/faalis/views/generic_add_view.html.slim +5 -0
  74. data/app/views/{angularjs_templates → angular}/fields/boolean/boolean.html +0 -0
  75. data/app/views/{angularjs_templates → angular}/fields/control-combo/control-list.html +0 -0
  76. data/app/views/{angularjs_templates → angular}/fields/datetime/datetime.html +0 -0
  77. data/app/views/{angularjs_templates → angular}/fields/datetime/time.html +0 -0
  78. data/app/views/angular/fields/file/file.html.slim +0 -0
  79. data/app/views/{angularjs_templates → angular}/fields/float/float.html +0 -0
  80. data/app/views/{angularjs_templates → angular}/fields/image/image.html +0 -0
  81. data/app/views/{angularjs_templates → angular}/fields/integer/integer.html +0 -0
  82. data/app/views/{angularjs_templates → angular}/fields/relation/relation.html +0 -0
  83. data/app/views/{angularjs_templates → angular}/fields/string/string.html +0 -0
  84. data/app/views/{angularjs_templates → angular}/fields/tag/tag.html +0 -0
  85. data/app/views/{angularjs_templates → angular}/fields/text/text.html +0 -0
  86. data/app/views/{angularjs_templates → angular}/filter/index.html +0 -0
  87. data/app/views/{angularjs_templates → angular}/index.html +0 -0
  88. data/app/views/{angularjs_templates → angular}/locale/fa.po +0 -0
  89. data/app/views/{angularjs_templates → angular}/locale/templates.pot +0 -0
  90. data/app/views/{angularjs_templates → angular}/logs/index.html +0 -0
  91. data/app/views/angular/modules.html +0 -0
  92. data/app/views/{angularjs_templates → angular}/nav.html.erb +0 -0
  93. data/app/views/faalis/api/v1/groups/index.json.jbuilder +1 -1
  94. data/app/views/faalis/api/v1/permissions/index.json.jbuilder +1 -1
  95. data/app/views/faalis/dashboard/index.html.erb +1 -1
  96. data/app/views/layouts/faalis/application.html.erb +1 -1
  97. data/config/routes.rb +1 -7
  98. data/config/spring.rb +1 -0
  99. data/db/migrate/20131013091000_devise_create_faalis_users.rb +4 -4
  100. data/db/migrate/20131020124701_create_faalis_groups.rb +3 -0
  101. data/db/migrate/20131021170923_create_faalis_permissions.rb +2 -0
  102. data/db/seeds.rb +15 -13
  103. data/lib/faalis.rb +2 -2
  104. data/lib/faalis/concerns/authorizable.rb +1 -0
  105. data/lib/faalis/engine.rb +15 -16
  106. data/lib/faalis/{extensions.rb → extension.rb} +1 -1
  107. data/lib/faalis/{extensions → extension}/base.rb +0 -0
  108. data/lib/faalis/fake_assets.rb +2 -0
  109. data/lib/faalis/generators/concerns.rb +1 -1
  110. data/lib/faalis/generators/concerns/angular.rb +1 -1
  111. data/lib/faalis/generators/concerns/bulk.rb +1 -2
  112. data/lib/faalis/generators/concerns/input_file.rb +49 -0
  113. data/lib/faalis/generators/concerns/resource_fields.rb +4 -0
  114. data/lib/faalis/generators/concerns/tabs.rb +1 -1
  115. data/lib/faalis/generators/dashboard_scaffold.rb +3 -1
  116. data/lib/faalis/i18n.rb +1 -0
  117. data/lib/faalis/route.rb +26 -9
  118. data/lib/faalis/version.rb +1 -1
  119. data/lib/faalis_application.rb +442 -0
  120. data/lib/generators/faalis/install_generator.rb +4 -2
  121. data/lib/generators/faalis/js/list_view_generator.rb +3 -22
  122. data/lib/generators/faalis/scaffold_generator.rb +7 -10
  123. data/lib/generators/faalis/templates/README +0 -7
  124. data/lib/generators/faalis/templates/angularjs/module.js.erb +4 -1
  125. data/lib/generators/faalis/templates/api/controller.rb.erb +18 -21
  126. data/lib/generators/faalis/templates/application.js +14 -1
  127. data/lib/generators/faalis/templates/faalis.rb +3 -1
  128. data/lib/generators/faalis/templates/i18n/Gruntfile.js.erb +2 -2
  129. data/lib/generators/faalis/templates/js/list_view/partials/add_controller.js.erb +3 -3
  130. data/lib/generators/faalis/views_generator.rb +1 -1
  131. data/lib/tasks/docs.rake +6 -0
  132. data/lib/tasks/faalis_tasks.rake +1 -0
  133. data/lib/tasks/grunt/Gruntfile.js +3 -3
  134. data/spec/dummy/app/controllers/api_controller.rb +5 -0
  135. data/spec/dummy/config/initializers/faalis.rb +3 -3
  136. data/spec/dummy/db/development.sqlite3 +0 -0
  137. data/spec/dummy/db/migrate/20150121060012_create_application_models.model_discovery_engine.rb +10 -0
  138. data/spec/dummy/db/schema.rb +71 -0
  139. data/spec/dummy/db/test.sqlite3 +0 -0
  140. data/spec/dummy/log/development.log +544 -0
  141. data/spec/dummy/log/test.log +12354 -0
  142. data/spec/factories/faalis/groups.rb +31 -0
  143. data/spec/factories/faalis/permissions.rb +16 -0
  144. data/spec/factories/faalis/users.rb +23 -0
  145. data/spec/models/faalis/group_spec.rb +32 -0
  146. data/spec/models/faalis/permission_spec.rb +15 -0
  147. data/spec/models/faalis/user_spec.rb +100 -0
  148. data/spec/policies/faalis/admin_only_policy_spec.rb +39 -0
  149. data/spec/policies/faalis/application_policy_spec.rb +49 -0
  150. data/spec/spec_helper.rb +26 -5
  151. data/spec/support/factory_girl.rb +3 -0
  152. metadata +225 -102
  153. data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +0 -155
  154. data/app/assets/javascripts/faalis/dashboard/modules/permissions.js +0 -52
  155. data/app/controllers/faalis/#api_controller.rb# +0 -51
  156. data/app/controllers/faalis/#dashboard_controller.rb# +0 -65
  157. data/app/models/ability.rb +0 -40
  158. data/app/models/faalis/user/permission.rb +0 -21
  159. data/app/views/angularjs_templates/modules.html +0 -17
  160. data/db/migrate/20140617124019_faalis_groups_users.rb +0 -4
  161. data/lib/faalis/generators/concerns/json_input.rb +0 -41
  162. data/lib/faalis/generators/fields/#relation.rb# +0 -61
  163. data/lib/faalis/patches/models.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: decd01b9d5bbffe1b8191a729790ba08c06cb249
4
- data.tar.gz: 210c6a7fbd8c2e7503aebc239c67f80e016765a1
3
+ metadata.gz: 6acd4dada94f462b0bf0aa50e1cfbd4115ab945e
4
+ data.tar.gz: a107748b9fc00d9b5c3281910d1af983777f5fd3
5
5
  SHA512:
6
- metadata.gz: 0a5cafb51d5ecea46ed6984ffd27f7c961100d2c98dd40d1bcddff420c77520ee8ab5175c06e6090886ce585b3728a032bf7755c6852b2e794bc354798519aa4
7
- data.tar.gz: a560057a8878fdcb0c152ac6dce76b859f5fa09d368053e3d9b5498c297bb87f494df9cf72e54cfa1d078b0f68acc9c1fda3f22442a4d4bd8e9bad73f7676d5e
6
+ metadata.gz: 099ac71657da9936d8fadb270eacfd040a6995648f17a8c940bfd78daad7c811a582b5b864d6eb6cbe2eee23f29208e0ee39a9712cc44f884b1412be8baa1734
7
+ data.tar.gz: 4dd6caa442bc1bc3e69e672a676fd4921a7e290c35a9e36abacf89f95d0e2a0d09cc59344d55bbcc91d1de57f74d79909e6f68970db398bb37db2d8991ea002f
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
- # Faalis [![Gem Version](https://badge.fury.io/rb/faalis.png)](http://badge.fury.io/rb/faalis) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Yellowen/Faalis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
2
-
1
+ # Faalis
2
+ [![Gem Version](https://badge.fury.io/rb/faalis.png)](http://badge.fury.io/rb/faalis)
3
+ [![Build Status](https://travis-ci.org/Yellowen/Faalis.svg?branch=master)](https://travis-ci.org/Yellowen/Faalis)
4
+ [![Downloads](https://img.shields.io/gem/dt/faalis.svg)](http://rubygems/gems/faalis)
3
5
 
4
6
  **Faalis** is a **RubyOnRails** Platform for rapid web application development. It provides a very
5
7
  robust dashboard subsystem with some fantastic generators and client side framework based on **AngularJS**
@@ -33,7 +35,7 @@ gem "dashstrap"
33
35
  gem "faalis"
34
36
  ```
35
37
 
36
- * Iinstall your project dependencies using `bundle`
38
+ * Install your project dependencies using `bundle`
37
39
 
38
40
  ```ruby
39
41
  bundle install
@@ -47,14 +49,14 @@ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
47
49
  > In production, `:host` should be set to the actual host of your application.
48
50
 
49
51
  * Ensure you have flash messages in `app/views/layouts/application.html.erb`.
50
- For example (Only if you want to change default layout):
52
+ For example (only if you want to change default layout):
51
53
 
52
54
  ```rhtml
53
55
  <p class="notice"><%= notice %></p>
54
56
  <p class="alert"><%= alert %></p>
55
57
  ```
56
58
 
57
- * Perfrom `rails generate faalis:install_all` to copy necessary files.
59
+ * Perform `rails generate faalis:install_all` to copy necessary files.
58
60
  * Add this to your `config/routes.rb` :
59
61
 
60
62
  ```ruby
@@ -64,10 +66,10 @@ Faalis::Routes.define_api_routes
64
66
 
65
67
  * Perform `rake db:migrate` and enjoy Faalis
66
68
 
67
- > **NOTE**: You change the orm you like to use in `config/initializers/faalis.rb`
69
+ > **NOTE**: You can specify the ORM you'd like to use in `config/initializers/faalis.rb`
68
70
 
69
71
  ## Documents
70
- There is couple of guides along side with **Ruby** and **JavaScript** API documents
72
+ There are a couple of guides along with **Ruby** and **JavaScript** API documents
71
73
  inside the source tree. We use `yardoc` so you can build them easily or look at automated [rubydoc](http://rubydoc.info/gems/faalis)
72
74
  docs.
73
75
 
@@ -81,8 +83,7 @@ Also take a look at [Wiki of Faalis](https://github.com/Yellowen/Faalis/wiki).
81
83
  4. Push to the branch (`git push origin my-new-feature`)
82
84
  5. Create new Pull Request
83
85
 
84
- Also you can join us in our `Gitter` group:
85
- [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Yellowen/Faalis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
86
+ Also you can join us in our `IRC` channel: **#Faalis** on freenode. ( It will redirect you to #5hit :P )
86
87
 
87
88
  ## Credit
88
89
  ![Yellowen](http://www.yellowen.com/images/logo.png)
@@ -92,4 +93,4 @@ Also you can join us in our `Gitter` group:
92
93
 
93
94
  # License
94
95
 
95
- **Faalis** is Copyright © 2013-2014 Yellowen. It is free software, and may be redistributed under the terms specified in the LICENSE file.
96
+ **Faalis** is Copyright © 2013-2015 Yellowen. It is free software, and may be redistributed under the terms specified in the LICENSE file.
data/Rakefile CHANGED
@@ -1,11 +1,15 @@
1
1
  require 'gettext_i18n_rails/tasks'
2
+ require 'rubygems'
3
+
2
4
  begin
3
5
  require 'bundler/setup'
4
6
  rescue LoadError
5
7
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
8
  end
7
9
 
8
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
10
+ #Bundler.setup(ENV['RAILS_ENV'] || :default)
11
+
12
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
9
13
  load 'rails/tasks/engine.rake'
10
14
 
11
15
  Bundler::GemHelper.install_tasks
@@ -13,7 +17,7 @@ Bundler::GemHelper.install_tasks
13
17
  require 'rspec/core'
14
18
  require 'rspec/core/rake_task'
15
19
 
16
- desc "Run all specs in spec directory (excluding plugin specs)"
20
+ desc 'Run all specs in spec directory (excluding plugin specs)'
17
21
  RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
18
22
  task :default => :spec
19
23
 
@@ -7,7 +7,9 @@
7
7
  //= require angular-route
8
8
  //= require angular-sanitize
9
9
  //= require angular-gettext/angular-gettext
10
+ //= require angular-ui-router/angular-ui-router
10
11
  //= require lodash
12
+ //= require sugar/sugar-full.development
11
13
  //= require restangular/restangular
12
14
  //= require ng-grid/ng-grid
13
15
  //= require ngQuickDate/ng-quick-date
@@ -16,3 +18,4 @@
16
18
  //= require flow
17
19
  //= require ng-flow
18
20
  //= require faalis/dashboard/functions
21
+ //= require_tree ./dashboard/lib
@@ -12,6 +12,5 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require foundation
16
15
  //= require_self
17
16
  //= require_directory .
@@ -3,21 +3,35 @@
3
3
  //= require_self
4
4
  //= require ./locale/translations
5
5
 
6
- var dependencies = ["gettext", "Modules", "ui.select2",
7
- "ngAnimate", "ngRoute", "restangular", "ngQuickDate",
8
- "Errors", "Profile", "Permissions"].concat(dashboard_dependencies);
6
+ var dependencies = window.STATIC_REQUIREMENTS.concat(window.dashboard_dependencies);
7
+
8
+ //Faalis.$injector = angular.injector(dependencies.concat(['ng', 'gettext']));
9
+
10
+ Faalis.$injector = angular.injector(['ng', 'Errors', 'gettext']);
9
11
 
10
12
  console.log("Dashboard dependencies:");
11
13
  console.log(dependencies);
12
14
 
13
15
  var Dashboard = angular.module("Dashboard", dependencies);
14
16
 
15
- Dashboard.config(["$routeProvider", "RestangularProvider", "$httpProvider", "ngQuickDateDefaultsProvider", function($routeProvider, RestangularProvider, $httpProvider, ngQuickDateDefaultsProvider) {
17
+ Dashboard.config(["$stateProvider","$urlRouterProvider", "RestangularProvider", "$httpProvider", "ngQuickDateDefaultsProvider", function($stateProvider, $urlRouterProvider , RestangularProvider, $httpProvider, ngQuickDateDefaultsProvider) {
16
18
 
17
- $routeProvider.when("/", {
18
- templateUrl: template("index")
19
+ $stateProvider.state("root", {
20
+ url: "",
21
+ templateUrl: template_url("index")
22
+ }).state("home", {
23
+ url: "/",
24
+ templateUrl: template_url("index")
25
+ }).state("not_find", {
26
+ url: "/403",
27
+ templateUrl: template_url("403")
28
+ }).state("permission_denied", {
29
+ url: "/404",
30
+ templateUrl: template_url("404")
19
31
  });
20
32
 
33
+ $urlRouterProvider.otherwise('/404');
34
+
21
35
  ngQuickDateDefaultsProvider.set({
22
36
  closeButtonHtml: "<i class='fa fa-times'></i>",
23
37
  buttonIconHtml: "<i class='fa fa-calendar'></i>",
@@ -12,4 +12,8 @@
12
12
  //
13
13
  //= require faalis/dashboard/init
14
14
  //= require faalis/dashboard/app
15
- //= require_tree .
15
+ //= require_tree ./lib
16
+ //= require_tree ./resources
17
+ //= require_tree ./modules
18
+ //= require_tree ./services
19
+ //= require_tree ./controllers
@@ -0,0 +1,42 @@
1
+ # Group module
2
+ Group = angular.module "Group", ["ListView", "Errors", "ui.router",
3
+ "Auth", "Faalis.Controllers"]
4
+
5
+ Group.config ["$stateProvider", "ResourcesProvider",
6
+ ($stateProvider, ResourcesProvider) ->
7
+
8
+ $stateProvider.
9
+ state("groups",{
10
+ url: "/auth/groups",
11
+ templateUrl: template_url("auth/groups/index"),
12
+ controller: "Faalis.GenericIndexController"
13
+ }).
14
+ state("groups.new",{
15
+ url: "/new",
16
+ templateUrl: template_url("auth/groups/new"),
17
+ controller: "NewGroupController"
18
+ }).
19
+ state("groups.edit",{
20
+ url: "/:id/edit",
21
+ templateUrl: template_url("auth/groups/new"),
22
+ controller: "AddGroupController"
23
+ })
24
+
25
+ group = new Faalis.GroupResource()
26
+ ResourcesProvider.resources = [group]
27
+ ]
28
+
29
+
30
+ Group.controller "NewGroupController", ["$state", "$rootScope", "$scope", "Resources", "$stateParams", "gettext",
31
+ ($state, $rootScope, $scope, Resources, $stateParams, _) ->
32
+
33
+
34
+ $scope.resource = Resources.main_resource()
35
+ $scope.group = {}
36
+
37
+ $rootScope.section_name = _("Groups")
38
+ $rootScope.section_slug = _("Add")
39
+
40
+ resource.initialize($stateParams)
41
+
42
+ ]
@@ -1,6 +1,8 @@
1
1
  function add_dependency(module) {
2
+
2
3
  window.dashboard_dependencies = window.dashboard_dependencies || [];
3
4
  window.dashboard_dependencies.push(module);
5
+
4
6
  }
5
7
 
6
8
  function debug(msg) {
@@ -47,6 +49,14 @@ function template(path){
47
49
  return templates_path + path + ".html";
48
50
  }
49
51
 
52
+ /*
53
+ * This function returns the currect path to a template
54
+ */
55
+ function template_url(path){
56
+ //console.log(templates_path + path + ".html");
57
+ return templates_path + path + ".html";
58
+ }
59
+
50
60
  /*
51
61
  * Check for page direction
52
62
  */
@@ -54,6 +64,16 @@ function is_ltr(){
54
64
  return $("html").attr("dir") == "ltr" ? true : false;
55
65
  }
56
66
 
67
+
68
+ /*
69
+ * Return current language of page
70
+ */
71
+ function current_language(){
72
+ return $("html").attr("lang");
73
+ }
74
+
75
+
76
+
57
77
  /*
58
78
  * Show subnav
59
79
  */
@@ -1,6 +1,6 @@
1
1
  //= require faalis/dashboard/objects
2
2
  // Get all the modules syncly
3
- console.log(DashboardURL);
3
+
4
4
  $.ajax({method: 'GET', type: 'json', async: false,
5
5
  url: DashboardURL + '.json'})
6
6
  .success(function(data, status, headers, config){
@@ -0,0 +1,17 @@
1
+ # This class represent a button to use in **Faalis** views.
2
+ class Faalis.Button
3
+ # options:
4
+ # * **title**: Title of the button
5
+ # * **icon**: Icon class to use in button
6
+ # * **classess**: Classes to assign the button element
7
+ # * **route**: Target route of the button, if any.
8
+ # * **on_click**: If provided it would have higher priority over **route**
9
+ # * **permission**: Required permission for user.
10
+ constructor: (options = {})->
11
+ @title = options.title
12
+ @icon = options.icon
13
+ @classes = options.classes || "btn btn-sm"
14
+ @route = options.route
15
+ @on_click = options.on_click
16
+
17
+ @required_permission = options.permission
@@ -0,0 +1,11 @@
1
+ Faalis.Factory = (controller, resource_name, options = {}) ->
2
+ resource = resource_name
3
+ if typeof(resource) != "object"
4
+ resource = new Resource('resource')
5
+
6
+ console.log("sadasda")
7
+ dup_controller = class extends controller
8
+ console.log("zxczxc")
9
+ dup_controller.resource = resource
10
+ console.log(dup_controller.resource)
11
+ return dup_controller
@@ -0,0 +1,14 @@
1
+ # Father of all the client side controllers of **Faalis**
2
+ class Faalis.BaseController
3
+ # **scope_obj** is an **AngularJS** scope instance that child
4
+ # class should provide using `super` syntax
5
+ constructor: (scope_obj)->
6
+
7
+ # Inject all the methods in current object prototype
8
+ # to the scope except for those which starts with an
9
+ # underscore.
10
+ Object.keys(this.__proto__, (key) ->
11
+ if (this[key] instanceof Function)
12
+ unless key.startsWith('_')
13
+ scope_obj[key] = this[key]
14
+ )
@@ -0,0 +1,33 @@
1
+ # General controller for a resource creation. As you can see it extends the faalis base
2
+ # controller.
3
+ class Faalis.GenericAddController extends Faalis.BaseController
4
+
5
+ constructor: ($scope, _, API, Resource, $rootScope, $state, $stateParams, $user) ->
6
+ # Call constructor of **Faalis.BaseController** which maps all
7
+ # the methods (prototype methods) of current object to $scope except of those that
8
+ # their name starts with a '_' ( underscore ). Those methods are reserved for internal
9
+ # usage.
10
+ super $scope
11
+
12
+ # Isn't it obvious ?
13
+ # Ok for those who are a little slow. I just mapped angular services
14
+ # accessible in this method scope to class level scope.
15
+ @scope = $scope
16
+ @_ = _
17
+ @API = API
18
+ @Resource = Resource
19
+ @rootScope = $rootScope
20
+ @state = $state
21
+ @stateParams = $stateParams
22
+ @user = $user
23
+
24
+ @__init__()
25
+
26
+ # ## Internal methods
27
+ __init__: ->
28
+ @Resource.initialize
29
+
30
+
31
+
32
+ Faalis.GenericAddController.$inject = ["$scope", "gettext", "APIFactory", "Resource", "$rootScope", "$state", "$stateParams", "$user"]
33
+ angular.module('Faalis.Controllers', ["API", "Resource", "User"]).controller("Faalis.GenericAddController", Faalis.GenericIndexController)
@@ -0,0 +1,85 @@
1
+ # General controller for a resource index. As you can see it extends the faalis base
2
+ # controller.
3
+ class Faalis.GenericIndexController extends Faalis.BaseController
4
+
5
+ constructor: ($scope, _, Resources, $rootScope, $state, $stateParams, $user) ->
6
+ # Call constructor of **Faalis.BaseController** which maps all
7
+ # the methods (prototype methods) of current object to $scope except of those that
8
+ # their name starts with a '_' ( underscore ). Those methods are reserved for internal
9
+ # usage.
10
+ super $scope
11
+
12
+ # Isn't it obvious ?
13
+ # Ok for those who are a little slow. I just mapped angular services
14
+ # accessible in this method scope to class level scope.
15
+ @scope = $scope
16
+ @_ = _
17
+ @Resource = Resources.main_resource()
18
+ @rootScope = $rootScope
19
+ @state = $state
20
+ @stateParams = $stateParams
21
+ @user = $user
22
+
23
+ @__init__()
24
+ @__setup_buttons__()
25
+ @__fetch_resources__()
26
+ return
27
+ # ## Internal methods
28
+
29
+ # This method is used for initializing process at the begining of the controller
30
+ # Users can override this method base on their needs
31
+ __init__: ->
32
+ # Set the list of objects at the angular scope.
33
+ # For example if our **Resource** name was 'group'
34
+ # it will create `$scope.groups`.
35
+ @scope[@Resource.plural_name()] = new Array()
36
+ @Resource.initialize(@stateParams)
37
+
38
+ # Container header informations
39
+ @rootScope.section_name = @_(@Resource.plural_name().capitalize())
40
+ @rootScope.section_slug = @_("list")
41
+
42
+ # List view template
43
+ @scope.details_template = template_url(@Resource.__detail_template__())
44
+
45
+ # List of buttons to use in index view. If you need more
46
+ # buttons in you own controller, just override this method.
47
+ # **Note**: Checkout **Faalis.Button** class for more details.
48
+ __buttons__: ->
49
+ return [
50
+ new Faalis.Button({
51
+ title: @_("New " + @Resource.__name__.capitalize()),
52
+ icon: "fa fa-plus",
53
+ classes: "btn btn-success btn-sm",
54
+ route: @state.href(@Resource.plural_name().underscore() + '.new')
55
+ permission: 'create'
56
+ })
57
+ ]
58
+
59
+ # Setup up buttons based on user permissions.
60
+ __setup_buttons__: ->
61
+
62
+ @scope.buttons = []
63
+
64
+ for button in @__buttons__()
65
+ if @user.can button.permission, @Resource.__name__
66
+ @scope.buttons.push(button)
67
+
68
+ # Fetch remote resource using API interface
69
+ __fetch_resources__: ->
70
+ Resource = @Resource
71
+ scope = @scope
72
+
73
+ @Resource.all()
74
+ .then (data) ->
75
+ scope[Resource.plural_name()] = data
76
+ scope.$apply()
77
+
78
+ on_delete: (resources) ->
79
+
80
+
81
+
82
+ Faalis.GenericIndexController.$inject = ["$scope", "gettext", "Resources", "$rootScope", "$state", "$stateParams", "$user"]
83
+
84
+ angular.module('Faalis.Controllers', ["Faalis.ResourceFactory", "User"])
85
+ .controller("Faalis.GenericIndexController", Faalis.GenericIndexController)
@@ -0,0 +1,6 @@
1
+ # Base of all **Faalis** fields
2
+ class Faalis.BaseField
3
+ constructor: (@name) ->
4
+
5
+ __init__: [ ->
6
+ ]
@@ -0,0 +1,4 @@
1
+ class Faalis.HasManyField extends Faalis.BaseField
2
+ type: 'has_many'
3
+
4
+ constructor: (@name, @to) ->