Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to completely disable transformation for admin or translation tools #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tap_i18n_db-client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ removeTrailingUndefs = share.helpers.removeTrailingUndefs
extend = $.extend

share.i18nCollectionTransform = (doc, collection) ->
if collection._disableTransformation
return doc

for route in collection._disabledOnRoutes
if route.test(window.location.pathname)
return doc
Expand Down Expand Up @@ -51,6 +54,7 @@ share.i18nCollectionExtensions = (obj) ->

return

obj._disableTransformation = false
obj._disabledOnRoutes = []
obj._disableTransformationOnRoute = (route) ->
obj._disabledOnRoutes.push(route)
Expand Down Expand Up @@ -104,7 +108,7 @@ TAPi18n.subscribe = (name) ->
subscription =
Meteor.subscribe.apply @, removeTrailingUndefs [].concat(name, params, lang_tag, callbacks)

# if the subscription is already ready:
# if the subscription is already ready:
local_session.set("ready", subscription.ready())

# If TAPi18n is called in a computation, to maintain Meteor.subscribe
Expand All @@ -115,7 +119,7 @@ TAPi18n.subscribe = (name) ->
if currentComputation?
# If TAPi18n.subscribe was called in a computation, call subscribe in a
# non-reactive context, but make sure that if the computation is getting
# invalidated also the subscription computation
# invalidated also the subscription computation
# (invalidations are allowed up->bottom but not bottom->up)
Deps.onInvalidate ->
subscription_computation.invalidate()
Expand Down
3 changes: 3 additions & 0 deletions tap_i18n_db-common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ TAPi18n.Collection = (name, options={}) ->
collection = share.i18nCollectionExtensions(commonCollectionExtensions(new Meteor.Collection(name, options)))

if Meteor.isClient
# Completely disable transformation in client (for admins, or translation tools)
collection._disableTransformation = if "disableTransformation" of options then options["disableTransformation"] else false
# TODO: remove hardcoded packages from code out to config or other file
if Package["yogiben:admin"]?
collection._disableTransformationOnRoute(/^\/admin(\/?$|\/)/)

Expand Down