Skip to content

Commit 91fba57

Browse files
committed
SSR.render #34
1 parent 990321a commit 91fba57

22 files changed

+188
-205
lines changed

client/helpers/methods_users.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ UI.registerHelper('isZwyczajnyLogged', () => {
1414
return profile && profile.userType == USERTYPE.CZLONEK ? true : false;
1515
});
1616

17+
UI.registerHelper('welcomeGender', () => {
18+
return Etc.recognizeSexMethod();
19+
});
20+
1721
IsAdminUser = function () {
1822
return Roles.userIsInRole(Meteor.user(), ['admin']);
1923
};

client/helpers/methods_utils.js

-13
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,6 @@ notificationPauseWarning = function (text, timeLeft) {
1414
});
1515
};
1616

17-
recognizeSexMethod = function (userData) {
18-
// gender identification based on PESEL number
19-
var welcomeGender = null;
20-
if (userData.profile.pesel) {
21-
if (userData.profile.pesel != '') {
22-
var pesel = userData.profile.pesel.substring(9, 10);
23-
if (_.contains(['1', '3', '5', '7', '9'], pesel)) welcomeGender = TAPi18n.__('txv.HONORABLE');
24-
else welcomeGender = TAPi18n.__('txv.DEAR');
25-
} else welcomeGender = TAPi18n.__('txv.MR_MRS');
26-
} else welcomeGender = TAPi18n.__('txv.MR_MRS');
27-
return welcomeGender;
28-
};
29-
3017
isInTab = function (item, tab) {
3118
// Checking the array
3219
var flag = false;

client/helpers/validators.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ validationPlacementError = function (error, element) {
6161

6262
Meteor.startup(function () {
6363
Tracker.autorun(function () {
64-
var lang = getUserLanguage();
64+
var lang = Etc.getUserLanguage();
6565

6666
jQuery.validator.addMethod('checkExistsNazwaKwestii', function (value, element) {
6767
var kwestie = Kwestia.find({

client/views/account/czlonek_zwyczajny_form.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ addKwestiaOsobowa = function (idUserDraft,newUser) {
264264
// If there is already a user, he is an advisor, then send him a confirmation in the message
265265
addPowiadomienieAplikacjaRespondFunction(ret,newKwestia[0].dataWprowadzenia,NOTIFICATION_TYPE.APPLICATION_CONFIRMATION);
266266
}
267-
Meteor.call('sendApplicationConfirmation', idUserDraft,function (error) {
267+
Meteor.call('sendApplicationConfirmation', idUserDraft, Etc.getUserLanguage(), function (error) {
268268
if (!error) {
269-
Meteor.call('sendEmailAddedIssue', ret, getUserLanguage(), function (error) {
269+
Meteor.call('sendEmailAddedIssue', ret, Etc.getUserLanguage(), function (error) {
270270
if (error) {
271271
var emailError = {
272272
idIssue: ret,

client/views/account/doradca_form.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ addKwestiaOsobowaDoradca = function (idUserDraft,newUser) {
184184
Router.go('home');
185185
addPowiadomienieAplikacjaIssueFunction(ret,newKwestia[0].dataWprowadzenia);
186186
przyjecieWnioskuConfirmation(Parametr.findOne().czasWyczekiwaniaKwestiiSpecjalnej, daneAplikanta.email, 'doradztwo');
187-
Meteor.call('sendApplicationConfirmation', idUserDraft,function (error) {
187+
Meteor.call('sendApplicationConfirmation', idUserDraft, Etc.getUserLanguage(), function (error) {
188188
if (!error) {
189-
Meteor.call('sendEmailAddedIssue', ret, getUserLanguage(), function (error) {
189+
Meteor.call('sendEmailAddedIssue', ret, Etc.getUserLanguage(), function (error) {
190190
if (error) {
191191
var emailError = {
192192
idIssue: ret,

client/views/account/forgotten_password_form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Template.forgottenPassword.events({
4242
if (ret == true) {
4343
// Accounts.forgotPassword ( options );
4444
document.getElementById('resetButton').disabled = true;
45-
Meteor.call('sendResetPasswordEmail', options.email, function (error, ret) {
45+
Meteor.call('sendResetPasswordEmail', options.email, null, function (error) {
4646
if (error) {
4747
document.getElementById('resetButton').disabled = false;
4848
throwError(TAPi18n.__('txv.ALERT_LOG4'));

client/views/account/register_form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Template.registerForm.rendered = function () {
8989
});
9090

9191
Tracker.autorun(() => {
92-
getUserLanguage();
92+
Etc.getUserLanguage();
9393
$('#userForm').valid();
9494
});
9595
};

client/views/kwestie/kwestia_crud/preview_kwestia.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ addKwestia = function (idTemat,idRodzaj,isOption,kwestia) {
184184
}
185185
} else {
186186
Session.set('kwestiaPreview', null);
187-
Meteor.call('sendEmailAddedIssue', ret, getUserLanguage(), function (error) {
187+
Meteor.call('sendEmailAddedIssue', ret, Etc.getUserLanguage(), function (error) {
188188
if (error) {
189189
var emailError = {
190190
idIssue: ret,

client/views/kwestie/opcje_crud/preview_kwestia_opcja.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Template.previewKwestiaOpcja.events({
6363
throwError(error.reason);
6464
}
6565
} else {
66-
Meteor.call('sendEmailAddedIssue', ret, getUserLanguage(), function (error) {
66+
Meteor.call('sendEmailAddedIssue', ret, Etc.getUserLanguage(), function (error) {
6767
if (error) {
6868
var emailError = {
6969
idIssue: ret,

client/views/powiadomienia/notification_info.js

-21
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ Template.notificationNewMessage.helpers({
4949
var user = Users.findOne({_id:this.idNadawca});
5050
return user ? user.profile.fullName : null;
5151
},
52-
welcomeGender: function () {
53-
return recognizeSexMethod(Meteor.user());
54-
},
5552
userData: function () {
5653
return Meteor.user().profile.fullName;
5754
},
@@ -66,9 +63,6 @@ Template.notificationNewIssue.helpers({
6663
actualKwestia: function (idKwestia) {
6764
return getIssue(idKwestia);
6865
},
69-
welcomeGender: function () {
70-
return recognizeSexMethod(Meteor.user());
71-
},
7266
userData: function () {
7367
return Meteor.user().profile.fullName;
7468
},
@@ -96,9 +90,6 @@ Template.notificationLackOfRealizationReport.helpers({
9690
actualKwestia: function (idKwestia) {
9791
return getIssue(idKwestia);
9892
},
99-
welcomeGender: function () {
100-
return recognizeSexMethod(Meteor.user());
101-
},
10293
userData: function () {
10394
return Meteor.user().profile.fullName;
10495
},
@@ -138,9 +129,6 @@ Template.notificationApplicationAnswer.helpers({
138129
actualKwestia: function (idKwestia) {
139130
return getIssue(idKwestia);
140131
},
141-
welcomeGender: function () {
142-
return recognizeSexMethod(Meteor.user());
143-
},
144132
userData: function () {
145133
return Meteor.user().profile.fullName;
146134
},
@@ -165,9 +153,6 @@ Template.notificationLobbingMessage.helpers({
165153
actualKwestia: function (idKwestia) {
166154
return getIssue(idKwestia);
167155
},
168-
welcomeGender: function () {
169-
return recognizeSexMethod(Meteor.user());
170-
},
171156
userData: function () {
172157
return Meteor.user().profile.fullName;
173158
},
@@ -199,9 +184,6 @@ Template.notificationNoActivity.helpers({
199184
actualKwestia: function (idKwestia) {
200185
return getIssue(idKwestia);
201186
},
202-
welcomeGender: function () {
203-
return recognizeSexMethod(Meteor.user());
204-
},
205187
userData: function () {
206188
return Meteor.user().profile.fullName;
207189
},
@@ -217,9 +199,6 @@ Template.notificationVoteStarted.helpers({
217199
actualKwestia: function (idKwestia) {
218200
return getIssue(idKwestia);
219201
},
220-
welcomeGender: function () {
221-
return recognizeSexMethod(Meteor.user());
222-
},
223202
userData: function () {
224203
return Meteor.user().profile.fullName;
225204
},

client/views/ustawienia/parametry/edit_parametr_modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ var createIssueChangeParam = function (paramName, title, oldValue, newValue) {
204204
throwError(error.reason);
205205
else {
206206
addPowiadomienieGlobalneFunction(ret);
207-
Meteor.call('sendEmailAddedIssue', ret, getUserLanguage(), function (error) {
207+
Meteor.call('sendEmailAddedIssue', ret, Etc.getUserLanguage(), function (error) {
208208
if (error) {
209209
var emailError = {
210210
idIssue: ret,

client/views/ustawienia/profile/sendMessage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sendMessage = function (newEmail,idReceiver) {
5050
} else {
5151
var from = Meteor.user().profile.firstName + ' ' + Meteor.user().profile.lastName;
5252
addPowiadomienieFunction(newEmail[0]);
53-
Meteor.call('sendDirectMessageToUser', idReceiver, from, newEmail[0].subject, newEmail[0].content, function (error) {
53+
Meteor.call('sendDirectMessageToUser', idReceiver, from, newEmail[0].subject, newEmail[0].content, Etc.getUserLanguage(), function (error) {
5454
if (error) {
5555

5656
var emailError = {

client/views/ustawienia/ustawienia_main.js

+34-27
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ Template.administracjaUserMain.helpers({
99
fields: [
1010
{key: 'dataWprowadzenia', label: TAPi18n.__('txv.DATE_OF_INTRO'), tmpl: Template.dataUtwKwestia},
1111
{key: 'kwestiaNazwa', label: TAPi18n.__('glob.NameIssue'), tmpl: Template.nazwaKwestiLink},
12-
{key: 'wartoscPriorytetu', label: TAPi18n.__('glob.Priority'), tmpl: Template.priorytetKwestia ,sortOrder:1,sortDirection:'ascending'},
12+
{
13+
key: 'wartoscPriorytetu',
14+
label: TAPi18n.__('glob.Priority'),
15+
tmpl: Template.priorytetKwestia,
16+
sortOrder: 1,
17+
sortDirection: 'ascending'
18+
},
1319
{key: 'options', label: TAPi18n.__('txv.OPTIONS'), tmpl: Template.lobbujZaKwestia}
1420
]
1521
};
1622
},
1723
listOfIssues: function () {
1824
var kwestie = Kwestia.find({
1925
$where: function () {
20-
var userDraft = UsersDraft.findOne({_id:this.idUser});
26+
var userDraft = UsersDraft.findOne({_id: this.idUser});
2127
var condition = false;
2228
if (userDraft) {
2329
if (userDraft.profile.idUser) {
@@ -28,11 +34,11 @@ Template.administracjaUserMain.helpers({
2834
return (this.czyAktywny == true && condition == true && (this.status != KWESTIA_STATUS.ZREALIZOWANA && this.status != KWESTIA_STATUS.REALIZOWANA)) ||
2935

3036
(((this.czyAktywny == true) && ((this.status == KWESTIA_STATUS.ADMINISTROWANA) || (this.idUser == Meteor.userId()))
31-
|| ((this.typ == KWESTIA_TYPE.ACCESS_DORADCA
32-
|| this.typ == KWESTIA_TYPE.ACCESS_ZWYCZAJNY))
33-
|| this.status == KWESTIA_STATUS.OCZEKUJACA
34-
|| this.idZglaszajacego == Meteor.userId())
35-
&& (this.status != KWESTIA_STATUS.ZREALIZOWANA && this.status != KWESTIA_STATUS.REALIZOWANA));
37+
|| ((this.typ == KWESTIA_TYPE.ACCESS_DORADCA
38+
|| this.typ == KWESTIA_TYPE.ACCESS_ZWYCZAJNY))
39+
|| this.status == KWESTIA_STATUS.OCZEKUJACA
40+
|| this.idZglaszajacego == Meteor.userId())
41+
&& (this.status != KWESTIA_STATUS.ZREALIZOWANA && this.status != KWESTIA_STATUS.REALIZOWANA));
3642
}
3743
});
3844
if (kwestie) return kwestie;
@@ -46,9 +52,11 @@ Template.administracjaUserMain.helpers({
4652
return Meteor.user();
4753
},
4854
myKwestia: function () {
49-
var userDraft = UsersDraft.findOne({'profile.idUser': Meteor.userId(),czyAktywny: true});
50-
var kwestia = Kwestia.findOne({czyAktywny: true,
51-
typ:{$in:[KWESTIA_TYPE.ACCESS_ZWYCZAJNY]},idUser:userDraft._id});
55+
var userDraft = UsersDraft.findOne({'profile.idUser': Meteor.userId(), czyAktywny: true});
56+
var kwestia = Kwestia.findOne({
57+
czyAktywny: true,
58+
typ: {$in: [KWESTIA_TYPE.ACCESS_ZWYCZAJNY]}, idUser: userDraft._id
59+
});
5260
return kwestia ? kwestia : null;
5361
},
5462
isDoradca: function () {
@@ -58,7 +66,7 @@ Template.administracjaUserMain.helpers({
5866
return Meteor.user().profile.userType == USERTYPE.CZLONEK ? true : false;
5967
},
6068
kwestiaDraftExists: function () {
61-
var userDraf = UsersDraft.find({'profile.idUser': Meteor.userId(),czyAktywny: true});
69+
var userDraf = UsersDraft.find({'profile.idUser': Meteor.userId(), czyAktywny: true});
6270
if (userDraf) {
6371
if (userDraf.count() == 0) return false;
6472
return true;
@@ -68,7 +76,7 @@ Template.administracjaUserMain.helpers({
6876

6977
Template.lobbujZaKwestia.helpers({
7078
IAmOwnerKwestiaGlosowanaOrDEliberowana: function () {
71-
var userDraft = UsersDraft.findOne({_id:this.idUser,czyAktywny: true});
79+
var userDraft = UsersDraft.findOne({_id: this.idUser, czyAktywny: true});
7280
var condition = false;
7381
if (userDraft) {
7482
if (userDraft.profile.idUser) {
@@ -78,9 +86,9 @@ Template.lobbujZaKwestia.helpers({
7886
}
7987
return (this.idUser == Meteor.userId() || this.idZglaszajacego == Meteor.userId() || condition == true) && this.czyAktywny == true &&
8088
(this.status == KWESTIA_STATUS.GLOSOWANA ||
81-
this.status == KWESTIA_STATUS.DELIBEROWANA ||
82-
this.status == KWESTIA_STATUS.OSOBOWA ||
83-
this.status == KWESTIA_STATUS.ADMINISTROWANA) ? true : false;
89+
this.status == KWESTIA_STATUS.DELIBEROWANA ||
90+
this.status == KWESTIA_STATUS.OSOBOWA ||
91+
this.status == KWESTIA_STATUS.ADMINISTROWANA) ? true : false;
8492
}
8593
});
8694

@@ -91,9 +99,9 @@ Template.lobbujZaKwestia.events({
9199
'click #lobbujZaKwestia': function (e) {
92100
e.preventDefault();
93101
var idKwestia = this._id;
94-
var kwestia = Kwestia.findOne({_id:idKwestia});
102+
var kwestia = Kwestia.findOne({_id: idKwestia});
95103
if (kwestia.lobbowana) {
96-
if (moment(kwestia.lobbowana).add(24,'hours').format() > moment(new Date()).format()) {
104+
if (moment(kwestia.lobbowana).add(24, 'hours').format() > moment(new Date()).format()) {
97105
GlobalNotification.warning({
98106
title: TAPi18n.__('txv.INFO'),
99107
content: TAPi18n.__('txv.NOT_POSS_LESS24'),
@@ -123,7 +131,7 @@ bootboxEmail = function (idKwestia) {
123131
className: 'btn-success successMessage',
124132
callback: function () {
125133
$('.successMessage').css('visibility', 'hidden');
126-
sendEmailAndNotification(idKwestia,$('#emailText').val());
134+
sendEmailAndNotification(idKwestia, $('#emailText').val());
127135
}
128136
},
129137
danger: {
@@ -136,7 +144,7 @@ bootboxEmail = function (idKwestia) {
136144
}
137145
});
138146
};
139-
sendEmailAndNotification = function (idKwestia,emailText) {
147+
sendEmailAndNotification = function (idKwestia, emailText) {
140148
if (emailText == null || emailText.trim() == '') {
141149
GlobalNotification.error({
142150
title: TAPi18n.__('txv.INFO'),
@@ -145,10 +153,10 @@ sendEmailAndNotification = function (idKwestia,emailText) {
145153
});
146154
bootboxEmail(idKwestia);
147155
} else {
148-
Meteor.call('updTheLobbTimeIssue',idKwestia,new Date(),function (error) {
156+
Meteor.call('updTheLobbTimeIssue', idKwestia, new Date(), function (error) {
149157
if (!error) {
150-
addPowiadomienieLobbingIssueFunction(idKwestia,emailText);
151-
Meteor.call('sendEmailLobbingIssue', idKwestia,emailText, Meteor.userId(), getUserLanguage(), function (error) {
158+
addPowiadomienieLobbingIssueFunction(idKwestia, emailText);
159+
Meteor.call('sendEmailLobbingIssue', idKwestia, emailText, Meteor.userId(), Etc.getUserLanguage(), function (error) {
152160
if (error) {
153161
var emailError = {
154162
idIssue: idKwestia,
@@ -165,9 +173,8 @@ sendEmailAndNotification = function (idKwestia,emailText) {
165173
}
166174
};
167175

168-
addPowiadomienieLobbingIssueFunction = function (idKwestia,uzasadnienie) {
176+
addPowiadomienieLobbingIssueFunction = function (idKwestia, uzasadnienie) {
169177
var users = Users.find({'profile.userType': USERTYPE.CZLONEK});
170-
var kwestia = Kwestia.findOne({_id:idKwestia});
171178
users.forEach(function (user) {
172179
var newPowiadomienie = {
173180
idOdbiorca: user._id,
@@ -176,12 +183,12 @@ addPowiadomienieLobbingIssueFunction = function (idKwestia,uzasadnienie) {
176183
tytul: '',
177184
powiadomienieTyp: NOTIFICATION_TYPE.LOOBBING_MESSAGE,
178185
tresc: '',
179-
uzasadnienie:uzasadnienie,
180-
idKwestia:idKwestia,
186+
uzasadnienie: uzasadnienie,
187+
idKwestia: idKwestia,
181188
czyAktywny: true,
182189
czyOdczytany: false
183190
};
184-
Meteor.call('addPowiadomienie',newPowiadomienie,function (error) {
191+
Meteor.call('addPowiadomienie', newPowiadomienie, function (error) {
185192
if (error)
186193
throwError(error.reason);
187194
});

i18n.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
i18n.setDefaultLanguage('pl');
22

3-
getUserLanguage = function () {
4-
var defaultLang = 'pl';
5-
var userId = Meteor.userId();
6-
var user = Users.findOne({_id: userId});
7-
if (user && user.profile.language) {
8-
return user.profile.language;
9-
}
10-
return Session.get('language') || defaultLang;
11-
};
12-
133
if (Meteor.isClient) {
144
Meteor.startup(function () {
155
Tracker.autorun(function () {
16-
var lang = getUserLanguage();
6+
const lang = Etc.getUserLanguage();
177
TAPi18n.setLanguage(lang)
188
.done(function () {})
199
.fail(function (error_message) {

lib/constants.js

-2
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,3 @@ NOTIFICATION_TYPE = {
8484
FIRST_LOGIN_DATA: 'Wysłanie danych do logowania do nowo utworzonego konta',
8585
RESET_PASSWORD: 'Wysłanie linku do resetowania hasła'
8686
};
87-
88-

0 commit comments

Comments
 (0)