Merge pull request #1826 from malfredo32/haxtuple1
[xtuple] / enyo-client / application / source / models / site.js
1 /*jshint indent:2, curly:true, eqeqeq:true, immed:true, latedef:true,
2 newcap:true, noarg:true, regexp:true, undef:true, strict:true, trailing:true,
3 white:true*/
4 /*global XT:true, XM:true, Backbone:true, _:true, console:true */
5
6 (function () {
7   "use strict";
8
9   /**
10     @class
11
12     @extends XM.Document
13   */
14   XM.SiteType = XM.Document.extend(/** @lends XM.Site.prototype */{
15
16     recordType: 'XM.SiteType',
17
18     documentKey: 'name'
19
20   });
21
22   /**
23     @class
24
25     @extends XM.Document
26   */
27   XM.SiteZone = XM.Document.extend(/** @lends XM.SiteZone.prototype */{
28
29     recordType: 'XM.SiteZone',
30
31     documentKey: 'name'
32
33   });
34
35   /**
36     @class
37
38     @extends XM.Document
39   */
40   XM.SiteZoneRelation = XM.Document.extend(/** @lends XM.SiteZoneRelation.prototype */{
41
42     recordType: 'XM.SiteZoneRelation',
43
44     documentKey: 'name'
45
46   });
47
48   /**
49     @class
50
51     @extends XM.Document
52   */
53   XM.Site = XM.Document.extend(/** @lends XM.Site.prototype */{
54
55     recordType: 'XM.Site',
56
57     documentKey: 'code'
58
59   });
60
61   /**
62     @class
63
64     @extends XM.Comments
65   */
66   XM.SiteComment = XM.Comment.extend(/** @lends XM.SiteComment.prototype */{
67
68     recordType: 'XM.SiteComment',
69
70     sourceName: 'W'
71
72   });
73
74   /**
75     @class
76
77     @extends XM.Info
78   */
79   XM.SiteRelation = XM.Info.extend(/** @lends XM.SiteRelation.prototype */{
80
81     recordType: 'XM.SiteRelation',
82
83     editableModel: 'XM.Site'
84
85   });
86
87   /**
88     @class
89
90     @extends XM.Info
91   */
92   XM.SiteListItem = XM.Info.extend(/** @lends XM.SiteListItem.prototype */{
93
94     recordType: 'XM.SiteListItem',
95
96     editableModel: 'XM.Site',
97
98     couldCreate: function () {
99       // Look to see if there are sites in the sites cache. If so, restrict new for Postbooks.
100       if (!XM.sites.length) {
101         return XM.Info.prototype.couldCreate.apply(this, arguments);
102       }
103       return false;
104     }
105
106   });
107
108   // ..........................................................
109   // COLLECTIONS
110   //
111
112   /**
113     @class
114
115     @extends XM.Collection
116   */
117   XM.SiteCollection = XM.Collection.extend(/** @lends XM.SiteCollection.prototype */{
118
119     model: XM.Site
120   });
121
122   /**
123     @class
124
125     @extends XM.Collection
126   */
127   XM.SiteTypeCollection = XM.Collection.extend(/** @lends XM.SiteTypeCollection.prototype */{
128
129     model: XM.SiteType
130   });
131
132   /**
133     @class
134
135     @extends XM.Collection
136   */
137   XM.SiteRelationCollection = XM.Collection.extend(/** @lends XM.SiteRelationCollection.prototype */{
138
139     model: XM.SiteRelation
140   });
141
142   /**
143     @class
144
145     @extends XM.Collection
146   */
147   XM.SiteListItemCollection = XM.Collection.extend(/** @lends XM.SiteListItemCollection.prototype */{
148
149     model: XM.SiteListItem
150   });
151
152   /**
153     @class
154
155     @extends XM.Collection
156   */
157   XM.SiteZoneRelationCollection = XM.Collection.extend(/** @lends XM.SiteListItemCollection.prototype */{
158
159     model: XM.SiteZoneRelation
160   });
161
162 }());