Skip to content
Snippets Groups Projects
Commit 98820e37 authored by daniquilez's avatar daniquilez
Browse files

apply linter corrections

parent 161923d0
No related branches found
No related tags found
2 merge requests!277[REL] Release Sprint 27/11/23,!244Feature/company data public form
Pipeline #67810 passed
This commit is part of merge request !244. Comments created here will be created in the context of that merge request.
......@@ -52,20 +52,87 @@ odoo.define("community_data.oe_community_data", function (require) {
maxDate: "today",
yearRange: "2010:+0",
});
//$(oe_cooperator).on("change", "#ordered_parts", function (event) {
// var $share_price = $("#share_price").text();
// var $link = $(event.currentTarget);
// var quantity = $link[0].value;
// var total_part = quantity * $share_price;
// $("#total_parts").val(total_part);
// return false;
//});
//$(oe_cooperator).on("focusout", "input.js_quantity", function () {
// $("a.js_add_cart_json").trigger("click");
//});
$(".form-group-disabled").each(function () {
$(this).hide();
});
//$("#share_product_id").trigger("change");
$(".data-trigger").each(function () {
$(this).on("change", function (e) {
var impacted_fields_array = $(this).data("trigger").split(",");
for (let i = 0; i < impacted_fields_array.length; i++) {
// flag to mark if we display conditional fields or not
let condition_satisfied = false;
// impacted field is the one that will be displayed or hidden based on it's own condition
let impacted_field = $(".field-" + impacted_fields_array[i]);
// condition is an array. first element defines field key and second field value condition
let showifcondition = impacted_field.data("showif").split(":");
// get dom element for the condition_field
let condition_field = $(".field-" + showifcondition[0]);
// try to see if condition_field is a fieldset
let condition_field_fieldset = condition_field.find("fieldset");
if (condition_field_fieldset.length > 0) {
// if a condition_field is a fieldset iterate trough inputs to see if they're marked and meet condition
condition_field_fieldset.find("input").each(function () {
if (
$(this).is(":checked") &&
showifcondition[1].split(",").includes($(this).attr("id"))
) {
condition_satisfied = true;
}
});
} else {
// if a condition_field is not fieldset get the input, it can be of type input or select.
let condition_field_input = false;
let condition_field_input_input = condition_field.find("input");
if (condition_field_input_input.length > 0) {
condition_field_input = condition_field_input_input;
}
let condition_field_input_select = condition_field.find("select");
if (condition_field_input_select.length > 0) {
condition_field_input = condition_field_input_select;
}
// check if it's a checkbox or radio. if so, check if checked to verify condition
let condition_field_type = condition_field_input.attr("type");
if (
condition_field_type == "radio" ||
condition_field_type == "checkbox"
) {
if (condition_field_input.is(":checked")) {
condition_satisfied = true;
}
} else {
// if condition_field is a regular input, check condition as a regular text
if (
showifcondition[1].split(",").includes(condition_field_input.val())
) {
condition_satisfied = true;
}
}
}
// if condition is satidified remove disabled attribute and display. Do the oppposite if not.
if (condition_satisfied) {
impacted_field.find("input").each(function () {
$(this).removeAttr("disabled");
});
impacted_field.find("select").each(function () {
$(this).removeAttr("disabled");
});
impacted_field.fadeIn();
} else {
impacted_field.find("input").each(function () {
$(this).attr("disabled", true);
});
impacted_field.find("select").each(function () {
$(this).removeAttr("disabled");
});
impacted_field.fadeOut();
}
}
});
});
// trigger change on load
$(".data-trigger").trigger("change");
});
});
});
......@@ -207,6 +207,9 @@
<t t-set="label" t-value="ce_constitution_status_label" />
<t t-set="options" t-value="community_constitution_status_options" />
<t t-set="required" t-value="pack_2" />
<t
t-set="trigger"
>ce_constitution_status_other,ce_legal_form,ce_creation_date,ce_vat</t>
</t>
</div>
<div class="col-md-12" t-if="pack_2">
......@@ -215,6 +218,8 @@
<t t-set="key" t-value="ce_constitution_status_other_key" />
<t t-set="label" t-value="ce_constitution_status_other_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_constitution_status:other</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-6" t-if="pack_2">
......@@ -224,6 +229,8 @@
<t t-set="label" t-value="ce_legal_form_label" />
<t t-set="options" t-value="community_legal_form_options" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_constitution_status:constituted</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-12" t-if="pack_2">
......@@ -232,6 +239,8 @@
<t t-set="key" t-value="ce_creation_date_key" />
<t t-set="label" t-value="ce_creation_date_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_constitution_status:constituted</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-12" t-if="pack_2">
......@@ -240,6 +249,8 @@
<t t-set="key" t-value="ce_vat_key" />
<t t-set="label" t-value="ce_vat_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_constitution_status:constituted</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-12" t-if="pack_2">
......@@ -296,11 +307,20 @@
<t t-set="label" t-value="ce_manager_label" />
<t t-set="options" t-value="community_manager_options" />
<t t-set="required" t-value="pack_2" />
<t
t-set="trigger"
>ce_manager_headline,ce_manager_firstname,ce_manager_surname,ce_manager_email,ce_manager_phone</t>
</t>
</div>
<div class="col-md-12" t-if="pack_2">
<label
>Contact person for the administrative management of the Energy Community</label>
<t t-call="energy_communities.form_headline">
<t t-set="key">ce_manager_headline</t>
<t t-set="showif">ce_manager:member_admin,both</t>
<t t-set="disabled">True</t>
<t
t-set="headline"
>Contact person for the administrative management of the Energy Community</t>
</t>
</div>
<div class="col-md-6" t-if="pack_2">
<t t-call="energy_communities.form_field_text">
......@@ -308,6 +328,8 @@
<t t-set="key" t-value="ce_manager_firstname_key" />
<t t-set="label" t-value="ce_manager_firstname_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_manager:member_admin,both</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-6" t-if="pack_2">
......@@ -316,6 +338,8 @@
<t t-set="key" t-value="ce_manager_surname_key" />
<t t-set="label" t-value="ce_manager_surname_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_manager:member_admin,both</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-6" t-if="pack_2">
......@@ -324,6 +348,8 @@
<t t-set="key" t-value="ce_manager_email_key" />
<t t-set="label" t-value="ce_manager_email_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_manager:member_admin,both</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-6" t-if="pack_2">
......@@ -332,6 +358,8 @@
<t t-set="key" t-value="ce_manager_phone_key" />
<t t-set="label" t-value="ce_manager_phone_label" />
<t t-set="required" t-value="pack_2" />
<t t-set="showif">ce_manager:member_admin,both</t>
<t t-set="disabled">True</t>
</t>
</div>
<div class="col-md-12" t-if="pack_2">
......@@ -500,7 +528,7 @@
<!-- TODO: Make this description dynamic and db translatable -->
<template id="community_data_headline" name="community_data_headline">
<t t-if="pack_2">
<h1
<h2
class="mt-4 text-center"
>Data collection form required for the integration of <strong><t
t-esc="ce_name"
......@@ -508,20 +536,20 @@
href="https://somcomunitats.coop"
target="_blank"
>web</a> and to our <strong
>administrative management space</strong> (Odoo program for corporate, accounting and financial management)</h1>
>administrative management space</strong> (Odoo program for corporate, accounting and financial management)</h2>
</t>
<t t-else="pack_1">
<h1
<h2
class="mt-4 text-center"
>Data collection form required for the integration of <strong><t
t-esc="ce_name"
/></strong> to the <strong>public spaces</strong> of our <a
href="https://somcomunitats.coop"
target="_blank"
>web</a></h1>
>web</a></h2>
</t>
<br />
<div class="alert alert-warning">
<div class="alert alert-warning" t-if="not display_success">
<p><strong
>Alert!</strong> The content you enter in this form is what we will show directly on your page within Som Comunitats.</p>
<p
......@@ -535,7 +563,7 @@
<div id="wrap" class="o_portal_wrap">
<div class="container oe_community_data">
<div class="row justify-content-center">
<div class="col-xs-12 col-sm-10 col-md-10 col-lg-10">
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-8">
<t t-call="energy_communities.community_data_headline" />
<t t-call="energy_communities.community_data_error_message_template" />
......
......@@ -11,10 +11,20 @@
t-if="field_required"
> *</span></label>
</template>
<template id="form_headline" name="form_headline">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group field-#{key} #{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<label><t t-esc="headline" /></label>
</div>
</template>
<template id="form_field_text" name="form_field_text">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -25,19 +35,22 @@
<t t-set="field_description" t-value="description" />
</t>
<input
class="form-control form-control-sm"
t-attf-class="form-control form-control-sm#{trigger and ' data-trigger' or ''}"
t-attf-id="#{key}"
type="text"
t-attf-name="#{key}"
t-attf-value="#{value or ''}"
t-att-required="required"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
/>
</div>
</template>
<template id="form_field_number" name="form_field_number">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -48,20 +61,23 @@
<t t-set="field_description" t-value="description" />
</t>
<input
class="form-control form-control-sm"
t-attf-class="form-control form-control-sm#{trigger and ' data-trigger'}"
t-attf-id="#{key}"
type="number"
t-attf-name="#{key}"
min="1"
t-attf-value="#{value or ''}"
t-att-required="required"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
/>
</div>
</template>
<template id="form_field_email" name="form_field_email">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -72,20 +88,23 @@
<t t-set="field_description" t-value="description" />
</t>
<input
class="form-control form-control-sm"
t-attf-class="form-control form-control-sm#{trigger and ' data-trigger'}"
t-attf-id="#{key}"
autocapitalize="off"
type="email"
t-attf-name="#{key}"
t-attf-value="#{value or ''}"
t-att-required="required"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
/>
</div>
</template>
<template id="form_field_textarea" name="form_field_textarea">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -96,19 +115,22 @@
<t t-set="field_description" t-value="description" />
</t>
<textarea
class="form-control form-control-sm"
t-attf-class="form-control form-control-sm#{trigger and ' data-trigger'}"
t-attf-id="#{key}"
t-attf-name="#{key}"
t-attf-rows="#{rows}"
t-attf-maxlength="#{maxlength}"
t-att-required="required"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
><t t-esc="value or ''" /></textarea>
</div>
</template>
<template id="form_field_selection" name="form_field_selection">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -119,10 +141,12 @@
<t t-set="field_description" t-value="description" />
</t>
<select
class="form-control form-control-sm"
t-attf-class="form-control form-control-sm#{trigger and ' data-trigger'}"
t-attf-id="#{key}"
t-attf-name="#{key}"
t-att-required="required"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
>
<option value="">Please choose an option</option>
<t t-foreach="options or []" t-as="option">
......@@ -139,10 +163,15 @@
<template id="form_field_selection_checkbox" name="form_field_selection_checkbox">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<!-- TODO: Required validation trough javascript -->
<fieldset t-att-required="required">
<!-- TODO: Possible required validation trough javascript -->
<fieldset
t-att-required="required"
t-attf-class="#{trigger and 'data-trigger'}"
t-att-data-trigger="trigger"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
<t t-set="field_label" t-value="label" />
......@@ -158,6 +187,7 @@
t-att-id="option['id']"
t-att-name="option['id']"
t-att-checked="option['id'] in value"
t-att-disabled="disabled"
/>
<span><t t-esc="option['name']" /></span>
</div>
......@@ -168,15 +198,19 @@
<template id="form_field_checkbox" name="form_field_checkbox">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<div>
<input
t-attf-class="#{trigger and ' data-trigger'}"
t-att-data-trigger="trigger"
type="checkbox"
t-att-id="key"
t-att-name="key"
t-att-checked="value=='on'"
t-att-required="required"
t-att-disabled="disabled"
/>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -192,9 +226,13 @@
<template id="form_field_selection_radio" name="form_field_selection_radio">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<fieldset>
<fieldset
t-attf-class="#{trigger and 'data-trigger'}"
t-att-data-trigger="trigger"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
<t t-set="field_label" t-value="label" />
......@@ -212,6 +250,7 @@
t-att-name="key"
t-att-checked="option['id'] == value"
t-att-required="required"
t-att-disabled="disabled"
/>
<span><t t-esc="option['name']" /></span>
</div>
......@@ -223,7 +262,8 @@
<div class="col-md-6">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-call="energy_communities.form_field_part_label">
<t t-set="field_key" t-value="key" />
......@@ -241,9 +281,11 @@
<input
type="file"
accept="image/*"
class="form-control form-control-sm #{key}"
t-attf-class="form-control form-control-sm #{key}#{trigger and ' data-trigger'}"
t-attf-name="#{key}"
t-att-required="required and not value"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
/>
</div>
</div>
......@@ -254,7 +296,8 @@
<template id="form_field_date_past" name="form_field_date_past">
<div
t-attf-name="#{key}_container"
t-attf-class="form-group #{error and key in error and 'has-error' or ''} field-#{key}"
t-attf-class="form-group#{error and key in error and ' has-error ' or ' '}field-#{key}#{disabled and ' form-group-disabled'}"
t-att-data-showif="showif"
>
<t t-set="date_placeholder" t-if="lang=='ca_ES'">dd/mm/aaaa</t>
<t t-set="date_placeholder" t-if="lang=='es_ES'">dd/mm/aaaa</t>
......@@ -265,7 +308,7 @@
<t t-set="field_required" t-value="required" />
</t>
<input
class="form-control form-control-sm o_website_form_date_past"
t-attf-class="form-control form-control-sm o_website_form_date_past#{trigger and ' data-trigger'}"
type="text"
t-attf-id="#{key}"
t-attf-name="#{key}"
......@@ -273,6 +316,8 @@
t-attf-data-locale="#{lang}"
t-attf-placeholder="#{date_placeholder}"
t-att-required="required"
t-att-disabled="disabled"
t-att-data-trigger="trigger"
/>
</div>
</template>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment