faalis 0.11.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/faalis/dashboard/app.js +0 -19
  3. data/app/assets/javascripts/faalis/dashboard/functions.js.erb +5 -22
  4. data/app/assets/javascripts/faalis/dashboard/init.js +1 -20
  5. data/app/assets/javascripts/faalis/dashboard/modules/anim.js +0 -19
  6. data/app/assets/javascripts/faalis/dashboard/modules/api.js +0 -19
  7. data/app/assets/javascripts/faalis/dashboard/modules/auth/auth.js +2 -21
  8. data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +0 -19
  9. data/app/assets/javascripts/faalis/dashboard/modules/auth/profile.js +0 -19
  10. data/app/assets/javascripts/faalis/dashboard/modules/auth/user.js +0 -18
  11. data/app/assets/javascripts/faalis/dashboard/modules/conversations.js +33 -32
  12. data/app/assets/javascripts/faalis/dashboard/modules/errors.js +7 -20
  13. data/app/assets/javascripts/faalis/dashboard/modules/fields/boolean.js +14 -21
  14. data/app/assets/javascripts/faalis/dashboard/modules/fields/controlcombo-field.js +63 -0
  15. data/app/assets/javascripts/faalis/dashboard/modules/fields/datetime.js +18 -20
  16. data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +1 -1
  17. data/app/assets/javascripts/faalis/dashboard/modules/fields/float.js +50 -0
  18. data/app/assets/javascripts/faalis/dashboard/modules/fields/input-grid.js +46 -0
  19. data/app/assets/javascripts/faalis/dashboard/modules/fields/input-list.js +31 -0
  20. data/app/assets/javascripts/faalis/dashboard/modules/fields/integer.js +22 -22
  21. data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +25 -19
  22. data/app/assets/javascripts/faalis/dashboard/modules/fields/string.js +11 -20
  23. data/app/assets/javascripts/faalis/dashboard/modules/fields/text.js +10 -19
  24. data/app/assets/javascripts/faalis/dashboard/modules/fields/time.js +123 -0
  25. data/app/assets/javascripts/faalis/dashboard/modules/filter.js +0 -19
  26. data/app/assets/javascripts/faalis/dashboard/modules/list-view.js +43 -25
  27. data/app/assets/javascripts/faalis/dashboard/modules/logs.js +0 -18
  28. data/app/assets/javascripts/faalis/dashboard/modules/modules.js +22 -21
  29. data/app/assets/javascripts/faalis/dashboard/modules/nav.js.erb +0 -19
  30. data/app/assets/javascripts/faalis/dashboard/modules/permissions.js +1 -20
  31. data/app/assets/javascripts/faalis/dashboard/objects.js +37 -0
  32. data/app/assets/stylesheets/faalis/dashboard/dashboard.css.scss +4 -0
  33. data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +2 -0
  34. data/app/assets/stylesheets/faalis/dashboard/ltr/buttons.css.scss.erb +7 -0
  35. data/app/assets/stylesheets/faalis/dashboard/ltr/time.css.scss +58 -0
  36. data/app/assets/stylesheets/faalis/dashboard/ltr/time.css_flymake.scss +58 -0
  37. data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +1 -0
  38. data/app/assets/stylesheets/faalis/dashboard/share/time.css.scss +55 -0
  39. data/app/assets/stylesheets/faalis/ltr/application.css +1 -1
  40. data/app/assets/stylesheets/faalis/rtl/buttons.css.scss.erb +5 -0
  41. data/app/controllers/faalis/api/v1/conversations_controller.rb +55 -27
  42. data/app/controllers/faalis/api/v1/groups_controller.rb +1 -1
  43. data/app/controllers/faalis/api/v1/permissions_controller.rb +1 -0
  44. data/app/views/angularjs_templates/conversations/details.html +3 -2
  45. data/app/views/angularjs_templates/conversations/index.html +8 -1
  46. data/app/views/angularjs_templates/conversations/show_details.html +6 -9
  47. data/app/views/angularjs_templates/fields/boolean/boolean.html +2 -2
  48. data/app/views/angularjs_templates/fields/control-combo/control-list.html +19 -0
  49. data/app/views/angularjs_templates/fields/datetime/datetime.html +1 -1
  50. data/app/views/angularjs_templates/fields/datetime/time.html +25 -0
  51. data/app/views/angularjs_templates/fields/float/float.html +4 -0
  52. data/app/views/angularjs_templates/fields/relation/relation.html +4 -3
  53. data/app/views/angularjs_templates/list-view/index.html +6 -5
  54. data/app/views/faalis/api/v1/conversations/destroy.json.jbuilder +1 -0
  55. data/app/views/faalis/api/v1/conversations/reply.json.jbuilder +1 -0
  56. data/app/views/faalis/api/v1/conversations/show.json.jbuilder +12 -8
  57. data/app/views/faalis/api/v1/conversations/trash.json.jbuilder +1 -0
  58. data/config/routes.rb +3 -3
  59. data/lib/faalis/permissions.rb +1 -1
  60. data/lib/faalis/version.rb +1 -1
  61. data/lib/generators/faalis/js_scaffold_generator.rb +10 -0
  62. data/lib/generators/faalis/templates/angularjs/index.html.erb +1 -1
  63. data/lib/generators/faalis/templates/angularjs/module.js.erb +14 -2
  64. data/lib/tasks/faalis_tasks.rake +11 -0
  65. metadata +255 -250
  66. data/spec/dummy/db/test.sqlite3 +0 -0
  67. data/spec/dummy/log/development.log +0 -0
  68. data/spec/dummy/log/test.log +0 -15
  69. data/spec/dummy/tmp/ember-rails/ember-data.js +0 -10204
  70. data/spec/dummy/tmp/ember-rails/ember.js +0 -36991
@@ -1,33 +1,24 @@
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
1
  var Text_ = angular.module("TextField", []);
21
2
 
22
3
  /*
23
4
  * <string-field></string-field> directive defination
24
5
  */
6
+
25
7
  Text_.directive('textField', ["$filter", "gettext", function($filter, gettext) {
26
8
 
27
9
  function link(scope, element, attrs){
28
10
  var ltr = is_ltr();
29
11
  scope.element_id = "id_" + scope.field;
30
12
  scope.msg_element_id = "id_" + scope.field + "_msg";
13
+
14
+ if (scope.on_change !== undefined) {
15
+ // Watch event changes
16
+ scope.$watch("model", function(newv, oldv, $scope) {
17
+ // TODO: maybe we should pass locals to $eval
18
+ scope.$parent.$eval(scope.on_change);
19
+ }, true);
20
+ }
21
+
31
22
  }
32
23
  // Actual object of <string-field> directive
33
24
  return {
@@ -0,0 +1,123 @@
1
+ var Time_ = angular.module("TimeField",[]);
2
+ /*
3
+ * <string-field></string-field> directive defination
4
+ */
5
+
6
+ Time_.directive('timeField', ["$filter", "gettext", function($filter, gettext){
7
+
8
+ function link(scope, element, attrs){
9
+
10
+ if (scope.model === undefined) {
11
+ scope.model = new Time();
12
+ }
13
+ else {
14
+ if (! scope.model instanceof Time) {
15
+ scope.model = new Time(scope.model);
16
+ }
17
+ }
18
+
19
+ if (scope.on_change !== undefined) {
20
+ // Watch event changes
21
+ scope.$watch("model", function(newv, oldv, $scope) {
22
+ // TODO: maybe we should pass locals to $eval
23
+ scope.$parent.$eval(scope.on_change);
24
+ }, true);
25
+ }
26
+
27
+ /* Increases hours by one */
28
+ scope.increaseHours = function () {
29
+
30
+ //Check whether hours have reached max
31
+ if (scope.hours < 23) {
32
+ scope.hours = ++scope.hours;
33
+ scope.model.set_hour = scope.hours;
34
+ }
35
+ else {
36
+ scope.hours = 0;
37
+ scope.model.set_hour = 0;
38
+ }
39
+ };
40
+
41
+ /* Decreases hours by one */
42
+ scope.decreaseHours = function () {
43
+
44
+ //Check whether hours have reached min
45
+ scope.hours = scope.hours <= 0 ? 23 : --scope.hours;
46
+ scope.model.set_hour = scope.hours;
47
+ };
48
+
49
+ /* Increases minutes by one */
50
+ scope.increaseMinutes = function () {
51
+ //Check whether to reset
52
+ if (scope.minutes < 59) {
53
+ scope.minutes++;
54
+ }else if(scope.minutes == 59) {
55
+ scope.increaseHours();
56
+ scope.minutes = 0;
57
+ }else {
58
+ scope.minutes = 0;
59
+ }
60
+ scope.model.set_minute = scope.minutes;
61
+ };
62
+
63
+ /* Decreases minutes by one */
64
+ scope.decreaseMinutes = function () {
65
+
66
+ //Check whether to reset
67
+ if (scope.minutes <= 0) {
68
+ scope.minutes = 59;
69
+ }else if (scope.minutes === 0){
70
+ scope.hours--;
71
+ }else {
72
+ scope.minutes--;
73
+ }
74
+ };
75
+
76
+
77
+ /* Displays hours - what the user sees */
78
+ scope.displayHours = function () {
79
+
80
+ //Create vars
81
+ var hoursToDisplay = scope.hours;
82
+
83
+ //Check whether to reset etc
84
+ if (scope.hours > 23) {
85
+ hoursToDisplay = scope.hours - 23;
86
+ }
87
+
88
+ else {
89
+
90
+ //Check whether to prepend 0
91
+ if (hoursToDisplay <= 9) {
92
+ hoursToDisplay = "0" + hoursToDisplay;
93
+ }
94
+ }
95
+
96
+ return hoursToDisplay;
97
+ };
98
+
99
+ /* Displays minutes */
100
+ scope.displayMinutes = function () {
101
+ return scope.minutes <= 9 ? "0" + scope.minutes : scope.minutes;
102
+ };
103
+
104
+ }
105
+ // Actual object of <string-field> directive
106
+ return {
107
+ templateUrl: template("fields/datetime/time"),
108
+ replace: true,
109
+ restrict: "E",
110
+ transclude: true,
111
+ scope: {
112
+ cssClasses: '=cssClass',
113
+ // A call back to pass to field ng-change directive
114
+ on_change: "@onChange",
115
+ // fieldname
116
+ field: "=fieldName",
117
+ // Actual Angularjs ng-model
118
+ model: '='
119
+ },
120
+ link: link
121
+ };
122
+
123
+ }]);
@@ -1,22 +1,3 @@
1
- /* -----------------------------------------------------------------------------
2
- Red Base - Basic website skel engine
3
- Copyright (C) 2012-2013 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
1
  var Filter = angular.module("Filter", ["Errors"]);
21
2
 
22
3
  /*
@@ -1,23 +1,4 @@
1
- /* -----------------------------------------------------------------------------
2
- Red Base - Basic website skel engine
3
- Copyright (C) 2012-2013 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 ListView = angular.module("ListView", ['ngGrid']);
1
+ var ListView = angular.module("ListView", ['ngGrid', 'Permissions']);
21
2
 
22
3
  /*
23
4
  * <element object-action></element> directive defination
@@ -52,7 +33,8 @@ ListView.directive("objectAction", function(){
52
33
  /*
53
34
  * <list-view></list-view> directive defination
54
35
  */
55
- ListView.directive('listView', ["$filter", "gettext", function($filter, gettext) {
36
+
37
+ ListView.directive('listView', ["$filter", "gettext", "UserPermissions", function($filter, gettext, User) {
56
38
 
57
39
  function link(scope, element, attrs){
58
40
  var ltr = is_ltr();
@@ -60,6 +42,15 @@ ListView.directive('listView', ["$filter", "gettext", function($filter, gettext)
60
42
  var _current_page = 1;
61
43
  scope.list_view = true;
62
44
  scope.grid_view = false;
45
+ var use_permissions;
46
+
47
+ if (scope.use_permissions === undefined) {
48
+ use_permissions = true;
49
+ }
50
+ else {
51
+ use_permissions = false;
52
+ }
53
+
63
54
 
64
55
  scope.title = function(object, t) {
65
56
  if (typeof(scope.title_attr) == "function") {
@@ -139,6 +130,7 @@ ListView.directive('listView', ["$filter", "gettext", function($filter, gettext)
139
130
  };
140
131
 
141
132
  scope.delete_items = function(){
133
+
142
134
  var len = scope.selected_count();
143
135
  var objects_to_delete = [];
144
136
 
@@ -283,9 +275,25 @@ ListView.directive('listView', ["$filter", "gettext", function($filter, gettext)
283
275
  scope.objects_count = function(){
284
276
  return filtered_objects().length;
285
277
  };
286
- // ----------------------------------------------------
287
- // TODO: create some methods in scope for those buttons
288
- // which need to call a method instead of changing location
278
+
279
+ scope.has_permission = function(button) {
280
+ if (use_permissions === true) {
281
+ if( "permission" in button ){
282
+ if ((!("name" in button.permission)) || (!("model" in button.permission))) {
283
+ console.log("Button permission should be an object and has 'name' and 'model' keys");
284
+ throw "Button permission should be an object and has 'name' and 'model' keys";
285
+ }
286
+ return User.can(button.permission.name, button.permission.model);
287
+ }
288
+ }
289
+ return true;
290
+ };
291
+ scope.can = function(perm, model) {
292
+ if (use_permissions === true) {
293
+ return User.can(perm, model);
294
+ }
295
+ return true;
296
+ };
289
297
  }
290
298
 
291
299
 
@@ -315,8 +323,18 @@ ListView.directive('listView', ["$filter", "gettext", function($filter, gettext)
315
323
 
316
324
  // Grid columns
317
325
  column_defs: "=columnDefs",
326
+
327
+ // Permissions
328
+ use_permissions: "=usePermissions",
329
+
330
+ // Permission model
331
+ permission_model: "=model",
332
+
318
333
  // On delete method
319
- on_delete: "=onDelete"
334
+ on_delete: "=onDelete",
335
+
336
+ // Custom delete title method
337
+ delete_title: "=deleteTitle"
320
338
  },
321
339
  link: link
322
340
  };
@@ -1,21 +1,3 @@
1
- /* -----------------------------------------------------------------------------
2
- Red Base - Basic website skel engine
3
- Copyright (C) 2012-2013 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
1
  var Logs = angular.module("Logs", []);
20
2
 
21
3
  Logs.config(["$routeProvider", function($routeProvider){
@@ -1,29 +1,25 @@
1
- /* -----------------------------------------------------------------------------
2
- Red Base - Basic website skel engine
3
- Copyright (C) 2012-2013 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
1
  var Modules = angular.module("Modules", ["ngRoute", "ngAnimate"]);
21
2
 
22
- Modules.controller("ModulesController", ["$location", "$scope", "$controller", function($location, $scope, $controller){
3
+ Modules.controller("ModulesController", ["$location", "$scope", "$controller", "UserPermissions", function($location, $scope, $controller, User){
23
4
  var that = this;
24
5
  this.modules = _.filter(DModules, function(module){
25
6
  if (module.sidemenu === true) {
26
- module.menu_items = $controller(camelCase(module.resource) + "MenuController", {$scope: $scope}).menu_items;
7
+ var menu_items = $controller(camelCase(module.resource) + "MenuController", {$scope: $scope}).menu_items;
8
+ module.menu_items = [];
9
+ _.each(menu_items, function(menu) {
10
+ if ("permission" in menu){
11
+ if ((!("action" in menu.permission)) || (!("model" in menu.permission))) {
12
+ console.log("Button permission should be an object and has 'action' and 'model' keys");
13
+ throw "Button permission should be an object and has 'name' and 'model' keys";
14
+ }
15
+ if (User.can(menu.permission.action, menu.permission.model)) {
16
+ module.menu_items.push(menu);
17
+ }
18
+ }
19
+ else {
20
+ module.menu_items.push(menu);
21
+ }
22
+ });
27
23
  module.show_menu = false;
28
24
  }
29
25
  return module.sidemenu || false;
@@ -33,6 +29,11 @@ Modules.controller("ModulesController", ["$location", "$scope", "$controller", f
33
29
  $location.path(url);
34
30
  };
35
31
  this.view_menu = function(module) {
32
+ _.each(this.modules, function(x){
33
+ if (x !== module) {
34
+ x.show_menu = false;
35
+ }
36
+ });
36
37
  module.show_menu = !module.show_menu;
37
38
  };
38
39
  }]);
@@ -1,22 +1,3 @@
1
- /* -----------------------------------------------------------------------------
2
- Red Base - Basic website skel engine
3
- Copyright (C) 2012-2013 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
1
  var Nav = angular.module("Navigation", ["ngAnimate"]);
21
2
 
22
3
  Nav.controller("NavigationController", ["$location", "gettext", "$interval", function($location, gettext, $interval){
@@ -1,22 +1,3 @@
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
1
  var Perm = angular.module("Permissions", []);
21
2
 
22
3
  Perm.factory('UserPermissions', ["$rootScope", function ($rootScope) {
@@ -54,7 +35,7 @@ Perm.factory('UserPermissions', ["$rootScope", function ($rootScope) {
54
35
  Perm.directive('ifUser', ["UserPermissions", function(User) {
55
36
 
56
37
  function link(scope, element, attrs) {
57
- if (scope.value) {
38
+ if (scope.value === true) {
58
39
  element.show();
59
40
  }
60
41
  else {
@@ -0,0 +1,37 @@
1
+ function Time(value) {
2
+ if( value !== undefined ){
3
+ // parse value
4
+ this.fromString(value);
5
+ }
6
+ else {
7
+ this.hour = 0;
8
+ this.minute = 0;
9
+ }
10
+
11
+ this.toString = function(){
12
+ return this.hour + ":" + this.minute + " ";
13
+ };
14
+
15
+ this.fromString = function(value) {
16
+ var time = value.split(":");
17
+ this.set_hour(time[0]);
18
+ this.set_minute(time[1]);
19
+ };
20
+
21
+ this.set_hour = function(value){
22
+ if (value <= 23){
23
+ this.hour = parseInt(value, 10);
24
+ }else{
25
+ this.hour = 0;
26
+ }
27
+ };
28
+
29
+ this.set_minute = function(value){
30
+ if (value <= 59){
31
+ this.minute = parseInt(value, 10);
32
+ }else{
33
+ this.minute = 0;
34
+ }
35
+ };
36
+
37
+ }