-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'epic/campaigns' into refactor/campaigns-migration-1178
- Loading branch information
Showing
39 changed files
with
1,678 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,41 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\Actions; | ||
|
||
use Give\Campaigns\Models\Campaign; | ||
use Give\Campaigns\ViewModels\CampaignDetailsPage; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class LoadCampaignDetailsAssets | ||
{ | ||
/** | ||
* @unreleased | ||
*/ | ||
public function __invoke(Campaign $campaign) | ||
{ | ||
$handleName = 'givewp-admin-campaign-details'; | ||
|
||
wp_register_script( | ||
$handleName, | ||
GIVE_PLUGIN_URL . 'assets/dist/js/give-admin-campaign-details.js', | ||
[], | ||
GIVE_VERSION, | ||
true | ||
); | ||
|
||
wp_localize_script($handleName, 'GiveCampaignDetails', | ||
[ | ||
'apiRoot' => esc_url_raw(rest_url('give-api/v2/campaigns')), | ||
'apiNonce' => wp_create_nonce('wp_rest'), | ||
'adminUrl' => admin_url(), | ||
'pluginUrl' => GIVE_PLUGIN_URL, | ||
'campaignDetailsPage' => (new CampaignDetailsPage($campaign))->exports(), | ||
] | ||
); | ||
|
||
wp_enqueue_script($handleName); | ||
wp_enqueue_style('givewp-design-system-foundation'); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\Actions; | ||
|
||
use Give\Campaigns\ListTable\CampaignsListTable; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class LoadCampaignsListTableAssets | ||
{ | ||
/** | ||
* @unreleased | ||
*/ | ||
public function __invoke() | ||
{ | ||
$handleName = 'givewp-admin-campaigns-list-table'; | ||
|
||
wp_register_script( | ||
$handleName, | ||
GIVE_PLUGIN_URL . 'assets/dist/js/give-admin-campaigns-list-table.js', | ||
[], | ||
GIVE_VERSION, | ||
true | ||
); | ||
|
||
wp_localize_script($handleName, 'GiveCampaignsListTable', | ||
[ | ||
'apiRoot' => esc_url_raw(rest_url('give-api/v2/campaigns/list-table')), | ||
'apiNonce' => wp_create_nonce('wp_rest'), | ||
'table' => give(CampaignsListTable::class)->toArray(), | ||
'adminUrl' => admin_url(), | ||
'paymentMode' => give_is_test_mode(), | ||
'pluginUrl' => GIVE_PLUGIN_URL, | ||
] | ||
); | ||
|
||
wp_enqueue_script($handleName); | ||
wp_enqueue_style('givewp-design-system-foundation'); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\ListTable; | ||
|
||
use Give\Campaigns\ListTable\Columns\DescriptionColumn; | ||
use Give\Campaigns\ListTable\Columns\EndDateColumn; | ||
use Give\Campaigns\ListTable\Columns\IdColumn; | ||
use Give\Campaigns\ListTable\Columns\StartDateColumn; | ||
use Give\Campaigns\ListTable\Columns\StatusColumn; | ||
use Give\Campaigns\ListTable\Columns\TitleColumn; | ||
use Give\Framework\ListTable\ListTable; | ||
use Give\Framework\ListTable\ModelColumn; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class CampaignsListTable extends ListTable | ||
{ | ||
/** | ||
* @unreleased | ||
*/ | ||
public function id(): string | ||
{ | ||
return 'campaigns'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @return array|ModelColumn[] | ||
*/ | ||
protected function getDefaultColumns(): array | ||
{ | ||
// TODO We need to decide which columns should be displayed | ||
return [ | ||
new IdColumn(), | ||
new TitleColumn(), | ||
new DescriptionColumn(), | ||
//new DonationsCountColumn(), | ||
new StartDateColumn(), | ||
new EndDateColumn(), | ||
new StatusColumn(), | ||
]; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @return array|string[] | ||
*/ | ||
protected function getDefaultVisibleColumns(): array | ||
{ | ||
return [ | ||
IdColumn::getId(), | ||
TitleColumn::getId(), | ||
DescriptionColumn::getId(), | ||
//DonationsCountColumn::getId(), | ||
StartDateColumn::getId(), | ||
EndDateColumn::getId(), | ||
StatusColumn::getId(), | ||
]; | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\ListTable\Columns; | ||
|
||
use Give\Campaigns\Models\Campaign; | ||
use Give\Framework\ListTable\ModelColumn; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class DescriptionColumn extends ModelColumn | ||
{ | ||
/** | ||
* @unreleased | ||
*/ | ||
public static function getId(): string | ||
{ | ||
return 'shortDescription'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return __('Short Description', 'give'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @param Campaign $model | ||
*/ | ||
public function getCellValue($model): string | ||
{ | ||
return wpautop($model->shortDescription); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\ListTable\Columns; | ||
|
||
use Give\Campaigns\Models\Campaign; | ||
use Give\Framework\ListTable\ModelColumn; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class DonationsCountColumn extends ModelColumn | ||
{ | ||
/** | ||
* @unreleased | ||
*/ | ||
public static function getId(): string | ||
{ | ||
return 'donationsCount'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return __('Donations Count', 'give'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @param Campaign $model | ||
*/ | ||
public function getCellValue($model): string | ||
{ | ||
return (string)$model->query()->count(); //Temp count | ||
} | ||
} |
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\Campaigns\ListTable\Columns; | ||
|
||
use Give\Campaigns\Models\Campaign; | ||
use Give\Framework\ListTable\ModelColumn; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class EndDateColumn extends ModelColumn | ||
{ | ||
protected $sortColumn = 'endDate'; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public static function getId(): string | ||
{ | ||
return 'endDate'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return __('End Date', 'give'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @param Campaign $model | ||
*/ | ||
public function getCellValue($model, $locale = ''): string | ||
{ | ||
$format = _x('m/d/Y \a\t g:ia', 'date format', 'give'); | ||
|
||
return $model->endDate->format($format); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Give\Campaigns\ListTable\Columns; | ||
|
||
use Give\Campaigns\Models\Campaign; | ||
use Give\Framework\ListTable\ModelColumn; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class IdColumn extends ModelColumn | ||
{ | ||
protected $sortColumn = 'id'; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public static function getId(): string | ||
{ | ||
return 'id'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return __('ID', 'give'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @param Campaign $model | ||
*/ | ||
public function getCellValue($model): int | ||
{ | ||
return $model->id; | ||
} | ||
} |
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\Campaigns\ListTable\Columns; | ||
|
||
use Give\Campaigns\Models\Campaign; | ||
use Give\Framework\ListTable\ModelColumn; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
class StartDateColumn extends ModelColumn | ||
{ | ||
protected $sortColumn = 'startDate'; | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public static function getId(): string | ||
{ | ||
return 'startDate'; | ||
} | ||
|
||
/** | ||
* @unreleased | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return __('Start Date', 'give'); | ||
} | ||
|
||
/** | ||
* @unreleased | ||
* | ||
* @param Campaign $model | ||
*/ | ||
public function getCellValue($model, $locale = ''): string | ||
{ | ||
$format = _x('m/d/Y \a\t g:ia', 'date format', 'give'); | ||
|
||
return $model->startDate->format($format); | ||
} | ||
} |
Oops, something went wrong.