-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dynamo_Client_Store_web_store.war_shared_js_pageLayout_space.js.html
executable file
·339 lines (293 loc) · 18.4 KB
/
Dynamo_Client_Store_web_store.war_shared_js_pageLayout_space.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: Dynamo/Client/Store/web/store.war/shared/js/pageLayout/space.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: Dynamo/Client/Store/web/store.war/shared/js/pageLayout/space.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* @fileoverview Defines a SpaceViewModel used for SWM Spaces Wishlist to differentiate share/private space
*
*/
/*global $ */
/*global define */
define(
//-------------------------------------------------------------------
// PACKAGE NAME
//-------------------------------------------------------------------
'pageLayout/space',
//-------------------------------------------------------------------
// DEPENDENCIES
//-------------------------------------------------------------------
['jquery', 'knockout', 'pubsub', 'notifier', 'ccLogger', 'CCi18n', 'swmRestClient', 'swmKoValidateRules'],
//-------------------------------------------------------------------
// MODULE DEFINITION
//-------------------------------------------------------------------
function ($, ko, PubSub, notifier, logger, CCi18n, swmRestClient, swmKoValidateRules) {
"use strict";
/**
* SpaceViewModel. Used for Storefront Spaces Wishlist.
* Used as a singleton - accessed through the getInstance method.
*
* @private
* @class SpaceViewModel
* @param {Object} pAdapter - The REST adapter.
* @param {Object} pUserData - The custom user data.
*
* @property {observable(string)} id The ID of the space.
* @property {observable(string)} name The name of the space.
* @property {observable(string)} ownerId The ID of the owner of this space.
* @property {observable(string)} ownerFirstName The owner's first name.
* @property {observable(string)} ownerLastName The owner's last name.
* @property {observable(string)} ownerMediaId The owner's media ID.
* @property {observable(string)} ownerMediaUrl The owner's media URL.
* @property {observable(string)} accessLevel Access level.
* @property {observable(string)} siteName Site name.
* @property {observable(string)} fbAppId Facebook App ID.
* @property {observableArray} members The members of the space.
* @property {observable(string)} ownerFullName The owner's full name.
* @property {observable(string)} contextId The context ID.
* @property {observable(boolean)} showSpace=false Show the space?
* @property {observable(string)} spaceProductMediaUrl Media URL for the first product in the space.
*
*/
function SpaceViewModel(pAdapter, pUserData) {
if (SpaceViewModel.singleInstance) {
throw new Error("Cannot instantiate more than one SpaceViewModel, use getInstance(pAdapter, pUserData, pParams)");
}
// Keep reference of current context.
var self = this;
// Values from calling context
self.adapter = pAdapter;
/**
* Define SpaceViewModel fields, modification of these fields should be done through SpaceViewModel.updateSpace()
*/
self.id = ko.observable('');
self.name = ko.observable('');
self.ownerId = ko.observable('');
self.ownerFirstName = ko.observable('');
self.ownerLastName = ko.observable('');
self.ownerMediaId = ko.observable('');
self.ownerMediaUrl = ko.observable('');
self.accessLevel = ko.observable('');
self.siteName = ko.observable('');
self.fbAppId = ko.observable('');
self.inviteAcceptInProgress = ko.observable(false);
/**
* Members array, modification to members of a space should be done through SpaceViewModel.updateMembers()
*/
self.members = ko.observableArray([]);
// Computed observables with self fields, these field do NOT need to be modified explicitly, they are computed from other fields
self.ownerFullName = ko.computed(function(){
return self.ownerFirstName() + " " + self.ownerLastName();
}, self);
// populated by space-header, if url is /spaces/{spaceid}
self.contextId = ko.observable('');
// Flag to determine whether or not to show space
self.showSpace = ko.observable(false);
// populated by space-content
self.spaceProductMediaUrl = ko.observable('');
return self;
};
/*
* Get information from passed in context
SpaceViewModel.prototype.setContext = function(pContext) {
var self = this;
if (pContext.global.user.firstName) {
self.id(pContext.global.user.id);
}
};
*/
/**
* Boolean Methods - widgets are mostly interested in these questions
*/
/**
* Determine if user is the owner of the space.
* @function SpaceViewModel#isSpaceOwner
* @param {string} apiUserId The API user ID.
* @returns {boolean} true if the API user ID matches the owner ID of the space.
*/
SpaceViewModel.prototype.isSpaceOwner = function(apiUserId) {
var self = this;
return self.ownerId() === apiUserId;
};
/**
* Determine if user is a member of the space.
* @function SpaceViewModel#isMember
* @param {string} apiUserId The API user ID.
* @returns {boolean} true if the API user ID matches the user ID of one of the members in the space.
*/
SpaceViewModel.prototype.isMember = function(apiUserId) {
var self = this;
var result = false;
$.each( self.members(), function( index, member ) {
if (member.userId == apiUserId){
//is member, so show widget
result = true;
return false;
}
});
return result;
};
/**
* Determine if space is a Private Wishlist
* @function SpaceViewModel#isPrivate
* @returns {boolean} true if the wishlist accessLevel = 0.
*/
SpaceViewModel.prototype.isPrivate = function() {
var self = this;
var result = false;
if (self.accessLevel() === '0') {
result = true;
}
return result;
};
/**
* Determine if space is a Group Wishlist
* @function SpaceViewModel#isGroup
* @returns {boolean} true if the wishlist accessLevel = 2.
*/
SpaceViewModel.prototype.isGroup = function() {
var self = this;
var result = false;
if (self.accessLevel() === '2') {
result = true;
}
return result;
};
/**
* Determine if space is a Shared Wishlist
* @function SpaceViewModel#isShared
* @returns {boolean} true if the wishlist accessLevel = 1.
*/
SpaceViewModel.prototype.isShared = function() {
var self = this;
var result = false;
if (self.accessLevel() === '1') {
result = true;
}
return result;
};
/**
* Determine if space is a Private OR Group Wishlist
* @function SpaceViewModel#isPrivateOrGroup
* @returns {boolean} true if the wishlist accessLevel = 0 OR 2.
*/
SpaceViewModel.prototype.isPrivateOrGroup = function() {
var self = this;
var result = false;
if (self.isPrivate() || self.isGroup()) {
result = true;
}
return result;
};
/**
* Update Methods - updates to the SpaceViewModel
*/
/**
* Updates the Space information.
* @function SpaceViewModel#updateSpace
* @param {SpaceViewModel} obj The object containing the updated values.
*/
SpaceViewModel.prototype.updateSpace = function(obj) {
var self = this;
if (obj.id) {
self.id(obj.id);
}
if (obj.name) {
self.name(obj.name);
}
if (obj.ownerId) {
self.ownerId(obj.ownerId);
}
if (obj.ownerFirstName) {
self.ownerFirstName(obj.ownerFirstName);
}
if (obj.ownerLastName) {
self.ownerLastName(obj.ownerLastName);
}
if (obj.ownerMediaId) {
self.ownerMediaId(obj.ownerMediaId);
}
if (obj.ownerMediaUrl) {
self.ownerMediaUrl(obj.ownerMediaUrl);
}
if (obj.accessLevel) {
self.accessLevel(obj.accessLevel);
}
if (obj.siteName) {
self.siteName(obj.siteName);
}
if (obj.fbAppId) {
self.fbAppId(obj.fbAppId);
}
if (obj.spaceProductMediaUrl) {
self.spaceProductMediaUrl(obj.spaceProductMediaUrl);
}
};
/**
* Update Members collection in the space.
* All existing members will be removed, and will be replaced by the list passed in.
* Publishes the SOCIAL_SPACE_MODEL_MEMBERS_CHANGED event after the members have
* been updated.
* @function SpaceViewModel#updateMembers
* @param {Object[]} membersArray The list of members to be updated.
*/
SpaceViewModel.prototype.updateMembers = function(membersArray) {
var self = this;
self.members.removeAll();
self.members(membersArray);
$.Topic(PubSub.topicNames.SOCIAL_SPACE_MODEL_MEMBERS_CHANGED).publish();
};
/**
* Returns a single global instance of SpaceViewModel.
* @function SpaceViewModel.getInstance
* @param {Object} pAdapter The REST adapter.
* @param {Object} pUserData Custom user data.
* @param {Object} pParams some additional params (server data).
* @returns {SpaceViewModel} The SpaceViewModel instance.
*/
SpaceViewModel.getInstance = function(pAdapter, pUserData, pParams) {
if (!SpaceViewModel.singleInstance) {
SpaceViewModel.singleInstance = new SpaceViewModel(pAdapter, pUserData);
//TODO: We may need to pass in a context in the future.
//SpaceViewModel.singleInstance.setContext(pParams);
}
return SpaceViewModel.singleInstance;
};
return SpaceViewModel;
}
);
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-ccKoErrorWrapper.html">ccKoErrorWrapper</a></li><li><a href="module-ccKoExtensions.html">ccKoExtensions</a></li></ul><h3>Classes</h3><ul><li><a href="Address.html">Address</a></li><li><a href="CartViewModel.html">CartViewModel</a></li><li><a href="DynamicProperty.html">DynamicProperty</a></li><li><a href="EventDispatcher.html">EventDispatcher</a></li><li><a href="GiftCardViewModel.html">GiftCardViewModel</a></li><li><a href="GiftProductListingViewModel.html">GiftProductListingViewModel</a></li><li><a href="ko.bindingHandlers.background.html">background</a></li><li><a href="ko.bindingHandlers.carouselSwipe.html">carouselSwipe</a></li><li><a href="ko.bindingHandlers.ccForm.html">ccForm</a></li><li><a href="ko.bindingHandlers.ccLink.html">ccLink</a></li><li><a href="ko.bindingHandlers.ccValidation.html">ccValidation</a></li><li><a href="ko.bindingHandlers.checkbox.html">checkbox</a></li><li><a href="ko.bindingHandlers.chosen.html">chosen</a></li><li><a href="ko.bindingHandlers.contextResourcesNamespace.html">contextResourcesNamespace</a></li><li><a href="ko.bindingHandlers.currency.html">currency</a></li><li><a href="ko.bindingHandlers.datepicker.html">datepicker</a></li><li><a href="ko.bindingHandlers.datepopover.html">datepopover</a></li><li><a href="ko.bindingHandlers.draggable.html">draggable</a></li><li><a href="ko.bindingHandlers.droppable.html">droppable</a></li><li><a href="ko.bindingHandlers.fade.html">fade</a></li><li><a href="ko.bindingHandlers.hover.html">hover</a></li><li><a href="ko.bindingHandlers.imageSource.html">imageSource</a></li><li><a href="ko.bindingHandlers.imageZoom.html">imageZoom</a></li><li><a href="ko.bindingHandlers.localeText.html">localeText</a></li><li><a href="ko.bindingHandlers.makeAccess.html">makeAccess</a></li><li><a href="ko.bindingHandlers.modal.html">modal</a></li><li><a href="ko.bindingHandlers.modalTabbingContraint.html">modalTabbingContraint</a></li><li><a href="ko.bindingHandlers.onRender.html">onRender</a></li><li><a href="ko.bindingHandlers.popeditor.html">popeditor</a></li><li><a href="ko.bindingHandlers.popover.html">popover</a></li><li><a href="ko.bindingHandlers.productImageSource.html">productImageSource</a></li><li><a href="ko.bindingHandlers.propertyEditor.html">propertyEditor</a></li><li><a href="ko.bindingHandlers.radio.html">radio</a></li><li><a href="ko.bindingHandlers.richTextEditor.html">richTextEditor</a></li><li><a href="ko.bindingHandlers.scrollAffix.html">scrollAffix</a></li><li><a href="ko.bindingHandlers.select2.html">select2</a></li><li><a href="ko.bindingHandlers.select2Tags.html">select2Tags</a></li><li><a href="ko.bindingHandlers.selectable.html">selectable</a></li><li><a href="ko.bindingHandlers.slickList.html">slickList</a></li><li><a href="ko.bindingHandlers.slide.html">slide</a></li><li><a href="ko.bindingHandlers.slider.html">slider</a></li><li><a href="ko.bindingHandlers.spectrum.html">spectrum</a></li><li><a href="ko.bindingHandlers.tagsInput.html">tagsInput</a></li><li><a href="ko.bindingHandlers.textCheck.html">textCheck</a></li><li><a href="ko.bindingHandlers.timepicker.html">timepicker</a></li><li><a href="ko.bindingHandlers.triggerMessage.html">triggerMessage</a></li><li><a href="ko.bindingHandlers.validatableTarget.html">validatableTarget</a></li><li><a href="ko.bindingHandlers.validatableValue.html">validatableValue</a></li><li><a href="ko.bindingHandlers.widgetLocaleText.html">widgetLocaleText</a></li><li><a href="koValidation.alphaNumeric.html">alphaNumeric</a></li><li><a href="koValidation.alphaNumericNoSpaces.html">alphaNumericNoSpaces</a></li><li><a href="koValidation.alphaNumericNoSpacesWithSeperators.html">alphaNumericNoSpacesWithSeperators</a></li><li><a href="koValidation.alphaNumericWithSeperators.html">alphaNumericWithSeperators</a></li><li><a href="koValidation.bool.html">bool</a></li><li><a href="koValidation.creditcard.html">creditcard</a></li><li><a href="koValidation.cvv.html">cvv</a></li><li><a href="koValidation.endmonth.html">endmonth</a></li><li><a href="koValidation.endyear.html">endyear</a></li><li><a href="koValidation.importFileName.html">importFileName</a></li><li><a href="koValidation.laterDate.html">laterDate</a></li><li><a href="koValidation.match.html">match</a></li><li><a href="koValidation.mediaZipFileName.html">mediaZipFileName</a></li><li><a href="koValidation.number.html">number</a></li><li><a href="koValidation.observablePattern.html">observablePattern</a></li><li><a href="koValidation.password.html">password</a></li><li><a href="koValidation.price.html">price</a></li><li><a href="koValidation.propertyIdAlreadyInUse.html">propertyIdAlreadyInUse</a></li><li><a href="koValidation.propertyNameAlreadyInUse.html">propertyNameAlreadyInUse</a></li><li><a href="koValidation.restrictSlashCharacters.html">restrictSlashCharacters</a></li><li><a href="koValidation.startmonth.html">startmonth</a></li><li><a href="koValidation.startyear.html">startyear</a></li><li><a href="koValidation.uniqueTrimmed.html">uniqueTrimmed</a></li><li><a href="koValidation.uniqueTrimmedCaseInsensitive.html">uniqueTrimmedCaseInsensitive</a></li><li><a href="koValidation.url.html">url</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.addTemplate.html">addTemplate</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.ccDate.html">ccDate</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.ccDateTime.html">ccDateTime</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.ccNumber.html">ccNumber</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.disabled.html">disabled</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.element.html">element</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.embeddedAssistance.html">embeddedAssistance</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.inTabFlow.html">inTabFlow</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.setContextVariable.html">setContextVariable</a></li><li><a href="NavStateViewModel.html">NavStateViewModel</a></li><li><a href="OrderHistoryViewModel.html">OrderHistoryViewModel</a></li><li><a href="OrderViewModel.html">OrderViewModel</a></li><li><a href="ParentOrganisation.html">ParentOrganisation</a></li><li><a href="ProductListingSearchViewModel.html">ProductListingSearchViewModel</a></li><li><a href="ProductListingViewModel.html">ProductListingViewModel</a></li><li><a href="ProductViewModel.html">ProductViewModel</a></li><li><a href="PubSub.topicNames.html">topicNames</a></li><li><a href="resetCVV.html">resetCVV</a></li><li><a href="resetPaymentDetails.html">resetPaymentDetails</a></li><li><a href="SearchRestClient.html">SearchRestClient</a></li><li><a href="UserViewModel.html">UserViewModel</a></li><li><a href="WidgetViewModel.html">WidgetViewModel</a></li><li><a href="WishlistContentViewModel.html">WishlistContentViewModel</a></li></ul><h3>Namespaces</h3><ul><li><a href="ko.bindingHandlers.html">bindingHandlers</a></li><li><a href="ko.extenders.html">extenders</a></li><li><a href="koValidation.html">koValidation</a></li></ul><h3>Global</h3><ul><li><a href="global.html#CCEETagProcessor">CCEETagProcessor</a></li><li><a href="global.html#isValidDeterminewhetherornotthepaymentdetailsobjectisvalidbasedonthevalidityofitscomponentparts.Thiswillnotcauseerrormessagestobedisplayedforanyobservablevaluesthatareunchangedandhaveneverreceivedfocusontherelatedformfield(s).">isValid
Determine whether or not the payment details object is valid
based on the validity of its component parts. This will not
cause error messages to be displayed for any observable values
that are unchanged and have never received focus on the
related form field(s).</a></li><li><a href="global.html#validatePaymentDetailsForceallrelevantmemberobservablestoperformtheirvalidationnow&displaytheerrors(ifany)">validatePaymentDetails
Force all relevant member observables to perform their
validation now & display the errors (if any)</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0</a> on Mon Oct 10 2016 10:49:03 GMT+0100 (BST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>