[IMP] website_crm_partner_assign: fix multi datepickers on portal
When a portal user is editing opportunity from front-end, there are two date inputs, 'Expected Cloing' and 'Next Activity Date'. But both of them have two pickers for selecting date, a native one and a bootstrap one, which was probably side effect of commit[1]. With this commit, we only keep the bootstrap picker so that it respects the date format based on language, and for the check, to make sure it doesnt break the backend (see ticket from commit[1] for more details), we simply consider the date with year less than 1900 as invalid. We also provide a bit more space for bootstrap datpicker to open while setting the closing date, so that the scrollbar is not introduced on the modal. And for the next activity date, we make sure that the picker is opened always on top of the input (which is not the case currenlty in some screensizes, sometimes it is opened below the input so it is hidden under the extra scroll introduced with picker). commit[1] - https://github.com/odoo/odoo/commit/b2b639b693dd7215e3ee501ac89c35f3a6b88bb5 TaskID-2624728 closes odoo/odoo#77289 X-original-commit: da7cac9b1293a0b8d5375e1b4a470f41fe76e8a4 Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({
|
||||
'click .new_opp_confirm': '_onNewOppConfirm',
|
||||
'click .edit_opp_confirm': '_onEditOppConfirm',
|
||||
'change .edit_opp_form .next_activity': '_onChangeNextActivity',
|
||||
'click div.input-group span.fa-calendar': '_onCalendarIconClick',
|
||||
'click div.input-group.date[data-target-input="nearest"]': '_onCalendarInputGroupClick',
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -227,9 +227,7 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({
|
||||
_onEditOppConfirm: function (ev) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
if ($(".edit_opp_form")[0].checkValidity()) {
|
||||
this._buttonExec($(ev.currentTarget), this._editOpportunity);
|
||||
}
|
||||
this._buttonExec($(ev.currentTarget), this._editOpportunity);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
@@ -250,8 +248,9 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({
|
||||
* @private
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onCalendarIconClick: function (ev) {
|
||||
$(ev.currentTarget).closest('div.date').datetimepicker({
|
||||
_onCalendarInputGroupClick: function (ev) {
|
||||
const $calendarInputGroup = $(ev.currentTarget);
|
||||
const calendarOptions = {
|
||||
format : time.getLangDateFormat(),
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
@@ -259,13 +258,20 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
},
|
||||
});
|
||||
};
|
||||
// in some screen sizes, the automatic position opens the picker below input,
|
||||
// but because #next_activity_div is the last element, we always open the
|
||||
// picker on top the input to prevent extra scroll
|
||||
if ($calendarInputGroup.is('#next_activity_div')) {
|
||||
calendarOptions.widgetPositioning = {vertical: 'top'};
|
||||
}
|
||||
$calendarInputGroup.datetimepicker(calendarOptions);
|
||||
},
|
||||
|
||||
_parse_date: function (value) {
|
||||
console.log(value);
|
||||
var date = moment(value, "YYYY-MM-DD", true);
|
||||
if (date.isValid()) {
|
||||
var date = moment(value, time.getLangDateFormat(), true);
|
||||
if (date.isValid() && date.year() >= 1900) {
|
||||
return time.date_to_str(date.toDate());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -645,7 +645,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-5">
|
||||
<label>Priority:</label>
|
||||
<div class="input-group">
|
||||
<label class="radio-inline">
|
||||
@@ -669,11 +669,11 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-7">
|
||||
<label>Expected Closing:</label>
|
||||
<div class="input-group date" id="exp_closing_div" data-target-input="nearest">
|
||||
<t t-set='date_formatted'><t t-options='{"widget": "date"}' t-esc="opportunity.date_deadline"/></t>
|
||||
<input type="date" min="1900-01-01" name="date_deadline" t-att-value="date_formatted" class="datetimepicker-input form-control date_deadline" data-date-format="YYYY-MM-DD" t-att-name="prefix" placeholder="YYYY-MM-DD"/>
|
||||
<input type="text" name="date_deadline" data-target="#exp_closing_div" t-att-value="date_formatted" class="datetimepicker-input form-control date_deadline" t-att-name="prefix"/>
|
||||
<div class="input-group-append" data-target="#exp_closing_div" data-toggle="datetimepicker">
|
||||
<span class="input-group-text">
|
||||
<span class="fa fa-calendar" role="img" aria-label="Calendar"></span>
|
||||
@@ -699,7 +699,7 @@
|
||||
<label class="col-form-label" for="activity_date_deadline">Next Activity Date</label>
|
||||
<div class="input-group date" id="next_activity_div" data-target-input="nearest">
|
||||
<t t-set='date_formatted'><t t-options='{"widget": "date"}' t-esc="user_activity.date_deadline"/></t>
|
||||
<input type="date" min="1900-01-01" name="activity_date_deadline" t-att-value="date_formatted" class="form-control activity_date_deadline datetimepicker-input" data-date-format="YYYY-MM-DD" t-att-name="prefix" placeholder="YYYY-MM-DD"/>
|
||||
<input type="text" name="activity_date_deadline" data-target="#next_activity_div" t-att-value="date_formatted" class="form-control activity_date_deadline datetimepicker-input" t-att-name="prefix"/>
|
||||
<div class="input-group-append" data-target="#next_activity_div" data-toggle="datetimepicker">
|
||||
<span class="input-group-text">
|
||||
<span class="fa fa-calendar" role="img" aria-label="Calendar" title="Calendar"></span>
|
||||
|
||||
Reference in New Issue
Block a user