faalis 0.7.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/faalis/dashboard/app.js +24 -9
  3. data/app/assets/javascripts/faalis/dashboard/application.js.erb +0 -1
  4. data/app/assets/javascripts/faalis/dashboard/functions.js.erb +4 -0
  5. data/app/assets/javascripts/faalis/dashboard/modules/anim.js +1 -1
  6. data/app/assets/javascripts/faalis/dashboard/modules/conversations.js +180 -0
  7. data/app/assets/javascripts/faalis/dashboard/modules/fields/boolean.js +49 -0
  8. data/app/assets/javascripts/faalis/dashboard/modules/fields/datetime.js +50 -0
  9. data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +1 -0
  10. data/app/assets/javascripts/faalis/dashboard/modules/fields/integer.js +50 -0
  11. data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +78 -0
  12. data/app/assets/javascripts/faalis/dashboard/modules/fields/string.js +49 -0
  13. data/app/assets/javascripts/faalis/dashboard/modules/fields/text.js +50 -0
  14. data/app/assets/javascripts/faalis/dashboard/modules/list-view.js +14 -1
  15. data/app/assets/javascripts/faalis/dashboard/modules/nav.js.erb +1 -1
  16. data/app/assets/javascripts/faalis/dashboard/modules/permissions.js +71 -0
  17. data/app/assets/javascripts/faalis/dashboard/variables.js.erb +2 -0
  18. data/app/assets/stylesheets/faalis/base.css.scss +28 -0
  19. data/app/controllers/faalis/api/v1/conversations_controller.rb +92 -0
  20. data/app/controllers/faalis/api/v1/permissions_controller.rb +39 -3
  21. data/app/controllers/faalis/dashboard_controller.rb +18 -1
  22. data/app/models/faalis/permissions/auth.rb +3 -0
  23. data/app/models/faalis/user.rb +3 -0
  24. data/app/views/angularjs_templates/auth/groups/new.html +7 -3
  25. data/app/views/angularjs_templates/auth/users/details.html +1 -1
  26. data/app/views/angularjs_templates/auth/users/new.html +4 -3
  27. data/app/views/angularjs_templates/conversations/details.html +18 -0
  28. data/app/views/angularjs_templates/conversations/index.html +6 -0
  29. data/app/views/angularjs_templates/conversations/new.html +39 -0
  30. data/app/views/angularjs_templates/conversations/show.html +6 -0
  31. data/app/views/angularjs_templates/conversations/show_details.html +18 -0
  32. data/app/views/angularjs_templates/fields/boolean/boolean.html +4 -0
  33. data/app/views/angularjs_templates/fields/datetime/datetime.html +4 -0
  34. data/app/views/angularjs_templates/fields/integer/integer.html +4 -0
  35. data/app/views/angularjs_templates/fields/relation/relation.html +28 -0
  36. data/app/views/angularjs_templates/fields/string/string.html +4 -0
  37. data/app/views/angularjs_templates/fields/text/text.html +4 -0
  38. data/app/views/angularjs_templates/list-view/index.html +1 -1
  39. data/app/views/angularjs_templates/modules.html +2 -2
  40. data/app/views/faalis/api/v1/conversations/create.json.jbuilder +1 -0
  41. data/app/views/faalis/api/v1/conversations/index.json.jbuilder +1 -0
  42. data/app/views/faalis/api/v1/conversations/show.json.jbuilder +10 -0
  43. data/app/views/faalis/api/v1/permissions/user_permissions.json.jbuilder +1 -0
  44. data/app/views/layouts/faalis/dashboard.html.erb +1 -1
  45. data/config/routes.rb +13 -2
  46. data/db/migrate/{20131013091000_devise_create_red_base_users.rb → 20131013091000_devise_create_faalis_users.rb} +0 -0
  47. data/db/migrate/{20131020124701_create_red_base_groups.rb → 20131020124701_create_faalis_groups.rb} +0 -0
  48. data/db/migrate/{20131021170923_create_red_base_permissions.rb → 20131021170923_create_faalis_permissions.rb} +0 -0
  49. data/db/seeds.rb +2 -0
  50. data/lib/faalis.rb +1 -0
  51. data/lib/faalis/active_record.rb +1 -56
  52. data/lib/faalis/engine.rb +1 -0
  53. data/lib/faalis/permissions.rb +65 -0
  54. data/lib/faalis/version.rb +1 -1
  55. data/lib/generators/faalis/install_generator.rb +4 -0
  56. data/lib/generators/faalis/js_scaffold_generator.rb +27 -8
  57. data/lib/generators/faalis/templates/angularjs/module.js.erb +11 -7
  58. data/lib/generators/faalis/templates/angularjs/new.html.erb +35 -78
  59. metadata +51 -11
  60. data/app/views/angularjs_templates/#index.html# +0 -8
@@ -0,0 +1,3 @@
1
+ class Faalis::Permissions::Auth
2
+ include Faalis::Permissions
3
+ end
@@ -19,6 +19,9 @@
19
19
 
20
20
  module Faalis
21
21
  class User < ActiveRecord::Base
22
+ #acts as messageable for mailboxer
23
+ acts_as_messageable
24
+
22
25
  validates :password, presence: true, length: {minimum: 5, maximum: 120}, on: :create
23
26
  validates :password, length: {minimum: 5, maximum: 120}, on: :update, allow_blank: true
24
27
  validates :email, presence: true, length: {minimum: 6}
@@ -1,4 +1,6 @@
1
1
  <div class="newform">
2
+ <form name="from" novalidate>
3
+
2
4
  <fieldset class="form">
3
5
 
4
6
  <legend ng-if="!editing"><span translate>New Group</span></legend>
@@ -7,7 +9,7 @@
7
9
  <div class="row">
8
10
  <div class="small-4 columns">
9
11
  <label translate>Name :</label>
10
- <input id="id_name" ng-model="new_name" type="text" class="">
12
+ <input id="id_name" ng-model="new_name" type="text" required>
11
13
  <small id="id_name_msg"></small>
12
14
  </div>
13
15
  </div>
@@ -21,7 +23,7 @@
21
23
  <div id="id_permissions" class="small-8 columns field">
22
24
  <ul>
23
25
 
24
- <li ng-repeat="permission in permissions" id="{{permission.name}}" class="" ng-click="select_permission(permission)"> <i ng-show="is_selected(permission)" class="fa fa-check"></i> {{ permission.string }} </li>
26
+ <li ng-repeat="permission in permissions" id="{{permission.name}}" ng-click="select_permission(permission)"> <i ng-show="is_selected(permission)" class="fa fa-check"></i> {{ permission.string }} </li>
25
27
 
26
28
  </ul>
27
29
  </div>
@@ -34,8 +36,10 @@
34
36
 
35
37
  <div class="row">
36
38
  <div class="small-6 columns">
37
- <button class="btn small green" ng-click="save()"><i class="fa fa-check"></i> <span translate>Save</span></button>
39
+ <button class="btn small green" ng-click="save()" ng-disabled="form.$invalid"><i class="fa fa-check"></i> <span translate>Save</span></button>
38
40
  <button class="btn small red" ng-click="cancel()"><i class="fa fa-times"></i><span translate>Cansel</span></button>
39
41
  </div>
40
42
  </div>
43
+ </form>
44
+
41
45
  </div>
@@ -15,7 +15,7 @@
15
15
  </p>
16
16
 
17
17
  <ul class="button-group float-right">
18
- <a href="#/auth/users/{{this.object.id}}/edit" class="small">
18
+ <a href="#/auth/users/{{this.object.id}}/reply" class="small">
19
19
  <span class="fa fa-edit"></span> <span translated>Edit</span>
20
20
  </a>
21
21
  <a href="" class="small">
@@ -1,4 +1,5 @@
1
1
  <div class="newform">
2
+ <form novalidate name="form">
2
3
  <fieldset class="form">
3
4
 
4
5
  <legend translate>New User</legend>
@@ -6,7 +7,7 @@
6
7
  <div class="row">
7
8
  <div class="small-4 columns">
8
9
  <label for="first_name" translate>First Name :</label>
9
- <input id="id_first_name" type="text" name="first_name" required ng-model="first_name" required>
10
+ <input id="id_first_name" type="text" name="first_name" required ng-model="first_name">
10
11
  <small id="id_first_name_msg"></small>
11
12
  </div>
12
13
 
@@ -48,9 +49,9 @@
48
49
 
49
50
  <div class="row">
50
51
  <div class="small-4 columns">
51
- <button ng-click="save()" class="btn small green" ng-disabled="form.first_name.$pristine || form.first_name.$dirty && form.fist_name.$invalid"><i class="fa fa-check"></i> <span translate>Save</span></button>
52
+ <button ng-click="save()" class="btn small green" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save</span></button>
52
53
  <button ng-click="cancel()" class="btn small red"><i class="fa fa-times"></i> <span translate>Cancel</span></button>
53
54
  </div>
54
55
  </div>
55
-
56
+ </form>
56
57
  </div>
@@ -0,0 +1,18 @@
1
+ <div class="details">
2
+ <p>
3
+ <b translate>Sent at : </b>{{this.object.created_at}} &nbsp;&nbsp;&nbsp; <b translate>Last Update : </b>{{this.object.updated_at}}
4
+ </p>
5
+
6
+ <ul class="button-group float-right">
7
+ <a class="small" href="#/conversations/{{this.object.id}}/show">
8
+ <span class="fa fa-eye"></span> <span translated>Read </span>
9
+ </a>
10
+ <a class="small" href="#/conversations/{{this.object.id}}/reply">
11
+ <span class="fa fa-edit"></span> <span translated>Reply</span>
12
+ </a>
13
+ <a class="small" ng-click="this.on_trash(this.object)">
14
+ <span class="fa fa-edit"></span> <span translated>Trash</span>
15
+ </a>
16
+ </a>
17
+ </ul>
18
+ </div>
@@ -0,0 +1,6 @@
1
+ <list-view buttons="buttons" objects="conversations" title-attribute="'subject'" details-template="details_template" item-per-page="10" on_delete="on_trash">
2
+
3
+ <div class="small-6 column text-left clearpadding">
4
+ <h3><i class="fa fa-group"></i> <span translate>Conversations</span></h3>
5
+ </div>
6
+ </list-view>
@@ -0,0 +1,39 @@
1
+ <div class="newform">
2
+ <form novalidate name="form">
3
+ <fieldset class="form">
4
+
5
+ <legend translate>New User</legend>
6
+
7
+ <div class="row">
8
+ <div class="small-4 columns">
9
+ <label for="recipients" translate> Recipient(s):</label>
10
+ <input id="id_recipients" type="text" name="recipients" required ng-model="recipients">
11
+ <small id="id_recipients_msg"></small>
12
+ </div>
13
+ </div>
14
+ <div class="row">
15
+
16
+ <div class="small-4 columns float-left">
17
+ <label for="subject" translate>subject :</label>
18
+ <input id="id_subject" type="text" name="subject" required ng-model="subject">
19
+ <small id="id_subject_msg"></small>
20
+ </div>
21
+ </div>
22
+ <div class="row">
23
+ <div class="small-8 columns float-left ">
24
+ <label for="body" translate>Message :</label>
25
+ <textarea id="id_body" name="body" required ng-model="body"></textarea>
26
+ <small id="id_body_msg"></small>
27
+ </div>
28
+ </div>
29
+
30
+ </fieldset>
31
+
32
+ <div class="row">
33
+ <div class="small-4 columns">
34
+ <button ng-click="save()" class="btn small green" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Send</span></button>
35
+ <button ng-click="cancel()" class="btn small red"><i class="fa fa-times"></i> <span translate>Cancel</span></button>
36
+ </div>
37
+ </div>
38
+ </form>
39
+ </div>
@@ -0,0 +1,6 @@
1
+ <list-view buttons="buttons" objects="conversations" title-attribute="message_title" details-template="details_template" item-per-page="10" on_delete="on_trash">
2
+
3
+ <div class="small-6 column text-left clearpadding">
4
+ <h3><i class="fa fa-group"></i> <span translate>Conversations</span></h3>
5
+ </div>
6
+ </list-view>
@@ -0,0 +1,18 @@
1
+ <div class="details">
2
+ <p>
3
+ <b translate>Sent at : </b>{{this.object.message.created_at}} &nbsp;&nbsp;&nbsp; <b translate>Last Update : </b>{{this.object.message.updateded_at}}
4
+ {{this.object.message.updated_at}}
5
+ </p>
6
+ <p>
7
+ {{this.object.message.body}}
8
+ </p>
9
+ <ul class="button-group float-right">
10
+ <a class="small" href="#/conversations//reply">
11
+ <span class="fa fa-edit"></span> <span translated>Reply</span>
12
+ </a>
13
+ <a class="small" ng-click="this.on_trash(this.object)">
14
+ <span class="fa fa-edit"></span> <span translated>Trash</span>
15
+ </a>
16
+ </a>
17
+ </ul>
18
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <input id="{{ element_id }}" ng-model="model" name="{{ field }}" ng-required="required" type="checkbox" class="{{cssClasses}}" />
3
+ <small id="{{ msg_element_id }}"></small>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <datepicker id="{{ element_id }}" ng-model="model" class="{{cssClasses}}" ng-required="required" name="{{ field }}" placeholder="{{ 'Click to pick a date' | translate }}" />
3
+ <small id="{{ msg_element_id }}"></small>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <input id="{{ element_id }}" ng-model="model" name="{{ field }}" ng-required="required" type="text" class="{{cssClasses}}" />
3
+ <small id="{{ msg_element_id }}"></small>
4
+ </div>
@@ -0,0 +1,28 @@
1
+ <div>
2
+ <select ui-select2="select2Options" id="{{ element_id }}" ng-model="model" name="{{ field.name }}" ng-required="required" ng-if="field.type === 'belongs_to'">
3
+ <option ng-repeat="item in all_options" value="{{ item.id }}" title="{{ item[titleField] || item }}" ng-selected="item.id === model.id">{{ item[titleField] || item }}</option>
4
+ </select>
5
+
6
+ <select ui-select2="select2Options" id="{{ element_id }}" ng-model="model" name="{{ field.name }}" ng-required="required" multiple ng-if="field.type === 'has_many'">
7
+ <option ng-repeat="item in all_options" value="{{ item.id }}" title="{{ item[titleField] || item }}" ng-selected="have(item.id)">{{ item[titleField] || item }}</option>
8
+ </select>
9
+
10
+ <select ui-select2="select2Options" id="{{ element_id }}" ng-model="model" name="{{ field.name }}" ng-required="required" ng-if="field.type === 'in'">
11
+ <option ng-repeat="item in field.choices" value="{{ item.name }}" title="{{ item.title }}" ng-selected="model === item.name">{{ item.title }}</option>
12
+ </select>
13
+
14
+ <!-- Add and Refresh buttons -->
15
+ <div class="float-right relation_links" ng-if="(field.type === 'belongs_to') || (field.type === 'has_many')">
16
+ <span>
17
+ <a ng-href="#{{ field.to }}/new" target="_blank">
18
+ <i class="fa fa-plus"></i>
19
+ </a>
20
+ </span>
21
+ <span ng-click="update_collection()">
22
+ <i class="fa fa-refresh"></i>
23
+ </span>
24
+ </div>
25
+
26
+ <small id="{{ msg_element_id }}"></small>
27
+ <!-- --------------------------------- -->
28
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <input id="{{ element_id }}" ng-model="model" name="{{ field }}" ng-required="required" type="text" class="{{cssClasses}}" />
3
+ <small id="{{ msg_element_id }}"></small>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <textarea id="{{ element_id }}" ng-model="model" name="{{ field }}" ng-required="required" class="{{cssClasses}}"></textarea>
3
+ <small id="{{ msg_element_id }}"></small>
4
+ </div>
@@ -28,7 +28,7 @@
28
28
  <i ng-click="toggle_details(object)" class="{{ handle_icon }} {{ handle_icon_expand(object) }} handle fa "></i>
29
29
 
30
30
  <div class="title" ng-click="select_item(object)">
31
- {{ object[title_attr] }}
31
+ {{ title(object, title_attr) }}
32
32
  </div>
33
33
 
34
34
  <div ng-show="should_view(object)" class="details">
@@ -2,7 +2,7 @@
2
2
 
3
3
  <li ng-click="controller.on_click('/')"><p><i class="fa fa-dashboard"></i> <span translate>Dashboard</span></p></li>
4
4
 
5
- <li data-ng-repeat="module in controller.modules">
5
+ <li data-ng-repeat="module in controller.modules" if-user="user.can('read', module.model)">
6
6
  <p ng-click="controller.view_menu(module)"><i class="{{ module.icon }}"></i> <span translate>{{ module.title }}</span></p>
7
7
  <ul class="submenu slide" ng-if="module.show_menu">
8
8
  <li ng-repeat="menu_item in module.menu_items" ng-click="controller.on_click(menu_item.url)"><span>{{ menu_item.title }}</span></li>
@@ -12,6 +12,6 @@
12
12
  </ul>
13
13
 
14
14
  <div class="brand">
15
- <h1 translate>Site_Title</h1>
15
+ <h1 translate><%= Faalis::Engine.site_title %></h1>
16
16
  <span translate>Some_Slug</span>
17
17
  </div>
@@ -0,0 +1 @@
1
+ json.extract! @conversation
@@ -0,0 +1 @@
1
+ json.array! @mailbox
@@ -0,0 +1,10 @@
1
+ json.extract! @conversations, :id, :subject, :created_at, :updated_at
2
+
3
+ json.messages @conversations.messages do |m|
4
+ json.subject m.subject
5
+ json.body m.body
6
+ end
7
+
8
+ json.recipients @conversations.recipients do |m|
9
+ json.email m.email
10
+ end
@@ -0,0 +1 @@
1
+ json.permissions @permissions
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html lang="<%= ::I18n.locale %>" dir="<%= Faalis::I18n.direction(I18n.locale) %>" ng-app="Dashboard">
2
+ <html lang="<%= ::I18n.locale %>" dir="<%= Faalis::I18n.direction(I18n.locale) %>">
3
3
  <head>
4
4
  <title><%= Faalis::Engine.site_title %></title>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
data/config/routes.rb CHANGED
@@ -25,12 +25,23 @@ Faalis::Engine.routes.draw do
25
25
  namespace :api, :defaults => {:format => :json} do
26
26
  namespace :v1 do
27
27
  get "permissions", :to => "permissions#index"
28
+ get "permissions/user", :to => "permissions#user_permissions"
28
29
  resources :groups, :except => [:new]
29
30
  resources :users, :except => [:new]
30
31
  resource :profile, :except => [:new, :destroy]
31
32
  get "logs" => "logs#index"
33
+
34
+ resources :conversations, only: [:index, :show, :create] do
35
+ collection do
36
+ get ":box/box" => "conversations#index"
37
+ end
38
+ member do
39
+ post :reply
40
+ post :trash
41
+ post :untrash
42
+ end
43
+
44
+ end
32
45
  end
33
46
  end
34
-
35
-
36
47
  end
data/db/seeds.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # Database initial data
2
2
 
3
+ ModelDiscovery::Engine.load_seed
4
+
3
5
  Faalis::Group.create({:name => "Admin"})
4
6
  Faalis::Group.create({:name => "Guest", :id => 2})
5
7
 
data/lib/faalis.rb CHANGED
@@ -23,6 +23,7 @@ module Faalis
23
23
  end
24
24
 
25
25
  require "faalis/engine"
26
+ require "faalis/permissions"
26
27
  require "faalis/dashboard"
27
28
  require "faalis/omniauth"
28
29
  require "faalis/active_record"
@@ -4,61 +4,6 @@
4
4
 
5
5
  module ActiveRecord
6
6
  class Base
7
- class Permissions
8
-
9
- # Default permission hash
10
- @@permissions = {
11
- :read => nil,
12
- :update => nil,
13
- :create => nil,
14
- :destory => nil,
15
- }
16
-
17
- @@only_owner = false
18
-
19
- # @return an array of strings representation of permissions
20
- def self.permission_strings(model)
21
- strings = []
22
- @@permissions.each do |key, value|
23
- strings << {
24
- :name => "#{key}|#{model.model_name}",
25
- :string => _("can %s %s") % [_(key.to_s), model.model_name.human]
26
- }
27
-
28
- end
29
- strings
30
- end
31
-
32
- # Define permissions using this method
33
- def self.permissions(*args)
34
-
35
- args.each do |permission|
36
- if permission.class == Symbol
37
- if not @@permissions.include? permission
38
- @@permission[permission] = nil
39
-
40
- elsif permission.class == Hash
41
-
42
- permission.each do |key, value|
43
- @@permissions[key.to_sym] = value
44
- end
45
-
46
- end
47
- end
48
-
49
-
50
- end
51
- end
52
-
53
- # This force user to have access to resources which is his.
54
- def self.only_his_objects
55
- @@only_owner = true
56
- end
57
-
58
- def self.only_his_objects?
59
- @@only_owner
60
- end
61
-
62
- end
7
+ include Faalis::Permissions
63
8
  end
64
9
  end
data/lib/faalis/engine.rb CHANGED
@@ -24,6 +24,7 @@ require "font-awesome-rails"
24
24
  require "devise"
25
25
  require "warden"
26
26
  require "cancan"
27
+ require "mailboxer"
27
28
 
28
29
 
29
30
  module Faalis
@@ -0,0 +1,65 @@
1
+ module Faalis
2
+ module Permissions
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ # Default permission hash
7
+ @@permissions = {
8
+ :read => nil,
9
+ :update => nil,
10
+ :create => nil,
11
+ :destory => nil,
12
+ }
13
+
14
+ @@only_owner = false
15
+
16
+ # @return an array of strings representation of permissions
17
+ def permission_strings(model)
18
+ strings = []
19
+ @@permissions.each do |key, value|
20
+ strings << {
21
+ :name => "#{key}|#{model.model_name}",
22
+ :string => _("can %s %s") % [_(key.to_s), model.model_name.human]
23
+ }
24
+ end
25
+ strings
26
+ end
27
+
28
+ def possible_permissions
29
+ @@permissions.keys
30
+ end
31
+
32
+ # Define permissions using this method
33
+ def permissions(*args)
34
+
35
+ args.each do |permission|
36
+ if permission.class == Symbol
37
+ if not @@permissions.include? permission
38
+ @@permission[permission] = nil
39
+
40
+ elsif permission.class == Hash
41
+
42
+ permission.each do |key, value|
43
+ @@permissions[key.to_sym] = value
44
+ end
45
+
46
+ end
47
+ end
48
+
49
+
50
+ end
51
+ end
52
+
53
+ # This force user to have access to resources which is his.
54
+ def only_his_objects
55
+ @@only_owner = true
56
+ end
57
+
58
+ def only_his_objects?
59
+ @@only_owner
60
+ end
61
+
62
+ end
63
+ end
64
+
65
+ end