Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
ab9371e5
Unverified
Commit
ab9371e5
authored
8 years ago
by
Rodrigo Nascimento
Browse files
Options
Downloads
Patches
Plain Diff
Improve lazy loading of custom fields and translations
parent
0522d2ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/rocketchat-lib/client/CustomTranslations.js
+11
-9
11 additions, 9 deletions
packages/rocketchat-lib/client/CustomTranslations.js
packages/rocketchat-ui-login/login/form.coffee
+16
-10
16 additions, 10 deletions
packages/rocketchat-ui-login/login/form.coffee
with
27 additions
and
19 deletions
packages/rocketchat-lib/client/CustomTranslations.js
+
11
−
9
View file @
ab9371e5
Meteor
.
startup
(
function
()
{
Meteor
.
autorun
(
function
()
{
let
CustomTranslations
=
RocketChat
.
settings
.
get
(
'
Custom_Translations
'
);
try
{
CustomTranslations
=
JSON
.
parse
(
CustomTranslations
);
}
catch
(
e
)
{
console
.
error
(
'
Invalid setting Custom_Translations
'
,
e
);
}
if
(
typeof
CustomTranslations
===
'
string
'
&&
CustomTranslations
.
trim
()
!==
''
)
{
try
{
CustomTranslations
=
JSON
.
parse
(
CustomTranslations
);
for
(
const
lang
in
CustomTranslations
)
{
if
(
CustomTranslations
.
hasOwnProperty
(
lang
))
{
const
translations
=
CustomTranslations
[
lang
];
TAPi18next
.
addResourceBundle
(
lang
,
'
project
'
,
translations
);
for
(
const
lang
in
CustomTranslations
)
{
if
(
CustomTranslations
.
hasOwnProperty
(
lang
))
{
const
translations
=
CustomTranslations
[
lang
];
TAPi18next
.
addResourceBundle
(
lang
,
'
project
'
,
translations
);
}
}
}
catch
(
e
)
{
console
.
error
(
'
Invalid setting Custom_Translations
'
,
e
);
}
}
});
...
...
This diff is collapsed.
Click to expand it.
packages/rocketchat-ui-login/login/form.coffee
+
16
−
10
View file @
ab9371e5
...
...
@@ -47,11 +47,11 @@ Template.loginForm.helpers
return
OnePassword
?
.
findLoginForUrl
?
&&
device
?
.
platform
?
.
toLocaleLowerCase
()
is
'ios'
customFields
:
->
if
not
Template
.
instance
().
customFields
if
not
Template
.
instance
().
customFields
.
get
()
return
[]
customFieldsArray
=
[]
for
key
,
value
of
Template
.
instance
().
customFields
for
key
,
value
of
Template
.
instance
().
customFields
.
get
()
customFieldsArray
.
push
fieldName
:
key
,
field
:
value
...
...
@@ -150,12 +150,17 @@ Template.loginForm.events
Template
.
loginForm
.
onCreated
->
instance
=
@
@
customFields
=
new
ReactiveVar
if
RocketChat
.
settings
.
get
(
'Accounts_CustomFields'
)
isnt
''
try
@
customFields
=
JSON
.
parse
RocketChat
.
settings
.
get
(
'Accounts_CustomFields'
)
catch
e
console
.
error
(
'Invalid JSON for Accounts_CustomFields'
)
Tracker
.
autorun
=>
Accounts_CustomFields
=
RocketChat
.
settings
.
get
(
'Accounts_CustomFields'
)
if
typeof
Accounts_CustomFields
is
'string'
and
Accounts_CustomFields
.
trim
()
isnt
''
try
@
customFields
.
set
JSON
.
parse
RocketChat
.
settings
.
get
(
'Accounts_CustomFields'
)
catch
e
console
.
error
(
'Invalid JSON for Accounts_CustomFields'
)
else
@
customFields
.
set
undefined
if
Meteor
.
settings
.
public
.
sandstorm
@
state
=
new
ReactiveVar
(
'sandstorm'
)
...
...
@@ -167,11 +172,12 @@ Template.loginForm.onCreated ->
@
validSecretURL
=
new
ReactiveVar
(
false
)
validateCustomFields
=
(
formObj
,
validationObj
)
->
if
not
instance
.
customFields
customFields
=
instance
.
customFields
.
get
()
if
not
customFields
return
for
field
,
value
of
formObj
when
instance
.
customFields
[
field
]
?
customField
=
instance
.
customFields
[
field
]
for
field
,
value
of
formObj
when
customFields
[
field
]
?
customField
=
customFields
[
field
]
if
customField
.
required
is
true
and
not
value
return
validationObj
[
field
]
=
t
(
'Field_required'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment