Skip to content

Commit

Permalink
[IMP] sign_oca: Add placeholder and show required
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Aug 23, 2023
1 parent 9eb23fb commit c6750c4
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sign_oca/models/sign_oca_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SignOcaTemplateItem(models.Model):
position_y = fields.Float(required=True)
width = fields.Float()
height = fields.Float()
placeholder = fields.Char()

@api.model
def _get_default_role(self):
Expand All @@ -98,4 +99,5 @@ def get_info(self):
"position_y": self.position_y,
"width": self.width,
"height": self.height,
"placeholder": self.placeholder,
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ odoo.define(
var required = dialog.$el
.find("input[name='required']")
.prop("checked");
var placeholder = dialog.$el
.find("input[name='placeholder']")
.val();
this.env.services
.rpc({
model: this.props.model,
Expand All @@ -168,6 +171,7 @@ odoo.define(
field_id,
role_id,
required,
placeholder,
},
],
})
Expand All @@ -179,6 +183,7 @@ odoo.define(
)[0].name;
item.role_id = role_id;
item.required = required;
item.placeholder = placeholder;
target.remove();
this.postIframeField(item);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
t-att-checked="item.required? 'checked': undefined"
/>
</div>
<label for="placeholder">Placeholder</label>
<div class="o_sign_oca_field_edition_value">
<input
type="text"
name="placeholder"
t-att-value="item.placeholder || ''"
/>
</div>
</div>
</t>
</templates>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ odoo.define(
var nbLayers = this.iframe.el.contentDocument.getElementsByClassName(
"textLayer"
).length;
if (nbPages > 0 && nbLayers > 0 && nbPages === nbLayers) {
if (nbPages > 0 && nbLayers > 0) {
this.postIframeFields();
} else {
var self = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</div>
<t t-name="sign_oca.sign_iframe_field">
<div
class="o_sign_oca_field"
t-attf-data-field="id"
t-attf-class="o_sign_oca_field #{required? 'sign_oca_field_required': ''}"
t-att-data-field="id"
t-attf-style="position:absolute;top:#{position_y}%; left: #{position_x}%; width: #{width}%;height: #{height}%"
>
</div>
Expand Down
3 changes: 2 additions & 1 deletion sign_oca/static/src/elements/elements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
type="text"
t-att-tabindex="-1"
t-att-value="item.value? item.value: undefined"
t-att-placeholder="item.placeholder || item.name"
t-if="item.role == role"
/>
<div
Expand All @@ -21,7 +22,7 @@
t-attf-src="data:image/png;base64,{{item.value}}"
t-if="item.value"
/>
<div style="width:100%;height:100%" t-else="" />
<div style="width:100%;height:100%" t-else="" t-esc="placeholder" />
</t>
<t t-name="sign_oca.sign_oca_sign_dialog">
<div>
Expand Down
9 changes: 8 additions & 1 deletion sign_oca/static/src/scss/sign.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
.o_sign_oca_field {
background-color: rgba(0, 128, 128, 0.3);
&.sign_oca_field_required {
background-color: rgba(255, 113, 113, 0.5);
}
&.sign_oca_selected {
background-color: rgba(0, 128, 128, 0.5);
background-color: rgba(0, 128, 128, 0.5) !important;
}
.o_placeholder {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
input {
border: transparent;
background-color: transparent;
}
}
.o_sign_oca_field_config {
position: absolute;
Expand Down
3 changes: 3 additions & 0 deletions sign_oca/static/src/scss/sign_oca.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ html
.o_sign_oca_field_edition_value {
margin-bottom: 10px;
max-width: 100%;
input[type="text"] {
max-width: 100%;
}
}
}
1 change: 1 addition & 0 deletions sign_oca/wizards/sign_oca_template_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _get_item_info(self, item, item_id):
"height": item.height,
"value": False,
"default_value": item.field_id.default_value,
"placeholder": item.placeholder,
}

def _generate_vals(self):
Expand Down

0 comments on commit c6750c4

Please sign in to comment.