merchi_sdk_js 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +4 -3
  2. package/dist/address.js +0 -109
  3. package/dist/assignment.js +0 -175
  4. package/dist/automatic_payment_relationship.js +0 -72
  5. package/dist/backup.js +0 -32
  6. package/dist/bank.js +0 -25
  7. package/dist/cart.js +0 -133
  8. package/dist/cart_item.js +0 -71
  9. package/dist/cart_shipment_group.js +0 -23
  10. package/dist/cart_shipment_quote.js +0 -26
  11. package/dist/category.js +0 -68
  12. package/dist/company.js +0 -248
  13. package/dist/company_invitation.js +0 -70
  14. package/dist/component.js +0 -107
  15. package/dist/component_tag.js +0 -60
  16. package/dist/component_version.js +0 -21
  17. package/dist/country_tax.js +0 -93
  18. package/dist/dictionary.js +0 -130
  19. package/dist/discount.js +0 -22
  20. package/dist/discount_group.js +0 -18
  21. package/dist/domain.js +0 -245
  22. package/dist/domain_invitation.js +0 -17
  23. package/dist/domain_tag.js +0 -87
  24. package/dist/domain_types.js +0 -22
  25. package/dist/draft.js +0 -97
  26. package/dist/draft_comment.js +0 -45
  27. package/dist/draft_template.js +0 -39
  28. package/dist/email_address.js +0 -34
  29. package/dist/email_counter.js +0 -47
  30. package/dist/enrolled_domain.js +0 -88
  31. package/dist/exchange_rate.js +0 -66
  32. package/dist/field_types.js +0 -19
  33. package/dist/helpers.js +0 -86
  34. package/dist/internal_tag.js +0 -98
  35. package/dist/inventory.js +0 -100
  36. package/dist/inventory_unit_variation.js +0 -19
  37. package/dist/invoice.js +0 -225
  38. package/dist/invoice_types.js +0 -11
  39. package/dist/item.js +0 -25
  40. package/dist/job.js +0 -536
  41. package/dist/job_comment.js +0 -45
  42. package/dist/job_status.js +0 -47
  43. package/dist/matching_inventory.js +0 -21
  44. package/dist/md5.js +0 -149
  45. package/dist/menu.js +0 -37
  46. package/dist/menu_item.js +0 -24
  47. package/dist/merchi.js +0 -1004
  48. package/dist/merchi_file.js +0 -165
  49. package/dist/model.js +0 -753
  50. package/dist/notification.js +0 -151
  51. package/dist/notification_types.js +0 -199
  52. package/dist/output.cjs.js +0 -31317
  53. package/dist/output.esm.js +0 -31312
  54. package/dist/page.js +0 -41
  55. package/dist/payment.js +0 -32
  56. package/dist/payment_device.js +0 -21
  57. package/dist/payment_types.js +0 -20
  58. package/dist/phone_number.js +0 -37
  59. package/dist/product.js +0 -288
  60. package/dist/product_types.js +0 -32
  61. package/dist/production_comment.js +0 -44
  62. package/dist/quote.js +0 -91
  63. package/dist/quote_item.js +0 -59
  64. package/dist/roles.js +0 -29
  65. package/dist/seo_domain_page.js +0 -42
  66. package/dist/session.js +0 -103
  67. package/dist/set.js +0 -29
  68. package/dist/shipment.js +0 -181
  69. package/dist/shipment_item.js +0 -17
  70. package/dist/shipment_item_fulfillment.js +0 -17
  71. package/dist/shipment_method.js +0 -81
  72. package/dist/shipment_method_variation.js +0 -38
  73. package/dist/subscription_plan.js +0 -75
  74. package/dist/supply_domain.js +0 -65
  75. package/dist/system_role.js +0 -12
  76. package/dist/theme.js +0 -180
  77. package/dist/theme_css_setting.js +0 -61
  78. package/dist/theme_status.js +0 -11
  79. package/dist/user.js +0 -409
  80. package/dist/user_company.js +0 -19
  81. package/dist/user_types.js +0 -23
  82. package/dist/uuid.js +0 -12
  83. package/dist/variation.js +0 -233
  84. package/dist/variation_field.js +0 -233
  85. package/dist/variation_fields_option.js +0 -41
  86. package/dist/variation_option.js +0 -62
  87. package/dist/variations_group.js +0 -43
  88. package/dist/white_label_accessibilities.js +0 -11
package/dist/job.js DELETED
@@ -1,536 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Job = Job;
7
- exports.Jobs = Jobs;
8
- var _uuid = require("./uuid.js");
9
- var _dictionary = require("./dictionary.js");
10
- var _model = require("./model.js");
11
- var _helpers = require("./helpers.js");
12
- var _job_status = require("./job_status.js");
13
- var _roles = require("./roles.js");
14
- var _address = require("./address.js");
15
- var _assignment = require("./assignment.js");
16
- var _product = require("./product.js");
17
- var _country_tax = require("./country_tax.js");
18
- var _company = require("./company.js");
19
- var _merchi_file = require("./merchi_file.js");
20
- var _draft = require("./draft.js");
21
- var _draft_comment = require("./draft_comment.js");
22
- var _domain = require("./domain.js");
23
- var _domain_tag = require("./domain_tag.js");
24
- var _email_address = require("./email_address.js");
25
- var _invoice = require("./invoice.js");
26
- var _notification = require("./notification.js");
27
- var _shipment = require("./shipment.js");
28
- var _phone_number = require("./phone_number.js");
29
- var _matching_inventory = require("./matching_inventory.js");
30
- var _user = require("./user.js");
31
- var _variation = require("./variation.js");
32
- var _variations_group = require("./variations_group.js");
33
- var _job_comment = require("./job_comment.js");
34
- var _internal_tag = require("./internal_tag.js");
35
- function Job() {
36
- this.resource = '/jobs';
37
- this.json = 'job';
38
- this.temporaryId = (0, _uuid.generateUUID)();
39
- (0, _model.addPropertyTo)(this, 'id');
40
- (0, _model.addPropertyTo)(this, 'currency');
41
- (0, _model.addPropertyTo)(this, 'quantity');
42
- (0, _model.addPropertyTo)(this, 'notes');
43
- (0, _model.addPropertyTo)(this, 'jobType');
44
- (0, _model.addPropertyTo)(this, 'product', _product.Product);
45
- (0, _model.addPropertyTo)(this, 'supplyChainRequestProduct', _product.Product);
46
- (0, _model.addPropertyTo)(this, 'createdProducts', _product.Product);
47
- (0, _model.addPropertyTo)(this, 'priority');
48
- (0, _model.addPropertyTo)(this, 'received');
49
- (0, _model.addPropertyTo)(this, 'deadline');
50
- (0, _model.addPropertyTo)(this, 'updated');
51
- (0, _model.addPropertyTo)(this, 'deductionDate');
52
- (0, _model.addPropertyTo)(this, 'preDraftCommentsCount');
53
- (0, _model.addPropertyTo)(this, 'clientFiles', _merchi_file.MerchiFile);
54
- (0, _model.addPropertyTo)(this, 'productionFiles', _merchi_file.MerchiFile);
55
- (0, _model.addPropertyTo)(this, 'drafts', _draft.Draft);
56
- (0, _model.addPropertyTo)(this, 'ownDrafts', _draft.Draft);
57
- (0, _model.addPropertyTo)(this, 'sharedDrafts', _draft.Draft);
58
- (0, _model.addPropertyTo)(this, 'draftComments', _draft_comment.DraftComment);
59
- (0, _model.addPropertyTo)(this, 'comments', _job_comment.JobComment);
60
- (0, _model.addPropertyTo)(this, 'invoice', _invoice.Invoice);
61
- (0, _model.addPropertyTo)(this, 'shipment', _shipment.Shipment);
62
- (0, _model.addPropertyTo)(this, 'client', _user.User);
63
- (0, _model.addPropertyTo)(this, 'clientEmail', _email_address.EmailAddress);
64
- (0, _model.addPropertyTo)(this, 'clientPhone', _phone_number.PhoneNumber);
65
- (0, _model.addPropertyTo)(this, 'clientCompany', _company.Company);
66
- (0, _model.addPropertyTo)(this, 'clientCompanyEmail', _email_address.EmailAddress);
67
- (0, _model.addPropertyTo)(this, 'clientCompanyPhone', _phone_number.PhoneNumber);
68
- (0, _model.addPropertyTo)(this, 'manager', _user.User);
69
- (0, _model.addPropertyTo)(this, 'designer', _user.User);
70
- (0, _model.addPropertyTo)(this, 'shipping', _address.Address);
71
- (0, _model.addPropertyTo)(this, 'dropShip');
72
- (0, _model.addPropertyTo)(this, 'pickUp');
73
- (0, _model.addPropertyTo)(this, 'productionShippingAddress', _address.Address);
74
- (0, _model.addPropertyTo)(this, 'supplyAssignment', _assignment.Assignment);
75
- (0, _model.addPropertyTo)(this, 'supplyJob', Job);
76
- (0, _model.addPropertyTo)(this, 'domain', _domain.Domain);
77
- (0, _model.addPropertyTo)(this, 'cost');
78
- (0, _model.addPropertyTo)(this, 'taxAmount');
79
- (0, _model.addPropertyTo)(this, 'totalCost');
80
- (0, _model.addPropertyTo)(this, 'taxType', _country_tax.CountryTax);
81
- (0, _model.addPropertyTo)(this, 'costPerUnit');
82
- (0, _model.addPropertyTo)(this, 'automaticPriceEnabled');
83
- (0, _model.addPropertyTo)(this, 'tags', _domain_tag.DomainTag);
84
-
85
- // not embedded by default
86
- (0, _model.addPropertyTo)(this, 'unreadNotificationsCount');
87
- (0, _model.addPropertyTo)(this, 'unreadJobInfoNotificationsCount');
88
- (0, _model.addPropertyTo)(this, 'unreadJobDraftingNotificationsCount');
89
- (0, _model.addPropertyTo)(this, 'unreadJobProductionNotificationsCount');
90
- (0, _model.addPropertyTo)(this, 'unreadJobShippingNotificationsCount');
91
- (0, _model.addPropertyTo)(this, 'unreadJobInvoicingNotificationsCount');
92
- (0, _model.addPropertyTo)(this, 'matchingInventories', _matching_inventory.MatchingInventory);
93
- (0, _model.addPropertyTo)(this, 'inventoryCount');
94
- (0, _model.addPropertyTo)(this, 'inventorySufficient');
95
- (0, _model.addPropertyTo)(this, 'limitedStock');
96
- (0, _model.addPropertyTo)(this, 'canDeduct');
97
- (0, _model.addPropertyTo)(this, 'productionNotes');
98
- (0, _model.addPropertyTo)(this, "needsDrafting");
99
- (0, _model.addPropertyTo)(this, "needsGroupBuy");
100
- (0, _model.addPropertyTo)(this, "needsProduction");
101
- (0, _model.addPropertyTo)(this, "needsShipping");
102
- (0, _model.addPropertyTo)(this, "needsInvoicing");
103
- (0, _model.addPropertyTo)(this, "needsSupplyChainRequest");
104
- (0, _model.addPropertyTo)(this, 'hasValidVolumes');
105
- (0, _model.addPropertyTo)(this, 'hasValidWeights');
106
- (0, _model.addPropertyTo)(this, 'showProductionFilesToClient');
107
- (0, _model.addPropertyTo)(this, 'allowClientDraftContribution');
108
- (0, _model.addPropertyTo)(this, 'groupBuyStatus');
109
- (0, _model.addPropertyTo)(this, 'groupBuyProductionStarted');
110
- (0, _model.addPropertyTo)(this, 'shippingStatus');
111
- (0, _model.addPropertyTo)(this, 'designStatus');
112
- (0, _model.addPropertyTo)(this, 'paymentStatus');
113
- (0, _model.addPropertyTo)(this, 'productionStatus');
114
- (0, _model.addPropertyTo)(this, 'supplyChainRequestStatus');
115
- (0, _model.addPropertyTo)(this, 'assignments', _assignment.Assignment);
116
- (0, _model.addPropertyTo)(this, 'archived');
117
- (0, _model.addPropertyTo)(this, 'notifications', _notification.Notification);
118
- (0, _model.addPropertyTo)(this, 'variationsGroups', _variations_group.VariationsGroup);
119
- (0, _model.addPropertyTo)(this, 'variations', _variation.Variation);
120
- (0, _model.addPropertyTo)(this, 'jobVolume');
121
- (0, _model.addPropertyTo)(this, 'jobWeight');
122
- (0, _model.addPropertyTo)(this, 'completed');
123
- (0, _model.addPropertyTo)(this, 'jobInfoApprovedByClient');
124
- (0, _model.addPropertyTo)(this, 'quoteSet');
125
- (0, _model.addPropertyTo)(this, 'shopifyShopUrl');
126
- (0, _model.addPropertyTo)(this, 'shopifyOrderId');
127
- (0, _model.addPropertyTo)(this, 'shopifyOrderLineItemId');
128
- (0, _model.addPropertyTo)(this, 'internalTags', _internal_tag.InternalTag);
129
- this.create = function (success, error, embed, asDomain, withRights) {
130
- var data = (0, _model.serialise)(this),
131
- self = this,
132
- settings = {
133
- as_domain: asDomain,
134
- embed: embed,
135
- error: error,
136
- files: (0, _model.enumerateFiles)(data[1]),
137
- parameters: data[0],
138
- resource: this.resource,
139
- withRights: withRights
140
- };
141
- function handleResponse(result) {
142
- success((0, _model.fromJson)(self, result[self.json]));
143
- }
144
- settings.success = handleResponse;
145
- (0, _model.create)(settings);
146
- };
147
- this.publicCreate = function (success, error) {
148
- var data = (0, _model.serialise)(this),
149
- self = this,
150
- request = new _model.Request(),
151
- jobType = this.product() && this.product().productType() === 0 ? 'mod' : 'supplier';
152
- request.data().merge(data[0]);
153
- request.resource("/public-".concat(jobType, "-quote/"));
154
- request.method('POST');
155
- request.query().add('skip_rights', true);
156
- function handleResponse(status, data) {
157
- if (status === 201) {
158
- success((0, _model.fromJson)(self, data[self.json]));
159
- } else {
160
- error(data);
161
- }
162
- }
163
- request.responseHandler(handleResponse).errorHandler(error);
164
- request.send();
165
- };
166
- this.get = function (success, error, embed, includeArchived, withRights) {
167
- var self = this,
168
- parameters = {
169
- embed: embed,
170
- error: error,
171
- id: this.id(),
172
- includeArchived: includeArchived,
173
- withRights: withRights,
174
- resource: this.resource
175
- };
176
- function handleResponse(data) {
177
- success((0, _model.fromJson)(self, data[self.json], {
178
- makesDirty: false
179
- }));
180
- }
181
- parameters.success = handleResponse;
182
- (0, _model.getOne)(parameters);
183
- };
184
- this.destroy = function (success, error) {
185
- (0, _model.deleteOne)(this.resource + "/" + this.id(), success, error);
186
- };
187
- this.recover = function (success, error) {
188
- (0, _model.recoverOne)("jobs", this.id(), success, error);
189
- };
190
- this.patch = function (success, error, embed, asDomain, withRights) {
191
- var self = this,
192
- data = (0, _model.serialise)(this, undefined, undefined, undefined, {
193
- excludeOld: true
194
- })[0],
195
- domain = Boolean(self.domain()) ? self.domain().id() : null,
196
- domainId = (0, _helpers.isUndefinedOrNull)(asDomain) ? domain : asDomain,
197
- settings = {
198
- as_domain: domainId,
199
- data: data,
200
- embed: embed,
201
- error: error,
202
- id: this.id(),
203
- withRights: withRights,
204
- resource: this.resource
205
- };
206
- function handleResponse(data) {
207
- success((0, _model.fromJson)(self, data[self.json], {
208
- makesDirty: false
209
- }));
210
- }
211
- settings.success = handleResponse;
212
- (0, _model.patchOne)(settings);
213
- };
214
- this.hasVariations = function () {
215
- var variations = this.variations();
216
- return Boolean(variations) && variations.length > 0;
217
- };
218
- this.hasVariationsGroups = function () {
219
- var groups = this.variationsGroups();
220
- return Boolean(groups) && groups.length > 0;
221
- };
222
- this.variationGroupsTotalQuantity = function () {
223
- var self = this,
224
- groups = Boolean(self.variationsGroups()) ? self.variationsGroups() : [],
225
- totalQuantity = 0,
226
- group,
227
- groupQuantity,
228
- i;
229
- for (i = 0; i < groups.length; i++) {
230
- group = groups[i];
231
- groupQuantity = isNaN(group.quantity()) ? 0 : group.quantity();
232
- totalQuantity += parseInt(groupQuantity, 10);
233
- }
234
- return totalQuantity;
235
- };
236
- this.productTotalCost = function () {
237
- var costPerUnit = this.costPerUnit() ? this.costPerUnit() : 0,
238
- qty = this.quantity() ? this.quantity() : 0;
239
- return costPerUnit * qty;
240
- };
241
- this.loopVariationsAndReturnAttributeTotal = function (attribute) {
242
- var variations = this.variations() ? this.variations() : [],
243
- total = 0,
244
- i;
245
- for (i = 0; i < variations.length; i++) {
246
- total += variations[i][attribute]();
247
- }
248
- return parseFloat(total).toFixed(2);
249
- };
250
- this.variationsUnitCostAndOnceOffCost = function () {
251
- return this.loopVariationsAndReturnAttributeTotal('unitCostAndOnceOffCost');
252
- };
253
- this.variationsTotalCost = function () {
254
- return this.loopVariationsAndReturnAttributeTotal('unitCostTotalAndOnceOffCost');
255
- };
256
- this.assignmentsUnarchived = function () {
257
- var assignments = this.assignments() ? this.assignments() : [],
258
- unarchived = [],
259
- i;
260
- for (i = 0; i < assignments.length; i++) {
261
- if (!assignments[i].archived()) {
262
- unarchived.push(assignments[i]);
263
- }
264
- }
265
- return unarchived;
266
- };
267
- this.productionAcceptedAssignment = function () {
268
- var assignments = this.assignmentsUnarchived(),
269
- i;
270
- for (i = 0; i < assignments.length; i++) {
271
- if (assignments[i].managerAccepts()) {
272
- return assignments[i];
273
- }
274
- }
275
- return null;
276
- };
277
- this.productionQuotingComplete = function () {
278
- return this.productionStatus() >= _job_status.jobStatusProduction.get('ASSIGN_DEADLINE_REACHED');
279
- };
280
- this.sectionReached = function (jobAttribute, sectionState) {
281
- var job = this,
282
- section = job[jobAttribute]();
283
- return section && section >= sectionState;
284
- };
285
- this.productionComplete = function () {
286
- var isShipped = this.sectionReached('productionStatus', _job_status.jobStatusProduction.get('SHIPPED'));
287
- var isCompleted = this.sectionReached('productionStatus', _job_status.jobStatusProduction.get('COMPLETED'));
288
- return isShipped || isCompleted || !this.needsProduction();
289
- };
290
- this.draftingComplete = function () {
291
- return this.sectionReached('designStatus', _job_status.jobStatusDrafting.get('DRAFTING_APPROVED')) || !this.needsDrafting();
292
- };
293
- this.paymentComplete = function () {
294
- return this.sectionReached('paymentStatus', _job_status.jobStatusPayment.get('FULLY_PAID'));
295
- };
296
- this.shippingComplete = function () {
297
- return this.sectionReached('shippingStatus', _job_status.jobStatusShipment.get('RECEIVED')) || !this.needsShipping();
298
- };
299
- this.isComplete = function () {
300
- return this.productionComplete() && this.draftingComplete() && this.paymentComplete() && this.shippingComplete();
301
- };
302
- this.assignmentArrayIndexById = function (assignmentId) {
303
- return this.assignments().findIndex(function (assignment) {
304
- return assignmentId === assignment.id();
305
- });
306
- };
307
- this.setAssignment = function (assignment) {
308
- var assignmentIndex = this.assignmentArrayIndexById(assignment.id()),
309
- assignments = this.assignments();
310
- assignments[assignmentIndex] = assignment;
311
- return assignments;
312
- };
313
- this.assignmentBySupplier = function (supplier) {
314
- var assignments = this.assignmentsUnarchived(),
315
- i;
316
- for (i = 0; i < assignments.length; i++) {
317
- if (assignments[i].isUserSupplier(supplier)) {
318
- return assignments[i];
319
- }
320
- }
321
- return null;
322
- };
323
- this.findAssignmentById = function (assignmentId) {
324
- var self = this,
325
- index = self.assignmentArrayIndexById(assignmentId);
326
- if (!isNaN(index) && index !== -1) {
327
- return self.assignments()[index];
328
- }
329
- return null;
330
- };
331
- this.fetchAndUpdateAssignmentById = function (success, error, assignmentId, embed) {
332
- var self = this,
333
- assignment = self.findAssignmentById(assignmentId),
334
- index = self.assignmentArrayIndexById(assignmentId);
335
- if (Boolean(assignment)) {
336
- assignment.get(function (latestAssignment) {
337
- self.assignments()[index] = latestAssignment;
338
- success();
339
- }, error, embed);
340
- } else {
341
- error();
342
- }
343
- };
344
- this.assignedSupplierIdArray = function () {
345
- // return an array of suppliers who have assignments
346
- var assignments = this.assignmentsUnarchived(),
347
- supplierIds = [],
348
- i;
349
- for (i = 0; i < assignments.length; i++) {
350
- supplierIds.push(assignments[i].supplier().id());
351
- }
352
- return supplierIds;
353
- };
354
- this.updateDateOfAssignments = function (newDate, dateAttribute) {
355
- var assignments = this.assignmentsUnarchived(),
356
- i;
357
- for (i = 0; i < assignments.length; i++) {
358
- // new date should be in current user unix local time
359
- assignments[i][dateAttribute](newDate);
360
- }
361
- return assignments;
362
- };
363
- this.firstAssignment = function () {
364
- return this.assignmentsUnarchived()[0];
365
- };
366
- this.productionShipment = function () {
367
- var acceptedAssignment = this.productionAcceptedAssignment();
368
- return Boolean(acceptedAssignment) ? acceptedAssignment.shipment() : null;
369
- };
370
- this.productionDeadline = function () {
371
- var firstAssignment = this.firstAssignment();
372
- return firstAssignment ? firstAssignment.productionDeadline() : null;
373
- };
374
- this.assignmentDeadline = function () {
375
- var firstAssignment = this.firstAssignment();
376
- return firstAssignment ? firstAssignment.assignmentDeadline() : null;
377
- };
378
- this.productionAssignmentDeadline = function () {
379
- return this.assignmentDeadline();
380
- };
381
- this.originalProduct = function () {
382
- var product = this.product();
383
- if (product) {
384
- var original = product.originalProduct();
385
- return original ? original : product;
386
- }
387
- return product;
388
- };
389
- this.draftsYoungestToEldest = function () {
390
- var drafts = this.drafts();
391
- return drafts ? (0, _helpers.sortArrayByObjectKeyDescending)(drafts, 'date') : [];
392
- };
393
- this.draftsEldestToYoungest = function () {
394
- var drafts = this.drafts();
395
- return drafts ? (0, _helpers.sortArrayByObjectKey)(drafts, 'date') : [];
396
- };
397
- this.currentDraft = function () {
398
- return this.draftsYoungestToEldest()[0];
399
- };
400
- this.draftIndexEldestToYoungest = function (draft) {
401
- return this.draftsEldestToYoungest().findIndex(function (draftEntity) {
402
- return draft.id() === draftEntity.id();
403
- });
404
- };
405
- this.draftCommentsYoungestToEldest = function () {
406
- return (0, _helpers.sortArrayByObjectKeyDescending)(this.draftComments(), 'date');
407
- };
408
- this.allDraftCommentsYoungestToEldest = function () {
409
- var jobDraftComments = this.draftCommentsYoungestToEldest(),
410
- drafts = this.draftsYoungestToEldest(),
411
- draftComments = [],
412
- i;
413
- for (i = 0; i < drafts.length; i++) {
414
- draftComments.concat(drafts[i].commentsYoungestToEldest());
415
- }
416
- return draftComments.concat(jobDraftComments);
417
- };
418
- this.activeDraft = function () {
419
- var drafts = this.draftsYoungestToEldest();
420
- return drafts.length > 0 ? drafts[0] : null;
421
- };
422
- this.shippingIsValid = function () {
423
- return this.shipping() && this.shipping().isValid();
424
- };
425
- this.userCanViewSection = function (user, allowedRoles) {
426
- var domain = this.domain();
427
- return domain ? user.hasAuthority(domain.id(), allowedRoles) : false;
428
- };
429
- this.isAdminOrManager = function (user) {
430
- return user.isAdminOrManager(this.domain().id());
431
- };
432
- this.isClient = function (user) {
433
- var clientId = this.client() ? this.client().id() : null;
434
- return clientId && user.id() === clientId;
435
- };
436
- this.userCanViewInfo = function (user) {
437
- var manager = _roles.roles.get('manager'),
438
- admin = _roles.roles.get('admin'),
439
- designer = _roles.roles.get('designer'),
440
- sales = _roles.roles.get('sales'),
441
- supplier = _roles.roles.get('supplier'),
442
- accountant = _roles.roles.get('accountant');
443
- return this.userCanViewSection(user, [manager, admin, designer, sales, supplier, accountant]);
444
- };
445
- this.userCanViewDrafting = function (user) {
446
- var client = _roles.roles.get('client'),
447
- manager = _roles.roles.get('manager'),
448
- admin = _roles.roles.get('admin'),
449
- designer = _roles.roles.get('designer');
450
- return this.userCanViewSection(user, [client, manager, admin, designer]);
451
- };
452
- this.userCanViewProduction = function (user) {
453
- var manager = _roles.roles.get('manager'),
454
- admin = _roles.roles.get('admin'),
455
- supplier = _roles.roles.get('supplier');
456
- return this.userCanViewSection(user, [manager, admin, supplier]);
457
- };
458
- this.userCanViewShipping = function (user) {
459
- var manager = _roles.roles.get('manager'),
460
- admin = _roles.roles.get('admin'),
461
- client = _roles.roles.get('client');
462
- return this.userCanViewSection(user, [manager, admin, client]);
463
- };
464
- this.userCanViewInvoice = function (user) {
465
- var manager = _roles.roles.get('manager'),
466
- admin = _roles.roles.get('admin'),
467
- accountant = _roles.roles.get('accountant');
468
- return this.userCanViewSection(user, [manager, admin, accountant]);
469
- };
470
- this.userHasRole = function (user, roles) {
471
- var domain = this.domain();
472
- return user.hasAuthority(domain.id(), roles);
473
- };
474
- this.tax = function () {
475
- var domain = this.domain();
476
- return domain && domain.company() ? domain.company().defaultTaxType() : null;
477
- };
478
- this.isUserClient = function (user) {
479
- var client = this.client();
480
- return client && client.id() === user.id();
481
- };
482
- this.isUserManager = function (user) {
483
- var manager = this.manager();
484
- return manager && manager.id() === user.id();
485
- };
486
- this.isUserAdminOrManagerOfDomain = function (user) {
487
- var domain = this.domain();
488
- return domain ? user.isAdminOrManager(domain.id()) : false;
489
- };
490
- this.isUserAssignmentSupplier = function (user) {
491
- var assignment = this.assignmentBySupplier(user);
492
- return assignment ? assignment.isUserSupplier(user) : false;
493
- };
494
- this.tryDeduct = function (success, error) {
495
- var request = new _model.Request(),
496
- data = (0, _model.serialise)(this)[0],
497
- query = new _dictionary.Dictionary(),
498
- self = this;
499
- query.add('embed', JSON.stringify({
500
- inventory: {}
501
- }));
502
- request.resource('/jobs/' + this.id() + '/deduct/');
503
- request.method('POST');
504
- request.data().merge(data);
505
- request.query().merge(query);
506
- function handleResponse(status, data) {
507
- if (status === 200) {
508
- success((0, _model.fromJson)(self, data['job']));
509
- } else {
510
- error(data);
511
- }
512
- }
513
- function handleError() {
514
- error({
515
- message: 'could not connect to server',
516
- errorCode: 0
517
- });
518
- }
519
- request.responseHandler(handleResponse).errorHandler(handleError);
520
- request.send();
521
- };
522
- }
523
- function Jobs() {
524
- this.resource = '/jobs';
525
- this.json = 'jobs';
526
- this.single = Job;
527
- this.get = function (success, error, parameters, withUpdates) {
528
- var self = this;
529
- function handleResponse(result) {
530
- success((0, _model.fromJsonList)(self, result, {
531
- makesDirty: false
532
- }));
533
- }
534
- return (0, _model.getList)(this.resource, handleResponse, error, parameters, withUpdates);
535
- };
536
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.JobComment = JobComment;
7
- var _uuid = require("./uuid.js");
8
- var _model = require("./model.js");
9
- var _job = require("./job.js");
10
- var _user = require("./user.js");
11
- var _merchi_file = require("./merchi_file.js");
12
- var _notification = require("./notification.js");
13
- function JobComment() {
14
- this.resource = '/job_comments';
15
- this.json = 'jobComment';
16
- this.temporaryId = (0, _uuid.generateUUID)();
17
- (0, _model.addPropertyTo)(this, 'id');
18
- (0, _model.addPropertyTo)(this, 'job', _job.Job);
19
- (0, _model.addPropertyTo)(this, 'user', _user.User);
20
- (0, _model.addPropertyTo)(this, 'file', _merchi_file.MerchiFile);
21
- (0, _model.addPropertyTo)(this, 'notifications', _notification.Notification);
22
- (0, _model.addPropertyTo)(this, 'date');
23
- (0, _model.addPropertyTo)(this, 'text');
24
- (0, _model.addPropertyTo)(this, 'urgency');
25
- (0, _model.addPropertyTo)(this, 'subject');
26
- (0, _model.addPropertyTo)(this, 'sendSms');
27
- (0, _model.addPropertyTo)(this, 'sendEmail');
28
- (0, _model.addPropertyTo)(this, 'openToClient');
29
- this.create = function (options) {
30
- var data = (0, _model.serialise)(this),
31
- self = this;
32
- function handleResponse(result) {
33
- options.success((0, _model.fromJson)(self, result[self.json]));
34
- }
35
- (0, _model.create)({
36
- resource: this.resource,
37
- parameters: data[0],
38
- files: (0, _model.enumerateFiles)(data[1]),
39
- success: handleResponse,
40
- as_domain: options.as_domain,
41
- error: options.error,
42
- embed: options.embed
43
- });
44
- };
45
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.jobStatusShipment = exports.jobStatusProduction = exports.jobStatusPayment = exports.jobStatusDrafting = exports.jobPriority = void 0;
7
- var _dictionary = require("./dictionary.js");
8
- var jobStatusPayment = exports.jobStatusPayment = new _dictionary.Dictionary();
9
- jobStatusPayment.add("INIT", 0);
10
- jobStatusPayment.add("ISSUED", 1);
11
- jobStatusPayment.add("OVERDUE", 2);
12
- jobStatusPayment.add("PARTIAL_PAID", 3);
13
- jobStatusPayment.add("FULLY_PAID", 4);
14
- var jobStatusDrafting = exports.jobStatusDrafting = new _dictionary.Dictionary();
15
- jobStatusDrafting.add("INIT", 0);
16
- jobStatusDrafting.add("WAIT_DRAFTING", 1);
17
- jobStatusDrafting.add("CHANGES_REQUESTED", 2);
18
- jobStatusDrafting.add("DRAFTING_UPLOADED", 3);
19
- jobStatusDrafting.add("DRAFTING_APPROVED", 4);
20
- var jobStatusProduction = exports.jobStatusProduction = new _dictionary.Dictionary();
21
- jobStatusProduction.add("INIT", 0);
22
- jobStatusProduction.add("REJECTED", 1);
23
- jobStatusProduction.add("QUOTING", 2);
24
- jobStatusProduction.add("ASSIGN_SENT", 3);
25
- jobStatusProduction.add("ASSIGN_DEADLINE_REACHED", 4);
26
- jobStatusProduction.add("ASSIGN_COMPLETE", 5);
27
- jobStatusProduction.add("QUESTIONING", 6);
28
- jobStatusProduction.add("COMMENCED", 7);
29
- jobStatusProduction.add("FINISHED", 8);
30
- jobStatusProduction.add("SHIPPED", 9);
31
- jobStatusProduction.add("COMPLETED", 10);
32
- var jobStatusShipment = exports.jobStatusShipment = new _dictionary.Dictionary();
33
- jobStatusShipment.add("NOT_ASSIGNED", 0);
34
- jobStatusShipment.add("ASSIGNED", 1);
35
- jobStatusShipment.add("DISPATCH_SET", 2);
36
- jobStatusShipment.add("DISPATCH_WARNING", 3);
37
- jobStatusShipment.add("DISPATCH_LATE", 4);
38
- jobStatusShipment.add("DISPATCHED", 5);
39
- jobStatusShipment.add("EXPECTED_RECEIVE_DATE_WARNING", 6);
40
- jobStatusShipment.add("EXPECTED_RECEIVE_DATE_PAST", 7);
41
- jobStatusShipment.add("RECEIVED", 8);
42
- jobStatusShipment.add("PICKED_UP", 9);
43
- var jobPriority = exports.jobPriority = new _dictionary.Dictionary();
44
- jobPriority.add('urgent', 1);
45
- jobPriority.add('high', 2);
46
- jobPriority.add('medium', 3);
47
- jobPriority.add('low', 4);
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MatchingInventory = MatchingInventory;
7
- var _uuid = require("./uuid.js");
8
- var _model = require("./model.js");
9
- var _inventory = require("./inventory.js");
10
- var _job = require("./job.js");
11
- var _variations_group = require("./variations_group.js");
12
- function MatchingInventory() {
13
- this.resource = '/matching_inventories';
14
- this.json = 'matching_inventory';
15
- this.temporaryId = (0, _uuid.generateUUID)();
16
- (0, _model.addPropertyTo)(this, 'deductionDate');
17
- (0, _model.addPropertyTo)(this, 'canDeduct');
18
- (0, _model.addPropertyTo)(this, 'inventory', _inventory.Inventory);
19
- (0, _model.addPropertyTo)(this, 'job', _job.Job);
20
- (0, _model.addPropertyTo)(this, 'group', _variations_group.VariationsGroup);
21
- }