|
@@ -15,7 +15,10 @@ var ProductService = {
|
|
|
return { path: '/productos/' + p._id, name: p.name };
|
|
return { path: '/productos/' + p._id, name: p.name };
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ listView: true,
|
|
|
|
|
+ descView: false,
|
|
|
|
|
+ shown: {}
|
|
|
}
|
|
}
|
|
|
/* ----------------------------------- */
|
|
/* ----------------------------------- */
|
|
|
|
|
|
|
@@ -68,11 +71,17 @@ var Productos = {
|
|
|
return {
|
|
return {
|
|
|
titulo: 'Productos',
|
|
titulo: 'Productos',
|
|
|
categories: null,
|
|
categories: null,
|
|
|
- activeCategory: null
|
|
|
|
|
|
|
+ activeCategory: null,
|
|
|
|
|
+ P: ProductService
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- fetchCategories: ProductService.getCategories
|
|
|
|
|
|
|
+ fetchCategories: ProductService.getCategories,
|
|
|
|
|
+ showProducts: function (categoryName) {
|
|
|
|
|
+ this.activeCategory = categoryName;
|
|
|
|
|
+ this.P.listView = true;
|
|
|
|
|
+ this.P.descView = false;
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
beforeRouteEnter: function (to, from, next) {
|
|
beforeRouteEnter: function (to, from, next) {
|
|
|
ProductService.getCategories().then(function (data) {
|
|
ProductService.getCategories().then(function (data) {
|
|
@@ -100,7 +109,15 @@ var CategoriasProducto = {
|
|
|
data: function () {
|
|
data: function () {
|
|
|
return {
|
|
return {
|
|
|
loading: true,
|
|
loading: true,
|
|
|
- products: null
|
|
|
|
|
|
|
+ products: null,
|
|
|
|
|
+ P: ProductService
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ showDesc: function (product) {
|
|
|
|
|
+ this.P.descView = true;
|
|
|
|
|
+ this.P.listView = false;
|
|
|
|
|
+ this.P.shown = product;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
beforeRouteEnter: function (to, from, next) {
|
|
beforeRouteEnter: function (to, from, next) {
|
|
@@ -122,6 +139,16 @@ var CategoriasProducto = {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+var Producto = {
|
|
|
|
|
+ template: '#product',
|
|
|
|
|
+ props: ['product'],
|
|
|
|
|
+ data: function () {
|
|
|
|
|
+ return {
|
|
|
|
|
+ P: ProductService
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+}
|
|
|
/* ----------------------------------- */
|
|
/* ----------------------------------- */
|
|
|
/**
|
|
/**
|
|
|
* ROUTES
|
|
* ROUTES
|
|
@@ -142,7 +169,11 @@ var routes = [{
|
|
|
children: [{
|
|
children: [{
|
|
|
path: ':category',
|
|
path: ':category',
|
|
|
component: CategoriasProducto,
|
|
component: CategoriasProducto,
|
|
|
- props: true
|
|
|
|
|
|
|
+ props: true,
|
|
|
|
|
+ children: [{
|
|
|
|
|
+ component: Producto,
|
|
|
|
|
+ path: ':product'
|
|
|
|
|
+ }]
|
|
|
}]
|
|
}]
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
@@ -201,7 +232,9 @@ new Vue({
|
|
|
el: '#app',
|
|
el: '#app',
|
|
|
router: router,
|
|
router: router,
|
|
|
data: {
|
|
data: {
|
|
|
- routes: routes
|
|
|
|
|
|
|
+ routes: routes,
|
|
|
|
|
+ productView: true,
|
|
|
|
|
+ productListView: true
|
|
|
},
|
|
},
|
|
|
http: {
|
|
http: {
|
|
|
root: URL,
|
|
root: URL,
|