Fixed up new generated coffescript

This commit is contained in:
Adolfo Gómez 2014-03-17 15:27:32 +00:00
parent 5f329552af
commit 095f21204d
12 changed files with 61 additions and 57 deletions

View File

@ -5,7 +5,7 @@ $ = jQuery
@api.spreadsheet.cell = (data, type, style) ->
type = type or "String"
if style isnt `undefined`
if style != undefined
style = " ss:StyleID=\"" + style + "\""
else
style = ""

View File

@ -90,7 +90,7 @@ api.templates.cache = new api.cache("tmpls") # Will cache templates locally. If
# '?', data will not be cached and always
# re-requested. We do not care about lang, because page will reload on language change
api.templates.get = (name, success_fnc) ->
$this = this
$this = @
success_fnc = success_fnc or ->
api.doLog "Getting template " + name
@ -128,13 +128,14 @@ api.templates.get = (name, success_fnc) ->
# Simple JavaScript Templating, using HandleBars
api.templates.evaluate = (str, context) ->
console.log "Evaluating ", str
# Figure out if we're getting a template, or if we need to
# load the template - and be sure to cache the result (compiled template).
cached = undefined
unless /\W/.test(str)
console.log @cache
cached = @cache.get("_" + str)
if cached is `undefined`
if cached is undefined
cached = api.templates.evaluate(document.getElementById(str).innerHTML)
@cache.put "_" + str, cached
template = cached or Handlebars.compile(str)

View File

@ -41,9 +41,9 @@ strftime = (fmt, d, locale) ->
# locale is optional
strftimeTZ = (fmt, d, locale, timezone) ->
if typeof locale is "number" and timezone is null
if typeof locale is "number" and timezone is undefined
timezone = locale
locale = `undefined`
locale = undefined
_strftime fmt, d, locale,
timezone: timezone
@ -68,7 +68,7 @@ _strftime = (fmt, d, locale, options) ->
# d and locale are optional so check if d is really the locale
if d and not quacksLikeDate(d)
locale = d
d = `undefined`
d = undefined
d = d or new Date()
locale = locale or DefaultLocale
locale.formats = locale.formats or {}
@ -134,11 +134,11 @@ _strftime = (fmt, d, locale, options) ->
day = Math.ceil((d.getTime() - y.getTime()) / (1000 * 60 * 60 * 24))
pad day, 3
when "k"
pad d.getHours(), (if padding is null then " " else padding)
pad d.getHours(), (if padding is undefined then " " else padding)
when "L"
pad Math.floor(timestamp % 1000), 3
when "l"
pad hours12(d), (if padding is null then " " else padding)
pad hours12(d), (if padding is undefined then " " else padding)
when "M"
pad d.getMinutes(), padding
when "m"
@ -217,7 +217,7 @@ pad = (n, padding, length) ->
padding = "0"
# Defaults handle pad(n) and pad(n, <padding>)
padding = "0" if padding is null
padding = "0" if padding is undefined
length = length or 2
s = String(n)

View File

@ -17,7 +17,7 @@ api.cache = (cacheName) ->
new Cache(cacheName)
api.cache.clear = (cacheName) ->
if cacheName is `undefined`
if cacheName is undefined
api.cacheTable = {}
else
api.cacheTable[cacheName] = {}
@ -131,10 +131,10 @@ class Cache
get: (key, not_found_fnc) ->
not_found_fnc = not_found_fnc or ->
null
undefined
@cache[key] = not_found_fnc() if @cache[key] is null
@cache[key]
@cache[key] = not_found_fnc() if @cache[key] == undefined
@cache[key] or undefined
put: (key, value) ->
@cache[key] = value
@ -275,7 +275,7 @@ class BasicModelRest
gui: (typeName, success_fnc, fail_fnc) ->
path = undefined
if typeName isnt `undefined`
if typeName isnt undefined
path = [
this.guiPath
typeName

View File

@ -11,14 +11,14 @@ gui.authenticators.link = (event) ->
# Clears the log of the detail, in this case, the log of "users"
# Memory saver :-)
detailLogTable = null
detailLogTable = undefined
clearDetailLog = ->
if detailLogTable
$tbl = $(detailLogTable).dataTable()
$tbl.fnClearTable()
$tbl.fnDestroy()
$("#user-log-placeholder").empty()
detailLogTable = null
detailLogTable = undefined
return
@ -247,7 +247,7 @@ gui.authenticators.link = (event) ->
onDelete: gui.methods.del(group, gettext("Delete group"), gettext("Group deletion error"))
)
tmpLogTable = null
tmpLogTable = undefined
# New button will only be shown on authenticators that can create new users
usrButtons = [
@ -305,7 +305,7 @@ gui.authenticators.link = (event) ->
staff_member: item.staff_member
is_admin: item.is_admin
needs_password: type.needsPassword
password: (if type.needsPassword then password else `undefined`)
password: (if type.needsPassword then password else undefined)
password_label: type.passwordLabel
groups_all: groups
groups: item.groups

View File

@ -28,7 +28,7 @@ gui.configuration.link = ->
unless $element.attr("data-val") is $element.val()
section = $element.attr("data-section")
key = $element.attr("data-key")
cfg[section] = {} if cfg[section] is `undefined`
cfg[section] = {} if cfg[section] is undefined
cfg[section][key] = value: $element.val()
return

View File

@ -8,14 +8,14 @@ gui.providers.link = (event) ->
text: gettext("Test")
css: "btn-info"
detailLogTable = null
detailLogTable = undefined
clearDetailLog = ->
if detailLogTable
$tbl = $(detailLogTable).dataTable()
$tbl.fnClearTable()
$tbl.fnDestroy()
$("#services-log-placeholder").empty()
detailLogTable = `undefined`
detailLogTable = undefined
return
prevTables = []
@ -78,7 +78,7 @@ gui.providers.link = (event) ->
# Giving the name compossed with type, will ensure that only styles will be reattached once
services = new GuiElement(api.providers.detail(id, "services"), "services-" + selected[0].type)
tmpLogTable = null
tmpLogTable = undefined
servicesTable = services.table(
container: "services-placeholder"
rowSelect: "single"

View File

@ -151,14 +151,14 @@ gui.servicesPools.link = (event) ->
servPool = selected[0]
gui.doLog "Selected services pool", servPool
clearDetails()
service = null
service = undefined
try
service = availableServices[servPool.service_id]
catch e
gui.doLog "Exception on rowSelect", e
gui.notify "Service pool " + gettext("error"), "danger"
return
if service isnt null
if service isnt undefined
$("#detail-placeholder").removeClass "hidden"
else
$("#detail-placeholder").addClass "hidden"
@ -167,7 +167,7 @@ gui.servicesPools.link = (event) ->
#
# * Cache Part
#
cachedItems = null
cachedItems = undefined
# If service does not supports cache, do not show it
# Shows/hides cache
@ -176,7 +176,7 @@ gui.servicesPools.link = (event) ->
cachedItems = new GuiElement(api.servicesPools.detail(servPool.id, "cache"), "cache")
# Cached items table
prevCacheLogTbl = null
prevCacheLogTbl = undefined
cachedItemsTable = cachedItems.table(
container: "cache-placeholder_tbl"
buttons: [
@ -208,7 +208,7 @@ gui.servicesPools.link = (event) ->
#
# * Groups part
#
groups = null
groups = undefined
# Shows/hides groups
if service.info.must_assign_manually is false
@ -285,7 +285,7 @@ gui.servicesPools.link = (event) ->
#
# * Assigned services part
#
prevAssignedLogTbl = null
prevAssignedLogTbl = undefined
assignedServices = new GuiElement(api.servicesPools.detail(servPool.id, "services"), "services")
assignedServicesTable = assignedServices.table(
container: "assigned-services-placeholder_tbl"
@ -373,7 +373,7 @@ gui.servicesPools.link = (event) ->
#
# * Publications part
#
publications = null
publications = undefined
if service.info.needs_publication
$("#publications-placeholder_tab").removeClass "hidden"
pubApi = api.servicesPools.detail(servPool.id, "publications")
@ -444,7 +444,7 @@ gui.servicesPools.link = (event) ->
$.each data, (index, value) ->
try
service = availableServices[value.service_id]
if service is `undefined`
if service is undefined
value.parent = gettext("undefined")
return
style = "display:inline-block; background: url(data:image/png;base64," + service.info.icon + "); " + "width: 16px; height: 16px; vertical-align: middle;"

View File

@ -145,9 +145,9 @@
column.sTitle = opts.title
column.mRender = renderEmptyCell
column.sWidth = opts.width if opts.width
column.bVisible = (if opts.visible is `undefined` then true else opts.visible)
column.bSortable = opts.sortable if opts.sortable isnt `undefined`
column.bSearchable = opts.searchable if opts.searchable isnt `undefined`
column.bVisible = (if opts.visible is undefined then true else opts.visible)
column.bSortable = opts.sortable if opts.sortable isnt undefined
column.bSearchable = opts.searchable if opts.searchable isnt undefined
if opts.type and column.bVisible
switch opts.type
when "date"
@ -164,11 +164,11 @@
#columnt.sType = 'html'; // html is default, so this is not needed
column.mRender = renderTypeIcon
when "icon"
column.mRender = renderIcon(opts.icon) if opts.icon isnt `undefined`
column.mRender = renderIcon(opts.icon) if opts.icon isnt undefined
when "icon_dict"
column.mRender = renderIconDict(opts.icon_dict) if opts.icon_dict isnt `undefined`
column.mRender = renderIconDict(opts.icon_dict) if opts.icon_dict isnt undefined
when "dict"
column.mRender = renderTextTransform(opts.dict) if opts.dict isnt `undefined`
column.mRender = renderTextTransform(opts.dict) if opts.dict isnt undefined
else
column.sType = opts.type
columns.push column
@ -184,7 +184,7 @@
self.rest.overview (data) -> # Gets "overview" data for table (table contents, but resume form)
tblParams.onData data if tblParams.onData
table = gui.table(title, tableId)
if tblParams.container is `undefined`
if tblParams.container is undefined
gui.appendToWorkspace "<div class=\"row\"><div class=\"col-lg-12\">" + table.text + "</div></div>"
else
$("#" + tblParams.container).empty()
@ -262,7 +262,7 @@
return
$.each tblParams.buttons, (index, value) -> # Iterate through button definition
btn = null
btn = undefined
switch value
when "new"
if Object.keys(self.types).length isnt 0
@ -434,7 +434,7 @@
dct = row_style.dict
prefix = row_style.prefix
dataTableOptions.fnCreatedRow = (nRow, aData, iDataIndex) ->
v = (if dct isnt `undefined` then dct[@fnGetData(iDataIndex)[field]] else @fnGetData(iDataIndex)[field])
v = (if dct isnt undefined then dct[@fnGetData(iDataIndex)[field]] else @fnGetData(iDataIndex)[field])
$(nRow).addClass prefix + v
gui.doLog prefix + v
return
@ -553,7 +553,7 @@
}
]
table = gui.table(tblParams.title or gettext("Logs"), tableId)
if tblParams.container is `undefined`
if tblParams.container is undefined
gui.appendToWorkspace "<div class=\"row\"><div class=\"col-lg-12\">" + table.text + "</div></div>"
else
$("#" + tblParams.container).empty()

View File

@ -24,7 +24,7 @@
# itemGui is expected to have fields sorted by .gui.order (REST api returns them sorted)
$.each itemGui, (index, f) ->
# Not exactly a field, maybe some other info...
return if f.gui is `undefined`
return if f.gui is undefined
# Fix multiline text fields to textbox
f.gui.type = "textbox" if f.gui.type is "text" and f.gui.multiline
@ -165,7 +165,7 @@
res[name] = $field.is(":checked")
else
res[name] = $field.val()
res[name] = [] if res[name] is null and $field.is("select")
res[name] = [] if res[name] is undefined and $field.is("select")
return
gui.doLog res
@ -265,7 +265,7 @@
# simple gui generators
gui.forms.guiField = (name, type, label, tooltip, value, values, length, multiline, readonly, required) ->
length = length or 128
multiline = (if multiline isnt `undefined` then multiline else 0)
multiline = multiline ? 0
readonly = readonly or false
required = required or false
name: name

View File

@ -1,6 +1,8 @@
# jshint strict: true
((gui, $, undefined_) ->
"use strict"
@gui = @gui ? {}
$ = jQuery
gui = @gui
gui.tools =
blockUI: (message) ->
message = message or "<h1><span class=\"fa fa-spinner fa-spin\"></span> " + gettext("Just a moment...") + "</h1>"
@ -19,13 +21,15 @@
$.each $(selector), (index, value) ->
# If no events associated, return
return if $._data(value, "events") is `undefined`
$this = $(this)
$this = $(@)
clkEvents = []
# Store old click events, so we can reconstruct click chain later
$.each $._data(value, "events").click, (index, fnc) ->
clkEvents.push fnc
try
$.each $._data(value, "events").click, (index, fnc) ->
clkEvents.push fnc
return
catch # no events associated ($._data(value, 'events') returns undefined)
return
$this.unbind "click"
@ -103,4 +107,3 @@
levels[data] or "OTHER"
return
) window.gui = window.gui or {}, jQuery

View File

@ -47,7 +47,7 @@
css: "btn btn3d-info btn3d btn3d-tables"
custom:
text: null
text: undefined
css: "btn btn3d-default btn3d btn3d-tables"
gui.genRamdonId = (prefix) ->
@ -306,7 +306,7 @@
(value, event, table, refreshFnc) ->
gui.tools.blockUI()
parent.rest.gui value.type, ((guiDefinition) ->
buttons = null
buttons = undefined
buttons = gui.methods.typedTestButton(parent.rest, options.testButton.text, options.testButton.css, value.type) if options.testButton
tabs = (if options.guiProcessor then options.guiProcessor(guiDefinition) else guiDefinition) # Preprocess fields (probably generate tabs...)
parent.rest.item value.id, (item) ->
@ -343,20 +343,20 @@
gui.tools.blockUI()
parent.rest.gui type, ((guiDefinition) ->
gui.tools.unblockUI()
buttons = null
buttons = undefined
buttons = gui.methods.typedTestButton(parent.rest, options.testButton.text, options.testButton.css, type) if options.testButton
tabs = (if options.guiProcessor then options.guiProcessor(guiDefinition) else guiDefinition) # Preprocess fields (probably generate tabs...)
title = modalTitle
title += " " + gettext("of type") + " <b>" + parent.types[type].name + "</b>" if parent.types[type] isnt `undefined`
title += " " + gettext("of type") + " <b>" + parent.types[type].name + "</b>" if parent.types[type] isnt undefined
gui.forms.launchModal
title: title
fields: tabs
item: `undefined`
item: undefined
preprocessor: options.preprocessor
buttons: buttons
success: (form_selector, closeFnc) ->
fields = gui.forms.read(form_selector)
fields.data_type = type if parent.types[type] isnt `undefined`
fields.data_type = type if parent.types[type] != undefined
fields = (if options.fieldsProcessor then options.fieldsProcessor(fields) else fields) # Process fields before creating?
parent.rest.create fields, ((data) -> # Success on put
closeFnc()