Skip to content

Commit

Permalink
Merge pull request #408 from frappe/develop
Browse files Browse the repository at this point in the history
chore: Merge develop to main
  • Loading branch information
shariquerik authored Oct 11, 2024
2 parents 5364f03 + 590b92c commit b015385
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
3 changes: 2 additions & 1 deletion crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_fields_layout(doctype: str, type: str):
for field in section.get("fields") if section.get("fields") else []:
field = next((f for f in fields if f.fieldname == field), None)
if field:
if field.fieldtype == "Select":
if field.fieldtype == "Select" and field.options:
field.options = field.options.split("\n")
field.options = [{"label": _(option), "value": option} for option in field.options]
field.options.insert(0, {"label": "", "value": ""})
Expand All @@ -45,6 +45,7 @@ def get_fields_layout(doctype: str, type: str):
"options": field.options,
"mandatory": field.reqd,
"placeholder": field.get("placeholder"),
"filters": field.get("link_filters")
}
section["fields"][section.get("fields").index(field["name"])] = field

Expand Down
42 changes: 32 additions & 10 deletions frontend/src/components/Modals/EmailTemplateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,33 @@
:placeholder="__('Payment Reminder from Frappé - (#{{ name }})')"
/>
</div>
<div>
<div class="mb-1.5 text-sm text-gray-600">
{{ __('Content Type') }}
</div>
<Select
variant="outline"
v-model="_emailTemplate.content_type"
default="Rich Text"
:options="['Rich Text', 'HTML']"
:placeholder="__('Rich Text')"
/>
</div>
<div>
<div class="mb-1.5 text-sm text-gray-600">
{{ __('Content') }}
<span class="text-red-500">*</span>
</div>
<FormControl
v-if="_emailTemplate.use_html"
v-if="_emailTemplate.content_type === 'HTML'"
type="textarea"
variant="outline"
ref="content"
:rows="10"
v-model="_emailTemplate.response_html"
:placeholder="
__(
'<p>Dear {{ lead_name }},</p>\n\n<p>This is a reminder for the payment of {{ grand_total }}.</p>\n\n<p>Thanks,</p>\n<p>Frappé</p>'
'<p>Dear {{ lead_name }},</p>\n\n<p>This is a reminder for the payment of {{ grand_total }}.</p>\n\n<p>Thanks,</p>\n<p>Frappé</p>',
)
"
/>
Expand All @@ -78,17 +90,14 @@
@change="(val) => (_emailTemplate.response = val)"
:placeholder="
__(
'Dear {{ lead_name }}, \n\nThis is a reminder for the payment of {{ grand_total }}. \n\nThanks, \nFrappé'
'Dear {{ lead_name }}, \n\nThis is a reminder for the payment of {{ grand_total }}. \n\nThanks, \nFrappé',
)
"
/>
</div>
<div>
<Checkbox v-model="_emailTemplate.enabled" :label="__('Enabled')" />
</div>
<div>
<Checkbox v-model="_emailTemplate.use_html" :label="__('Use HTML')" />
</div>
<ErrorMessage :message="__(errorMessage)" />
</div>
</template>
Expand Down Expand Up @@ -116,7 +125,9 @@ const emit = defineEmits(['after'])
const subjectRef = ref(null)
const nameRef = ref(null)
const editMode = ref(false)
let _emailTemplate = ref({})
let _emailTemplate = ref({
content_type: 'Rich Text',
})
async function updateEmailTemplate() {
if (!validate()) return
Expand Down Expand Up @@ -184,6 +195,9 @@ function handleEmailTemplateUpdate(doc) {
}
function validate() {
_emailTemplate.value.use_html = Boolean(
_emailTemplate.value.content_type == 'HTML',
)
if (!_emailTemplate.value.name) {
errorMessage.value = 'Name is required'
return false
Expand All @@ -193,12 +207,17 @@ function validate() {
return false
}
if (
!_emailTemplate.value.response ||
_emailTemplate.value.response === '<p></p>'
!_emailTemplate.value.use_html &&
(!_emailTemplate.value.response ||
_emailTemplate.value.response === '<p></p>')
) {
errorMessage.value = 'Content is required'
return false
}
if (_emailTemplate.value.use_html && !_emailTemplate.value.response_html) {
errorMessage.value = 'Content is required'
return false
}
return true
}
Expand All @@ -215,10 +234,13 @@ watch(
nameRef.value.el.focus()
}
_emailTemplate.value = { ...props.emailTemplate }
_emailTemplate.value.content_type = _emailTemplate.value.use_html
? 'HTML'
: 'Rich Text'
if (_emailTemplate.value.name) {
editMode.value = true
}
})
}
},
)
</script>

0 comments on commit b015385

Please sign in to comment.