Skip to content
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

add placeholder widget option #3897

Merged
merged 2 commits into from Oct 10, 2022

Conversation

ETLaurent
Copy link
Contributor

@ETLaurent ETLaurent commented Sep 30, 2022

Summary

Add placeholder option to widget modules.
If truthy, it will automatically disable the initial modal (by setting initialModal to false) and render widgets that do not have data yet with their placeholder(s).

Placeholder for image, video and rich text widgets are enabled by default in core.

What are the specific steps to test this change?

In testbed, add placeholder: true to a widget of your choice.

  • the initial modal should not appear
  • the widget should have been inserted with the placeholder defined in the widget field(s).
  • image, video and RT widgets should be inserted directly with their placeholder by default.
  • placeholders should be overridable (placeholderUrl for image and video widgets, placeholderText for rich text widget, and placeholderClass for any other widget)
  • placeholders can be disabled by setting it to a falsy value in a project's widget modules
  • initialModal can be set to false, even with placeholder: false --> the widget is inserted without having the initial modal displayed, and without placeholder(s)

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@ETLaurent ETLaurent changed the title Pro 3199 placeholder option add placeholder widget option Sep 30, 2022
Comment on lines +101 to +103
initialModal: true,
placeholder: false,
placeholderClass: 'apos-placeholder'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add these by default, so a developer is aware they exist just by checking the widget-type module options

@@ -2,7 +2,7 @@ module.exports = {
extend: '@apostrophecms/widget-type',
options: {
label: 'Placeholder Test Widget',
initialModal: false
placeholder: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no impact on the tests because this options is used by Vue on front-end.
but does no harm to add it for clarity

return {};
}

const className = placeholderClass || 'apos-placeholder';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now 'apos-placeholder' is added to the widget-type module by default

@ETLaurent ETLaurent requested review from boutell and removed request for boutell October 4, 2022 14:43
@ETLaurent ETLaurent merged commit 0e58146 into feature-widget-placeholders Oct 10, 2022
@ETLaurent ETLaurent deleted the pro-3199-placeholder-option branch October 10, 2022 08:36
ETLaurent added a commit that referenced this pull request Oct 11, 2022
ETLaurent added a commit that referenced this pull request Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant