|
1
|
|
|
/* |
|
2
|
|
|
* Circles - Bring cloud-users closer together. |
|
3
|
|
|
* |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. See the COPYING file. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Maxence Lange <[email protected]> |
|
8
|
|
|
* @copyright 2017 |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** global: OC */ |
|
27
|
|
|
/** global: OCA */ |
|
28
|
|
|
/** global: Notyf */ |
|
29
|
|
|
|
|
30
|
|
|
/** global: actions */ |
|
31
|
|
|
/** global: nav */ |
|
32
|
|
|
/** global: elements */ |
|
33
|
|
|
/** global: curr */ |
|
34
|
|
|
/** global: api */ |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
var resultCircles = { |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
joinCircleResult: function (result) { |
|
41
|
|
|
if (result.status === 0) { |
|
42
|
|
|
OCA.notification.onFail( |
|
43
|
|
|
t('circles', "Cannot join this circle") + ': ' + |
|
44
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
45
|
|
|
return; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
elements.removeMemberslistEntry(result.member.user_id); |
|
49
|
|
|
if (result.member.level === define.levelMember) { |
|
|
|
|
|
|
50
|
|
|
OCA.notification.onSuccess( |
|
51
|
|
|
t('circles', "You have successfully joined this circle")); |
|
52
|
|
|
} else { |
|
53
|
|
|
OCA.notification.onSuccess( |
|
54
|
|
|
t('circles', "You have requested to join this circle")); |
|
55
|
|
|
} |
|
56
|
|
|
actions.selectCircle(result.circle_id); |
|
57
|
|
|
}, |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
leaveCircleResult: function (result) { |
|
61
|
|
|
if (result.status === 1) { |
|
62
|
|
|
|
|
63
|
|
|
elements.mainUIMembers.children("[member-id='" + result.name + "']").each( |
|
64
|
|
|
function () { |
|
65
|
|
|
$(this).hide(300); |
|
66
|
|
|
}); |
|
67
|
|
|
|
|
68
|
|
|
actions.selectCircle(result.circle_id); |
|
69
|
|
|
OCA.notification.onSuccess( |
|
70
|
|
|
t('circles', "You have successfully left this circle")); |
|
71
|
|
|
return; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
OCA.notification.onFail( |
|
75
|
|
|
t('circles', "Cannot leave this circle") + ': ' + |
|
76
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
77
|
|
|
}, |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
destroyCircleResult: function (result) { |
|
81
|
|
|
if (result.status === 1) { |
|
82
|
|
|
|
|
83
|
|
|
actions.unselectCircle(result.circle_id); |
|
84
|
|
|
OCA.notification.onSuccess( |
|
85
|
|
|
t('circles', "You have successfully deleted this circle")); |
|
86
|
|
|
return; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
OCA.notification.onFail( |
|
90
|
|
|
t('circles', "Cannot delete this circle") + ': ' + |
|
91
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
92
|
|
|
}, |
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
createCircleResult: function (result) { |
|
96
|
|
|
var type = actions.getStringTypeFromType(result.type); |
|
97
|
|
|
|
|
98
|
|
|
if (result.status === 1) { |
|
99
|
|
|
OCA.notification.onSuccess(t('circles', " {type} '{name}' created", { |
|
100
|
|
|
type: type, |
|
101
|
|
|
name: result.name |
|
102
|
|
|
})); |
|
103
|
|
|
elements.emptyCircleCreation(); |
|
104
|
|
|
nav.displayCirclesList(result.circle.type); |
|
105
|
|
|
actions.selectCircle(result.circle.id); |
|
106
|
|
|
return; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
OCA.notification.onFail( |
|
110
|
|
|
t('circles', " {type} '{name}' could not be created", { |
|
111
|
|
|
type: type, |
|
112
|
|
|
name: result.name |
|
113
|
|
|
}) + ': ' + |
|
114
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
115
|
|
|
}, |
|
116
|
|
|
|
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
selectCircleResult: function (result) { |
|
120
|
|
|
|
|
121
|
|
|
elements.mainUIMembers.emptyTable(); |
|
122
|
|
|
if (result.status < 1) { |
|
123
|
|
|
OCA.notification.onFail( |
|
124
|
|
|
t('circles', 'Issue while retrieving the details of this circle') + '" ' + |
|
125
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
126
|
|
|
return; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
elements.navigation.children('.circle').removeClass('selected'); |
|
130
|
|
|
elements.navigation.children(".circle[circle-id='" + result.circle_id + "']").each( |
|
131
|
|
|
function () { |
|
132
|
|
|
$(this).addClass('selected'); |
|
133
|
|
|
}); |
|
134
|
|
|
|
|
135
|
|
|
elements.emptyContent.hide(800); |
|
136
|
|
|
elements.mainUI.fadeIn(800); |
|
137
|
|
|
curr.circle = result.circle_id; |
|
138
|
|
|
curr.circleLevel = result.details.user.level; |
|
139
|
|
|
curr.circleStatus = result.details.user.status; |
|
140
|
|
|
|
|
141
|
|
|
nav.displayCircleDetails(result.details); |
|
142
|
|
|
nav.displayMembersInteraction(result.details); |
|
143
|
|
|
nav.displayMembers(result.details.members); |
|
144
|
|
|
}, |
|
145
|
|
|
|
|
146
|
|
|
|
|
147
|
|
|
listCirclesResult: function (result) { |
|
148
|
|
|
|
|
149
|
|
|
if (result.status < 1) { |
|
150
|
|
|
OCA.notification.onFail( |
|
151
|
|
|
t('circles', 'Issue while retrieving the list of circles') + '; ' + |
|
152
|
|
|
((result.error) ? result.error : t('circles', 'no error message'))); |
|
153
|
|
|
return; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
elements.resetCirclesList(); |
|
157
|
|
|
|
|
158
|
|
|
var data = result.data; |
|
159
|
|
|
for (var i = 0; i < data.length; i++) { |
|
160
|
|
|
var tmpl = elements.generateTmplCircle(data[i]); |
|
161
|
|
|
elements.navigation.append( |
|
162
|
|
|
'<div class="circle" circle-id="' + data[i].id + '">' + tmpl + '</div>'); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
elements.navigation.children('.circle').on('click', function () { |
|
166
|
|
|
actions.selectCircle($(this).attr('circle-id')); |
|
167
|
|
|
}); |
|
168
|
|
|
}, |
|
169
|
|
|
|
|
170
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
}; |
|
173
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.