| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- module.exports = {
- _id: '_design/admin',
- version: '1.0.0',
- appVersion: '1.0.0',
- hash: 'admin_v1_0_0_' + Date.now(),
-
- views: {
- # Слайды главной страницы
- slides: {
- map: ((doc) ->
- if doc.type == 'hero_slide' && doc.active != false
- emit(doc.order, {
- _id: doc._id,
- title: doc.title,
- subtitle: doc.subtitle,
- image: doc.image,
- buttonText: doc.buttonText,
- buttonLink: doc.buttonLink,
- active: doc.active,
- order: doc.order,
- domains: doc.domains
- })
- ).toString()
- },
-
- # Товары
- products: {
- map: ((doc) ->
- if doc.type == 'product'
- emit([doc.category, doc.createdAt], {
- _id: doc._id,
- name: doc.name,
- price: doc.price,
- oldPrice: doc.oldPrice,
- active: doc.active,
- sku: doc.sku,
- category: doc.category,
- domains: doc.domains,
- createdAt: doc.createdAt
- })
- ).toString()
- },
-
- # Товары по категориям
- products_by_category: {
- map: ((doc) ->
- if doc.type == 'product' && doc.active != false
- emit(doc.category, {
- _id: doc._id,
- name: doc.name,
- price: doc.price,
- oldPrice: doc.oldPrice,
- sku: doc.sku,
- image: doc.image
- })
- ).toString()
- },
-
- # Категории
- categories: {
- map: ((doc) ->
- if doc.type == 'category'
- emit(doc.order, {
- _id: doc._id,
- name: doc.name,
- slug: doc.slug,
- parent: doc.parent,
- order: doc.order,
- active: doc.active
- })
- ).toString()
- },
-
- # Статьи блога
- blog_articles: {
- map: ((doc) ->
- if doc.type == 'blog_article' && doc.published != false
- emit(doc.createdAt, {
- _id: doc._id,
- title: doc.title,
- slug: doc.slug,
- excerpt: doc.excerpt,
- image: doc.image,
- author: doc.author,
- published: doc.published,
- createdAt: doc.createdAt,
- domains: doc.domains
- })
- ).toString()
- },
-
- # Настройки доменов
- domain_settings: {
- map: ((doc) ->
- if doc.type == 'domain_settings'
- emit(doc.domain, {
- _id: doc._id,
- domain: doc.domain,
- companyName: doc.companyName,
- languages: doc.languages,
- theme: doc.theme,
- contacts: doc.contacts
- })
- ).toString()
- },
-
- # Пользовательские маршруты
- custom_routes: {
- map: ((doc) ->
- if doc.type == 'route'
- emit(doc.path, {
- _id: doc._id,
- path: doc.path,
- component: doc.component,
- title: doc.title,
- active: doc.active,
- domains: doc.domains
- })
- ).toString()
- }
- },
-
- filters: {
- # Фильтр по доменам
- by_domain: ((doc, req) ->
- if !doc.domains || doc.domains.length == 0
- return true
-
- domain = req.query.domain
- if domain && doc.domains.includes(domain)
- return true
-
- return false
- ).toString(),
-
- # Фильтр по типу документа
- by_type: ((doc, req) ->
- type = req.query.type
- if type && doc.type == type
- return true
- return !type
- ).toString()
- }
- }
|