-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mail): implement the send mail view
- Loading branch information
Showing
15 changed files
with
424 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package apply.application.mail | ||
|
||
import javax.validation.constraints.NotEmpty | ||
|
||
data class MailData( | ||
@field:NotEmpty | ||
var subject: String = "", | ||
|
||
@field:NotEmpty | ||
var body: String = "", | ||
|
||
@field:NotEmpty | ||
var recipients: List<String> = emptyList() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/main/kotlin/apply/ui/admin/mail/GroupMailTargetDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package apply.ui.admin.mail | ||
|
||
import apply.application.EvaluationService | ||
import apply.application.MailTargetResponse | ||
import apply.application.MailTargetService | ||
import apply.application.RecruitmentResponse | ||
import apply.application.RecruitmentService | ||
import apply.domain.evaluation.Evaluation | ||
import apply.domain.evaluationtarget.EvaluationStatus | ||
import com.vaadin.flow.component.Component | ||
import com.vaadin.flow.component.button.Button | ||
import com.vaadin.flow.component.dialog.Dialog | ||
import com.vaadin.flow.component.grid.Grid | ||
import com.vaadin.flow.component.html.H2 | ||
import com.vaadin.flow.component.orderedlayout.FlexComponent | ||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout | ||
import com.vaadin.flow.component.select.Select | ||
import com.vaadin.flow.data.provider.ListDataProvider | ||
import support.views.addSortableColumn | ||
import support.views.createContrastButton | ||
import support.views.createItemSelect | ||
import support.views.createPrimaryButton | ||
import support.views.toText | ||
|
||
class GroupMailTargetDialog( | ||
private val recruitmentService: RecruitmentService, | ||
private val evaluationService: EvaluationService, | ||
private val mailTargetService: MailTargetService, | ||
private val accept: (Collection<MailTargetResponse>) -> Unit | ||
) : Dialog() { | ||
private val mailTargetsGrid: Grid<MailTargetResponse> = createMailTargetsGrid() | ||
|
||
init { | ||
add(H2("그룹 불러오기"), createSearchFilter(), mailTargetsGrid, createButtons()) | ||
width = "900px" | ||
height = "70%" | ||
open() | ||
} | ||
|
||
private fun createMailTargetsGrid(): Grid<MailTargetResponse> { | ||
return Grid<MailTargetResponse>(10).apply { | ||
addSortableColumn("이름", MailTargetResponse::name) | ||
addSortableColumn("이메일", MailTargetResponse::email) | ||
} | ||
} | ||
|
||
private fun createSearchFilter(): HorizontalLayout { | ||
val evaluationItem = createItemSelect<Evaluation>("평가") | ||
return HorizontalLayout( | ||
createRecruitmentItem(evaluationItem), evaluationItem, createEvaluationStatusItem(evaluationItem), | ||
).apply { | ||
element.style.set("margin-bottom", "10px") | ||
} | ||
} | ||
|
||
private fun createRecruitmentItem(evaluationItem: Select<Evaluation>): Select<RecruitmentResponse> { | ||
return createItemSelect<RecruitmentResponse>("모집").apply { | ||
setItems(*recruitmentService.findAll().toTypedArray()) | ||
setItemLabelGenerator { it.title } | ||
addValueChangeListener { | ||
evaluationItem.apply { | ||
setItems(*evaluationService.findAllByRecruitmentId(it.value.id).toTypedArray()) | ||
setItemLabelGenerator { it.title } | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun createEvaluationStatusItem( | ||
evaluationItem: Select<Evaluation> | ||
): Select<EvaluationStatus> { | ||
return createItemSelect<EvaluationStatus>("평가 상태").apply { | ||
setItems(*EvaluationStatus.values()) | ||
setItemLabelGenerator { it.toText() } | ||
addValueChangeListener { | ||
mailTargetsGrid.setItems(mailTargetService.findMailTargets(evaluationItem.value.id, it.value)) | ||
} | ||
} | ||
} | ||
|
||
private fun createButtons(): Component { | ||
return HorizontalLayout(createAddButton(), createCancelButton()).apply { | ||
setSizeFull() | ||
justifyContentMode = FlexComponent.JustifyContentMode.CENTER | ||
element.style.set("margin-top", "10px") | ||
} | ||
} | ||
|
||
private fun createAddButton(): Button { | ||
return createPrimaryButton("추가") { | ||
val dataProvider = mailTargetsGrid.dataProvider as ListDataProvider | ||
accept(dataProvider.items) | ||
close() | ||
} | ||
} | ||
|
||
private fun createCancelButton(): Button { | ||
return createContrastButton("취소") { | ||
close() | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/kotlin/apply/ui/admin/mail/IndividualMailTargetDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package apply.ui.admin.mail | ||
|
||
import apply.application.ApplicantResponse | ||
import apply.application.ApplicantService | ||
import apply.application.MailTargetResponse | ||
import com.vaadin.flow.component.Component | ||
import com.vaadin.flow.component.button.Button | ||
import com.vaadin.flow.component.dialog.Dialog | ||
import com.vaadin.flow.component.grid.Grid | ||
import com.vaadin.flow.component.html.H2 | ||
import com.vaadin.flow.component.orderedlayout.FlexComponent | ||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout | ||
import com.vaadin.flow.data.renderer.ComponentRenderer | ||
import com.vaadin.flow.data.renderer.Renderer | ||
import support.views.addSortableColumn | ||
import support.views.createContrastButton | ||
import support.views.createPrimarySmallButton | ||
import support.views.createSearchBox | ||
|
||
class IndividualMailTargetDialog( | ||
private val applicantService: ApplicantService, | ||
private val accept: (MailTargetResponse) -> Unit | ||
) : Dialog() { | ||
private val mailTargetsGrid: Grid<ApplicantResponse> = createMailTargetsGrid() | ||
|
||
init { | ||
add(H2("개별 불러오기"), createSearchFilter(), mailTargetsGrid, createButtons()) | ||
width = "900px" | ||
height = "70%" | ||
open() | ||
} | ||
|
||
private fun createSearchFilter(): Component { | ||
return HorizontalLayout( | ||
createSearchBox { mailTargetsGrid.setItems(applicantService.findAllByKeyword(it)) } | ||
).apply { | ||
element.style.set("margin-top", "10px") | ||
element.style.set("margin-bottom", "10px") | ||
} | ||
} | ||
|
||
private fun createMailTargetsGrid(): Grid<ApplicantResponse> { | ||
return Grid<ApplicantResponse>(10).apply { | ||
addSortableColumn("이름", ApplicantResponse::name) | ||
addSortableColumn("이메일", ApplicantResponse::email) | ||
addColumn(createAddButton()).apply { isAutoWidth = true } | ||
} | ||
} | ||
|
||
private fun createAddButton(): Renderer<ApplicantResponse> { | ||
return ComponentRenderer<Component, ApplicantResponse> { applicantResponse -> | ||
createPrimarySmallButton("추가") { | ||
accept(MailTargetResponse(applicantResponse)) | ||
}.apply { | ||
isDisableOnClick = true | ||
} | ||
} | ||
} | ||
|
||
private fun createButtons(): Component { | ||
return HorizontalLayout(createCancelButton()).apply { | ||
setSizeFull() | ||
justifyContentMode = FlexComponent.JustifyContentMode.CENTER | ||
element.style.set("margin-top", "10px") | ||
} | ||
} | ||
|
||
private fun createCancelButton(): Button { | ||
return createContrastButton("취소") { | ||
close() | ||
} | ||
} | ||
} |
Oops, something went wrong.