Skip to content

Commit

Permalink
Commit number field file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Nov 20, 2024
1 parent 3bca31f commit 53610bf
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions glue_ar/jupyter/number_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import traitlets
import ipyvuetify as v

Check warning on line 2 in glue_ar/jupyter/number_field.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/jupyter/number_field.py#L1-L2

Added lines #L1 - L2 were not covered by tests


# Based on https://github.com/widgetti/ipyvuetify/issues/241
class NumberField(v.VuetifyTemplate):
label = traitlets.Unicode().tag(sync=True)
value = traitlets.Unicode().tag(sync=True)

Check warning on line 8 in glue_ar/jupyter/number_field.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/jupyter/number_field.py#L6-L8

Added lines #L6 - L8 were not covered by tests

temp_error = traitlets.Unicode(allow_none=True, default_value=None).tag(sync=True)

Check warning on line 10 in glue_ar/jupyter/number_field.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/jupyter/number_field.py#L10

Added line #L10 was not covered by tests

def __init__(self, type, label, error_message, *args, **kwargs):
super().__init__(*args, **kwargs)
self.number_type = type
self.label = label
self.error_message = error_message

Check warning on line 16 in glue_ar/jupyter/number_field.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/jupyter/number_field.py#L12-L16

Added lines #L12 - L16 were not covered by tests

@traitlets.default("template")
def _template(self):
return """

Check warning on line 20 in glue_ar/jupyter/number_field.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/jupyter/number_field.py#L18-L20

Added lines #L18 - L20 were not covered by tests
<v-text-field
:label="label"
type="number"
v-model="value"
@change="temp_rule"
:rules="[temp_error]"
>
</v-text-field>
"""

def vue_temp_rule(self, value):
self.temp_error = None
try:
self.number_type(value)
except ValueError:
self.temp_error = self.error_message

Check warning on line 36 in glue_ar/jupyter/number_field.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/jupyter/number_field.py#L31-L36

Added lines #L31 - L36 were not covered by tests

0 comments on commit 53610bf

Please sign in to comment.