Merge pull request #408 from frappe/develop
chore: Merge develop to main
This commit is contained in:
commit
b015385db8
@ -34,7 +34,7 @@ def get_fields_layout(doctype: str, type: str):
|
|||||||
for field in section.get("fields") if section.get("fields") else []:
|
for field in section.get("fields") if section.get("fields") else []:
|
||||||
field = next((f for f in fields if f.fieldname == field), None)
|
field = next((f for f in fields if f.fieldname == field), None)
|
||||||
if field:
|
if field:
|
||||||
if field.fieldtype == "Select":
|
if field.fieldtype == "Select" and field.options:
|
||||||
field.options = field.options.split("\n")
|
field.options = field.options.split("\n")
|
||||||
field.options = [{"label": _(option), "value": option} for option in field.options]
|
field.options = [{"label": _(option), "value": option} for option in field.options]
|
||||||
field.options.insert(0, {"label": "", "value": ""})
|
field.options.insert(0, {"label": "", "value": ""})
|
||||||
@ -45,6 +45,7 @@ def get_fields_layout(doctype: str, type: str):
|
|||||||
"options": field.options,
|
"options": field.options,
|
||||||
"mandatory": field.reqd,
|
"mandatory": field.reqd,
|
||||||
"placeholder": field.get("placeholder"),
|
"placeholder": field.get("placeholder"),
|
||||||
|
"filters": field.get("link_filters")
|
||||||
}
|
}
|
||||||
section["fields"][section.get("fields").index(field["name"])] = field
|
section["fields"][section.get("fields").index(field["name"])] = field
|
||||||
|
|
||||||
|
|||||||
@ -50,13 +50,25 @@
|
|||||||
:placeholder="__('Payment Reminder from Frappé - (#{{ name }})')"
|
:placeholder="__('Payment Reminder from Frappé - (#{{ name }})')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
||||||
<div class="mb-1.5 text-sm text-gray-600">
|
<div class="mb-1.5 text-sm text-gray-600">
|
||||||
{{ __('Content') }}
|
{{ __('Content') }}
|
||||||
<span class="text-red-500">*</span>
|
<span class="text-red-500">*</span>
|
||||||
</div>
|
</div>
|
||||||
<FormControl
|
<FormControl
|
||||||
v-if="_emailTemplate.use_html"
|
v-if="_emailTemplate.content_type === 'HTML'"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
ref="content"
|
ref="content"
|
||||||
@ -64,7 +76,7 @@
|
|||||||
v-model="_emailTemplate.response_html"
|
v-model="_emailTemplate.response_html"
|
||||||
:placeholder="
|
: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>',
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@ -78,7 +90,7 @@
|
|||||||
@change="(val) => (_emailTemplate.response = val)"
|
@change="(val) => (_emailTemplate.response = val)"
|
||||||
:placeholder="
|
: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é',
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@ -86,9 +98,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<Checkbox v-model="_emailTemplate.enabled" :label="__('Enabled')" />
|
<Checkbox v-model="_emailTemplate.enabled" :label="__('Enabled')" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<Checkbox v-model="_emailTemplate.use_html" :label="__('Use HTML')" />
|
|
||||||
</div>
|
|
||||||
<ErrorMessage :message="__(errorMessage)" />
|
<ErrorMessage :message="__(errorMessage)" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -116,7 +125,9 @@ const emit = defineEmits(['after'])
|
|||||||
const subjectRef = ref(null)
|
const subjectRef = ref(null)
|
||||||
const nameRef = ref(null)
|
const nameRef = ref(null)
|
||||||
const editMode = ref(false)
|
const editMode = ref(false)
|
||||||
let _emailTemplate = ref({})
|
let _emailTemplate = ref({
|
||||||
|
content_type: 'Rich Text',
|
||||||
|
})
|
||||||
|
|
||||||
async function updateEmailTemplate() {
|
async function updateEmailTemplate() {
|
||||||
if (!validate()) return
|
if (!validate()) return
|
||||||
@ -184,6 +195,9 @@ function handleEmailTemplateUpdate(doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validate() {
|
function validate() {
|
||||||
|
_emailTemplate.value.use_html = Boolean(
|
||||||
|
_emailTemplate.value.content_type == 'HTML',
|
||||||
|
)
|
||||||
if (!_emailTemplate.value.name) {
|
if (!_emailTemplate.value.name) {
|
||||||
errorMessage.value = 'Name is required'
|
errorMessage.value = 'Name is required'
|
||||||
return false
|
return false
|
||||||
@ -193,12 +207,17 @@ function validate() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!_emailTemplate.value.response ||
|
!_emailTemplate.value.use_html &&
|
||||||
_emailTemplate.value.response === '<p></p>'
|
(!_emailTemplate.value.response ||
|
||||||
|
_emailTemplate.value.response === '<p></p>')
|
||||||
) {
|
) {
|
||||||
errorMessage.value = 'Content is required'
|
errorMessage.value = 'Content is required'
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (_emailTemplate.value.use_html && !_emailTemplate.value.response_html) {
|
||||||
|
errorMessage.value = 'Content is required'
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,10 +234,13 @@ watch(
|
|||||||
nameRef.value.el.focus()
|
nameRef.value.el.focus()
|
||||||
}
|
}
|
||||||
_emailTemplate.value = { ...props.emailTemplate }
|
_emailTemplate.value = { ...props.emailTemplate }
|
||||||
|
_emailTemplate.value.content_type = _emailTemplate.value.use_html
|
||||||
|
? 'HTML'
|
||||||
|
: 'Rich Text'
|
||||||
if (_emailTemplate.value.name) {
|
if (_emailTemplate.value.name) {
|
||||||
editMode.value = true
|
editMode.value = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user