diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt index 40c1af24..503ebcc0 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/panelStates/DefaultStates.kt @@ -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 @@ -25,6 +27,8 @@ fun Panel.agreementAcceptance() { .onSuccess { if (!it) { welcomePage() + } else { + notifyError(project, UIBundle.message("ui.please.fill")) } } .onError { diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/template/AgreementTemplate.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/template/AgreementTemplate.kt index 1da04d9f..fccd342b 100644 --- a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/template/AgreementTemplate.kt +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/ui/main/panel/template/AgreementTemplate.kt @@ -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("") diff --git a/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/notifier/NotifyError.kt b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/notifier/NotifyError.kt new file mode 100644 index 00000000..b5fe1f4e --- /dev/null +++ b/ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/notifier/NotifyError.kt @@ -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) +} diff --git a/ijPlugin/src/main/resources/META-INF/plugin.xml b/ijPlugin/src/main/resources/META-INF/plugin.xml index 5ff121c8..dc8f62d8 100644 --- a/ijPlugin/src/main/resources/META-INF/plugin.xml +++ b/ijPlugin/src/main/resources/META-INF/plugin.xml @@ -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> diff --git a/ijPlugin/src/main/resources/messages/UIBundle.properties b/ijPlugin/src/main/resources/messages/UIBundle.properties index 3f551eb1..36453fe9 100644 --- a/ijPlugin/src/main/resources/messages/UIBundle.properties +++ b/ijPlugin/src/main/resources/messages/UIBundle.properties @@ -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 diff --git a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/agreement_default.yaml b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/agreement_default.yaml index 346806c2..8ad8b3a6 100644 --- a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/agreement_default.yaml +++ b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/config/agreement_default.yaml @@ -1,4 +1,4 @@ agreements: - text: "example" required: false - - text: "example1" \ No newline at end of file + - text: "example1 <a href=\"https://github.com/JetBrains-Research/tasktracker-3\">link</a>" \ No newline at end of file diff --git a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/agreement.html b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/agreement.html index 222346c3..15c0bcca 100644 --- a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/agreement.html +++ b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/agreement.html @@ -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="example@example.com" required> - <br> - %s + <div class="form-group"> + <label for="email">Please put your email: </label> + <input type="email" name="email" id="email" placeholder="example@example.com" 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") { diff --git a/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/css/agreement.css b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/css/agreement.css new file mode 100644 index 00000000..4cc806f5 --- /dev/null +++ b/ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/css/agreement.css @@ -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; +}