File tree 2 files changed +46
-23
lines changed
2 files changed +46
-23
lines changed Original file line number Diff line number Diff line change 1
- /**
2
- * WordPress dependencies
3
- */
4
1
/**
5
2
* WordPress dependencies
6
3
*/
@@ -10,27 +7,9 @@ import { useSelect } from '@wordpress/data';
10
7
import { store as coreDataStore } from '@wordpress/core-data' ;
11
8
12
9
/**
13
- * A helper to retrieve the correct items to display or save in the token field
14
- *
15
- * @param {Array } subSet
16
- * @param {Array } fullSet
17
- * @param {string } lookupProperty
18
- * @param {string } returnProperty
19
- * @return {Array } The correct items to display or save in the token field
10
+ * Internal dependencies
20
11
*/
21
- function prepDataFromTokenField (
22
- subSet ,
23
- fullSet ,
24
- lookupProperty ,
25
- returnProperty
26
- ) {
27
- const subsetFullObjects = fullSet . filter ( ( item ) =>
28
- subSet . includes ( item [ lookupProperty ] )
29
- ) ;
30
- return subsetFullObjects . map (
31
- ( { [ returnProperty ] : returnVal } ) => returnVal
32
- ) ;
33
- }
12
+ import { prepDataFromTokenField } from '../utils' ;
34
13
35
14
export const ExcludeTaxonomies = ( { attributes, setAttributes } ) => {
36
15
const {
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Helper function to update taxonomy queries.
3
+ *
4
+ * @param {Array } queries The current queries.
5
+ * @param {string } queryId The query ID to update.
6
+ * @param {string } item The key to update.
7
+ * @param {string } value The value to update.
8
+ *
9
+ * @return {Array } The updated queries.
10
+ */
11
+ export const updateTaxonomyQuery = ( queries , queryId , item , value ) => {
12
+ return queries . map ( ( query ) => {
13
+ if ( query . id === queryId ) {
14
+ return {
15
+ ...query ,
16
+ [ item ] : value ,
17
+ } ;
18
+ }
19
+ return query ;
20
+ } ) ;
21
+ } ;
22
+
23
+ /**
24
+ * A helper to retrieve the correct items to display or save in the token field
25
+ *
26
+ * @param {Array } subSet
27
+ * @param {Array } fullSet
28
+ * @param {string } lookupProperty
29
+ * @param {string } returnProperty
30
+ * @return {Array } The correct items to display or save in the token field
31
+ */
32
+ export const prepDataFromTokenField = (
33
+ subSet ,
34
+ fullSet ,
35
+ lookupProperty ,
36
+ returnProperty
37
+ ) => {
38
+ const subsetFullObjects = fullSet . filter ( ( item ) =>
39
+ subSet . includes ( item [ lookupProperty ] )
40
+ ) ;
41
+ return subsetFullObjects . map (
42
+ ( { [ returnProperty ] : returnVal } ) => returnVal
43
+ ) ;
44
+ } ;
You can’t perform that action at this time.
0 commit comments