|
|
|
@ -121,8 +121,7 @@ class WorkPackageField |
|
|
|
|
# For fields of type select, will check for an option with that value. |
|
|
|
|
def set_value(content) |
|
|
|
|
scroll_to_element(input_element) |
|
|
|
|
|
|
|
|
|
if input_element.tag_name == 'ng-select' |
|
|
|
|
if field_type == 'create-autocompleter' |
|
|
|
|
page.find('.ng-dropdown-panel .ng-option', text: content).click |
|
|
|
|
else |
|
|
|
|
input_element.set(content) |
|
|
|
@ -135,7 +134,7 @@ class WorkPackageField |
|
|
|
|
def unset_value(content, multi=false) |
|
|
|
|
scroll_to_element(input_element) |
|
|
|
|
|
|
|
|
|
if input_element.tag_name == 'ng-select' |
|
|
|
|
if field_type == 'create-autocompleter' |
|
|
|
|
if multi |
|
|
|
|
page.find('.ng-value-label', text: content).sibling('.ng-value-icon').click |
|
|
|
|
else |
|
|
|
@ -146,6 +145,15 @@ class WorkPackageField |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Use option of ng-select field to create new element from within the autocompleter |
|
|
|
|
def set_new_value(content) |
|
|
|
|
scroll_to_element(input_element) |
|
|
|
|
input_element.find('input').set content |
|
|
|
|
|
|
|
|
|
page.find('.ng-option', text: 'Create new: ' + content).click |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def type(text) |
|
|
|
|
scroll_to_element(input_element) |
|
|
|
|
input_element.send_keys text |
|
|
|
@ -162,13 +170,13 @@ class WorkPackageField |
|
|
|
|
set_value value |
|
|
|
|
|
|
|
|
|
# select fields are saved on change |
|
|
|
|
save! if save && field_type != 'ng-select' |
|
|
|
|
save! if save && field_type != 'create-autocompleter' |
|
|
|
|
expect_state! open: expect_failure |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def submit_by_enter |
|
|
|
|
if field_type == 'ng-select' |
|
|
|
|
if field_type == 'create-autocompleter' |
|
|
|
|
autocomplete_selector.send_keys :return |
|
|
|
|
else |
|
|
|
|
input_element.native.send_keys :return |
|
|
|
@ -176,7 +184,7 @@ class WorkPackageField |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def cancel_by_escape |
|
|
|
|
if field_type == 'ng-select' |
|
|
|
|
if field_type == 'create-autocompleter' |
|
|
|
|
autocomplete_selector.send_keys :escape |
|
|
|
|
else |
|
|
|
|
input_element.native.send_keys :escape |
|
|
|
@ -210,7 +218,7 @@ class WorkPackageField |
|
|
|
|
'type', |
|
|
|
|
'version', |
|
|
|
|
'category' |
|
|
|
|
'ng-select' |
|
|
|
|
'create-autocompleter' |
|
|
|
|
else |
|
|
|
|
:input |
|
|
|
|
end.to_s |
|
|
|
|