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

Lectures: Disable submit button on invalid form and add tooltip #10430

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

laxerhd
Copy link
Contributor

@laxerhd laxerhd commented Feb 28, 2025

Opening this PR from a branch in the main repository to enable test server deployment, as it wasn't possible with the previous PR from a forked repository (see #9846), and reopened it again after the old PR was open for too long #10129.

Checklist

General

Server

Client

  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Fixes #9829. The submit button did not indicate that a mandatory field was still missing and could be clicked.
This led to confusion among users.
The error message for files that were too large also had an redundant sentence.

Description

I have updated/changed the conditions in isValidForm to recognize empty string names and uploaded files.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Course
  • 1 Lecture
  1. Log in to Artemis
  2. Navigate the Course
  3. Create a new Lecture
  4. Click on Units -> File
  5. Take a look at tooltip and unclickable submit button

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Screenshots

image

tooltip-submit-button.mp4

Summary by CodeRabbit

  • New Features

    • The submit button now displays a tooltip to provide additional guidance.
    • Enhanced validation messaging now clearly indicates that both a name and file selection are required.
  • Style

    • Adjusted label formatting for a cleaner appearance.
    • Removed redundant file limitation messaging to streamline user feedback.

@laxerhd laxerhd requested a review from a team as a code owner February 28, 2025 16:49
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Feb 28, 2025
Copy link

coderabbitai bot commented Feb 28, 2025

Walkthrough

This pull request adjusts the attachment unit form component. In the HTML template, it removes an extra space before the asterisk in the name label, deletes an existing file size error message, and wraps the submit button with a tooltip-enabled span. The TypeScript file is updated to inject a translation service, use signals for reactive validations, and include a new computed property for tooltip text. Additionally, new validation error messages have been added to both the German and English translation files for attachment unit creation.

Changes

File(s) Change Summary
src/main/webapp/app/lecture/.../attachment-unit-form.component.html Removed extra space before the asterisk in the name label, deleted the file size error message, and wrapped the submit button in a <span> with a tooltip directive.
src/main/webapp/app/lecture/.../attachment-unit-form.component.ts Injected TranslateService, updated form validation logic to use signals, and introduced the computed tooltipText property for validation feedback.
src/main/webapp/i18n/.../lectureUnit.json Added new validation error message "nameAndFileRequiredValidationError" for attachment unit creation in both German and English translation files.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as AttachmentUnitFormComponent
    participant T as TranslateService

    U->>C: Enter name and select file
    C->>C: Update signals and validate form
    U->>C: Hover on submit button
    C->>C: Compute tooltipText based on input validations
    C->>T: Retrieve translated error message (if applicable)
    T-->>C: Return translation
    C-->>U: Display tooltip with error message

Possibly related PRs

Suggested labels

tests, bugfix, ready for review, small

Suggested reviewers

  • BBesrour
  • Feras797
  • SimonEntholzer
  • Hialus
  • krusche
  • ItsaaaMeMario

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d527e7 and b716c1b.

📒 Files selected for processing (1)
  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...

src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

  • src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts
🧠 Learnings (1)
src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts (1)
Learnt from: florian-glombik
PR: ls1intum/Artemis#9656
File: src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts:69-71
Timestamp: 2024-11-12T12:52:03.805Z
Learning: In the `src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts`, the `isFormValid` computed property intentionally uses a logical OR between `this.statusChanges() === 'VALID'` and `this.fileName()` to mirror the original `isSubmitPossible` getter, ensuring consistent form validation behavior.
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: client-style
  • GitHub Check: server-tests
  • GitHub Check: server-style
  • GitHub Check: client-tests-selected
  • GitHub Check: client-tests
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Analyse
🔇 Additional comments (7)
src/main/webapp/app/lecture/lecture-unit/lecture-unit-management/attachment-unit-form/attachment-unit-form.component.ts (7)

9-11: Good addition of necessary imports.

The imports for of from 'rxjs' and TranslateService from '@ngx-translate/core' are well-placed and necessary for the implementation of the form validation enhancements.


70-70: Good use of the inject pattern.

Using the inject API for dependency injection of TranslateService follows modern Angular patterns and best practices.


81-81: Good use of toSignal for reactive access.

Converting the nameControl's valueChanges to a signal provides a consistent reactive pattern for accessing the form control value. The inclusion of a fallback empty string with of('') is a good defensive programming practice.


83-83: Improved form validation logic.

The updated condition correctly ensures that all required conditions are met before considering the form valid: form status is 'VALID', file size is not too big, a filename exists, and the date picker is valid.


92-96: Good localization implementation for error messages.

Using the translation service with toSignal creates reactive properties for validation error messages, ensuring they're updated when the language changes. This is consistent with Angular best practices for internationalization.


107-107: Refactored to use the name signal.

Good update to use the reactive name() signal rather than a direct property access, keeping the code consistent with the reactive pattern established elsewhere.


116-127: Well-implemented tooltip text computation.

The tooltipText computed property effectively provides contextual validation messages based on the form state. The hierarchical checks properly prioritize the messages:

  1. When both name and file are missing
  2. When only file is missing
  3. When only name is missing
  4. Returns undefined when all required fields are present

This implementation aligns with the PR objectives of improving form validation feedback.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 28, 2025
@laxerhd laxerhd changed the title Bugfix/lectures/disable submit button on invalid form add tooltip Lectures: Disable submit button on invalid form and add tooltip Feb 28, 2025
Copy link
Contributor

@magaupp magaupp left a comment

Choose a reason for hiding this comment

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

Code looks good 👍

Copy link

github-actions bot commented Mar 9, 2025

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) stale
Projects
Status: Work In Progress
Development

Successfully merging this pull request may close these issues.

Lectures: Disable submit button in file upload dialog if no file is uploaded yet
2 participants