Sha256: 7f94c5df98debd131a526c5497de9749681337b12acf5af4f8f43e28186bb394

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

class BaseComponent

    constructor: (options={})->
        super
        @access ||= this.calculate_access()

    session:
        access:
            type: 'string',
            values: ['read','write','none']

    derived:
        readOnly:  { deps: ['access'], fn:-> @access=='read' }
        writeAble: { deps: ['access'], fn:-> @access=='write' }

    emptyTemplateName: -> this.writeTemplate()
    readTemplateName:  -> this.writeTemplate()
    writeTemplateName: -> 'lanes/views/empty-span'

    renderContextFree: ->
        tmpl = if this.writeAble
            'writeTemplate'
        else if this.readOnly
            'readTemplate'
        else
            'emptyTemplate'

        this.replaceEl( this.renderTemplateMethod(tmpl) );

    templatePrefix: -> this.FILE.extensionName.toLowerCase() + "/components/"

    calculate_access:->
        if ! @field_name || Lanes.Views.RenderContext.canWrite(@field_name)
            'write'
        else if Lanes.Views.RenderContext.canRead(@field_name)
            'read'
        else
            'none'

Lanes.Components.Base = Lanes.Views.Base.extend(BaseComponent)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lanes-0.1.2 client/lanes/components/Base.coffee