Update JavaScript to support labels in readonly mode for both Gregorian and Hijri dates

This commit is contained in:
Mohamed Eltayar 2025-08-28 15:14:27 +03:00
parent ffe2251802
commit 885edd2d31
1 changed files with 27 additions and 6 deletions

View File

@ -125,14 +125,35 @@ odoo.define('web_hijri_datepicker.datepicker', function (require) {
var value = this.value ? this.datewidget._formatClients(this.value) : '';
var parsed_date = this.value ? this.datewidget._parseDate(this.value) : '';
var hijri_value = parsed_date ? this.datewidget._convertGregorianToHijri(parsed_date) : '';
// Gregorian Date Section
$('<div>', {
class: this.$el.attr('class'),
text: value,
}).appendTo($div);
class: 'o_date_section'
}).append([
$('<label>', {
class: 'o_date_label o_gregorian_label',
text: 'التاريخ الميلادي'
}),
$('<div>', {
class: 'o_date_value ' + this.$el.attr('class'),
text: value,
})
]).appendTo($div);
// Hijri Date Section
$('<div>', {
class: this.$el.attr('class'),
text: hijri_value,
}).appendTo($div);
class: 'o_date_section'
}).append([
$('<label>', {
class: 'o_date_label o_hijri_label',
text: 'التاريخ الهجري'
}),
$('<div>', {
class: 'o_date_value ' + this.$el.attr('class'),
text: hijri_value,
})
]).appendTo($div);
this.datewidget.appendTo('<div>').then(function () {
self._replaceElement($div);
});