Sha256: 10c414ed4cd389645016dfc377972121da5ffc3f0628d9c8265a751bd8ded420

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

SHARED_DATA = null
SHARED_COLLECTION = null

class Skr.Models.Location extends Skr.Models.Base

    mixins: [ 'FileSupport', 'HasCodeField' ]

    props:
        id:            {type:"integer"}
        code:          {type:"code"}
        name:          {type:"string"}
        address_id:    {type:"integer"}
        is_active:     {type:"boolean", "default":true}
        gl_branch_code:{type:"string", "default":"01"}
        options: "any"

    associations:
        address:  { model: "Address" }
        sku_locs: { collection: "SkuLoc" }
        logo:     { model: "Lanes.Models.Asset" }

    @initialize: (data) ->
        SHARED_DATA = data.locations

    addChangeSet: (change) ->
        if change.update.logo
            change.update.logo[1] = change.update.logo[1].logo
        super

Object.defineProperties Skr.Models.Location, {
    all:
        get: ->
            SHARED_COLLECTION ||= new Skr.Models.Location.Collection( SHARED_DATA )
    default:
        get: ->
            @all.findWhere(code: 'DEFAULT') || @all.first()
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stockor-0.5.0 client/skr/models/Location.coffee
stockor-0.4.0 client/skr/models/Location.coffee