OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/spec/support/edit_fields/edit_field.rb

247 lines
5.8 KiB

class EditField
include Capybara::DSL
include RSpec::Matchers
attr_reader :selector,
:property_name,
:context
attr_accessor :field_type
def initialize(context,
property_name,
selector: nil)
@property_name = property_name.to_s
@context = context
[31023] Preparation for project edit fields: Generalize edit and display fields currently work package specific (#7726) * Check edit fields for Work package dependencies * Make EditForm, NotificationService, EditContext indepenedent of Work Packages * Make EventsService independent of WorkPackages * Start renaming WpNotificationService (WiP) * Fix more references * Fix typescript errors * Add basic halEditingService * Rename to global halResourceEditingService (WiP) * Move typing from class to methods (WiP) * Fix typescript errors * Remove space in type * Add test project widget && generalize the editFieldGroup * Rename editing portal service [ci skip] * Rename WpEditFieldComponent * Rename WpDisplayFields * Rename display-XX-field to XX-display-field [ci skip] * Add WP specific ID field to distinguish between resources * Re-add state in work package resource * Generalize display field renderer * Rename spent-time to wp-spent-time and fix highlight specifics [ci skip] * Actually load the project schema and make field editable * Make edit-field-group.component an edit-form.component and subclass EditForm * Remove edit context in favor of specialized EditForm * Add special cases for work package editing * Fix edit actions bar * Fix codeclimate issues * Use WorkPackageNotificationService if necessary * Override NotificationService for WPs to allow WP specififc notifications (WiP) * Correctly provide wpNotification service Because the ui-router doesn't seem to correctly use the parent element's injector, we need to provide the wpNotification service not in the wp-base, but rather the wp-list component as well as in the isolated query space. * Allow to filter halEvents for specific resourceTypes (e.g. WorkPackage) * Remove superfluous cell class constant * Start renaming selectors for wp-edit-field into generics * Remove wp-table--cell-span in favor of display field selector * Consolidate other display and edit field styles * Provide specialized service for transitions in active edit forms * Remove superfluous overflowSelector * Accept that date field contains some work package specifics * Ignore unreadable files * Provide the changeset for work packages as a hook Since hal resource editing service is provided per query space, we cannot register them once (would only work globally) * Fix dangerfile * Remove another todo in halResourceNotification service * Fix npm TestBed for changed dependencies * Show inplace edit field in project details widget * Fix highlighting in single view * Provide HalResourceEditingService outside of project context * Used typedState for single-view * Also provide wpNotification service in split view * Correct check for resource type in eventsService * Fix getSchemaName in display field renderer * Fix passing ids into `halEditing.stopEditing` * Do not globally inject the halResourceEditingService There's a bug(?) in ui-router that gives you the global service before the parent injected service for a ui-view * Fix wpCreate service on copying and parallel creation * Remove test project widget * Revert changes for project details widget
5 years ago
@selector = selector || ".inline-edit--container.#{property_name}"
end
def field_container
context.find @selector
end
7 years ago
def display_selector
[31023] Preparation for project edit fields: Generalize edit and display fields currently work package specific (#7726) * Check edit fields for Work package dependencies * Make EditForm, NotificationService, EditContext indepenedent of Work Packages * Make EventsService independent of WorkPackages * Start renaming WpNotificationService (WiP) * Fix more references * Fix typescript errors * Add basic halEditingService * Rename to global halResourceEditingService (WiP) * Move typing from class to methods (WiP) * Fix typescript errors * Remove space in type * Add test project widget && generalize the editFieldGroup * Rename editing portal service [ci skip] * Rename WpEditFieldComponent * Rename WpDisplayFields * Rename display-XX-field to XX-display-field [ci skip] * Add WP specific ID field to distinguish between resources * Re-add state in work package resource * Generalize display field renderer * Rename spent-time to wp-spent-time and fix highlight specifics [ci skip] * Actually load the project schema and make field editable * Make edit-field-group.component an edit-form.component and subclass EditForm * Remove edit context in favor of specialized EditForm * Add special cases for work package editing * Fix edit actions bar * Fix codeclimate issues * Use WorkPackageNotificationService if necessary * Override NotificationService for WPs to allow WP specififc notifications (WiP) * Correctly provide wpNotification service Because the ui-router doesn't seem to correctly use the parent element's injector, we need to provide the wpNotification service not in the wp-base, but rather the wp-list component as well as in the isolated query space. * Allow to filter halEvents for specific resourceTypes (e.g. WorkPackage) * Remove superfluous cell class constant * Start renaming selectors for wp-edit-field into generics * Remove wp-table--cell-span in favor of display field selector * Consolidate other display and edit field styles * Provide specialized service for transitions in active edit forms * Remove superfluous overflowSelector * Accept that date field contains some work package specifics * Ignore unreadable files * Provide the changeset for work packages as a hook Since hal resource editing service is provided per query space, we cannot register them once (would only work globally) * Fix dangerfile * Remove another todo in halResourceNotification service * Fix npm TestBed for changed dependencies * Show inplace edit field in project details widget * Fix highlighting in single view * Provide HalResourceEditingService outside of project context * Used typedState for single-view * Also provide wpNotification service in split view * Correct check for resource type in eventsService * Fix getSchemaName in display field renderer * Fix passing ids into `halEditing.stopEditing` * Do not globally inject the halResourceEditingService There's a bug(?) in ui-router that gives you the global service before the parent injected service for a ui-view * Fix wpCreate service on copying and parallel creation * Remove test project widget * Revert changes for project details widget
5 years ago
'.inline-edit--display-field'
7 years ago
end
def display_element
context.find "#{@selector} #{display_selector}"
end
def input_element
context.find "#{@selector} #{input_selector}"
end
def clear(with_backspace: false)
if with_backspace
input_element.set(' ', fill_options: { clear: :backspace })
else
input_element.native.clear
end
end
def expect_read_only
expect(context).to have_selector "#{@selector} #{display_selector}.-read-only"
end
def expect_state_text(text)
expect(context).to have_selector(@selector, text: text)
end
alias :expect_text :expect_state_text
def expect_value(value)
expect(input_element.value).to eq(value)
end
def expect_display_value(value)
expect(display_element)
.to have_content(value)
end
##
# Activate the field and check it opened correctly
def activate!(expect_open: true)
retry_block do
unless active?
SeleniumHubWaiter.wait
scroll_to_and_click(display_element)
SeleniumHubWaiter.wait
end
if expect_open && !active?
[32880] Display scheduling mode in work package view (full, split & table) (#8410) * Show icon next to start date depending on the scheduling mode * Show modal when opening date edit fields which shall be able to change the dates and the scheduling mode * Introduce flatpickr as a datepicker for the modal of the dateEditField * Use new datepicker within opDatePickerComponent * Reuse existing Datepicker class for better code abstraction * Set dates only when Instance is ready * Let augmentedDatePicker use generic DatePicker class, too. * Remove jQuery UI datepicker specific styles as they do not apply any more. * Use localized strings in new datepicker * Close datepicker only on click outside * Allow single and multi selection of dates and save changes * Update schedulingMode button correctly && remove unused method * Show combined field for start and end date within the WP single view * Show normal datepicker for most date fields and the modal with the extended datepicker only for startDate * Add datepicker edit field and component helper * Correctly save start and end date * Show correct default value for dateEditFields && Adapt some tests to new datepicker and combined date field * Fix date editor spec * Fix expecting datepicker for start/due date as milestone * Prevent overflow on body by using modal-portal class && make edit input for combinedDates visible again to show something in a create form * Only output one debounced change event for op datepicker * Show combined datepickerModal for dueDate in table, too && save correct scheduling value * Hide modal if the showing component gets destroyed * Correctly check for closed datepicker * Add spec for toggling scheduling mode * Fix setting dates to modal * Avoid too many (unnecessary) close events and use keydown instead * Fix date setting and add custom field date spec * Change layout of combined date picker modal * Switch from a range date picker to a multiple selection in order to be able to set only start or due date && Highlight date field that is changed next * Highlight range manually * Highlight dueDate initially when the user clicked on the due date field && handle special case that one of the values is not set yet. In this case we don't want to keep both values but only the newly clicked. * Move helper functions to own class && Improve the range selection to be able highlight ranges over multiple months && Prevent that a start date > due date can be chosen by setting minDate and maxDate * Adapt test to new way of changing the scheduling mode * Handle case that the user clicks on a already selected date and thus deselects it Co-authored-by: Oliver Günther <mail@oliverguenther.de>
4 years ago
raise "Expected field for attribute '#{property_name}' to be active."
end
end
end
alias :activate_edition :activate!
def openSelectField
autocomplete_selector.click
end
def expect_state!(open:)
if open
expect_active!
else
expect_inactive!
end
end
def active?
7 years ago
@context.has_selector? "#{@selector} #{input_selector}", wait: 1
end
alias :editing? :active?
def expect_active!
7 years ago
expect(field_container)
.to have_selector(field_type, wait: 10),
"Expected field input type '#{field_type}' for attribute '#{property_name}'."
# Also ensure the element is not disabled
expect_enabled!
end
def expect_inactive!
expect(field_container).to have_selector(display_selector, wait: 10)
expect(field_container).to have_no_selector(field_type)
end
def expect_enabled!
expect(@context).to have_no_selector "#{@selector} #{input_selector}[disabled]"
end
def expect_invalid
expect(page).to have_selector("#{@selector} #{field_type}:invalid")
end
def expect_error
7 years ago
expect(page).to have_selector("#{@selector} .-error")
end
def save!
submit_by_enter
end
7 years ago
def submit_by_dashboard
field_container.find('.inplace-edit--control--save', wait: 5).click
7 years ago
end
##
# Set or select the given value.
# For fields of type select, will check for an option with that value.
def set_value(content)
scroll_to_element(input_element)
if field_type.end_with?('-autocompleter')
Feature/36382 multi selection for project custom fields base (#9164) * Projects form working with formly 50% * Removed console.log * Working with formattable * Working with formattable * Input with id and label * Input with id and label * Useless dependencies removed * Saving forms + required labels with * * First backend validation approach * Removed reload on type change + keep model on route changes * Handlig backend validations with setError * Formatting the form model to submit * Make up refactor * working with op-form-field * Form creation moved to the service * Working with op-form-field wrapper * Working with validation and op-form-field * Working with []CustomFields * Clean up * Clean up * Clean up * Clean up * Form routing working * Notification on form error and success * Refactor + removed useless dynamic form observable * DynamicFieldsService with tests * Refactor: inputs catalog + catch form load error * Filter out non writable fields * Refactor: naming consistency * Cleaning comments * dynamic-fields-service tests + wrapper component * DynamicForm Tests * @ngx-formly/core dependency added * Cleaning up * Provide DynamicFieldsService in root so it can be used independently * DynamicForm working as a FormControl * Getting route params sync * Global FormsService: submit + formatting + error handling * Fix: @Optional() FormGroupDirective in OpFormFieldComponent * Code climate fix * Removed CdkTextareaAutosize because of CDK issue 22469 * DynamicFormComponent tests * Dynamic input test helpers + boolean and text tests * Refactor edit fields to avoid circular dependencies in the dynamic forms * Naming fix * IntegerInputComponent tests * SelectInputComponent tests * Fix: duplicated identifier on inputs * Extract toolbar to be reused for now Still TBD whether we want to move them right now to the frontend? * Create new project route and redirect to rails view after saving * fieldsSettingsPipe + hide 'identifier' on projects * Handling multi-values (also as links) and passwords * Some TODOs removed * FormattableTextareaInputComponent tests * Projects form working with formly 50% * Removed console.log * Working with formattable * Working with formattable * Input with id and label * Input with id and label * Useless dependencies removed * Saving forms + required labels with * * First backend validation approach * Removed reload on type change + keep model on route changes * Handlig backend validations with setError * Formatting the form model to submit * Make up refactor * working with op-form-field * Form creation moved to the service * Working with op-form-field wrapper * Working with validation and op-form-field * Working with []CustomFields * Clean up * Clean up * Clean up * Clean up * Form routing working * Notification on form error and success * Refactor + removed useless dynamic form observable * DynamicFieldsService with tests * Refactor: inputs catalog + catch form load error * Filter out non writable fields * Refactor: naming consistency * Cleaning comments * dynamic-fields-service tests + wrapper component * DynamicForm Tests * @ngx-formly/core dependency added * Cleaning up * DynamicForm working as a FormControl * Getting route params sync * Global FormsService: submit + formatting + error handling * Fix: @Optional() FormGroupDirective in OpFormFieldComponent * Code climate fix * Removed CdkTextareaAutosize because of CDK issue 22469 * DynamicFormComponent tests * Dynamic input test helpers + boolean and text tests * Refactor edit fields to avoid circular dependencies in the dynamic forms * Naming fix * IntegerInputComponent tests * SelectInputComponent tests * Fix: duplicated identifier on inputs * Extract toolbar to be reused for now Still TBD whether we want to move them right now to the frontend? * Create new project route and redirect to rails view after saving * fieldsSettingsPipe + hide 'identifier' on projects * Handling multi-values (also as links) and passwords * Some TODOs removed * FormattableTextareaInputComponent tests * _isResourceSchema based on parent?.location * Scope DynamicFieldsService to DynamicFormComponent * Added backend validation method to FormsService * Remove form from DynamicForm when not isStandaloneForm * Allow multiple form keys to validate * Remove form from non standalone forms * Remove duplicated button * Fix: dynamic form with ng-template not showing validations * DynamicForm programatic validation * Hide the submit button input * Unify ckeditor spacings with other dynamic-form elements * Basic fixes to invalid dynamic form fields * Fix invalid styles for dynamic inputs * Updates to form styles, add op-form and op-fieldset * Soften inputs to 2px * Update input styles globally * Fix selectors in copy spec * Undo new project route Will be handled in separate PR * Add separate module for field controls Otherwise it will not be found in the FormattableEditField component * Fix paths now having a trailing slash due to ui-router * Remove new project lazy route * Add data attribute to locate fields * Fix spec by locating field with data * Accept that ng-select can be cut off No idea why that changed in this PR though? * Fix success message to match tests * Redirect settings to generic to match angular path * Fix other project spec * Remove fdescribe * Fix missing cv with magic wait time for now * Remove broken angular tests * Fix routing spec * Import field controls module in wp module * Wait after inserting link into ckeditor It looks like the formly field doesn't get the current ckeditor value before saving * Decouple settings fetching from dynamicform mode (Standalone/FormControl) Co-authored-by: Oliver Günther <mail@oliverguenther.de> Co-authored-by: Benjamin Bädorf <b.baedorf@openproject.com>
4 years ago
page.find('.ng-dropdown-panel .ng-option', visible: :all, text: content).click
else
# A normal fill_in would cause the focus loss on the input for empty strings.
# Thus the form would be submitted.
# https://github.com/erikras/redux-form/issues/686
input_element.fill_in with: content, fill_options: { clear: :backspace }
end
end
##
# Set or select the given value.
# For fields of type select, will check for an option with that value.
def unset_value(content, multi = false)
scroll_to_element(input_element)
if field_type.end_with?('-autocompleter')
if multi
Feature/36382 multi selection for project custom fields base (#9164) * Projects form working with formly 50% * Removed console.log * Working with formattable * Working with formattable * Input with id and label * Input with id and label * Useless dependencies removed * Saving forms + required labels with * * First backend validation approach * Removed reload on type change + keep model on route changes * Handlig backend validations with setError * Formatting the form model to submit * Make up refactor * working with op-form-field * Form creation moved to the service * Working with op-form-field wrapper * Working with validation and op-form-field * Working with []CustomFields * Clean up * Clean up * Clean up * Clean up * Form routing working * Notification on form error and success * Refactor + removed useless dynamic form observable * DynamicFieldsService with tests * Refactor: inputs catalog + catch form load error * Filter out non writable fields * Refactor: naming consistency * Cleaning comments * dynamic-fields-service tests + wrapper component * DynamicForm Tests * @ngx-formly/core dependency added * Cleaning up * Provide DynamicFieldsService in root so it can be used independently * DynamicForm working as a FormControl * Getting route params sync * Global FormsService: submit + formatting + error handling * Fix: @Optional() FormGroupDirective in OpFormFieldComponent * Code climate fix * Removed CdkTextareaAutosize because of CDK issue 22469 * DynamicFormComponent tests * Dynamic input test helpers + boolean and text tests * Refactor edit fields to avoid circular dependencies in the dynamic forms * Naming fix * IntegerInputComponent tests * SelectInputComponent tests * Fix: duplicated identifier on inputs * Extract toolbar to be reused for now Still TBD whether we want to move them right now to the frontend? * Create new project route and redirect to rails view after saving * fieldsSettingsPipe + hide 'identifier' on projects * Handling multi-values (also as links) and passwords * Some TODOs removed * FormattableTextareaInputComponent tests * Projects form working with formly 50% * Removed console.log * Working with formattable * Working with formattable * Input with id and label * Input with id and label * Useless dependencies removed * Saving forms + required labels with * * First backend validation approach * Removed reload on type change + keep model on route changes * Handlig backend validations with setError * Formatting the form model to submit * Make up refactor * working with op-form-field * Form creation moved to the service * Working with op-form-field wrapper * Working with validation and op-form-field * Working with []CustomFields * Clean up * Clean up * Clean up * Clean up * Form routing working * Notification on form error and success * Refactor + removed useless dynamic form observable * DynamicFieldsService with tests * Refactor: inputs catalog + catch form load error * Filter out non writable fields * Refactor: naming consistency * Cleaning comments * dynamic-fields-service tests + wrapper component * DynamicForm Tests * @ngx-formly/core dependency added * Cleaning up * DynamicForm working as a FormControl * Getting route params sync * Global FormsService: submit + formatting + error handling * Fix: @Optional() FormGroupDirective in OpFormFieldComponent * Code climate fix * Removed CdkTextareaAutosize because of CDK issue 22469 * DynamicFormComponent tests * Dynamic input test helpers + boolean and text tests * Refactor edit fields to avoid circular dependencies in the dynamic forms * Naming fix * IntegerInputComponent tests * SelectInputComponent tests * Fix: duplicated identifier on inputs * Extract toolbar to be reused for now Still TBD whether we want to move them right now to the frontend? * Create new project route and redirect to rails view after saving * fieldsSettingsPipe + hide 'identifier' on projects * Handling multi-values (also as links) and passwords * Some TODOs removed * FormattableTextareaInputComponent tests * _isResourceSchema based on parent?.location * Scope DynamicFieldsService to DynamicFormComponent * Added backend validation method to FormsService * Remove form from DynamicForm when not isStandaloneForm * Allow multiple form keys to validate * Remove form from non standalone forms * Remove duplicated button * Fix: dynamic form with ng-template not showing validations * DynamicForm programatic validation * Hide the submit button input * Unify ckeditor spacings with other dynamic-form elements * Basic fixes to invalid dynamic form fields * Fix invalid styles for dynamic inputs * Updates to form styles, add op-form and op-fieldset * Soften inputs to 2px * Update input styles globally * Fix selectors in copy spec * Undo new project route Will be handled in separate PR * Add separate module for field controls Otherwise it will not be found in the FormattableEditField component * Fix paths now having a trailing slash due to ui-router * Remove new project lazy route * Add data attribute to locate fields * Fix spec by locating field with data * Accept that ng-select can be cut off No idea why that changed in this PR though? * Fix success message to match tests * Redirect settings to generic to match angular path * Fix other project spec * Remove fdescribe * Fix missing cv with magic wait time for now * Remove broken angular tests * Fix routing spec * Import field controls module in wp module * Wait after inserting link into ckeditor It looks like the formly field doesn't get the current ckeditor value before saving * Decouple settings fetching from dynamicform mode (Standalone/FormControl) Co-authored-by: Oliver Günther <mail@oliverguenther.de> Co-authored-by: Benjamin Bädorf <b.baedorf@openproject.com>
4 years ago
page.find('.ng-value-label', visible: :all, text: content).sibling('.ng-value-icon').click
else
Feature/36382 multi selection for project custom fields base (#9164) * Projects form working with formly 50% * Removed console.log * Working with formattable * Working with formattable * Input with id and label * Input with id and label * Useless dependencies removed * Saving forms + required labels with * * First backend validation approach * Removed reload on type change + keep model on route changes * Handlig backend validations with setError * Formatting the form model to submit * Make up refactor * working with op-form-field * Form creation moved to the service * Working with op-form-field wrapper * Working with validation and op-form-field * Working with []CustomFields * Clean up * Clean up * Clean up * Clean up * Form routing working * Notification on form error and success * Refactor + removed useless dynamic form observable * DynamicFieldsService with tests * Refactor: inputs catalog + catch form load error * Filter out non writable fields * Refactor: naming consistency * Cleaning comments * dynamic-fields-service tests + wrapper component * DynamicForm Tests * @ngx-formly/core dependency added * Cleaning up * Provide DynamicFieldsService in root so it can be used independently * DynamicForm working as a FormControl * Getting route params sync * Global FormsService: submit + formatting + error handling * Fix: @Optional() FormGroupDirective in OpFormFieldComponent * Code climate fix * Removed CdkTextareaAutosize because of CDK issue 22469 * DynamicFormComponent tests * Dynamic input test helpers + boolean and text tests * Refactor edit fields to avoid circular dependencies in the dynamic forms * Naming fix * IntegerInputComponent tests * SelectInputComponent tests * Fix: duplicated identifier on inputs * Extract toolbar to be reused for now Still TBD whether we want to move them right now to the frontend? * Create new project route and redirect to rails view after saving * fieldsSettingsPipe + hide 'identifier' on projects * Handling multi-values (also as links) and passwords * Some TODOs removed * FormattableTextareaInputComponent tests * Projects form working with formly 50% * Removed console.log * Working with formattable * Working with formattable * Input with id and label * Input with id and label * Useless dependencies removed * Saving forms + required labels with * * First backend validation approach * Removed reload on type change + keep model on route changes * Handlig backend validations with setError * Formatting the form model to submit * Make up refactor * working with op-form-field * Form creation moved to the service * Working with op-form-field wrapper * Working with validation and op-form-field * Working with []CustomFields * Clean up * Clean up * Clean up * Clean up * Form routing working * Notification on form error and success * Refactor + removed useless dynamic form observable * DynamicFieldsService with tests * Refactor: inputs catalog + catch form load error * Filter out non writable fields * Refactor: naming consistency * Cleaning comments * dynamic-fields-service tests + wrapper component * DynamicForm Tests * @ngx-formly/core dependency added * Cleaning up * DynamicForm working as a FormControl * Getting route params sync * Global FormsService: submit + formatting + error handling * Fix: @Optional() FormGroupDirective in OpFormFieldComponent * Code climate fix * Removed CdkTextareaAutosize because of CDK issue 22469 * DynamicFormComponent tests * Dynamic input test helpers + boolean and text tests * Refactor edit fields to avoid circular dependencies in the dynamic forms * Naming fix * IntegerInputComponent tests * SelectInputComponent tests * Fix: duplicated identifier on inputs * Extract toolbar to be reused for now Still TBD whether we want to move them right now to the frontend? * Create new project route and redirect to rails view after saving * fieldsSettingsPipe + hide 'identifier' on projects * Handling multi-values (also as links) and passwords * Some TODOs removed * FormattableTextareaInputComponent tests * _isResourceSchema based on parent?.location * Scope DynamicFieldsService to DynamicFormComponent * Added backend validation method to FormsService * Remove form from DynamicForm when not isStandaloneForm * Allow multiple form keys to validate * Remove form from non standalone forms * Remove duplicated button * Fix: dynamic form with ng-template not showing validations * DynamicForm programatic validation * Hide the submit button input * Unify ckeditor spacings with other dynamic-form elements * Basic fixes to invalid dynamic form fields * Fix invalid styles for dynamic inputs * Updates to form styles, add op-form and op-fieldset * Soften inputs to 2px * Update input styles globally * Fix selectors in copy spec * Undo new project route Will be handled in separate PR * Add separate module for field controls Otherwise it will not be found in the FormattableEditField component * Fix paths now having a trailing slash due to ui-router * Remove new project lazy route * Add data attribute to locate fields * Fix spec by locating field with data * Accept that ng-select can be cut off No idea why that changed in this PR though? * Fix success message to match tests * Redirect settings to generic to match angular path * Fix other project spec * Remove fdescribe * Fix missing cv with magic wait time for now * Remove broken angular tests * Fix routing spec * Import field controls module in wp module * Wait after inserting link into ckeditor It looks like the formly field doesn't get the current ckeditor value before saving * Decouple settings fetching from dynamicform mode (Standalone/FormControl) Co-authored-by: Oliver Günther <mail@oliverguenther.de> Co-authored-by: Benjamin Bädorf <b.baedorf@openproject.com>
4 years ago
page.find('.ng-dropdown-panel .ng-option', visible: :all, text: '-').click
end
else
input_element.set('')
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: ' + content).click
end
def type(text)
scroll_to_element(input_element)
input_element.send_keys text
end
##
# Update this attribute while retrying to open the field
# if unsuccessful at first.
def update(value, save: true, expect_failure: false)
# Retry to set attributes due to reloading the page after setting
# an attribute, which may cause an input not to open properly.
retry_block do
activate_edition
set_value value
# select fields are saved on change
save! if save && !field_type.end_with?('-autocompleter')
expect_state! open: expect_failure
end
end
def submit_by_enter
if field_type.end_with? '-autocompleter'
autocomplete_selector.send_keys :return
else
input_element.native.send_keys :return
end
end
def cancel_by_escape
if field_type.end_with? '-autocompleter'
autocomplete_selector.send_keys :escape
else
input_element.native.send_keys :escape
end
end
def editable?
7 years ago
field_container.has_selector? "#{display_selector}.-editable"
end
def input_selector
6 years ago
if property_name == 'description'
'.op-ckeditor--wrapper'
6 years ago
else
[31023] Preparation for project edit fields: Generalize edit and display fields currently work package specific (#7726) * Check edit fields for Work package dependencies * Make EditForm, NotificationService, EditContext indepenedent of Work Packages * Make EventsService independent of WorkPackages * Start renaming WpNotificationService (WiP) * Fix more references * Fix typescript errors * Add basic halEditingService * Rename to global halResourceEditingService (WiP) * Move typing from class to methods (WiP) * Fix typescript errors * Remove space in type * Add test project widget && generalize the editFieldGroup * Rename editing portal service [ci skip] * Rename WpEditFieldComponent * Rename WpDisplayFields * Rename display-XX-field to XX-display-field [ci skip] * Add WP specific ID field to distinguish between resources * Re-add state in work package resource * Generalize display field renderer * Rename spent-time to wp-spent-time and fix highlight specifics [ci skip] * Actually load the project schema and make field editable * Make edit-field-group.component an edit-form.component and subclass EditForm * Remove edit context in favor of specialized EditForm * Add special cases for work package editing * Fix edit actions bar * Fix codeclimate issues * Use WorkPackageNotificationService if necessary * Override NotificationService for WPs to allow WP specififc notifications (WiP) * Correctly provide wpNotification service Because the ui-router doesn't seem to correctly use the parent element's injector, we need to provide the wpNotification service not in the wp-base, but rather the wp-list component as well as in the isolated query space. * Allow to filter halEvents for specific resourceTypes (e.g. WorkPackage) * Remove superfluous cell class constant * Start renaming selectors for wp-edit-field into generics * Remove wp-table--cell-span in favor of display field selector * Consolidate other display and edit field styles * Provide specialized service for transitions in active edit forms * Remove superfluous overflowSelector * Accept that date field contains some work package specifics * Ignore unreadable files * Provide the changeset for work packages as a hook Since hal resource editing service is provided per query space, we cannot register them once (would only work globally) * Fix dangerfile * Remove another todo in halResourceNotification service * Fix npm TestBed for changed dependencies * Show inplace edit field in project details widget * Fix highlighting in single view * Provide HalResourceEditingService outside of project context * Used typedState for single-view * Also provide wpNotification service in split view * Correct check for resource type in eventsService * Fix getSchemaName in display field renderer * Fix passing ids into `halEditing.stopEditing` * Do not globally inject the halResourceEditingService There's a bug(?) in ui-router that gives you the global service before the parent injected service for a ui-view * Fix wpCreate service on copying and parallel creation * Remove test project widget * Revert changes for project details widget
5 years ago
'.inline-edit--field'
6 years ago
end
end
def autocomplete_selector
field_container.find('.ng-input input')
end
def field_type
@field_type ||= begin
case property_name.to_s
when 'version'
'version-autocompleter'
when 'assignee',
'responsible',
'priority',
'status',
'project',
'type',
'category',
'workPackage'
'create-autocompleter'
when 'activity'
'activity-autocompleter'
else
:input
end.to_s
end
end
end