@@ -23,10 +23,11 @@ Template.tenantForm.onDestroyed(() => {
23
23
24
24
Template . tenantForm . events ( {
25
25
'click #save-tenant' : function ( ) {
26
+
26
27
if ( $ ( '#add-tenant-name' ) . val ( ) === '' ) {
27
- sAlert . error ( 'Tenant must have a name!' , { timeout : 'none' } ) ;
28
+ sAlert . error ( TAPi18n . __ ( 'tenantForm_tenant_noName_error' ) , { timeout : 'none' } ) ;
28
29
} else if ( $ ( '#add-tenant-description' ) . val ( ) === '' ) {
29
- sAlert . error ( 'Tenant must have a description!' , { timeout : 'none' } ) ;
30
+ sAlert . error ( TAPi18n . __ ( 'tenantForm_tenant_noDescription_error' ) , { timeout : 'none' } ) ;
30
31
} else {
31
32
// Save new Tenant operation began, inform spinner
32
33
Session . set ( 'tenantUpdateOngoing' , true ) ;
@@ -62,15 +63,12 @@ Template.tenantForm.events({
62
63
} ) ;
63
64
}
64
65
65
- // Set local tenant list empty
66
- let tenantList = [ ] ;
67
-
68
66
// POST /tenant
69
67
Meteor . call ( 'addTenant' , tenant , ( error , result ) => {
70
68
if ( result ) {
71
69
if ( result . status === 201 ) {
72
70
// Empty the tenant user list
73
- tenantUsers . splice ( 0 , tenantUsers . length ) ;
71
+ tenantUsers = [ ] ;
74
72
// Remove users from session
75
73
Session . set ( 'tenantUsers' , tenantUsers ) ;
76
74
@@ -80,7 +78,7 @@ Template.tenantForm.events({
80
78
$ ( '#add-tenant-description' ) . val ( '' ) ;
81
79
82
80
// New tenant successfully added on manager side, empty local list
83
- tenantList = [ ] ;
81
+ const tenantList = [ ] ;
84
82
// Save to sessionStorage to be used while adding users to tenant
85
83
Session . set ( 'tenantList' , tenantList ) ;
86
84
@@ -94,7 +92,7 @@ Template.tenantForm.events({
94
92
// eslint-disable-next-line max-len
95
93
Meteor . call ( 'informTenantUser' , notifyUserList , 'tenantAddition' , tenant . name , ( nofityChangeError ) => {
96
94
if ( nofityChangeError ) {
97
- sAlert . error ( 'Error in notifying users' , { timeout : 'none' } ) ;
95
+ sAlert . error ( TAPi18n . __ ( 'tenantForm_addTenant_notify_error' ) , { timeout : 'none' } ) ;
98
96
}
99
97
} ) ;
100
98
@@ -108,15 +106,17 @@ Template.tenantForm.events({
108
106
// Operation finished, failure, inform spinner
109
107
Session . set ( 'tenantUpdateOngoing' , false ) ;
110
108
// Tenant addition failure on manager side, save new tenant object to local array
111
- const errorMessage = `Tenant manager error! Returns code (${ result . status } ).` ;
109
+ let errorMessage = TAPi18n . __ ( 'tenantForm_addTenant_failure_Message' ) ;
110
+ errorMessage = errorMessage . concat ( ` (${ result . status } ).` ) ;
112
111
sAlert . error ( errorMessage , { timeout : 'none' } ) ;
113
112
}
114
113
}
115
114
if ( error ) {
116
115
// Operation finished, failure, inform spinner
117
116
Session . set ( 'tenantUpdateOngoing' , false ) ;
118
117
// Tenant addition failure on manager side, save new tenant object to local array
119
- const errorMessage = `Tenant operation failed! (${ error } ).` ;
118
+ let errorMessage = TAPi18n . __ ( 'tenantForm_addTenant_error_Message' ) ;
119
+ errorMessage = errorMessage . concat ( ` (${ error } ).` ) ;
120
120
sAlert . error ( errorMessage , { timeout : 'none' } ) ;
121
121
}
122
122
} ) ;
@@ -129,9 +129,9 @@ Template.tenantForm.events({
129
129
130
130
// Name and description must be given in order to be able to send modify
131
131
if ( $ ( '#add-tenant-name' ) . val ( ) === '' ) {
132
- sAlert . error ( 'Tenant must have a name!' , { timeout : 'none' } ) ;
132
+ sAlert . error ( TAPi18n . __ ( 'tenantForm_tenant_noName_error' ) , { timeout : 'none' } ) ;
133
133
} else if ( $ ( '#add-tenant-description' ) . val ( ) === '' ) {
134
- sAlert . error ( 'Tenant must have a description!' , { timeout : 'none' } ) ;
134
+ sAlert . error ( TAPi18n . __ ( 'tenantForm_tenant_noDescription_error' ) , { timeout : 'none' } ) ;
135
135
} else {
136
136
// Update Tenant operation began, inform spinner
137
137
Session . set ( 'tenantUpdateOngoing' , true ) ;
@@ -154,12 +154,12 @@ Template.tenantForm.events({
154
154
// Fill in tenant id
155
155
modifyTenantPayload . id = originalTenant . id ;
156
156
// Fill in replace for name operation
157
- const changedDescription = {
157
+ const changedName = {
158
158
op : 'replace' ,
159
159
value : $ ( '#add-tenant-name' ) . val ( ) ,
160
160
path : '/name' ,
161
161
} ;
162
- modifyTenantPayload . body . push ( changedDescription ) ;
162
+ modifyTenantPayload . body . push ( changedName ) ;
163
163
}
164
164
165
165
// Any changes in description
@@ -181,7 +181,7 @@ Template.tenantForm.events({
181
181
-> fill "remove" op for user
182
182
- if user is present in both, but no changes,
183
183
-> remove user from NEW tenant user list
184
- - if user is present in both, and there are changes
184
+ - if user is present in both, and there are changes in roles
185
185
-> fill "replace" op for user
186
186
-> remove user from NEW tenant user list
187
187
@@ -231,7 +231,7 @@ Template.tenantForm.events({
231
231
// Add remove operation for user to request list
232
232
changeList . push ( removedUser ) ;
233
233
234
- // Add user info also to check list
234
+ // Add user info also to check list to be checked from tenant manager
235
235
const checkPath = path . concat ( '/name' ) ;
236
236
const checkUser = {
237
237
op : 'test' ,
@@ -241,7 +241,7 @@ Template.tenantForm.events({
241
241
// Add user to to-be-checked list
242
242
usersNeedChecking . push ( checkUser ) ;
243
243
244
- // Always add user to list for notification about removal
244
+ // Always add user to list for notification about removal by email
245
245
notifyRemovedUsers . push ( origUser ) ;
246
246
247
247
// If user data is modified, set user to be replaced
0 commit comments