Skip to content

Commit

Permalink
[EASI-3098] Share Model Plan (#665)
Browse files Browse the repository at this point in the history
* wip: draft revision

* chore: fixes to model plan share email template and better match with figma spec

* chore: implemented view filter link, updated text for fields which were not selected

* chore: refactored error wrapping into store method and loader logic

* chore: extended model categories to support additional model categories

* fix: do not show model plan share optional message where it has zero length

* chore: updated postman collection

* Added UI for share model plan

* Added mutation and status states/messages

* Added close prop to modal alert

* Updated unit tests

* Added overflow scroll to modal

* Imported ModelViewFilter enum to replace FE defined const

* Replace IDR with MDM filter view

* Trimmed emails strings and added form disable if no emails

* Uodated incorrect email recipient hint

---------

Co-authored-by: Clay Benson <[email protected]>
Co-authored-by: Patrick Segura <[email protected]>
  • Loading branch information
3 people authored Sep 1, 2023
1 parent 052d059 commit 78e5deb
Show file tree
Hide file tree
Showing 28 changed files with 7,268 additions and 112 deletions.
32 changes: 32 additions & 0 deletions MINT.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@
},
"response": []
},
{
"name": "Share Model Plan",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "graphql",
"graphql": {
"query": "mutation shareModelPlan($modelPlanID: UUID!, $viewFilter: ModelViewFilter, $receiverEmails: [String!]!, $optionalMessage: String) {\n shareModelPlan(modelPlanID: $modelPlanID, viewFilter: $viewFilter, receiverEmails: $receiverEmails, optionalMessage: $optionalMessage)\n}\n",
"variables": "{\n \"modelPlanID\": \"{{modelPlanID}}\",\n \"viewFilter\": \"CMMI\",\n \"receiverEmails\": [\"[email protected]\", \"[email protected]\"],\n \"optionalMessage\": \"\"\n}\n"
}
},
"url": {
"raw": "{{url}}",
"host": [
"{{url}}"
]
}
},
"response": []
},
{
"name": "Update Model Plan",
"request": {
Expand Down
28 changes: 28 additions & 0 deletions pkg/email/model_plan_share.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package email

import (
"time"

"github.com/cmsgov/mint-app/pkg/models"
)

// ModelPlanShareSubjectContent defines the parameters necessary for the corresponding email subject
type ModelPlanShareSubjectContent struct {
UserName string
}

// ModelPlanShareBodyContent defines the parameters necessary for the corresponding email body
type ModelPlanShareBodyContent struct {
UserName string
OptionalMessage *string
ModelName string
ModelShortName *string
ModelCategories []models.ModelCategory
ModelStatus models.TaskStatus
ModelLastUpdated time.Time
ModelLeads []string
ModelViewFilter *string
HumanizedModelViewFilter *string
ClientAddress string
ModelID string
}
14 changes: 14 additions & 0 deletions pkg/email/template_service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ var modelPlanDateChangedSubjectTemplate string
//go:embed templates/model_plan_date_changed_body.html
var modelPlanDateChangedBodyTemplate string

// ModelPlanShareTemplateName is the template name definition for the corresponding email template
const ModelPlanShareTemplateName string = "model_plan_share"

//go:embed templates/model_plan_share_subject.html
var modelPlanShareSubjectTemplate string

//go:embed templates/model_plan_share_body.html
var modelPlanShareBodyTemplate string

// TemplateServiceImpl is an implementation-specific structure loading all resources necessary for server execution
type TemplateServiceImpl struct {
templateCache *emailTemplates.TemplateCache
Expand Down Expand Up @@ -113,6 +122,11 @@ func (t *TemplateServiceImpl) Load() error {
return err
}

err = t.loadEmailTemplate(ModelPlanShareTemplateName, modelPlanShareSubjectTemplate, modelPlanShareBodyTemplate)
if err != nil {
return err
}

return nil
}

Expand Down
153 changes: 153 additions & 0 deletions pkg/email/templates/model_plan_share_body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Content</title>
<style type="text/css">
/* CSS Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* General */
body {
padding-left: 5px;
text-align: left;
}

/* Headings */
h1 {
font-size: 30pt;
font-weight: bold;
font-style: normal;
color: #1B1B1B;
font-family: 'Public Sans', sans-serif;
text-decoration: none;
}

h2 {
font-size: 24pt;
font-weight: bold;
font-style: normal;
color: #1B1B1B;
font-family: 'Public Sans', sans-serif;
text-decoration: none;
}

h3 {
font-size: 16.5pt;
font-weight: bold;
font-style: normal;
color: #1B1B1B;
font-family: 'Public Sans', sans-serif;
text-decoration: none;
line-height: 1.4;
}

/* Subtitle */
.subtitle {
font-size: 15.5pt;
font-weight: normal;
font-style: normal;
color: #71767A;
font-family: 'Public Sans', sans-serif;
text-decoration: none;
}

/* Paragraph */
p {
font-size: 12pt;
font-weight: normal;
font-style: normal;
color: #1B1B1B;
font-family: 'Public Sans', sans-serif;
text-decoration: none;
line-height: 1.4;
}

/* Links */
a {
font-size: 12pt;
color: #005EA2;
font-family: 'Public Sans', sans-serif;
text-decoration: none;
}
</style>
</head>
<body>
<h1 style="padding-top: 3pt;">MINT</h1>
<p class="subtitle" style="padding-top: 11pt;">The Model Innovation Tool</p>
<br/>
<h2 style="padding-top: 14pt;">{{.UserName}} has shared a Model Plan with you:</h2>
<br/>
<!-- Only show the optional message if it exists -->
{{if and .OptionalMessage (gt (len .OptionalMessage) 0)}}
<p style="font-size: 15.5pt;
font-weight: normal;
font-style: normal;
color: #565C65;
font-family: 'Public Sans', sans-serif;
text-decoration: none;">"{{.OptionalMessage}}"</p>
<br/>
{{end}}

<table style="border: 1px solid #E6E6E6; border-radius: 6px; padding: 20px; display: inline-table;">
<tr>
<td style="vertical-align: top; padding: 20px;">
<h1 style="display: inline-block;">{{.ModelName}}</h1>
{{if .ModelShortName}}<h2 style="display: inline-block;"> ({{.ModelShortName}})</h2>{{end}}
<br/>

<h3>Category</h3>
<p>
{{if .ModelCategories}}
{{- range $index, $element := .ModelCategories -}}
{{- if $index -}}, {{- end -}}
{{$element}}
{{- end -}}
{{else}}
To be determined
{{end}}
</p>
<br/>

<h3>Status</h3>
<p>{{.ModelStatus}}</p>
<br/>

<h3>Last Updated</h3>
<p>{{.ModelLastUpdated.Format "2006-01-02 15:04:05"}}</p>
<br/>

<h3>Model Leads</h3>
<p>
{{if .ModelLeads}}
{{- range $index, $element := .ModelLeads -}}
{{- if $index -}}, {{- end -}}
{{$element}}
{{- end -}}
{{else}}
To be determined
{{end}}
</p>
<br/>
</td>
</tr>
</table>

<br/>
<p style="padding-top: 14pt;">
{{if .ModelViewFilter}}
<a href="{{.ClientAddress}}/models/{{.ModelID}}/read-only?filter-view={{.ModelViewFilter}}" class="link">
View {{.HumanizedModelViewFilter}} details in MINT
</a>
{{else}}
<a href="{{.ClientAddress}}/models/{{.ModelID}}/read-only" class="link">
View more details in MINT
</a>
{{end}}
</p>
</body>
1 change: 1 addition & 0 deletions pkg/email/templates/model_plan_share_subject.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{.UserName}} has shared a Model Plan with you
Loading

0 comments on commit 78e5deb

Please sign in to comment.