-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for combined fields in the regular dataform view as well
- Loading branch information
Showing
6 changed files
with
62 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
packages/dataviews/src/components/dataform-combined-edit/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.dataforms-combined-edit { | ||
&__field:not(:first-child) { | ||
border-top: $border-width solid $gray-200; | ||
padding-top: $grid-unit-20; | ||
.dataforms-layouts-panel__field-dropdown { | ||
.dataforms-combined-edit { | ||
&__field:not(:first-child) { | ||
border-top: $border-width solid $gray-200; | ||
padding-top: $grid-unit-20; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/dataviews/src/dataforms-layouts/get-visible-fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { normalizeCombinedFields } from '../normalize-fields'; | ||
import type { | ||
Field, | ||
CombinedFormField, | ||
NormalizedCombinedFormField, | ||
} from '../types'; | ||
|
||
export function getVisibleFields( | ||
fields: Field< any >[], | ||
formFields: string[] = [], | ||
combinedFields?: CombinedFormField< any >[] | ||
): Field< any >[] { | ||
const visibleFields: Array< | ||
Field< any > | NormalizedCombinedFormField< any > | ||
> = [ ...fields ]; | ||
if ( combinedFields ) { | ||
visibleFields.push( | ||
...normalizeCombinedFields( combinedFields, fields ) | ||
); | ||
} | ||
return formFields | ||
.map( ( fieldId ) => | ||
visibleFields.find( ( { id } ) => id === fieldId ) | ||
) | ||
.filter( ( field ): field is Field< any > => !! field ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters