-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15619 from craftcms/feature/field-settings-chip
Add a global field chip to the top of FLD field setting slideouts
- Loading branch information
Showing
5 changed files
with
104 additions
and
4 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 |
---|---|---|
|
@@ -43,7 +43,7 @@ | |
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 3.0.0 | ||
*/ | ||
abstract class Field extends SavableComponent implements FieldInterface | ||
abstract class Field extends SavableComponent implements FieldInterface, Iconic, Actionable | ||
{ | ||
use FieldTrait; | ||
|
||
|
@@ -510,6 +510,14 @@ public function getHandle(): ?string | |
return $this->handle; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getIcon(): ?string | ||
{ | ||
return static::icon(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -518,6 +526,41 @@ public function getCpEditUrl(): ?string | |
return $this->id ? UrlHelper::cpUrl("settings/fields/edit/$this->id") : null; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getActionMenuItems(): array | ||
{ | ||
$items = []; | ||
|
||
if ( | ||
$this->id && | ||
Craft::$app->getUser()->getIsAdmin() && | ||
Craft::$app->getConfig()->getGeneral()->allowAdminChanges | ||
) { | ||
$editId = sprintf('action-edit-%s', mt_rand()); | ||
$items[] = [ | ||
'id' => $editId, | ||
'icon' => 'edit', | ||
'label' => Craft::t('app', 'Edit'), | ||
]; | ||
|
||
$view = Craft::$app->getView(); | ||
$view->registerJsWithVars(fn($id, $params) => <<<JS | ||
$('#' + $id).on('click', () => { | ||
new Craft.CpScreenSlideout('fields/edit-field', { | ||
params: $params, | ||
}); | ||
}); | ||
JS, [ | ||
$view->namespaceInputId($editId), | ||
['fieldId' => $this->id], | ||
]); | ||
} | ||
|
||
return $items; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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