Skip to content

Commit

Permalink
Fix CP edit url not linking to the admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Aug 2, 2019
1 parent 3c4593d commit a4058ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2 - 2019-08-02
### Fixed
- Fix CP edit url not linking to the admin

## 1.0.1 - 2019-04-24
### Fixed
- Fixed project config not syncing field layout
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ether/cart-notices",
"description": "Automatically show notices based off cart details",
"version": "1.0.1",
"version": "1.0.2",
"type": "craft-plugin",
"license": "proprietary",
"minimum-stability": "dev",
Expand Down
21 changes: 11 additions & 10 deletions src/elements/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace ether\cartnotices\elements;

use Craft;
use craft\base\Element;
use craft\commerce\elements\Product;
use craft\elements\actions\Restore;
Expand Down Expand Up @@ -136,9 +137,9 @@ public static function find (): ElementQueryInterface

public function getEditorHtml (): string
{
$html = \Craft::$app->getView()->renderTemplateMacro('_includes/forms', 'textField', [
$html = Craft::$app->getView()->renderTemplateMacro('_includes/forms', 'textField', [
[
'label' => \Craft::t('app', 'Title'),
'label' => Craft::t('app', 'Title'),
'siteId' => $this->siteId,
'id' => 'title',
'name' => 'title',
Expand All @@ -159,13 +160,13 @@ public function getEditorHtml (): string

public function getFieldLayout ()
{
return \Craft::$app->getFields()->getLayoutByType(Notice::class);
return Craft::$app->getFields()->getLayoutByType(Notice::class);
}

public function getCpEditUrl ()
{
$url = '/cart-notices/' . $this->id . '/';
$url .= \Craft::$app->getSites()->getSiteById($this->siteId)->handle;
$url = 'cart-notices/' . $this->id . '/';
$url .= Craft::$app->getSites()->getSiteById($this->siteId)->handle;

return UrlHelper::cpUrl($url);
}
Expand All @@ -180,7 +181,7 @@ protected static function defineActions (string $source = null): array
protected static function defineTableAttributes (): array
{
return [
'title' => \Craft::t('app', 'Title'),
'title' => Craft::t('app', 'Title'),
'type' => CartNotices::t('Type'),
'target' => CartNotices::t('Target'),
'threshold' => CartNotices::t('Threshold'),
Expand All @@ -191,8 +192,8 @@ protected static function defineTableAttributes (): array
'maxQty' => CartNotices::t('Max Qty'),
'products' => CartNotices::t('Products'),
'categories' => CartNotices::t('Categories'),
'dateCreated' => \Craft::t('app', 'Date Created'),
'dateUpdated' => \Craft::t('app', 'Date Updated'),
'dateCreated' => Craft::t('app', 'Date Created'),
'dateUpdated' => Craft::t('app', 'Date Updated'),
];
}

Expand Down Expand Up @@ -326,7 +327,7 @@ public function setEagerLoadedElements (string $handle, array $elements)
*/
public function afterSave (bool $isNew)
{
$db = \Craft::$app->getDb();
$db = Craft::$app->getDb();

$transaction = $db->beginTransaction();

Expand Down Expand Up @@ -402,7 +403,7 @@ public function afterSave (bool $isNew)
*/
private function _saveRelations ($target, $ids)
{
$db = \Craft::$app->getDb();
$db = Craft::$app->getDb();
$table = '{{%cart-notices_notice_' . $target . '}}';

$db->createCommand()
Expand Down

0 comments on commit a4058ae

Please sign in to comment.