Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added New Entities (referencing from TS) #654

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/address.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, fromJson, getOne, fromJsonList,
Request } from './model.js'
import { isUndefinedOrNull } from './helpers.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/assignment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, fromJson, create, serialise, enumerateFiles, getList,
patchOne, fromJsonList, getOne } from './model.js';
import { notificationTypes, notificationRecieverIsCurrentUserFilter,
Expand Down
2 changes: 1 addition & 1 deletion javascript/automatic_payment_relationship.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Company } from './company.js';
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import {
addPropertyTo, serialise, fromJson, create, enumerateFiles,
deleteOne, getList, fromJsonList, getOne } from './model.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/bank.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';
import { Address } from './address.js';
import { Companies } from './company.js';
Expand Down
4 changes: 2 additions & 2 deletions javascript/cart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, serialise, enumerateFiles, getOne, fromJson, patchOne,
create } from './model.js';
create, Request } from './model.js';
import { Address } from './address.js';
import { CartItem } from './cart_item.js';
import { CartShipmentGroup } from './cart_shipment_group.js';
Expand Down
77 changes: 64 additions & 13 deletions javascript/cart_item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { generateUUID } from './uuid.js';
import { addPropertyTo, serialise, fromJson, create,
enumerateFiles } from './model.js';
import generateUUID from './uuid.js';
import {
addPropertyTo, serialise, fromJson, create,
enumerateFiles, deleteOneV2, getOne,Request, patchOne
} from './model.js';
import { Cart } from './cart.js';
import { CountryTax } from './country_tax.js';
import { Product } from './product.js';
Expand Down Expand Up @@ -36,18 +38,58 @@ export function CartItem() {
function handleResponse(result) {
success(fromJson(self, result[self.json]));
}
create({resource: this.resource,
parameters: data[0],
as_domain: asDomain,
files: enumerateFiles(data[1]),
success: handleResponse,
create({
resource: this.resource,
parameters: data[0],
as_domain: asDomain,
files: enumerateFiles(data[1]),
success: handleResponse,
error: error,
embed: embed
});
};

this.get = function (success, error, embed, includeArchived,
withRights) {
var self = this,
parameters = {
embed: embed,
error: error,
embed: embed});
id: this.id(),
includeArchived: includeArchived,
withRights: withRights,
resource: this.resource,
cartToken: this.cart().token()
};
function handleResponse(result) {
success(fromJson(self, result[self.json],
{ makesDirty: false }));
}
parameters.success = handleResponse;
getOne(parameters);
};


this.patch = function (success, error, embed) {
var self = this,
data = serialise(this, undefined, undefined, undefined,
{excludeOld: true})[0];
function handleResponse(result) {
success(fromJson(self, result[self.json],
{makesDirty: false}));
}
patchOne({cartToken: this.cart().token(),
resource: this.resource,
id: this.id(),
success: handleResponse,
error: error,
data: data,
embed: embed});
};

this.calculate = function (success, error, embed) {
var request = new Request(),
data = serialise(this)[0];
var request = new Request();
var data = serialise(this)[0];
request.resource('/cart-item-cost-estimate/');
request.method('POST');
request.query().add('skip_rights', true);
Expand All @@ -63,9 +105,18 @@ export function CartItem() {
request.send();
};

this.requiresShipment = function() {
this.destroy = function (success, error) {
deleteOneV2({
resource: this.resource + "/" + this.id(),
success: success,
error: error,
cartToken: this.cart().token()
});
};

this.requiresShipment = function () {
var product = this.product();
//console.log("bhbh")
return product ? product.needsShipping() : false;
};

}
2 changes: 1 addition & 1 deletion javascript/cart_shipment_group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';
import { CartItem } from './cart_item.js';
import { CartShipmentQuote } from './cart_shipment_quote.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/cart_shipment_quote.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';
import { ShipmentMethod } from './shipment_method.js';

Expand Down
2 changes: 1 addition & 1 deletion javascript/category.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, fromJson, serialise, create, enumerateFiles,
getOne, deleteOne, fromJsonList, getList } from './model.js';
import { Domain } from './domain.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/company_invitation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, serialise, fromJson, create, enumerateFiles,
deleteOne, getList, fromJsonList, getOne } from './model.js';

Expand Down
2 changes: 1 addition & 1 deletion javascript/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, fromJson, getOne, serialise, enumerateFiles, patchOne,
fromJsonList, getList, create } from './model.js';
import { MerchiFile } from './merchi_file.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/component_tag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, fromJson, getOne, serialise, create, enumerateFiles,
fromJsonList, getList } from './model.js';

Expand Down
2 changes: 1 addition & 1 deletion javascript/discount.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';

export function Discount() {
Expand Down
2 changes: 1 addition & 1 deletion javascript/discount_group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';


Expand Down
2 changes: 1 addition & 1 deletion javascript/domain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { Dictionary } from './dictionary.js';
import { addPropertyTo, serialise, fromJson, getList, fromJsonList, patchOne,
getOne, create, enumerateFiles, Request } from './model.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/domain_invitation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';

export function DomainInvitation() {
Expand Down
2 changes: 1 addition & 1 deletion javascript/domain_tag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, serialise, create, fromJson, patchOne, deleteOne,
fromJsonList, getList, enumerateFiles, getOne } from './model.js';
import { Domain } from './domain.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/email_address.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, getList, fromJsonList } from './model.js';

export function EmailAddress() {
Expand Down
2 changes: 1 addition & 1 deletion javascript/enrolled_domain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, serialise, fromJson, create, enumerateFiles,
getOne, patchOne, deleteOne, getList, fromJsonList } from './model.js';
import { Domain } from './domain.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/exchange_rate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, serialise, fromJson, create, enumerateFiles, deleteOne,
getOne, fromJsonList, getList } from './model.js';

Expand Down
2 changes: 1 addition & 1 deletion javascript/inventory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, serialise, fromJson, create, getOne, deleteOne,
patchOne, fromJsonList, getList, enumerateFiles } from './model.js';
import { Address } from './address.js';
Expand Down
4 changes: 2 additions & 2 deletions javascript/invoice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment-timezone';
import { generateUUID } from './uuid.js';
import moment from 'moment';
import generateUUID from './uuid.js';
import { addPropertyTo, create, serialise, enumerateFiles, getOne, getList,
fromJson, deleteOne, fromJsonList, patchOne, Request } from './model.js';
import { isUndefinedOrNull } from './helpers.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';
import { CountryTax } from './country_tax.js';

Expand Down
2 changes: 1 addition & 1 deletion javascript/job.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { Dictionary } from './dictionary.js';
import { addPropertyTo, getOne, create, serialise, recoverOne, deleteOne,
fromJson, patchOne, getList, fromJsonList, enumerateFiles,
Expand Down
2 changes: 1 addition & 1 deletion javascript/job_comment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, enumerateFiles, fromJson, create,
serialise } from './model.js';
import { Job } from './job.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/matching_inventory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';
import { Inventory } from './inventory.js';
import { Job } from './job.js';
Expand Down
2 changes: 1 addition & 1 deletion javascript/menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo, fromJson, getOne, deleteOne } from './model.js';
import { MenuItem } from './menu_item.js';

Expand Down
2 changes: 1 addition & 1 deletion javascript/menu_item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { addPropertyTo } from './model.js';

export function MenuItem() {
Expand Down
4 changes: 3 additions & 1 deletion javascript/merchi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { isNull, isUndefined, isUndefinedOrNull, id,
notEmptyArray, isArray, removeObjectFromArrayWithIntegerValue,
sortArrayByObjectKey, getGlobal } from './helpers.js';
Expand Down Expand Up @@ -75,6 +75,7 @@ import { VariationFieldsOption } from './variation_fields_option.js';
import { VariationsGroup } from './variations_group.js';
import { QuoteItem, QuoteItems } from './quote_item.js';
import { Quotes, Quote } from './quote.js';
import { CartShipmentQuote } from './cart_shipment_quote.js';

export function merchi(backendUri, websocketUri) {
getGlobal().merchiJsonpHandlers = {};
Expand Down Expand Up @@ -944,6 +945,7 @@ export function merchi(backendUri, websocketUri) {
'JobComment': JobComment,
'Cart': Cart,
'CartItem': CartItem,
'CartShipmentQuote': CartShipmentQuote,
'Bank': Bank,
'QuoteItem': QuoteItem,
'QuoteItems': new QuoteItems(),
Expand Down
2 changes: 1 addition & 1 deletion javascript/merchi_file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateUUID } from './uuid.js';
import generateUUID from './uuid.js';
import { Dictionary } from './dictionary.js';
import { addPropertyTo, fromJson, getOne, serialise, create, enumerateFiles,
getList, fromJsonList, deleteOne, Request } from './model.js';
Expand Down
Loading