-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/3.0.0' into develop
- Loading branch information
Showing
19 changed files
with
651 additions
and
33 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
6 changes: 5 additions & 1 deletion
6
src/DonationForms/Actions/DispatchDonateControllerDonationCreatedListeners.php
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,24 +1,28 @@ | ||
<?php | ||
|
||
namespace Give\DonationForms\Actions; | ||
|
||
use Give\DonationForms\DataTransferObjects\DonateControllerData; | ||
use Give\DonationForms\Listeners\AddRedirectUrlsToGatewayData; | ||
use Give\DonationForms\Listeners\StoreCustomFields; | ||
use Give\DonationForms\Listeners\TemporarilyReplaceLegacySuccessPageUri; | ||
use Give\DonationForms\Listeners\UpdateDonationLevelId; | ||
use Give\Donations\Models\Donation; | ||
use Give\Framework\Exceptions\Primitives\Exception; | ||
use Give\Framework\FieldsAPI\Exceptions\NameCollisionException; | ||
use Give\Subscriptions\Models\Subscription; | ||
|
||
class DispatchDonateControllerDonationCreatedListeners | ||
{ | ||
/** | ||
* @since 3.0.0 | ||
* @throws NameCollisionException | ||
* @throws NameCollisionException|Exception | ||
*/ | ||
public function __invoke(DonateControllerData $formData, Donation $donation, ?Subscription $subscription) | ||
{ | ||
(new StoreCustomFields())($formData->getDonationForm(), $donation, $subscription, $formData->getCustomFields()); | ||
(new TemporarilyReplaceLegacySuccessPageUri())($formData, $donation); | ||
(new AddRedirectUrlsToGatewayData())($formData, $donation); | ||
(new UpdateDonationLevelId())($formData->getDonationForm(), $donation); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace Give\DonationForms\Listeners; | ||
|
||
use Give\DonationForms\Models\DonationForm; | ||
use Give\Donations\Models\Donation; | ||
use Give\Framework\Exceptions\Primitives\Exception; | ||
use Give\Framework\FieldsAPI\Amount; | ||
use Give\Framework\FieldsAPI\Exceptions\NameCollisionException; | ||
|
||
class UpdateDonationLevelId | ||
{ | ||
/** | ||
* if the intended donation amount matches a donation level from the amount block settings, | ||
* this will update the donation level ID meta with the level array key, | ||
* which is used in the donation details screen. | ||
* | ||
* @since 3.0.0-rc.7 | ||
* | ||
* @throws NameCollisionException|Exception | ||
*/ | ||
public function __invoke(DonationForm $donationForm, Donation $donation) | ||
{ | ||
/** @var Amount $amountField */ | ||
$amountField = $donationForm->schema()->getNodeByName('amount'); | ||
|
||
if (!$amountField) { | ||
return; | ||
} | ||
|
||
$donationLevel = array_search( | ||
(float)$donation->intendedAmount()->formatToDecimal(), | ||
$amountField->getLevels(), | ||
true | ||
); | ||
|
||
if ($donationLevel !== false) { | ||
$donation->levelId = (string)$donationLevel; | ||
$donation->save(); | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/FormBuilder/resources/js/form-builder/src/blocks/section/EmptyBlockInserter.tsx
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,36 @@ | ||
import {Button, Tooltip} from '@wordpress/components'; | ||
import {Inserter} from '@wordpress/block-editor'; | ||
import {__, _x} from '@wordpress/i18n'; | ||
|
||
/** | ||
* The inserter used in sections for dragging and dropping blocks or clicking to add a block. | ||
*/ | ||
export default function EmptyBlockInserter({rootClientId}) { | ||
return ( | ||
<Inserter | ||
position="bottom center" | ||
rootClientId={rootClientId} | ||
__experimentalIsQuick | ||
className="give-section__empty-block-inserter" | ||
renderToggle={({onToggle, disabled, isOpen}) => { | ||
const label = _x('Add block', 'Generic label for block inserter button', 'give'); | ||
|
||
return ( | ||
<Tooltip text={label}> | ||
<Button | ||
className="block-editor-button-block-appender" | ||
onClick={onToggle} | ||
aria-haspopup="true" // attribute wants a true value, not a boolean | ||
aria-expanded={isOpen} | ||
disabled={disabled} | ||
label={label} | ||
> | ||
{__('Drag a block here or click to add a block', 'give')} | ||
</Button> | ||
</Tooltip> | ||
); | ||
}} | ||
isAppender | ||
/> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/FormBuilder/resources/js/form-builder/src/blocks/section/styles.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.give-section { | ||
&__empty-block-inserter { | ||
width: 100%; | ||
|
||
.block-editor-inserter { | ||
width: 100%; | ||
} | ||
|
||
.block-editor-button-block-appender { | ||
width: 100%; | ||
box-shadow: none; | ||
border: dashed var(--givewp-gray-60) 2px; | ||
padding: 3rem 0 !important; | ||
font-size: var(--givewp-font-weight-paragraph-lg); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.