Commit 25155939 by Damien Moulard

add issuers dropdown in meal voucher issuer popup

parent d5a1f82e
...@@ -63,3 +63,6 @@ ...@@ -63,3 +63,6 @@
padding: 8px 12px; padding: 8px 12px;
} }
.popup-textinput select {
margin: 10px 16px !important;
}
\ No newline at end of file
...@@ -215,4 +215,45 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -215,4 +215,45 @@ odoo.define("pos_meal_voucher.models", function (require) {
models.Paymentline = Paymentline; models.Paymentline = Paymentline;
var gui = require('point_of_sale.gui');
var PopupWidget = require('point_of_sale.popups');
var SelectOrTextInputPopupWidget = PopupWidget.extend({
template: 'TextInputPopupWidget',
show: function(options){
options = options || {};
this._super(options);
this.renderElement();
// On input change of value, reset select, and vice versa
this.$("input").on("input", (e) => {
if (e.target.value !== '') {
this.$("select").val('').change();
}
})
this.$("select").on("change", (e) => {
if (e.target.value !== '') {
this.$("input").val('');
}
})
},
click_confirm: function(){
var value =
this.$('select').find(":selected").val() ?
this.$('select').find(":selected").val() :
this.$('input,textarea').val();
// At least one field is mandatory
if (value === '') {
return;
}
this.gui.close_popup();
if( this.options.confirm ){
this.options.confirm.call(this,value);
}
},
});
gui.define_popup({name:'select-or-textinput', widget: SelectOrTextInputPopupWidget});
}); });
...@@ -195,6 +195,7 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -195,6 +195,7 @@ odoo.define("pos_meal_voucher.screens", function (require) {
}; };
this.meal_voucher_issuers = [];
// get meal voucher issuers from config // get meal voucher issuers from config
config_parameter.call('get_param', ['pos_meal_voucher.meal_voucher_issuers']) config_parameter.call('get_param', ['pos_meal_voucher.meal_voucher_issuers'])
.then( function(value){ .then( function(value){
...@@ -306,8 +307,6 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -306,8 +307,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
// if user choose card meal voucher // if user choose card meal voucher
if(order.selected_paymentline.is_meal_voucher() && order.selected_paymentline.is_dematerialized_meal_voucher()){ if(order.selected_paymentline.is_meal_voucher() && order.selected_paymentline.is_dematerialized_meal_voucher()){
// console.log(this.meal_voucher_issuers);
// update selected (last) payment line & order with meal voucher data // update selected (last) payment line & order with meal voucher data
function update_order_meal_voucher_data(issuer = '') { function update_order_meal_voucher_data(issuer = '') {
var total_eligible = order.get_total_meal_voucher_eligible(); var total_eligible = order.get_total_meal_voucher_eligible();
...@@ -332,9 +331,23 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -332,9 +331,23 @@ odoo.define("pos_meal_voucher.screens", function (require) {
// If required by the config, ask for the meal voucher issuer // If required by the config, ask for the meal voucher issuer
if (this.pos.config.meal_voucher_ask_for_issuer) { if (this.pos.config.meal_voucher_ask_for_issuer) {
this.gui.show_popup("textinput", { let select_data = [{
'title': _t("Emetteur du titre restaurant"), 'val': "",
'body': _t("Veuillez renseigner ci-dessous le nom de l'entité émettrice du titre restaurant."), 'text': "- Choississez un émetteur"
}];
for (let issuer of this.meal_voucher_issuers) {
select_data.push({
"val": issuer,
"text": issuer
});
}
this.gui.show_popup("select-or-textinput", {
'title': _t("Émetteur du titre restaurant"),
'body': _t("Si l'émetteur n'est pas dans la liste ci-dessus, veuillez le noter dans le champs ci-dessous : "),
'selectText': _t("Veuillez sélectionner l'émetteur de CB déj dans la liste ci-dessous : "),
'selectData': select_data,
confirm: function(value) { confirm: function(value) {
let issuer = value; let issuer = value;
update_order_meal_voucher_data(issuer) update_order_meal_voucher_data(issuer)
......
...@@ -78,6 +78,18 @@ ...@@ -78,6 +78,18 @@
</t> </t>
<t t-extend="TextInputPopupWidget"> <t t-extend="TextInputPopupWidget">
<t t-jquery="p.title" t-operation="after"> <t t-jquery="p.title" t-operation="after">
<t t-if="widget.options.selectText">
<p class="body"><t t-esc="widget.options.selectText"/></p>
</t>
<t t-if="widget.options.selectData">
<select class="select body">
<t t-as="element" t-foreach="widget.options.selectData">
<option t-att-value="element.val">
<t t-esc="element.text"/>
</option>
</t>
</select>
</t>
<p class="body"><t t-esc=" widget.options.body || '' "/></p> <p class="body"><t t-esc=" widget.options.body || '' "/></p>
</t> </t>
</t> </t>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment