faalis 0.7.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/faalis/dashboard/app.js +24 -9
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +0 -1
- data/app/assets/javascripts/faalis/dashboard/functions.js.erb +4 -0
- data/app/assets/javascripts/faalis/dashboard/modules/anim.js +1 -1
- data/app/assets/javascripts/faalis/dashboard/modules/conversations.js +180 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/boolean.js +49 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/datetime.js +50 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +1 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/integer.js +50 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +78 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/string.js +49 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/text.js +50 -0
- data/app/assets/javascripts/faalis/dashboard/modules/list-view.js +14 -1
- data/app/assets/javascripts/faalis/dashboard/modules/nav.js.erb +1 -1
- data/app/assets/javascripts/faalis/dashboard/modules/permissions.js +71 -0
- data/app/assets/javascripts/faalis/dashboard/variables.js.erb +2 -0
- data/app/assets/stylesheets/faalis/base.css.scss +28 -0
- data/app/controllers/faalis/api/v1/conversations_controller.rb +92 -0
- data/app/controllers/faalis/api/v1/permissions_controller.rb +39 -3
- data/app/controllers/faalis/dashboard_controller.rb +18 -1
- data/app/models/faalis/permissions/auth.rb +3 -0
- data/app/models/faalis/user.rb +3 -0
- data/app/views/angularjs_templates/auth/groups/new.html +7 -3
- data/app/views/angularjs_templates/auth/users/details.html +1 -1
- data/app/views/angularjs_templates/auth/users/new.html +4 -3
- data/app/views/angularjs_templates/conversations/details.html +18 -0
- data/app/views/angularjs_templates/conversations/index.html +6 -0
- data/app/views/angularjs_templates/conversations/new.html +39 -0
- data/app/views/angularjs_templates/conversations/show.html +6 -0
- data/app/views/angularjs_templates/conversations/show_details.html +18 -0
- data/app/views/angularjs_templates/fields/boolean/boolean.html +4 -0
- data/app/views/angularjs_templates/fields/datetime/datetime.html +4 -0
- data/app/views/angularjs_templates/fields/integer/integer.html +4 -0
- data/app/views/angularjs_templates/fields/relation/relation.html +28 -0
- data/app/views/angularjs_templates/fields/string/string.html +4 -0
- data/app/views/angularjs_templates/fields/text/text.html +4 -0
- data/app/views/angularjs_templates/list-view/index.html +1 -1
- data/app/views/angularjs_templates/modules.html +2 -2
- data/app/views/faalis/api/v1/conversations/create.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/conversations/index.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/conversations/show.json.jbuilder +10 -0
- data/app/views/faalis/api/v1/permissions/user_permissions.json.jbuilder +1 -0
- data/app/views/layouts/faalis/dashboard.html.erb +1 -1
- data/config/routes.rb +13 -2
- data/db/migrate/{20131013091000_devise_create_red_base_users.rb → 20131013091000_devise_create_faalis_users.rb} +0 -0
- data/db/migrate/{20131020124701_create_red_base_groups.rb → 20131020124701_create_faalis_groups.rb} +0 -0
- data/db/migrate/{20131021170923_create_red_base_permissions.rb → 20131021170923_create_faalis_permissions.rb} +0 -0
- data/db/seeds.rb +2 -0
- data/lib/faalis.rb +1 -0
- data/lib/faalis/active_record.rb +1 -56
- data/lib/faalis/engine.rb +1 -0
- data/lib/faalis/permissions.rb +65 -0
- data/lib/faalis/version.rb +1 -1
- data/lib/generators/faalis/install_generator.rb +4 -0
- data/lib/generators/faalis/js_scaffold_generator.rb +27 -8
- data/lib/generators/faalis/templates/angularjs/module.js.erb +11 -7
- data/lib/generators/faalis/templates/angularjs/new.html.erb +35 -78
- metadata +51 -11
- data/app/views/angularjs_templates/#index.html# +0 -8
@@ -0,0 +1,49 @@
|
|
1
|
+
/* -----------------------------------------------------------------------------
|
2
|
+
Red Base - Basic website skel engine
|
3
|
+
Copyright (C) 2012-2014 Yellowen
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
6
|
+
it under the terms of the GNU General Public License as published by
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
8
|
+
(at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License along
|
16
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
----------------------------------------------------------------------------- */
|
19
|
+
|
20
|
+
var String_ = angular.module("StringField", []);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* <string-field></string-field> directive defination
|
24
|
+
*/
|
25
|
+
String_.directive('stringField', ["$filter", "gettext", function($filter, gettext) {
|
26
|
+
|
27
|
+
function link(scope, element, attrs){
|
28
|
+
var ltr = is_ltr();
|
29
|
+
scope.element_id = "id_" + scope.field;
|
30
|
+
scope.msg_element_id = "id_" + scope.field + "_msg";
|
31
|
+
}
|
32
|
+
// Actual object of <string-field> directive
|
33
|
+
return {
|
34
|
+
templateUrl: template("fields/string/string"),
|
35
|
+
replace: true,
|
36
|
+
restrict: "E",
|
37
|
+
scope: {
|
38
|
+
cssClasses: '=cssClass',
|
39
|
+
|
40
|
+
// fieldname
|
41
|
+
field: "=fieldName",
|
42
|
+
// Does this field is required
|
43
|
+
required: "=",
|
44
|
+
// Actual Angularjs ng-model
|
45
|
+
model: '='
|
46
|
+
},
|
47
|
+
link: link
|
48
|
+
};
|
49
|
+
}]);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/* -----------------------------------------------------------------------------
|
2
|
+
Red Base - Basic website skel engine
|
3
|
+
Copyright (C) 2012-2014 Yellowen
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
6
|
+
it under the terms of the GNU General Public License as published by
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
8
|
+
(at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License along
|
16
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
----------------------------------------------------------------------------- */
|
19
|
+
|
20
|
+
var Text_ = angular.module("TextField", []);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* <string-field></string-field> directive defination
|
24
|
+
*/
|
25
|
+
Text_.directive('textField', ["$filter", "gettext", function($filter, gettext) {
|
26
|
+
|
27
|
+
function link(scope, element, attrs){
|
28
|
+
var ltr = is_ltr();
|
29
|
+
scope.element_id = "id_" + scope.field;
|
30
|
+
scope.msg_element_id = "id_" + scope.field + "_msg";
|
31
|
+
}
|
32
|
+
// Actual object of <string-field> directive
|
33
|
+
return {
|
34
|
+
templateUrl: template("fields/text/text"),
|
35
|
+
replace: true,
|
36
|
+
restrict: "E",
|
37
|
+
transclude: true,
|
38
|
+
scope: {
|
39
|
+
cssClasses: '=cssClass',
|
40
|
+
|
41
|
+
// fieldname
|
42
|
+
field: "=fieldName",
|
43
|
+
// Does this field is required
|
44
|
+
required: "=",
|
45
|
+
// Actual Angularjs ng-model
|
46
|
+
model: '='
|
47
|
+
},
|
48
|
+
link: link
|
49
|
+
};
|
50
|
+
}]);
|
@@ -61,9 +61,21 @@ ListView.directive('listView', ["$filter", "gettext", function($filter, gettext)
|
|
61
61
|
scope.list_view = true;
|
62
62
|
scope.grid_view = false;
|
63
63
|
|
64
|
+
scope.title = function(object, t) {
|
65
|
+
if (typeof(scope.title_attr) == "function") {
|
66
|
+
return scope.title_attr(object);
|
67
|
+
}
|
68
|
+
return object[scope.title_attr];
|
69
|
+
};
|
70
|
+
|
64
71
|
var filtered_objects = function(){
|
65
72
|
var filterby = {};
|
66
|
-
|
73
|
+
if (typeof(scope.title_attr) == "function") {
|
74
|
+
filterby = scope.title_attr;
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
filterby[scope.title_attr] = scope.searchterm;
|
78
|
+
}
|
67
79
|
var result = $filter('filter')(scope.objects, filterby, function(expected, actual){
|
68
80
|
var re = new RegExp(".*" + actual + ".*", "ig");
|
69
81
|
scope.go_to_first_page();
|
@@ -75,6 +87,7 @@ ListView.directive('listView', ["$filter", "gettext", function($filter, gettext)
|
|
75
87
|
// TODO: Double check this or condition
|
76
88
|
return result || [];
|
77
89
|
};
|
90
|
+
|
78
91
|
scope.grid_options = {
|
79
92
|
data: 'objects',
|
80
93
|
headerRowHeight: 30,
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/* -----------------------------------------------------------------------------
|
2
|
+
Red Base - Basic website skel engine
|
3
|
+
Copyright (C) 2012-2014 Yellowen
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
6
|
+
it under the terms of the GNU General Public License as published by
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
8
|
+
(at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License along
|
16
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
----------------------------------------------------------------------------- */
|
19
|
+
|
20
|
+
var Perm = angular.module("Permissions", []);
|
21
|
+
|
22
|
+
Perm.factory('UserPermissions', ["$rootScope", function ($rootScope) {
|
23
|
+
var permissionList;
|
24
|
+
return {
|
25
|
+
set_permissions: function(permissions) {
|
26
|
+
PERMISSIONS = permissions;
|
27
|
+
$rootScope.$broadcast('permissions_changed');
|
28
|
+
},
|
29
|
+
|
30
|
+
/*
|
31
|
+
* Check if user has specific permission on an object
|
32
|
+
*/
|
33
|
+
can: function(action, model) {
|
34
|
+
if (model in PERMISSIONS) {
|
35
|
+
if (_.indexOf(PERMISSIONS[model], action) !== -1) {
|
36
|
+
//console.log("User can " + action + " " + model);
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
//console.log("User can't " + action + " " + model);
|
41
|
+
return false;
|
42
|
+
|
43
|
+
},
|
44
|
+
/*
|
45
|
+
* Check if user has specific permission on an object
|
46
|
+
*/
|
47
|
+
can_not: function(action, model) {
|
48
|
+
return ! this.can(action,model);
|
49
|
+
}
|
50
|
+
|
51
|
+
};
|
52
|
+
}]);
|
53
|
+
|
54
|
+
Perm.directive('ifUser', ["UserPermissions", function(User) {
|
55
|
+
|
56
|
+
function link(scope, element, attrs) {
|
57
|
+
if (scope.value) {
|
58
|
+
element.show();
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
element.hide();
|
62
|
+
}
|
63
|
+
}
|
64
|
+
return {
|
65
|
+
restrict: "A",
|
66
|
+
scope: {
|
67
|
+
value: "=ifUser"
|
68
|
+
},
|
69
|
+
link: link
|
70
|
+
};
|
71
|
+
}]);
|
@@ -1,6 +1,8 @@
|
|
1
1
|
//<% environment.context_class.instance_eval { include ActionView::Helpers::UrlHelper } %>
|
2
2
|
//<% url = Faalis::Engine.routes.url_helpers %>
|
3
3
|
|
4
|
+
// User Permissions
|
5
|
+
window.PERMISSIONS = [];
|
4
6
|
// Prefix url of API
|
5
7
|
window.API_PREFIX = "/api/v1/";
|
6
8
|
// Modules is an array of dashboard modules
|
@@ -262,3 +262,31 @@ input {
|
|
262
262
|
.inline {
|
263
263
|
display: inline;
|
264
264
|
}
|
265
|
+
|
266
|
+
small.error {
|
267
|
+
margin-top: 1em !important;
|
268
|
+
border-radius: 3px;
|
269
|
+
}
|
270
|
+
|
271
|
+
.relation_links {
|
272
|
+
span {
|
273
|
+
font-size: 0.8em;
|
274
|
+
padding: 2px 5px;
|
275
|
+
color: $darkgray;
|
276
|
+
cursor: pointer;
|
277
|
+
opacity: 0.3;
|
278
|
+
@include transition(opacity 300ms linear 0ms);
|
279
|
+
&:hover {
|
280
|
+
opacity: 1;
|
281
|
+
@include transition(opacity 300ms linear 0ms);
|
282
|
+
}
|
283
|
+
a {
|
284
|
+
opacity: 0.4;
|
285
|
+
@include transition(opacity 300ms linear 0ms);
|
286
|
+
&:hover {
|
287
|
+
opacity: 1;
|
288
|
+
@include transition(opacity 300ms linear 0ms);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}
|
292
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_dependency "faalis/application_controller"
|
2
|
+
|
3
|
+
module Faalis
|
4
|
+
class API::V1::ConversationsController < APIController
|
5
|
+
before_filter :authenticate_user!
|
6
|
+
helper_method :mailbox, :conversation
|
7
|
+
|
8
|
+
def create
|
9
|
+
recipient_emails = conversation_params(:recipients).split(',')
|
10
|
+
recipients = User.where(email: recipient_emails).all
|
11
|
+
|
12
|
+
@conversation = current_user.
|
13
|
+
send_message(recipients, *conversation_params(:body, :subject)).conversation
|
14
|
+
|
15
|
+
respond_with(@conversation)
|
16
|
+
end
|
17
|
+
|
18
|
+
def reply
|
19
|
+
current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
|
20
|
+
respond_to conversation
|
21
|
+
end
|
22
|
+
|
23
|
+
def trash
|
24
|
+
conversation.move_to_trash(current_user)
|
25
|
+
redirect_to :conversations
|
26
|
+
end
|
27
|
+
|
28
|
+
def untrash
|
29
|
+
conversation.untrash(current_user)
|
30
|
+
redirect_to :conversations
|
31
|
+
end
|
32
|
+
|
33
|
+
def index
|
34
|
+
if params[:box] == "inbox"
|
35
|
+
box = "inbox"
|
36
|
+
elsif params[:box] == "sentbox"
|
37
|
+
box = "sentbox"
|
38
|
+
elsif params[:box] == "trash"
|
39
|
+
box = "trash"
|
40
|
+
else
|
41
|
+
respond_to do |f|
|
42
|
+
f.any { head :not_found }
|
43
|
+
end
|
44
|
+
return
|
45
|
+
end
|
46
|
+
# puts current_user.mailbox.sent.to_json
|
47
|
+
@mailbox ||= current_user.mailbox.send(box.to_sym)
|
48
|
+
respond_with @mailbox
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def show
|
53
|
+
#def conversation
|
54
|
+
@conversations ||= current_user.mailbox.conversations.find(params[:id])
|
55
|
+
#binding.pry
|
56
|
+
# @conversation = {}
|
57
|
+
# conversations.each do |conversation|
|
58
|
+
# tmp = {
|
59
|
+
# :receipts => conversation.receipts,
|
60
|
+
# :body => conversation.messages.body,
|
61
|
+
# :is_read => conversation.is_read,
|
62
|
+
# :trashed => conversation.trashed,
|
63
|
+
# :deleted => conversation.deleted,
|
64
|
+
# :recipients => conversation.recipients
|
65
|
+
# }
|
66
|
+
#unless @conversation.include? conversation.id
|
67
|
+
# @conversation[conversation.id] = tmp
|
68
|
+
#end
|
69
|
+
#end
|
70
|
+
|
71
|
+
end
|
72
|
+
private
|
73
|
+
def conversation_params(*keys)
|
74
|
+
#binding.pry
|
75
|
+
fetch_params(:conversation, *keys)
|
76
|
+
end
|
77
|
+
|
78
|
+
def message_params(*keys)
|
79
|
+
fetch_params(:message, *keys)
|
80
|
+
end
|
81
|
+
|
82
|
+
def fetch_params(key, *subkeys)
|
83
|
+
params[key].instance_eval do
|
84
|
+
case subkeys.size
|
85
|
+
when 0 then self
|
86
|
+
when 1 then self[subkeys.first]
|
87
|
+
else subkeys.map{|k| self[k] }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -1,17 +1,53 @@
|
|
1
1
|
require_dependency "faalis/application_controller"
|
2
2
|
|
3
3
|
module Faalis
|
4
|
-
class API::V1::PermissionsController <
|
4
|
+
class API::V1::PermissionsController < APIController
|
5
5
|
|
6
|
-
|
6
|
+
class DummyPerm
|
7
|
+
attr_accessor :model, :permission_type
|
8
|
+
end
|
9
|
+
|
10
|
+
# @api GET permissions
|
11
|
+
# @return All permissions
|
7
12
|
def index
|
8
13
|
@permissions = []
|
9
14
|
|
10
15
|
Faalis::Engine.models_with_permission.each do |model|
|
11
16
|
model = Object.const_get(model)
|
12
|
-
@permissions.concat(model
|
17
|
+
@permissions.concat(model.permission_strings(model))
|
13
18
|
end
|
19
|
+
respond_with(@permissions)
|
20
|
+
end
|
14
21
|
|
22
|
+
# @api GET permissions/user
|
23
|
+
# @return current user permissions
|
24
|
+
def user_permissions
|
25
|
+
@permissions = {}
|
26
|
+
perms = []
|
27
|
+
if current_user.group_id == 1
|
28
|
+
# Generate all possible permissions for admin group
|
29
|
+
Faalis::Engine.models_with_permission.each do |model|
|
30
|
+
Object.const_get(model).possible_permissions.each do |p|
|
31
|
+
perm = DummyPerm.new
|
32
|
+
perm.model = model
|
33
|
+
perm.permission_type = p
|
34
|
+
perms << perm
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
perms = current_user.group.permissions
|
39
|
+
end
|
40
|
+
|
41
|
+
# Generate a suitable Hash for permissions
|
42
|
+
perms.each do |perm|
|
43
|
+
if @permissions.include? perm.model
|
44
|
+
@permissions[perm.model] << perm.permission_type.to_s
|
45
|
+
else
|
46
|
+
@permissions[perm.model] = [perm.permission_type.to_s]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
respond_with(@permissions)
|
15
50
|
end
|
51
|
+
|
16
52
|
end
|
17
53
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_dependency "faalis/application_controller"
|
2
2
|
|
3
|
+
|
3
4
|
module Faalis
|
4
5
|
class DashboardController < ApplicationController
|
5
6
|
|
@@ -24,7 +25,6 @@ module Faalis
|
|
24
25
|
|
25
26
|
def modules
|
26
27
|
dashboard_modules = []
|
27
|
-
|
28
28
|
Faalis::Engine.dashboard_modules.each do |module_name, attrs|
|
29
29
|
if not attrs.include? :title
|
30
30
|
attrs[:title] = _(module_name.to_s)
|
@@ -34,6 +34,23 @@ module Faalis
|
|
34
34
|
attrs[:resource] = module_name.to_s
|
35
35
|
end
|
36
36
|
|
37
|
+
# If class did not given by user in settings
|
38
|
+
# Faalis tries to guess the class name
|
39
|
+
if not attrs.include? :model
|
40
|
+
begin
|
41
|
+
klass = attrs[:resource].camelize.constantize
|
42
|
+
|
43
|
+
if klass.respond_to? :possible_permissions
|
44
|
+
attrs[:model] = attrs[:resource].camelize
|
45
|
+
else
|
46
|
+
attrs[:model] = ""
|
47
|
+
end
|
48
|
+
|
49
|
+
rescue NameError
|
50
|
+
attrs[:model] = ""
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
37
54
|
dashboard_modules << attrs
|
38
55
|
end
|
39
56
|
dashboard_modules = {:modules => dashboard_modules}
|