2018-12-06 22:21:46 +00:00
/** @format */
/ * *
* External dependencies
* /
2018-12-10 20:01:22 +00:00
import { _ _ , _x } from '@wordpress/i18n' ;
2018-12-14 15:13:34 +00:00
import { decodeEntities } from '@wordpress/html-entities' ;
2018-12-17 20:50:45 +00:00
/ * *
* Internal dependencies
* /
import { getRequestByIdString } from 'lib/async-requests' ;
import { NAMESPACE } from 'store/constants' ;
2018-12-06 22:21:46 +00:00
export const filters = [
{
label : _ _ ( 'Show' , 'wc-admin' ) ,
staticParams : [ ] ,
param : 'filter' ,
showFilters : ( ) => true ,
2018-12-10 20:01:22 +00:00
filters : [
{ label : _ _ ( 'All Registered Customers' , 'wc-admin' ) , value : 'all' } ,
{ label : _ _ ( 'Advanced Filters' , 'wc-admin' ) , value : 'advanced' } ,
] ,
2018-12-06 22:21:46 +00:00
} ,
] ;
2018-12-10 20:01:22 +00:00
/*eslint-disable max-len*/
export const advancedFilters = {
title : _x (
'Customers Match {{select /}} Filters' ,
'A sentence describing filters for Customers. See screen shot for context: https://cloudup.com/cCsm3GeXJbE' ,
'wc-admin'
) ,
filters : {
name : {
labels : {
add : _ _ ( 'Name' , 'wc-admin' ) ,
2018-12-14 15:13:34 +00:00
placeholder : _ _ ( 'Search' , 'wc-admin' ) ,
2018-12-10 20:01:22 +00:00
remove : _ _ ( 'Remove customer name filter' , 'wc-admin' ) ,
rule : _ _ ( 'Select a customer name filter match' , 'wc-admin' ) ,
2018-12-10 22:18:45 +00:00
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cCsm3GeXJbE */
2018-12-10 20:01:22 +00:00
title : _ _ ( 'Name {{rule /}} {{filter /}}' , 'wc-admin' ) ,
filter : _ _ ( 'Select customer name' , 'wc-admin' ) ,
} ,
rules : [
{
value : 'includes' ,
2018-12-10 22:18:45 +00:00
/* translators: Sentence fragment, logical, "Includes" refers to customer names including a given name(s). Screenshot for context: https://cloudup.com/cCsm3GeXJbE */
2018-12-10 20:01:22 +00:00
label : _x ( 'Includes' , 'customer names' , 'wc-admin' ) ,
} ,
{
value : 'excludes' ,
2018-12-10 22:18:45 +00:00
/* translators: Sentence fragment, logical, "Excludes" refers to customer names excluding a given name(s). Screenshot for context: https://cloudup.com/cCsm3GeXJbE */
2018-12-10 20:01:22 +00:00
label : _x ( 'Excludes' , 'customer names' , 'wc-admin' ) ,
} ,
] ,
input : {
// Use products autocompleter for now, see https://github.com/woocommerce/wc-admin/issues/1029 for progress
component : 'Search' ,
type : 'products' ,
getLabels : getRequestByIdString ( NAMESPACE + 'products' , product => ( {
id : product . id ,
label : product . name ,
} ) ) ,
} ,
} ,
2018-12-14 15:13:34 +00:00
country : {
labels : {
add : _ _ ( 'Country' , 'wc-admin' ) ,
placeholder : _ _ ( 'Search' , 'wc-admin' ) ,
remove : _ _ ( 'Remove country filter' , 'wc-admin' ) ,
rule : _ _ ( 'Select a country filter match' , 'wc-admin' ) ,
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cCsm3GeXJbE */
title : _ _ ( 'Country {{rule /}} {{filter /}}' , 'wc-admin' ) ,
filter : _ _ ( 'Select country' , 'wc-admin' ) ,
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to countries including a given country or countries. Screenshot for context: https://cloudup.com/cCsm3GeXJbE */
label : _x ( 'Includes' , 'countries' , 'wc-admin' ) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to countries excluding a given country or countries. Screenshot for context: https://cloudup.com/cCsm3GeXJbE */
label : _x ( 'Excludes' , 'countries' , 'wc-admin' ) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'countries' ,
getLabels : async value => {
const countries =
( wcSettings . dataEndpoints && wcSettings . dataEndpoints . countries ) || [ ] ;
const allLabels = countries . map ( country => ( {
id : country . code ,
label : decodeEntities ( country . name ) ,
} ) ) ;
const labels = value . split ( ',' ) ;
return await allLabels . filter ( label => {
return labels . includes ( label . id ) ;
} ) ;
} ,
} ,
} ,
2018-12-17 16:20:11 +00:00
email : {
labels : {
add : _ _ ( 'Email' , 'wc-admin' ) ,
placeholder : _ _ ( 'Search customer email' , 'wc-admin' ) ,
remove : _ _ ( 'Remove customer email filter' , 'wc-admin' ) ,
rule : _ _ ( 'Select a customer email filter match' , 'wc-admin' ) ,
/* translators: A sentence describing a customer email filter. See screen shot for context: https://cloudup.com/cCsm3GeXJbE */
title : _ _ ( 'Email {{rule /}} {{filter /}}' , 'wc-admin' ) ,
filter : _ _ ( 'Select customer email' , 'wc-admin' ) ,
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to customer emails including a given email(s). Screenshot for context: https://cloudup.com/cCsm3GeXJbE */
label : _x ( 'Includes' , 'customer emails' , 'wc-admin' ) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to customer emails excluding a given email(s). Screenshot for context: https://cloudup.com/cCsm3GeXJbE */
label : _x ( 'Excludes' , 'customer emails' , 'wc-admin' ) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'emails' ,
getLabels : getRequestByIdString ( NAMESPACE + 'customers' , customer => ( {
id : customer . id ,
label : customer . email ,
} ) ) ,
} ,
} ,
2018-12-10 20:01:22 +00:00
} ,
} ;
/*eslint-enable max-len*/