-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
92 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { find } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import JobListing from './job-listing.jsx'; | ||
import SelectJobListing from './select-job-listing.jsx'; | ||
|
||
/** | ||
* Edit UI for the Job block. | ||
*/ | ||
const EditJob = ( { attributes, isSelected, jobListings, jobTypes, setAttributes } ) => { | ||
const listing = find( jobListings, { id: attributes.jobId } ); | ||
|
||
if ( ! isSelected && listing ) { | ||
return <JobListing listing={ listing } jobTypes={ jobTypes } />; | ||
} | ||
|
||
return <SelectJobListing attributes={ attributes } jobListings={ jobListings } setAttributes={ setAttributes } />; | ||
}; | ||
|
||
export default withSelect( ( select, props ) => ( { | ||
jobListings: select( 'wp-job-manager' ).getAllJobListings(), | ||
jobTypes: select( 'wp-job-manager' ).getAllJobTypes() | ||
} ) )( EditJob ); |
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,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
import { applyFilters } from '@wordpress/hooks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import EditJob from './edit.jsx'; | ||
import './style.scss'; | ||
import registerStore from '../data'; | ||
|
||
const attributesConfig = { | ||
jobId: { | ||
type: 'integer', | ||
default: 0, | ||
} | ||
}; | ||
|
||
const edit = ( { className, ...props } ) => ( | ||
<div className={ className }> | ||
<EditJob { ...props } /> | ||
</div> | ||
); | ||
|
||
const save = ( { attributes } ) => { | ||
if ( ! attributes.id ) { | ||
return; | ||
} | ||
|
||
return `[job id="${ attributes.id }"]`; | ||
}; | ||
|
||
registerStore(); | ||
|
||
registerBlockType( 'wp-job-manager/job', { | ||
title: 'Job', | ||
icon: 'list-view', | ||
category: 'common', | ||
attributes: applyFilters( 'wpjm_block_job_attributes_config', attributesConfig ), | ||
edit, | ||
save | ||
} ); |
Large diffs are not rendered by default.
Oops, something went wrong.
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