File "analytics-report-categories.js"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/woocommerce/assets/client/admin/chunks/analytics-report-categories.js
File size: 13.71 KB
MIME-type: text/plain
Charset: utf-8

"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[185],{5029:(e,t,r)=>{r.d(t,{Z:()=>l});var o=r(69307),s=r(92819),a=r(55609),c=r(22629),n=r(86020),i=r(10431);class l extends o.Component{getCategoryAncestorIds(e,t){const r=[];let o=e.parent;for(;o;)r.unshift(o),o=t.get(o).parent;return r}getCategoryAncestors(e,t){const r=this.getCategoryAncestorIds(e,t);if(r.length)return 1===r.length?t.get((0,s.first)(r)).name+" › ":2===r.length?t.get((0,s.first)(r)).name+" › "+t.get((0,s.last)(r)).name+" › ":t.get((0,s.first)(r)).name+" … "+t.get((0,s.last)(r)).name+" › "}render(){const{categories:e,category:t,query:r}=this.props,s=(0,i.getPersistedQuery)(r);return t?(0,o.createElement)("div",{className:"woocommerce-table__breadcrumbs"},(0,c.decodeEntities)(this.getCategoryAncestors(t,e)),(0,o.createElement)(n.Link,{href:(0,i.getNewPath)(s,"/analytics/categories",{filter:"single_category",categories:t.id}),type:"wc-admin"},(0,c.decodeEntities)(t.name))):(0,o.createElement)(a.Spinner,null)}}},4818:(e,t,r)=>{r.r(t),r.d(t,{default:()=>F});var o=r(69307),s=r(7862),a=r.n(s),c=r(65736),n=r(92694),i=r(9818),l=r(75606),m=r(20513);const{addCesSurveyForAnalytics:u}=(0,i.dispatch)(l.STORE_KEY),d=(0,n.applyFilters)("woocommerce_admin_categories_report_charts",[{key:"items_sold",label:(0,c.__)("Items sold","woocommerce"),order:"desc",orderby:"items_sold",type:"number"},{key:"net_revenue",label:(0,c.__)("Net sales","woocommerce"),order:"desc",orderby:"net_revenue",type:"currency"},{key:"orders_count",label:(0,c.__)("Orders","woocommerce"),order:"desc",orderby:"orders_count",type:"number"}]),g=(0,n.applyFilters)("woocommerce_admin_category_report_advanced_filters",{filters:{},title:(0,c._x)("Categories match <select/> filters","A sentence describing filters for Categories. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ","woocommerce")}),p=[{label:(0,c.__)("All categories","woocommerce"),value:"all"},{label:(0,c.__)("Single category","woocommerce"),value:"select_category",chartMode:"item-comparison",subFilters:[{component:"Search",value:"single_category",chartMode:"item-comparison",path:["select_category"],settings:{type:"categories",param:"categories",getLabels:m.YC,labels:{placeholder:(0,c.__)("Type to search for a category","woocommerce"),button:(0,c.__)("Single Category","woocommerce")}}}]},{label:(0,c.__)("Comparison","woocommerce"),value:"compare-categories",chartMode:"item-comparison",settings:{type:"categories",param:"categories",getLabels:m.YC,labels:{helpText:(0,c.__)("Check at least two categories below to compare","woocommerce"),placeholder:(0,c.__)("Search for categories to compare","woocommerce"),title:(0,c.__)("Compare Categories","woocommerce"),update:(0,c.__)("Compare","woocommerce")},onClick:u}}];Object.keys(g.filters).length&&p.push({label:(0,c.__)("Advanced filters","woocommerce"),value:"advanced"});const _=(0,n.applyFilters)("woocommerce_admin_categories_report_filters",[{label:(0,c.__)("Show","woocommerce"),staticParams:["chartType","paged","per_page"],param:"filter",showFilters:()=>!0,filters:p}]);var y=r(94333),h=r(92819),b=r(10431),w=r(86020),f=r(81595),C=r(67221),v=r(17844),S=r(5029),k=r(42968);class E extends o.Component{constructor(e){super(e),this.getRowsContent=this.getRowsContent.bind(this),this.getSummary=this.getSummary.bind(this)}getHeadersContent(){return[{label:(0,c.__)("Category","woocommerce"),key:"category",required:!0,isSortable:!0,isLeftAligned:!0},{label:(0,c.__)("Items sold","woocommerce"),key:"items_sold",required:!0,defaultSort:!0,isSortable:!0,isNumeric:!0},{label:(0,c.__)("Net sales","woocommerce"),key:"net_revenue",isSortable:!0,isNumeric:!0},{label:(0,c.__)("Products","woocommerce"),key:"products_count",isSortable:!0,isNumeric:!0},{label:(0,c.__)("Orders","woocommerce"),key:"orders_count",isSortable:!0,isNumeric:!0}]}getRowsContent(e){const{render:t,formatDecimal:r,getCurrencyConfig:s}=this.context,{categories:a,query:c}=this.props;if(!a)return[];const n=s();return(0,h.map)(e,(e=>{const{category_id:s,items_sold:i,net_revenue:l,products_count:m,orders_count:u}=e,d=a.get(s),g=(0,b.getPersistedQuery)(c);return[{display:(0,o.createElement)(S.Z,{query:c,category:d,categories:a}),value:d&&d.name},{display:(0,f.formatValue)(n,"number",i),value:i},{display:t(l),value:r(l)},{display:d&&(0,o.createElement)(w.Link,{href:(0,b.getNewPath)(g,"/analytics/categories",{filter:"single_category",categories:d.id}),type:"wc-admin"},(0,f.formatValue)(n,"number",m)),value:m},{display:(0,f.formatValue)(n,"number",u),value:u}]}))}getSummary(e,t=0){const{items_sold:r=0,net_revenue:o=0,orders_count:s=0}=e,{formatAmount:a,getCurrencyConfig:n}=this.context,i=n();return[{label:(0,c._n)("Category","Categories",t,"woocommerce"),value:(0,f.formatValue)(i,"number",t)},{label:(0,c._n)("Item sold","Items sold",r,"woocommerce"),value:(0,f.formatValue)(i,"number",r)},{label:(0,c.__)("Net sales","woocommerce"),value:a(o)},{label:(0,c._n)("Order","Orders",s,"woocommerce"),value:(0,f.formatValue)(i,"number",s)}]}render(){const{advancedFilters:e,filters:t,isRequesting:r,query:s}=this.props,a={helpText:(0,c.__)("Check at least two categories below to compare","woocommerce"),placeholder:(0,c.__)("Search by category name","woocommerce")};return(0,o.createElement)(k.Z,{compareBy:"categories",endpoint:"categories",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:["items_sold","net_revenue","orders_count"],isRequesting:r,itemIdField:"category_id",query:s,searchBy:"categories",labels:a,tableQuery:{orderby:s.orderby||"items_sold",order:s.order||"desc",extended_info:!0},title:(0,c.__)("Categories","woocommerce"),columnPrefsKey:"categories_report_columns",filters:t,advancedFilters:e})}}E.contextType=v.CurrencyContext;const q=(0,y.compose)((0,i.withSelect)(((e,t)=>{const{isRequesting:r,query:o}=t;if(r||o.search&&(!o.categories||!o.categories.length))return{};const{getItems:s,getItemsError:a,isResolving:c}=e(C.ITEMS_STORE_NAME),n={per_page:-1};return{categories:s("categories",n),isError:Boolean(a("categories",n)),isRequesting:c("getItems",["categories",n])}})))(E);var A=r(83573),N=r(47478),R=r(80272),P=r(33863),x=r(31511);class I extends o.Component{getChartMeta(){const{query:e}=this.props,t="compare-categories"===e.filter&&e.categories&&e.categories.split(",").length>1,r="single_category"===e.filter&&!!e.categories,o=t||r?"item-comparison":"time-comparison";return{isSingleCategoryView:r,itemsLabel:r?(0,c.__)("%d products","woocommerce"):(0,c.__)("%d categories","woocommerce"),mode:o}}render(){const{isRequesting:e,query:t,path:r}=this.props,{mode:s,itemsLabel:a,isSingleCategoryView:c}=this.getChartMeta(),n={...t};return"item-comparison"===s&&(n.segmentby=c?"product":"category"),(0,o.createElement)(o.Fragment,null,(0,o.createElement)(x.Z,{query:t,path:r,filters:_,advancedFilters:g,report:"categories"}),(0,o.createElement)(R.Z,{charts:d,endpoint:"products",limitProperties:c?["products","categories"]:["categories"],query:n,selectedChart:(0,A.Z)(t.chart,d),filters:_,advancedFilters:g,report:"categories"}),(0,o.createElement)(N.Z,{charts:d,filters:_,advancedFilters:g,mode:s,endpoint:"products",limitProperties:c?["products","categories"]:["categories"],path:r,query:n,isRequesting:e,itemsLabel:a,selectedChart:(0,A.Z)(t.chart,d)}),c?(0,o.createElement)(P.Z,{isRequesting:e,query:n,baseSearchQuery:{filter:"single_category"},hideCompare:c,filters:_,advancedFilters:g}):(0,o.createElement)(q,{isRequesting:e,query:t,filters:_,advancedFilters:g}))}}I.propTypes={query:a().object.isRequired,path:a().string.isRequired};const F=I},33863:(e,t,r)=>{r.d(t,{Z:()=>v});var o=r(69307),s=r(65736),a=r(94333),c=r(22629),n=r(9818),i=r(92819),l=r(10431),m=r(86020),u=r(81595),d=r(74617),g=r(67221),p=r(17844),_=r(5029),y=r(46358),h=r(42968),b=r(17062);const w=(0,b.O3)("manageStock","no"),f=(0,b.O3)("stockStatuses",{});class C extends o.Component{constructor(){super(),this.getHeadersContent=this.getHeadersContent.bind(this),this.getRowsContent=this.getRowsContent.bind(this),this.getSummary=this.getSummary.bind(this)}getHeadersContent(){return[{label:(0,s.__)("Product title","woocommerce"),key:"product_name",required:!0,isLeftAligned:!0,isSortable:!0},{label:(0,s.__)("SKU","woocommerce"),key:"sku",hiddenByDefault:!0,isSortable:!0},{label:(0,s.__)("Items sold","woocommerce"),key:"items_sold",required:!0,defaultSort:!0,isSortable:!0,isNumeric:!0},{label:(0,s.__)("Net sales","woocommerce"),screenReaderLabel:(0,s.__)("Net sales","woocommerce"),key:"net_revenue",required:!0,isSortable:!0,isNumeric:!0},{label:(0,s.__)("Orders","woocommerce"),key:"orders_count",isSortable:!0,isNumeric:!0},{label:(0,s.__)("Category","woocommerce"),key:"product_cat"},{label:(0,s.__)("Variations","woocommerce"),key:"variations",isSortable:!0},"yes"===w?{label:(0,s.__)("Status","woocommerce"),key:"stock_status"}:null,"yes"===w?{label:(0,s.__)("Stock","woocommerce"),key:"stock",isNumeric:!0}:null].filter(Boolean)}getRowsContent(e=[]){const{query:t}=this.props,r=(0,l.getPersistedQuery)(t),{render:a,formatDecimal:n,getCurrencyConfig:g}=this.context,p=g();return(0,i.map)(e,(e=>{const{product_id:i,items_sold:g,net_revenue:h,orders_count:b}=e,C=e.extended_info||{},{category_ids:v,low_stock_amount:S,manage_stock:k,sku:E,stock_status:q,stock_quantity:A,variations:N=[]}=C,R=(0,c.decodeEntities)(C.name),P=(0,l.getNewPath)(r,"/analytics/orders",{filter:"advanced",product_includes:i}),x=(0,l.getNewPath)(r,"/analytics/products",{filter:"single_product",products:i}),{categories:I}=this.props,F=v&&I&&v.map((e=>I.get(e))).filter(Boolean)||[],T=(0,y.d)(q,A,S)?(0,o.createElement)(m.Link,{href:(0,d.getAdminLink)("post.php?action=edit&post="+i),type:"wp-admin"},(0,s._x)("Low","Indication of a low quantity","woocommerce")):f[q];return[{display:(0,o.createElement)(m.Link,{href:x,type:"wc-admin"},R),value:R},{display:E,value:E},{display:(0,u.formatValue)(p,"number",g),value:g},{display:a(h),value:n(h)},{display:(0,o.createElement)(m.Link,{href:P,type:"wc-admin"},b),value:b},{display:(0,o.createElement)("div",{className:"woocommerce-table__product-categories"},F[0]&&(0,o.createElement)(_.Z,{category:F[0],categories:I}),F.length>1&&(0,o.createElement)(m.Tag,{label:(0,s.sprintf)((0,s._x)("+%d more","categories","woocommerce"),F.length-1),popoverContents:F.map((e=>(0,o.createElement)(_.Z,{category:e,categories:I,key:e.id,query:t})))})),value:F.map((e=>e.name)).join(", ")},{display:(0,u.formatValue)(p,"number",N.length),value:N.length},"yes"===w?{display:k?T:(0,s.__)("N/A","woocommerce"),value:k?f[q]:null}:null,"yes"===w?{display:k?(0,u.formatValue)(p,"number",A):(0,s.__)("N/A","woocommerce"),value:A}:null].filter(Boolean)}))}getSummary(e){const{products_count:t=0,items_sold:r=0,net_revenue:o=0,orders_count:a=0}=e,{formatAmount:c,getCurrencyConfig:n}=this.context,i=n();return[{label:(0,s._n)("Product","Products",t,"woocommerce"),value:(0,u.formatValue)(i,"number",t)},{label:(0,s._n)("Item sold","Items sold",r,"woocommerce"),value:(0,u.formatValue)(i,"number",r)},{label:(0,s.__)("Net sales","woocommerce"),value:c(o)},{label:(0,s._n)("Order","Orders",a,"woocommerce"),value:(0,u.formatValue)(i,"number",a)}]}render(){const{advancedFilters:e,baseSearchQuery:t,filters:r,hideCompare:a,isRequesting:c,query:n}=this.props,i={helpText:(0,s.__)("Check at least two products below to compare","woocommerce"),placeholder:(0,s.__)("Search by product name or SKU","woocommerce")};return(0,o.createElement)(h.Z,{compareBy:a?void 0:"products",endpoint:"products",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:["products_count","items_sold","net_revenue","orders_count"],itemIdField:"product_id",isRequesting:c,labels:i,query:n,searchBy:"products",baseSearchQuery:t,tableQuery:{orderby:n.orderby||"items_sold",order:n.order||"desc",extended_info:!0,segmentby:n.segmentby},title:(0,s.__)("Products","woocommerce"),columnPrefsKey:"products_report_columns",filters:r,advancedFilters:e})}}C.contextType=p.CurrencyContext;const v=(0,a.compose)((0,n.withSelect)(((e,t)=>{const{query:r,isRequesting:o}=t,{getItems:s,getItemsError:a,isResolving:c}=e(g.ITEMS_STORE_NAME);if(o||r.search&&(!r.products||!r.products.length))return{};const n={per_page:-1};return{categories:s("categories",n),isError:Boolean(a("categories",n)),isRequesting:c("getItems",["categories",n])}})))(C)},46358:(e,t,r)=>{function o(e,t,r){return!!t&&e&&t<=r==="instock"}r.d(t,{d:()=>o})},86806:(e,t,r)=>{r.d(t,{I:()=>s});var o=r(65736);function s(e){return[e.country,e.state,e.name||(0,o.__)("TAX","woocommerce"),e.priority].map((e=>e.toString().toUpperCase().trim())).filter(Boolean).join("-")}},20513:(e,t,r)=>{r.d(t,{FI:()=>h,V1:()=>b,YC:()=>g,hQ:()=>p,jk:()=>_,oC:()=>y,qc:()=>d,uC:()=>w});var o=r(65736),s=r(96483),a=r(86989),c=r.n(a),n=r(92819),i=r(10431),l=r(67221),m=r(86806),u=r(17062);function d(e,t=n.identity){return function(r="",o){const a="function"==typeof e?e(o):e,n=(0,i.getIdsFromQuery)(r);if(n.length<1)return Promise.resolve([]);const l={include:n.join(","),per_page:n.length};return c()({path:(0,s.addQueryArgs)(a,l)}).then((e=>e.map(t)))}}d(l.NAMESPACE+"/products/attributes",(e=>({key:e.id,label:e.name})));const g=d(l.NAMESPACE+"/products/categories",(e=>({key:e.id,label:e.name}))),p=d(l.NAMESPACE+"/coupons",(e=>({key:e.id,label:e.code}))),_=d(l.NAMESPACE+"/customers",(e=>({key:e.id,label:e.name}))),y=d(l.NAMESPACE+"/products",(e=>({key:e.id,label:e.name}))),h=d(l.NAMESPACE+"/taxes",(e=>({key:e.id,label:(0,m.I)(e)})));function b({attributes:e,name:t}){const r=(0,u.O3)("variationTitleAttributesSeparator"," - ");if(t&&t.indexOf(r)>-1)return t;const s=(e||[]).map((({name:e,option:t})=>(t||(e=e.charAt(0).toUpperCase()+e.slice(1),t=(0,o.sprintf)((0,o.__)("Any %s","woocommerce"),e)),t))).join(", ");return s?t+r+s:t}const w=d((({products:e})=>e?l.NAMESPACE+`/products/${e}/variations`:l.NAMESPACE+"/variations"),(e=>({key:e.id,label:b(e)})))}}]);