Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Fix setAttributes bug in search form
Browse files Browse the repository at this point in the history
  • Loading branch information
mikethicke committed Mar 22, 2021
1 parent bbb274e commit e70f4b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fedora-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @wordpress-plugin
* Plugin Name: Fedora Embed
* Description: Embeds items stored in Fedora repositories in WordPress.
* Version: 0.0.1
* Version: 0.1.1
* Author: Mike Thicke
* Author URI: http://www.mikethicke.com
* Text Domain: fedora-embed
Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
VERSION_NUMBER=$(sed -n "s/\* Version: \(.*\)$/\1/p" ./fedora-embed | tr -d '[:space:]')
VERSION_NUMBER=$(sed -n "s/\* Version: \(.*\)$/\1/p" ./fedora-embed.php | tr -d '[:space:]')
BASE_RELEASE_DIR="./release"
SUB_RELEASE_DIR="fedora-embed-${VERSION_NUMBER}"
RELEASE_DIR="${BASE_RELEASE_DIR}/${SUB_RELEASE_DIR}"
Expand Down
22 changes: 14 additions & 8 deletions src/blocks/src/embed-block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ const FedoraEmbedEdit = props => {
const [ editSearch, setEditSearch ] = useState( false );

useEffect( () => {
if ( searchValues.length === 0 ) {
if ( baseURL && searchValues.length === 0 ) {
setAttributes( {
searchValues: JSON.stringify( [
{ field: fields[0], searchText: '', comparator: comparatorOptions[0].value },
{ field: fields[0], searchText: '', comparator: comparatorOptions[0].value },
{ field: fields[0], searchText: '', comparator: comparatorOptions[0].value }
{ field: '', searchText: '', comparator: '' },
{ field: '', searchText: '', comparator: '' },
{ field: '', searchText: '', comparator: '' }
] )
} );
}
}, [] );
}, [ baseURL ] );

const urlInput = useRef( null );

Expand Down Expand Up @@ -136,9 +136,15 @@ const FedoraEmbedEdit = props => {

const searchFields = [];
for ( let row = 0; row < 3; row++ ) {
const selectedField = searchValues[ row ] ? searchValues[ row ].field : fields[0];
const searchText = searchValues[ row ] ? searchValues[ row ].searchText : '';
const comparator = searchValues[ row ] ? searchValues[ row ].comparator : comparatorOptions[0].value;
const selectedField = searchValues[ row ] && searchValues[ row ].field ?
searchValues[ row ].field :
fields[0];
const searchText = searchValues[ row ] ?
searchValues[ row ].searchText :
'';
const comparator = searchValues[ row ] && searchValues[ row ].comparator ?
searchValues[ row ].comparator :
comparatorOptions[0].value;
searchFields[ row ] = (
<div className = 'fem-edit-search'
key = { row }
Expand Down

0 comments on commit e70f4b5

Please sign in to comment.