Commit 9e6e0011 by Tim Krones

Address review comments.

parent 602d0212
...@@ -105,20 +105,33 @@ class TestVectorDraw(StudioEditableBaseTest): ...@@ -105,20 +105,33 @@ class TestVectorDraw(StudioEditableBaseTest):
def check_vector_properties( def check_vector_properties(
self, menu, is_present=False, expected_label="Vector Properties", self, menu, is_present=False, expected_label="Vector Properties",
expected_name=None, expected_tail=None, expected_length=None, expected_angle=None expected_name=None, expected_tail=None, expected_length=None, expected_angle=None,
input_fields_disabled=True
): ):
if is_present: if is_present:
vector_properties = menu.find_element_by_css_selector(".vector-properties") vector_properties = menu.find_element_by_css_selector(".vector-properties")
vector_properties_label = vector_properties.find_element_by_css_selector("h3") vector_properties_label = vector_properties.find_element_by_css_selector("h3")
self.assertEquals(vector_properties_label.text, expected_label) self.assertEquals(vector_properties_label.text, expected_label)
# Name # Name
self.check_vector_property(vector_properties, "name", "select", "name:", expected_name or "-") self.check_vector_property(
vector_properties, "name", "select", "name:", expected_name or "-",
field_disabled=input_fields_disabled
)
# Tail # Tail
self.check_vector_property(vector_properties, "tail", "input", "tail position:", expected_tail or "-") self.check_vector_property(
vector_properties, "tail", "input", "tail position:", expected_tail or "",
field_disabled=input_fields_disabled
)
# Length # Length
self.check_vector_property(vector_properties, "length", "input", "length:", expected_length or "-") self.check_vector_property(
vector_properties, "length", "input", "length:", expected_length or "",
field_disabled=input_fields_disabled
)
# Angle # Angle
self.check_vector_property(vector_properties, "angle", "input", "angle:", expected_angle or "-") self.check_vector_property(
vector_properties, "angle", "input", "angle:", expected_angle or "",
field_disabled=input_fields_disabled
)
# Slope # Slope
vector_slope = vector_properties.find_element_by_css_selector(".vector-prop-slope") vector_slope = vector_properties.find_element_by_css_selector(".vector-prop-slope")
self.assertFalse(vector_slope.is_displayed()) self.assertFalse(vector_slope.is_displayed())
...@@ -130,7 +143,8 @@ class TestVectorDraw(StudioEditableBaseTest): ...@@ -130,7 +143,8 @@ class TestVectorDraw(StudioEditableBaseTest):
) )
def check_vector_property( def check_vector_property(
self, vector_properties, property_name, input_type, expected_label, expected_value=None self, vector_properties, property_name, input_type, expected_label, expected_value=None,
field_disabled=False
): ):
vector_property = vector_properties.find_element_by_css_selector( vector_property = vector_properties.find_element_by_css_selector(
".vector-prop-{}".format(property_name) ".vector-prop-{}".format(property_name)
...@@ -145,6 +159,8 @@ class TestVectorDraw(StudioEditableBaseTest): ...@@ -145,6 +159,8 @@ class TestVectorDraw(StudioEditableBaseTest):
) )
if input_type == "input": if input_type == "input":
self.assertEquals(vector_property_input.get_attribute("value"), expected_value) self.assertEquals(vector_property_input.get_attribute("value"), expected_value)
disabled = vector_property_input.get_attribute("disabled")
self.assertEquals(bool(disabled), field_disabled)
else: else:
selected_option = vector_property_input.find_element_by_css_selector('option[selected="selected"]') selected_option = vector_property_input.find_element_by_css_selector('option[selected="selected"]')
self.assertEquals(selected_option.text, expected_value) self.assertEquals(selected_option.text, expected_value)
...@@ -297,7 +313,8 @@ class TestVectorDraw(StudioEditableBaseTest): ...@@ -297,7 +313,8 @@ class TestVectorDraw(StudioEditableBaseTest):
# "Vector Properties" should display correct info # "Vector Properties" should display correct info
self.check_vector_properties( self.check_vector_properties(
menu, is_present=True, expected_label="Custom properties label", menu, is_present=True, expected_label="Custom properties label",
expected_name="N", expected_tail="2.00, 2.00", expected_length="4.00", expected_angle="45.00" expected_name="N", expected_tail="2.00, 2.00", expected_length="4.00", expected_angle="45.00",
input_fields_disabled=False
) )
self.check_edit_dropdown(menu, vectors) self.check_edit_dropdown(menu, vectors)
...@@ -330,7 +347,8 @@ class TestVectorDraw(StudioEditableBaseTest): ...@@ -330,7 +347,8 @@ class TestVectorDraw(StudioEditableBaseTest):
# "Vector Properties" should display correct info # "Vector Properties" should display correct info
self.check_vector_properties( self.check_vector_properties(
menu, is_present=True, expected_label="Custom properties label", menu, is_present=True, expected_label="Custom properties label",
expected_name="N", expected_tail="2.00, 2.00", expected_length="4.00", expected_angle="45.00" expected_name="N", expected_tail="2.00, 2.00", expected_length="4.00", expected_angle="45.00",
input_fields_disabled=False
) )
def reset(self, board, vectors, points): def reset(self, board, vectors, points):
...@@ -552,7 +570,8 @@ class TestVectorDraw(StudioEditableBaseTest): ...@@ -552,7 +570,8 @@ class TestVectorDraw(StudioEditableBaseTest):
menu = self.exercise.find_element_by_css_selector(".menu") menu = self.exercise.find_element_by_css_selector(".menu")
self.check_vector_properties( self.check_vector_properties(
menu, is_present=True, expected_label="Custom properties label", menu, is_present=True, expected_label="Custom properties label",
expected_name="N", expected_tail="2.00, 2.00", expected_length="4.00", expected_angle="45.00" expected_name="N", expected_tail="2.00, 2.00", expected_length="4.00", expected_angle="45.00",
input_fields_disabled=False
) )
@data( @data(
......
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
} }
.vectordraw_block .menu .vector-properties .vector-prop-list .row .vector-prop-update .update-error { .vectordraw_block .menu .vector-properties .vector-prop-list .row .vector-prop-update .update-error {
visibility: hidden; display: none;
color: #ff0000; color: #ff0000;
} }
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
margin-bottom: 1em; margin-bottom: 1em;
} }
.vectordraw_edit_block #wysiwyg-description {
display: none;
}
.vectordraw_edit_block p { .vectordraw_edit_block p {
margin-bottom: 1em; margin-bottom: 1em;
font-size: 0.9em; font-size: 0.9em;
...@@ -59,6 +63,11 @@ ...@@ -59,6 +63,11 @@
float: right; float: right;
} }
.vectordraw_block .menu .vector-properties .vector-prop-list .row .vector-prop-update .update-pending {
display: none;
color: #ffa500;
}
.vectordraw_edit_block h3 { .vectordraw_edit_block h3 {
margin-top: 5px; margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;
...@@ -83,11 +92,16 @@ ...@@ -83,11 +92,16 @@
} }
.vectordraw_edit_block .checks .check span, .vectordraw_edit_block .checks .check span,
.vectordraw_edit_block .checks .check input[type="text"] { .vectordraw_edit_block .checks .check input[type="number"] {
height: 1.5em; height: 1.5em;
min-width: 0px;
margin-right: 12px; margin-right: 12px;
} }
.vectordraw_edit_block .checks .check input[type="number"] {
padding: 0 0 0 5px;
}
.vectordraw_edit_block .checks .check input[type="checkbox"] { .vectordraw_edit_block .checks .check input[type="checkbox"] {
height: 1.2em; height: 1.2em;
width: 20%; width: 20%;
......
...@@ -367,6 +367,10 @@ function VectorDrawXBlock(runtime, element, init_args) { ...@@ -367,6 +367,10 @@ function VectorDrawXBlock(runtime, element, init_args) {
$('.vector-prop-slope input', this.element).val(slope.toFixed(2)); $('.vector-prop-slope input', this.element).val(slope.toFixed(2));
} }
} }
// Enable input fields
$('.vector-properties input').prop('disabled', false);
// Hide error message
$('.vector-prop-update .update-error', element).hide();
}; };
VectorDraw.prototype.resetVectorProperties = function(vector) { VectorDraw.prototype.resetVectorProperties = function(vector) {
...@@ -374,8 +378,8 @@ function VectorDrawXBlock(runtime, element, init_args) { ...@@ -374,8 +378,8 @@ function VectorDrawXBlock(runtime, element, init_args) {
this.element.find('.menu .element-list-edit option').attr('selected', false); this.element.find('.menu .element-list-edit option').attr('selected', false);
// Select default value // Select default value
$('.menu .element-list-edit option[value="-"]', element).attr('selected', true); $('.menu .element-list-edit option[value="-"]', element).attr('selected', true);
// Reset input fields to default values // Reset input fields to default values and disable them
$('.menu .vector-prop-list input', element).val('-'); $('.menu .vector-prop-list input', element).prop('disabled', true).val('');
}; };
VectorDraw.prototype.isVectorTailDraggable = function(vector) { VectorDraw.prototype.isVectorTailDraggable = function(vector) {
...@@ -478,7 +482,7 @@ function VectorDrawXBlock(runtime, element, init_args) { ...@@ -478,7 +482,7 @@ function VectorDrawXBlock(runtime, element, init_args) {
var values = [newTail[0], newTail[1], newLength, newAngle]; var values = [newTail[0], newTail[1], newLength, newAngle];
// Validate values // Validate values
if (!_.some(values, Number.isNaN)) { if (!_.some(values, Number.isNaN)) {
$('.vector-prop-update .update-error', element).css('visibility', 'hidden'); $('.vector-prop-update .update-error', element).hide();
// Use coordinates of new tail, new length, new angle to calculate new position of tip // Use coordinates of new tail, new length, new angle to calculate new position of tip
var radians = newAngle * Math.PI / 180; var radians = newAngle * Math.PI / 180;
var newTip = [ var newTip = [
...@@ -491,7 +495,7 @@ function VectorDrawXBlock(runtime, element, init_args) { ...@@ -491,7 +495,7 @@ function VectorDrawXBlock(runtime, element, init_args) {
board_object.point2.setPosition(JXG.COORDS_BY_USER, newTip); board_object.point2.setPosition(JXG.COORDS_BY_USER, newTip);
this.board.update(); this.board.update();
} else { } else {
$('.vector-prop-update .update-error', element).css('visibility', 'visible'); $('.vector-prop-update .update-error', element).show();
} }
}; };
......
...@@ -74,13 +74,13 @@ ...@@ -74,13 +74,13 @@
<span id="vector-prop-tail-label"> <span id="vector-prop-tail-label">
{% trans "tail position" %}: {% trans "tail position" %}:
</span> </span>
<input type="text" value="-" aria-labelledby="vector-prop-tail-label"> <input type="text" disabled="disabled" placeholder="-" aria-labelledby="vector-prop-tail-label">
</div> </div>
<div class="vector-prop vector-prop-length"> <div class="vector-prop vector-prop-length">
<span id="vector-prop-length-label"> <span id="vector-prop-length-label">
{% trans "length" %}: {% trans "length" %}:
</span> </span>
<input type="text" value="-" aria-labelledby="vector-prop-length-label"> <input type="text" disabled="disabled" placeholder="-" aria-labelledby="vector-prop-length-label">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
...@@ -88,13 +88,13 @@ ...@@ -88,13 +88,13 @@
<span id="vector-prop-angle-label"> <span id="vector-prop-angle-label">
{% trans "angle" %}: {% trans "angle" %}:
</span> </span>
<input type="text" value="-" aria-labelledby="vector-prop-angle-label"> <input type="text" disabled="disabled" placeholder="-" aria-labelledby="vector-prop-angle-label">
</div> </div>
<div class="vector-prop vector-prop-slope"> <div class="vector-prop vector-prop-slope">
<span id="vector-prop-slope-label"> <span id="vector-prop-slope-label">
{% trans "slope" %}: {% trans "slope" %}:
</span> </span>
<input type="text" value="-" aria-labelledby="vector-prop-slope-label" disabled="disabled"> <input type="text" disabled="disabled" placeholder="-" aria-labelledby="vector-prop-slope-label">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
......
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