[IMP]pms: added error handling in precheckin send invitation

This commit is contained in:
braisab
2021-10-21 12:16:37 +02:00
parent dff4ec16d9
commit 321005cc7d
3 changed files with 59 additions and 19 deletions

View File

@@ -634,6 +634,6 @@ class PortalPrecheckin(CustomerPortal):
) )
firstname = kw["firstname"] firstname = kw["firstname"]
email = kw["email"] email = kw["email"]
checkin_partner.write({"firstname": firstname, "email": email}) if firstname and email:
checkin_partner.send_portal_invitation_email(firstname, email) checkin_partner.write({"firstname": firstname, "email": email})
# request.portal_my_folio_precheckin(kw) checkin_partner.send_portal_invitation_email(firstname, email)

View File

@@ -28,14 +28,40 @@ odoo.define("pms.SendInvitationData", function (require) {
.parent() .parent()
.find("input[name=invitation_email]") .find("input[name=invitation_email]")
.val(); .val();
this._rpc({ var error_firstname = $(ev.currentTarget)
route: "/my/precheckin/send_invitation", .parent()
params: { .parent()
checkin_partner_id: checkinPartnerId, .find("span:first");
firstname: firstname, var error_email = $(ev.currentTarget)
email: email, .parent()
}, .parent()
}); .find("input[name=invitation_email]")
.siblings("span");
console.log(error_firstname);
console.log(error_email);
if (firstname === "" || email === "") {
if (firstname === "") {
error_firstname.removeClass("d-none");
} else {
error_firstname.addClass("d-none");
}
if (email === "") {
error_email.removeClass("d-none");
} else {
error_email.addClass("d-none");
}
} else {
error_firstname.addClass("d-none");
error_email.addClass("d-none");
this._rpc({
route: "/my/precheckin/send_invitation",
params: {
checkin_partner_id: checkinPartnerId,
firstname: firstname,
email: email,
},
});
}
}, },
}); });
return publicWidget.registry.SendInvitationData; return publicWidget.registry.SendInvitationData;

View File

@@ -927,6 +927,11 @@
t-attf-class="form-control" t-attf-class="form-control"
t-att-value="firstname or (checkin_partner.firstname)" t-att-value="firstname or (checkin_partner.firstname)"
/> />
<span
style="color:red"
class="d-none"
t-att-id="error_inv_firstname"
>Mandatory Firstname</span>
</div> </div>
<div <div
t-attf-class="form-group col-4 p-2" t-attf-class="form-group col-4 p-2"
@@ -939,12 +944,16 @@
Email Email
</label> </label>
<input <input
id="invitation_email" t-att-id="'invitation_email'+str(checkin_partner.id)"
type="email" type="email"
t-att-name="'invitation_email'" t-att-name="'invitation_email'"
t-attf-class="form-control " t-attf-class="form-control "
t-att-value="invitation_email or checkin_partner.email" t-att-value="invitation_email or checkin_partner.email"
/> />
<span
style="color:red"
class="d-none error_inv_email"
>Mandatory Email</span>
</div> </div>
<div <div
t-attf-class="form-group col-4 p-3" t-attf-class="form-group col-4 p-3"
@@ -1366,19 +1375,19 @@
</style> </style>
<script> <script>
function launchSnackBar(element) { function launchSnackBar(element) {
var x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
var checkin_partner_id = element.firstChild.nextSibling.innerText var checkin_partner_id = element.firstChild.nextSibling.innerText
var inputEmailId = "invitation_email" + checkin_partner_id;
var email = document.getElementById(inputEmailId).value;
var nameId = "invitation_firstname" + checkin_partner_id; var nameId = "invitation_firstname" + checkin_partner_id;
var hostId = "host_name" + checkin_partner_id; var hostId = "host_name" + checkin_partner_id;
var host = document.getElementById(hostId); var host = document.getElementById(hostId);
var name = document.getElementById(nameId).value; var name = document.getElementById(nameId).value;
host.innerHTML = name; if(email){
if(name){
console.log("non ten email");
host.innerHTML = name;
var divId = "invitation_group" + checkin_partner_id; var divId = "invitation_group" + checkin_partner_id;
var btnId = "btnResendInvitation" + checkin_partner_id; var btnId = "btnResendInvitation" + checkin_partner_id;
@@ -1386,6 +1395,11 @@
var btn_show_invitation = document.getElementById(btnId); var btn_show_invitation = document.getElementById(btnId);
div_invitation.classList.add("d-none"); div_invitation.classList.add("d-none");
btn_show_invitation.classList.remove("d-none"); btn_show_invitation.classList.remove("d-none");
var x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
}
} }
function show_invitation(element) { function show_invitation(element) {