Skip to content

Commit

Permalink
[ML4SE-185] Design fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 committed Oct 31, 2023
1 parent e6068b9 commit 440d074
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import org.jetbrains.research.tasktracker.tracking.activity.ActivityTracker
import org.jetbrains.research.tasktracker.ui.main.panel.MainPluginPanelFactory
import org.jetbrains.research.tasktracker.ui.main.panel.storage.MainPanelStorage
import org.jetbrains.research.tasktracker.ui.main.panel.template.*
import org.jetbrains.research.tasktracker.util.UIBundle
import org.jetbrains.research.tasktracker.util.notifier.notifyError
import org.jetbrains.research.tasktracker.util.survey.SurveyParser

typealias Panel = MainPluginPanelFactory
Expand All @@ -25,6 +27,8 @@ fun Panel.agreementAcceptance() {
.onSuccess {
if (!it) {
welcomePage()
} else {
notifyError(project, UIBundle.message("ui.please.fill"))
}
}
.onError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ class AgreementTemplate(private val agreements: List<Agreement>) : HtmlBaseFileT
override val arguments: Array<String>
get() = arrayOf(agreementsToHtml())

override val cssFilename: String
get() = "agreement"

private fun agreementsToHtml() = agreements.mapIndexed { index, element ->
buildString {
append("""<p><input id="$index" type="checkbox" name="$index" """)
append("""${if (element.required) "required" else ""}> ${element.text}</p>""")
append("""<div><input id="$index" type="checkbox" name="$index" """)
append("""${if (element.required) "required" else ""}>""")
append("""<label for="$index">${element.text}</label></div>""")
}
}.joinToString("")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.jetbrains.research.tasktracker.util.notifier

import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.project.Project
import org.jetbrains.annotations.Nls

fun notifyError(project: Project, content: @Nls String?) {
println("hello")
NotificationGroupManager.getInstance().getNotificationGroup("Tasktracker")
.createNotification(content ?: "Unknown error", NotificationType.ERROR).notify(project)
}
4 changes: 3 additions & 1 deletion ijPlugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
<resource-bundle>messages.MyBundle</resource-bundle>

<extensions defaultExtensionNs="com.intellij">
<toolWindow factoryClass="org.jetbrains.research.tasktracker.ui.main.panel.MainPluginPanelFactory" id="TaskTracker" anchor="right"/>
<toolWindow factoryClass="org.jetbrains.research.tasktracker.ui.main.panel.MainPluginPanelFactory"
id="TaskTracker" anchor="right"/>
<postStartupActivity implementation="org.jetbrains.research.tasktracker.activities.InitActivity"/>
<notificationGroup id="Tasktracker" displayType="BALLOON"/>
</extensions>

<actions>
Expand Down
2 changes: 2 additions & 0 deletions ijPlugin/src/main/resources/messages/UIBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ ui.button.submit=submit
ui.button.welcome=welcome screen

ui.progress.webcam.title=Making Photos Via All Available Devices

ui.please.fill=Please fill all required fields
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
agreements:
- text: "example"
required: false
- text: "example1"
- text: "example1 <a href=\"https://github.com/JetBrains-Research/tasktracker-3\">link</a>"
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
<div class="container">
<label for="name">Please write your name: </label>
<input type="text" name="name" id="name" placeholder="Name" required>
<div class="form-group">
<label for="name">Please put your name: </label>
<input type="text" name="name" id="name" placeholder="Name" required>
</div>
<br>
<label for="email">Please write your email: </label>
<input type="email" name="email" id="email" placeholder="[email protected]" required>
<br>
%s
<div class="form-group">
<label for="email">Please put your email: </label>
<input type="email" name="email" id="email" placeholder="[email protected]" required>
</div>
<div class="agreement-container">
<p>I agree to the terms and conditions:</p>
%s
<p><span style="color: red">*</span> - Required field</p>
</div>
</div>
<script>
let requiredFields = document.querySelectorAll('input[required]')

// Loop through each required input element and add the 'required' class to its parent label
requiredFields.forEach(function(inputElement) {
const parentLabel = inputElement.parentElement.querySelector('label');
if (parentLabel) {
parentLabel.classList.add('required');
}
});

requiredFields.forEach(function (field) {
field.onclick = function () {
if (field.type === "checkbox") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.form-group {
display: flex;
flex-direction: column;
margin-bottom: 3vmin;
}

.form-group label{
margin-bottom: 2vmin;
}

label {
font-size: 2vmin;
}

.agreement-container {
margin-top: 25vmin;
align-items: flex-start;
text-align: left;
justify-content: left;
width: 70vw;
}

.agreement-container div{
display:flex;
align-items:center;
}

.required:after{
content:" *";
font-weight:bold;
color:red;
}

0 comments on commit 440d074

Please sign in to comment.