types .model('Project', { id: types.optional(types.identifier, () => uuid.v4()), group: types.maybeNull(types.reference(Group)), generatorList: types.optional(types.array(Generator), []), isWebBased: false, webUrl: '', name: '', path: '', type: '', allItems: types.optional(types.frozen(), []), tabs: types.optional(types.array(Tab), []), ready: true, editingScript: types.optional(types.string, ''), addingScript: createModel(Boolean), //frozen packageJson: types.frozen(), gitConfig: types.frozen(), gitBranch: types.frozen(), contents: types.frozen() })
types .model('ToggleArray', { items: types.optional(types.array(types.string), []) }) .actions(self => ({ toggle: id => { if (self.items.includes(id)) { self.remove(id); } else { self.add(id); } }, remove: id => { self.items = self.items.filter(i => i !== id); }, add: id => { self.items.push(id); }, reset: () => { self.items = []; } }))
description: '', fullCommand: '', listOfCommands: types.optional(types.array(types.string), []) }) .actions(self => ({
types .model('Processes', { list: types.optional(types.array(types.maybeNull(Process)), []), selectedProcess: types.maybeNull(types.safeReference(Process)) })
types.model('WishList', { items: types.optional(types.array(WishListItem), []), }) .actions(self => ({ add(item) { self.items.push(item) } })) .views(self => ({ get totalPrice() { return self.items.reduce((sum, entry) => sum + entry.price, 0) } }))
types .model('ShoppinCartStore', { products: types.array(types.reference(ProductModel)), }) .views(self => ({ get totalProducts() { return self.products.length; }, get totalAmount() { return self.products .reduce((acc, current) => acc + parseFloat(current.totalPrice), 0) .toFixed(2); }, get productsList() { return self.products.slice(); }, })) .actions(self => ({ addProduct(product) { const entry = self.products.find(el => el.id === product.id); if (!entry) { self.products.push(product); } }, removeProduct(product) { self.products = self.products.filter(el => el.id !== product.id); }, }))
lastName: types.string, avatarUrl: types.maybe(types.string), addresses: types.optional(types.array(UserAddressModel), []), }) .views(self => ({