Skip to content

1226: fixed issue with visible delete button in the new entity form #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
### Fixed

- Throwable: Stub index points to a file without PSI [#1232](https://github.com/magento/magento2-phpstorm-plugin/pull/1232)
- Create an entity - delete button is displayed in a new entity form [#1268](https://github.com/magento/magento2-phpstorm-plugin/pull/1268)

## 5.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class ${NAME} extends ${GENERIC_BUTTON} implements ${DATA_PROVIDER_TYPE}
*/
public function getButtonData(): array
{
#if (${GET_ID})
if (!$this->${GET_ID}) {
return [];
}

#end
return $this->wrapButtonSettings(
'${LABEL}',
'${CLASS}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ protected void fillAttributes(final @NotNull Properties attributes) {
attributes.setProperty("SORT_ORDER", String.valueOf(buttonTypeSettings.getSortOrder()));
attributes.setProperty("ENTITY_NAME", Strings.toLowerCase(entityName));
attributes.setProperty("ENTITY_ID", entityIdField);
if (buttonData.getButtonType().equals(FormButtonBlockFile.TYPE_DELETE)) {
attributes.setProperty("GET_ID", entityIdAccessor);
}

attributes.setProperty("USES", PhpClassGeneratorUtil.formatUses(uses));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class DeleteBlock extends GenericButton implements ButtonProviderInterface
*/
public function getButtonData(): array
{
if (!$this->getBookId()) {
return [];
}

return $this->wrapButtonSettings(
'Delete',
'delete',
Expand Down