Don't gulp errors in PromiseLike

pull/5799/head
Oliver Günther 7 years ago
parent ed52245351
commit 4a8a16f82c
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 4
      frontend/app/components/wp-edit-form/work-package-changeset.ts
  2. 26
      frontend/app/components/wp-edit-form/work-package-edit-form.ts
  3. 4
      frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.ts
  4. 2
      spec/features/work_packages/table/edit_work_packages_spec.rb
  5. 3
      spec/features/work_packages/table/switch_types_spec.rb

@ -114,13 +114,13 @@ export class WorkPackageChangeset {
return this.changes.hasOwnProperty(key);
}
public getForm():PromiseLike<FormResourceInterface> {
public getForm():Promise<FormResourceInterface> {
this.wpForm.putFromPromiseIfPristine(() => this.updateForm());
if (this.wpForm.hasValue()) {
return Promise.resolve(this.wpForm.value);
} else {
return this.wpForm.valuesPromise();
return new Promise((resolve,) => this.wpForm.valuesPromise().then(resolve));
}
}

@ -229,7 +229,10 @@ export class WorkPackageEditForm {
_.each(erroneousAttributes, (fieldName:string) => {
this.editContext.requireVisible(fieldName).then(() => {
this.activateWhenNeeded(fieldName);
this.activeFields[fieldName].setErrors(this.errorsPerAttribute[fieldName] || []);
if (this.activeFields[fieldName]) {
this.activeFields[fieldName].setErrors(this.errorsPerAttribute[fieldName] || []);
}
});
});
@ -258,7 +261,11 @@ export class WorkPackageEditForm {
) as EditField;
resolve(field);
});
})
.catch((error) => {
console.error("Failed to build edit field:" + error);
this.wpNotificationsService.handleRawError(error);
});
});
}
@ -266,11 +273,16 @@ export class WorkPackageEditForm {
const promise = this.editContext.activateField(this,
field,
this.errorsPerAttribute[fieldName] || []);
return promise.then((fieldHandler) => {
this.lastActiveField = fieldName;
this.activeFields[fieldName] = fieldHandler;
return fieldHandler;
});
return promise
.then((fieldHandler) => {
this.lastActiveField = fieldName;
this.activeFields[fieldName] = fieldHandler;
return fieldHandler;
})
.catch((error) => {
console.error("Failed to render edit field:" + error);
this.wpNotificationsService.handleRawError(error);
});
}
}

@ -72,7 +72,7 @@ export class MultiSelectEditField extends EditField {
public get value() {
const val = this.changeset.value(this.name);
if (this.isMultiselect) {
if (!Array.isArray(val) || this.isMultiselect) {
return val;
} else {
return val[0];
@ -93,7 +93,7 @@ export class MultiSelectEditField extends EditField {
public isValueMulti() {
const val = this.changeset.value(this.name);
return val.length > 1;
return val && val.length > 1;
}
public toggleMultiselect() {

@ -178,7 +178,7 @@ describe 'Inline editing work packages', js: true do
expect(wp_table.row(work_package)).to have_selector('.wp-table--cell-container.-error', count: 2)
cf_text = wp_table.edit_field(work_package, :customField2)
cf_text.update('my custom text')
cf_text.update('my custom text', expect_failure: true)
cf_list = wp_table.edit_field(work_package, :customField1)
cf_list.field_type = 'select'

@ -93,9 +93,6 @@ describe 'Switching types in work package table', js: true do
message: "#{cf_req_text.name} can't be blank."
)
# Old text field should disappear
expect { text_field.display_element }.to raise_error(Capybara::ElementNotFound)
# Required CF requires activation
req_text_field.activate!
req_text_field.set_value 'Required'

Loading…
Cancel
Save