From 440d07441fe30a1f2ce19dd93d4c3f1070661e11 Mon Sep 17 00:00:00 2001 From: mikrise2 Date: Tue, 31 Oct 2023 03:38:26 +0100 Subject: [PATCH] [ML4SE-185] Design fixes. --- .../main/panel/panelStates/DefaultStates.kt | 4 +++ .../main/panel/template/AgreementTemplate.kt | 8 +++-- .../tasktracker/util/notifier/NotifyError.kt | 12 +++++++ .../src/main/resources/META-INF/plugin.xml | 4 ++- .../resources/messages/UIBundle.properties | 2 ++ .../tasktracker/config/agreement_default.yaml | 2 +- .../ui/main/panel/template/agreement.html | 27 ++++++++++++---- .../ui/main/panel/template/css/agreement.css | 32 +++++++++++++++++++ 8 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 ijPlugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/notifier/NotifyError.kt create mode 100644 ijPlugin/src/main/resources/org/jetbrains/research/tasktracker/ui/main/panel/template/css/agreement.css 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) : HtmlBaseFileT override val arguments: Array get() = arrayOf(agreementsToHtml()) + override val cssFilename: String + get() = "agreement" + private fun agreementsToHtml() = agreements.mapIndexed { index, element -> buildString { - append("""

${element.text}

""") + append("""
""") + append("""
""") } }.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 @@ messages.MyBundle - + + 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 link" \ 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 @@
- - +
+ + +

- - -
- %s +
+ + +
+
+

I agree to the terms and conditions:

+ %s +

* - Required field

+