Skip to content

Commit

Permalink
Release 2.32 (#2214)
Browse files Browse the repository at this point in the history
This release adds a new form notification option for updated entries,
resolves file upload issues on the Edit Entry screen, and includes
developer-focused enhancements.

#### 🚀 Added
* New notification option for forms, triggered when an entry is updated.

#### 🐛 Fixed
* File upload field issues on the Edit Entry screen:
  - Delete/download icons not displaying in Gravity Forms 2.9+;
- Unable to select files for upload when the form field's "Multiple
Files" setting was enabled without a "Maximum Number of Files" value.

#### 💻 Developer Updates
* Added `gk/gravityview/view/entries/join-conditions` filter to modify
the join conditions applied when retrieving View entries.
* Added `gk/gravityview/template/options` filter to programmatically
modify field settings in the View editor.
* Added `gravityview/row-added` JavaScript event, triggered when a new
row is added to a widget or field area.


💾 [Build
file](https://www.dropbox.com/scl/fi/e71qjufft29psjij0fhzr/gravityview-2.32-d6bfd6fca.zip?rlkey=8qe5f24zlahm6dh28s3um00y4&dl=1)
(d6bfd6f).
  • Loading branch information
mrcasual authored Nov 21, 2024
2 parents 67e1ef3 + 136e759 commit 484d91c
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 212 deletions.
11 changes: 11 additions & 0 deletions assets/js/admin-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
const $row = $( result?.row );
$row.insertBefore( $add_row );

$( document.body ).trigger(
'gravityview/row-added',
$row,
{
type,
row_type,
zone,
template_id
}
);

window?.gvAdminActions?.initTooltips();
window?.gvAdminActions?.initDroppables( $row );
} ) );
Expand Down
18 changes: 13 additions & 5 deletions assets/js/fe-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ jQuery( function ( $ ) {
$.each(gfMultiFileUploader.uploaders, function(index, uploader){
uploader.bind('Init', function(up, params) {
var data = up.settings;
var max = data.gf_vars.max_files;
var max = parseInt(data.gf_vars.max_files, 10);
if(max === 0){
return;
}
var fieldId = data.multipart_params.field_id;
var existingFilesCount = $('#preview_existing_files_'+fieldId).children().length;
var limitReached = existingFilesCount >= max;
Expand All @@ -74,7 +77,10 @@ jQuery( function ( $ ) {

uploader.bind('FilesAdded', function(up, files) {
var data = up.settings;
var max = data.gf_vars.max_files;
var max = parseInt(data.gf_vars.max_files, 10);
if(max === 0){
return;
}
var fieldId = data.multipart_params.field_id;
var formId = data.multipart_params.form_id;
var newFilesCount = $('#gform_preview_'+formId+'_'+fieldId).children().length;
Expand All @@ -94,20 +100,22 @@ jQuery( function ( $ ) {
gfMultiFileUploader.toggleDisabled(data, limitReached);


// Only show message if max is greater than 1
if(max <= 1){
// Only show message if max is greater than 1 or limit is reached
if(max <= 1 || !limitReached){
return true;
}

// Check if message already exists

// Check if message already exists
if($("#" + up.settings.gf_vars.message_id).children().length > 0){
return true;
}

$( "#" + up.settings.gf_vars.message_id ).prepend( "<li class='gfield_description gfield_validation_message'>" +
$('<div/>').text(gform_gravityforms.strings.max_reached).html()
+
"</li>" );

// Announce errors.
setTimeout(function () {
wp.a11y.speak( $( "#" + up.settings.gf_vars.message_id ).text() );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/fe-views.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 51 additions & 35 deletions future/includes/class-gv-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace GV;

use GF_Query_Column;
use GF_Query_Condition;
use GF_Query_Literal;
use GravityKit\GravityView\Foundation\Helpers\Arr;
use GF_Query;
use GravityKitFoundation;
Expand Down Expand Up @@ -1147,7 +1150,7 @@ public function get_entries( $request = null ) {
continue;
}

$order = new \GF_Query_Column( $field['id'], $this->form->ID );
$order = new GF_Query_Column( $field['id'], $this->form->ID );

if ( 'id' !== $field['id'] && (int) $field['is_numeric'] ) {
$order = \GF_Query_Call::CAST( $order, defined( 'GF_Query::TYPE_DECIMAL' ) ? \GF_Query::TYPE_DECIMAL : \GF_Query::TYPE_SIGNED );
Expand All @@ -1172,10 +1175,10 @@ public function get_entries( $request = null ) {

$column = null;

if ( $order[0] instanceof \GF_Query_Column ) {
if ( $order[0] instanceof GF_Query_Column ) {
$column = $order[0];
} elseif ( $order[0] instanceof \GF_Query_Call ) {
if ( 1 != count( $order[0]->columns ) || ! $order[0]->columns[0] instanceof \GF_Query_Column ) {
if ( 1 != count( $order[0]->columns ) || ! $order[0]->columns[0] instanceof GF_Query_Column ) {
$orders[ $oid ] = $order;
continue; // Need something that resembles a single sort
}
Expand Down Expand Up @@ -1225,33 +1228,46 @@ public function get_entries( $request = null ) {
if ( $this->settings->get( 'multiple_forms_disable_null_joins' ) ) {

// Disable NULL outputs
$condition = new \GF_Query_Condition(
new \GF_Query_Column( $join->join_on_column->ID, $join->join_on->ID ),
\GF_Query_Condition::NEQ,
new \GF_Query_Literal( '' )
$condition = new GF_Query_Condition(
new GF_Query_Column( $join->join_on_column->ID, $join->join_on->ID ),
GF_Query_Condition::NEQ,
new GF_Query_Literal( '' )
);

$query_parameters = $query->_introspect();

$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
$query->where( GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
}

// Filter to active entries only
$status_conditions = \GF_Query_Condition::_or(
new \GF_Query_Condition(
new \GF_Query_Column( 'status', $join->join_on->ID ),
\GF_Query_Condition::EQ,
new \GF_Query_Literal( 'active' )
$status_conditions = GF_Query_Condition::_or(
new GF_Query_Condition(
new GF_Query_Column( 'status', $join->join_on->ID ),
GF_Query_Condition::EQ,
new GF_Query_Literal( 'active' )
),
new \GF_Query_Condition(
new \GF_Query_Column( 'status', $join->join_on->ID ),
\GF_Query_Condition::IS,
\GF_Query_Condition::NULL
new GF_Query_Condition(
new GF_Query_Column( 'status', $join->join_on->ID ),
GF_Query_Condition::IS,
GF_Query_Condition::NULL
)
);

/**
* Modifies the join conditions applied during the retrieval of View entries.
*
* @filter `gk/gravityview/view/entries/join-conditions`
*
* @since 2.32.0
*
* @param GF_Query_Condition $status_conditions The GF_Query_Condition instance.
* @param Join $join The Join instance.
* @param View $this The View instance.
*/
$status_conditions = apply_filters( 'gk/gravityview/view/entries/join-conditions', $status_conditions, $join, $this );

$q = $query->_introspect();
$query->where( \GF_Query_Condition::_and( $q['where'], $status_conditions ) );
$query->where( GF_Query_Condition::_and( $q['where'], $status_conditions ) );

/**
* Applies legacy modifications to Query for is_approved settings.
Expand All @@ -1268,11 +1284,11 @@ public function get_entries( $request = null ) {
$unions_sql = array();

/**
* @param \GF_Query_Condition $condition
* @param GF_Query_Condition $condition
* @param array $fields
* @param $recurse
*
* @return \GF_Query_Condition
* @return GF_Query_Condition
*/
$where_union_substitute = function ( $condition, $fields, $recurse ) {
if ( $condition->expressions ) {
Expand All @@ -1288,9 +1304,9 @@ public function get_entries( $request = null ) {
);
}

if ( ! ( $condition->left && $condition->left instanceof \GF_Query_Column ) || ( ! $condition->left->is_entry_column() && ! $condition->left->is_meta_column() ) ) {
return new \GF_Query_Condition(
new \GF_Query_Column( $fields[ $condition->left->field_id ]->ID ),
if ( ! ( $condition->left && $condition->left instanceof GF_Query_Column ) || ( ! $condition->left->is_entry_column() && ! $condition->left->is_meta_column() ) ) {
return new GF_Query_Condition(
new GF_Query_Column( $fields[ $condition->left->field_id ]->ID ),
$condition->operator,
$condition->right
);
Expand All @@ -1314,9 +1330,9 @@ public function get_entries( $request = null ) {
foreach ( $query_parameters['order'] as $order ) {
[ $column, $_order ] = $order;

if ( $column && $column instanceof \GF_Query_Column ) {
if ( $column && $column instanceof GF_Query_Column ) {
if ( ! $column->is_entry_column() && ! $column->is_meta_column() ) {
$column = new \GF_Query_Column( $fields[ $column->field_id ]->ID );
$column = new GF_Query_Column( $fields[ $column->field_id ]->ID );
}

$q->order( $column, $_order );
Expand Down Expand Up @@ -1856,24 +1872,24 @@ protected function apply_legacy_join_is_approved_query_conditions( \GF_Query $qu
}

// Show only approved joined entries
$condition = new \GF_Query_Condition(
new \GF_Query_Column( \GravityView_Entry_Approval::meta_key, $join->join_on->ID ),
\GF_Query_Condition::EQ,
new \GF_Query_Literal( \GravityView_Entry_Approval_Status::APPROVED )
$condition = new GF_Query_Condition(
new GF_Query_Column( \GravityView_Entry_Approval::meta_key, $join->join_on->ID ),
GF_Query_Condition::EQ,
new GF_Query_Literal( \GravityView_Entry_Approval_Status::APPROVED )
);

$condition = \GF_Query_Condition::_or(
$condition = GF_Query_Condition::_or(
$condition,
new \GF_Query_Condition(
new \GF_Query_Column( \GravityView_Entry_Approval::meta_key, $join->join_on->ID ),
\GF_Query_Condition::IS,
\GF_Query_Condition::NULL
new GF_Query_Condition(
new GF_Query_Column( \GravityView_Entry_Approval::meta_key, $join->join_on->ID ),
GF_Query_Condition::IS,
GF_Query_Condition::NULL
)
);

$query_parameters = $query->_introspect();

$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
$query->where( GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions gravityview.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: GravityView
* Plugin URI: https://www.gravitykit.com
* Description: The best, easiest way to display Gravity Forms entries on your website.
* Version: 2.31.1
* Version: 2.32
* Requires PHP: 7.4.0
* Author: GravityKit
* Author URI: https://www.gravitykit.com
Expand Down Expand Up @@ -32,7 +32,7 @@
/**
* The plugin version.
*/
define( 'GV_PLUGIN_VERSION', '2.31.1' );
define( 'GV_PLUGIN_VERSION', '2.32' );

/**
* Full path to the GravityView file
Expand Down
Loading

0 comments on commit 484d91c

Please sign in to comment.