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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 211e5ba2ce64c3da64cb9977367eb4a2ae1594cc
|
4
|
+
data.tar.gz: 6a81b397d0532901c7025ef829c25acb8d368bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b71d8ad541c9fb372730de7907c9b61963163cabb44b0fbef81f2b83874190bf3884835994ba98318bd696cc0ef854dbf8d2648c5f162d5a6299a86e8122766
|
7
|
+
data.tar.gz: dbd7e18ca0c10d0a29852edf7ae93f1024469cff6e1c117c6a811e09504839de2a0933f603717ba8305c0ba6b053f5cf511345ca1c9e02cc6bf07efdeb0940e3
|
@@ -23,22 +23,18 @@
|
|
23
23
|
//= require ./locale/translations
|
24
24
|
|
25
25
|
var dependencies = ["gettext", "Modules", "Navigation","ui.select2", "ngAnimate", "ngRoute",
|
26
|
-
"restangular", "ngQuickDate", "Errors", "Profile"].concat(dashboard_dependencies);
|
26
|
+
"restangular", "ngQuickDate", "Errors", "Profile", "Permissions", "Conversation"].concat(dashboard_dependencies);
|
27
27
|
|
28
28
|
console.log("Dashboard dependencies:");
|
29
29
|
console.log(dependencies);
|
30
30
|
|
31
31
|
var Dashboard = angular.module('Dashboard', dependencies);
|
32
32
|
|
33
|
-
Dashboard.config([
|
34
|
-
$routeProvider.
|
35
|
-
when("/", {
|
36
|
-
templateUrl: template("index")
|
37
|
-
});
|
33
|
+
Dashboard.config(["$routeProvider", "RestangularProvider", "$httpProvider", "ngQuickDateDefaultsProvider", function($routeProvider, RestangularProvider, $httpProvider, ngQuickDateDefaultsProvider) {
|
38
34
|
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
$routeProvider.when("/", {
|
36
|
+
templateUrl: template("index")
|
37
|
+
});
|
42
38
|
|
43
39
|
ngQuickDateDefaultsProvider.set({
|
44
40
|
closeButtonHtml: "<i class='fa fa-times'></i>",
|
@@ -73,3 +69,22 @@ Dashboard.config(["RestangularProvider", "$httpProvider", "ngQuickDateDefaultsPr
|
|
73
69
|
}
|
74
70
|
});
|
75
71
|
}]);
|
72
|
+
|
73
|
+
Dashboard.run(["UserPermissions", "$rootScope", function(User, $rootScope){
|
74
|
+
$rootScope.user = User;
|
75
|
+
}]);
|
76
|
+
|
77
|
+
angular.element(document).ready(function(){
|
78
|
+
$.ajax({method: 'GET', type: 'json',
|
79
|
+
url: API_PREFIX + "permissions/user"})
|
80
|
+
.success(function(data, status, headers, config){
|
81
|
+
PERMISSIONS = data.permissions;
|
82
|
+
angular.bootstrap(document, ["Dashboard"]);
|
83
|
+
})
|
84
|
+
.fail(function(data){
|
85
|
+
alert('Can not connect to remote, please try again');
|
86
|
+
}).always(function(){
|
87
|
+
$("#mainloader").hide();
|
88
|
+
$("#content").show();
|
89
|
+
});
|
90
|
+
});
|
@@ -10,7 +10,6 @@
|
|
10
10
|
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
|
-
//= require_self
|
14
13
|
//= require_tree ./lib
|
15
14
|
//= require faalis/dashboard/init
|
16
15
|
//= require faalis/dashboard/app
|
@@ -17,6 +17,10 @@
|
|
17
17
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
18
|
----------------------------------------------------------------------------- */
|
19
19
|
|
20
|
+
|
21
|
+
function can(action, model) {
|
22
|
+
console.log(">>>>>>>>>>>>");
|
23
|
+
}
|
20
24
|
/*
|
21
25
|
* This function convert snake_type to CamelCase
|
22
26
|
*/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -----------------------------------------------------------------------------
|
2
2
|
Red Base - Basic website skel engine
|
3
|
-
Copyright (C) 2012-
|
3
|
+
Copyright (C) 2012-2014 Yellowen
|
4
4
|
|
5
5
|
This program is free software; you can redistribute it and/or modify
|
6
6
|
it under the terms of the GNU General Public License as published by
|
@@ -0,0 +1,180 @@
|
|
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
|
+
var Conversation = angular.module("Conversation",["ListView", "Errors"]);
|
20
|
+
|
21
|
+
|
22
|
+
Conversation.config(["$routeProvider", function($routeProvider){
|
23
|
+
$routeProvider.
|
24
|
+
when("/conversations/:id/show",{
|
25
|
+
templateUrl: template("conversations/show"),
|
26
|
+
controller: "ConversationControllerIndex"
|
27
|
+
}).
|
28
|
+
when("/conversations/new",{
|
29
|
+
templateUrl: template("conversations/new"),
|
30
|
+
controller: "ConversationControllerNew"
|
31
|
+
}).
|
32
|
+
when("/conversations/:id/reply",{
|
33
|
+
templateUrl: template("conversations/new"),
|
34
|
+
controller: "ConversationControllerNew"
|
35
|
+
}).
|
36
|
+
when("/conversations/:type",{
|
37
|
+
templateUrl: template("conversations/index"),
|
38
|
+
controller: "ConversationControllerIndex"
|
39
|
+
});
|
40
|
+
}]);
|
41
|
+
|
42
|
+
Conversation.controller("ConversationControllerIndex",["$scope", "Restangular", "gettext", "catch_error", "$routeParams","$location", function($scope, API, gettext, catch_error, $routeParams, $location){
|
43
|
+
if ($routeParams.id){
|
44
|
+
$scope.details_template = template("conversations/show_details");
|
45
|
+
console.log($scope.details_templates);
|
46
|
+
API.all("conversations").get($routeParams.id).then(function(data){
|
47
|
+
$scope.conversations = data;
|
48
|
+
});
|
49
|
+
}else{
|
50
|
+
$scope.details_template = template("conversations/details");
|
51
|
+
var type;
|
52
|
+
switch ($routeParams.type){
|
53
|
+
case "inbox":
|
54
|
+
type = "inbox";
|
55
|
+
break;
|
56
|
+
case "sentbox":
|
57
|
+
type = "sentbox";
|
58
|
+
break;
|
59
|
+
case "trash":
|
60
|
+
type = "trash";
|
61
|
+
break;
|
62
|
+
default:
|
63
|
+
$location.path("conversations/inbox/box");
|
64
|
+
}
|
65
|
+
API.all("conversations").all(type).all("box").getList().then(function(data){
|
66
|
+
$scope.conversations = data;
|
67
|
+
|
68
|
+
});
|
69
|
+
}
|
70
|
+
$scope.buttons = [
|
71
|
+
{
|
72
|
+
title: gettext("New"),
|
73
|
+
icon: "fa fa-plus",
|
74
|
+
classes: "btn tiny green",
|
75
|
+
route: "#conversations/new"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
title: gettext("Sent box"),
|
79
|
+
icon: "fa fa-plus",
|
80
|
+
classes: "btn tiny green",
|
81
|
+
route: "#/conversations/sentbox"
|
82
|
+
},
|
83
|
+
{
|
84
|
+
title: gettext("Trash box"),
|
85
|
+
icon: "fa fa-plus",
|
86
|
+
classes: "btn tiny green",
|
87
|
+
route: "#/conversations/trash"
|
88
|
+
}
|
89
|
+
];
|
90
|
+
|
91
|
+
$scope.message_title = function(conversation){
|
92
|
+
console.log(conversation);
|
93
|
+
console.log('fix me : check why multiple run');
|
94
|
+
return conversation.message.subject;
|
95
|
+
};
|
96
|
+
|
97
|
+
$scope.on_trash = function(conversations){
|
98
|
+
return conversations;
|
99
|
+
var query = [];
|
100
|
+
conversations.forEach(function(conversation){
|
101
|
+
query.push(conversation.id);
|
102
|
+
});
|
103
|
+
|
104
|
+
API.all("conversations",query.join(",")).post()
|
105
|
+
.then(function(data) {
|
106
|
+
|
107
|
+
$scope.conversations = _.filter($scope.Conversations, function(x){
|
108
|
+
return !(query.indexOf(x.id) != -1);
|
109
|
+
});
|
110
|
+
success_message(data.msg);
|
111
|
+
})
|
112
|
+
.catch(catch_error);
|
113
|
+
|
114
|
+
};
|
115
|
+
|
116
|
+
$scope.on_untrash = function(conversations){
|
117
|
+
var query = [];
|
118
|
+
conversations.forEach(function(conversation){
|
119
|
+
query.push(conversation.id);
|
120
|
+
});
|
121
|
+
|
122
|
+
API.all("conversations",query.join(",")).post()
|
123
|
+
.then(function(data) {
|
124
|
+
|
125
|
+
$scope.conversations = _.filter($scope.Conversations, function(x){
|
126
|
+
return !(query.indexOf(x.id) != -1);
|
127
|
+
});
|
128
|
+
success_message(data.msg);
|
129
|
+
})
|
130
|
+
.catch(catch_error);
|
131
|
+
};
|
132
|
+
|
133
|
+
|
134
|
+
}]);
|
135
|
+
|
136
|
+
|
137
|
+
Conversation.controller("ConversationControllerNew", ["$scope", "Restangular", "gettext", "catch_error", "$routeParams", "$location", function($scope, API, gettext, catch_error, $routeParams, $location){
|
138
|
+
$scope.obj_id = null;
|
139
|
+
if("id" in $routeParams){
|
140
|
+
$scope.obj_id = $routeParams.id;
|
141
|
+
var obj = API.all("conversations").get($routeParams.id)
|
142
|
+
.then(function(data){
|
143
|
+
var recipients= [];
|
144
|
+
data.recipients.forEach(function(entry){
|
145
|
+
if( $.inArray(entry.email,recipients) == -1 )
|
146
|
+
recipients.push(entry.email);
|
147
|
+
});
|
148
|
+
$scope.recipients = recipients;
|
149
|
+
$scope.subject = "Re: " + data.subject;
|
150
|
+
$scope.body = "\n\n_____________\n"+data.body;
|
151
|
+
});
|
152
|
+
}
|
153
|
+
|
154
|
+
$scope.save = function() {
|
155
|
+
var conversation = {conversation: {
|
156
|
+
recipients: $scope.recipients,
|
157
|
+
subject: $scope.subject,
|
158
|
+
body: $scope.body
|
159
|
+
}};
|
160
|
+
console.log(conversation);
|
161
|
+
if ($scope.obj_id){
|
162
|
+
API.all("conversations").one($scope.obj_id).one("reply").customPOST(conversation,"",{}).then(function(){
|
163
|
+
success_message(gettext("Message sent successfully."));
|
164
|
+
$location.path("conversations/inbox");
|
165
|
+
});
|
166
|
+
}else{
|
167
|
+
API.all("conversations").post(conversation).then(function(){
|
168
|
+
success_message(gettext("Message sent Successfully"));
|
169
|
+
$location.path("conversations/inbox");
|
170
|
+
}).catch(catch_error);
|
171
|
+
}
|
172
|
+
};
|
173
|
+
|
174
|
+
$scope.cancel = function(){
|
175
|
+
$(".form input").val("");
|
176
|
+
$location.path("conversations/index");
|
177
|
+
};
|
178
|
+
|
179
|
+
|
180
|
+
}]);
|
@@ -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 Boolean_ = angular.module("BooleanField", []);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* <string-field></string-field> directive defination
|
24
|
+
*/
|
25
|
+
Boolean_.directive('booleanField', ["$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 <boolean-field> directive
|
33
|
+
return {
|
34
|
+
templateUrl: template("fields/boolean/boolean"),
|
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 Datetime_ = angular.module("DatetimeField", ['ngQuickDate']);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* <string-field></string-field> directive defination
|
24
|
+
*/
|
25
|
+
Datetime_.directive('datetimeField', ["$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/datetime/datetime"),
|
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
|
+
}]);
|
@@ -0,0 +1 @@
|
|
1
|
+
angular.module("Fields", ["RelationField", "StringField", "IntegerField", "TextField", "BooleanField", "DatetimeField"]);
|
@@ -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 Integer_ = angular.module("IntegerField", []);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* <string-field></string-field> directive defination
|
24
|
+
*/
|
25
|
+
Integer_.directive('integerField', ["$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/integer/integer"),
|
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
|
+
}]);
|
@@ -0,0 +1,78 @@
|
|
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 Relation = angular.module("RelationField", ["ui.select2"]);
|
21
|
+
|
22
|
+
/*
|
23
|
+
* <relation-field></relation-field> directive defination
|
24
|
+
*/
|
25
|
+
Relation.directive('relationField', ["$filter", "gettext", "Restangular", "catch_error", function($filter, gettext, API, catch_error) {
|
26
|
+
|
27
|
+
function link(scope, element, attrs){
|
28
|
+
var ltr = is_ltr();
|
29
|
+
scope.element_id = "id_" + scope.field.name;
|
30
|
+
scope.msg_element_id = "id_" + scope.field.name + "_msg";
|
31
|
+
|
32
|
+
if( scope.field.type != "in" ){
|
33
|
+
scope.have = function(obj_id) {
|
34
|
+
var tmp = _.where(scope.model, { id: obj_id });
|
35
|
+
if (tmp.length > 0) {
|
36
|
+
return true;
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
scope.update_collection = function(){
|
44
|
+
API.all(scope.field.to).getList().then(function(data){
|
45
|
+
scope.all_options = data;
|
46
|
+
}, function(data){
|
47
|
+
catch_error(data);
|
48
|
+
});
|
49
|
+
};
|
50
|
+
|
51
|
+
scope.update_collection();
|
52
|
+
}
|
53
|
+
}
|
54
|
+
// Actual object of <relation-field> directive
|
55
|
+
return {
|
56
|
+
templateUrl: template("fields/relation/relation"),
|
57
|
+
replace: true,
|
58
|
+
restrict: "E",
|
59
|
+
transclude: true,
|
60
|
+
scope: {
|
61
|
+
// select2 options
|
62
|
+
select2Options: '=',
|
63
|
+
|
64
|
+
// Does this field is required
|
65
|
+
required: "=",
|
66
|
+
|
67
|
+
// Field to use as title of options
|
68
|
+
titleField: '=',
|
69
|
+
|
70
|
+
// relation field data
|
71
|
+
field: '=fieldData',
|
72
|
+
|
73
|
+
// Actual Angularjs ng-model
|
74
|
+
model: '='
|
75
|
+
},
|
76
|
+
link: link
|
77
|
+
};
|
78
|
+
}]);
|