Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Delete Value UI Bug #171

Merged
merged 13 commits into from Sep 14, 2020
Merged

FIX: Delete Value UI Bug #171

merged 13 commits into from Sep 14, 2020

Conversation

mdelez
Copy link
Contributor

@mdelez mdelez commented Sep 8, 2020

@mdelez mdelez added the bug Something isn't working label Sep 8, 2020
@mdelez mdelez self-assigned this Sep 8, 2020
Copy link
Collaborator

@flavens flavens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

return this._subject$
.pipe(
// Filter down based on event name to any events that are emitted out of the subject from the emit method below.
filter((e: EmitEvent) => e.name === event),
map((e: EmitEvent) => e.value)
map((e: EmitEvent) => e.value),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comma is not required

@tobiasschweizer
Copy link
Contributor

@mdelez I think I can look at this PR tomorrow.

@@ -64,6 +64,8 @@ describe('Test App', () => {
await browser.wait(EC.presenceOf(element(by.css('.rm-value'))), timeout,
'Wait for read value to be visible.');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment that this is necessary because the DOM element has been re-created

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in 4768a6b

@@ -17,29 +17,38 @@ export class ValueOperationEventService {

// Used in the listening component.
// i.e. this.valueOperationEventSubscription = this._valueOperationEventService.on(Events.ValueAdded, () => doSomething());
on(event: Events, action: (newValue) => void): Subscription {
on(event: Events, action: (newValue: any) => void): Subscription {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of any, could you use a more restrictive type annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in fd17180


/**
* @param currentValue the current value
* @param newValue value to update the current value with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why the current value would have to be updated with the new value?

@@ -46,7 +46,9 @@ class TestParentComponent implements OnInit, OnDestroy {
constructor(public _valueOperationEventService: ValueOperationEventService) { }

ngOnInit() {
this.voeSubscription = this._valueOperationEventService.on(Events.ValueAdded, () => this.myNum += 1);
this.voeSubscription = this._valueOperationEventService.on(Events.ValueAdded, () => this.myNum = 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to add the subscriptions to an array of subscriptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in dda33f8

@@ -78,21 +78,25 @@ export class ResourceViewComponent implements OnInit, OnChanges, OnDestroy {
private _valueOperationEventService: ValueOperationEventService) { }

ngOnInit() {
// subscribe to the event bus and listen for the ValueAdded event to be emitted
// when a ValueAdded event is emitted, get the resource again to display the newly created value
// subscribe to the ValueOperationEventService and listen for an event to be emitted
this.valueOperationEventSubscription = this._valueOperationEventService.on(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment relating to subscriptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in dda33f8

}

ngOnChanges() {
this.getResource(this.iri);
}

ngOnDestroy() {
// unsubscribe from the event bus when component is destroyed
// unsubscribe from the ValueOperationEventService when component is destroyed
if (this.valueOperationEventSubscription !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should the rather be an array of subscriptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in dda33f8


this.valueOperationEventSubscription = this._valueOperationEventService.on(
Events.ValueDeleted, (deletedValue: DeleteValue) => this.updateResource(deletedValue, true));
Events.ValueUpdated, (updatedValue: EventValues) =>
this.updateResource(updatedValue.currentValue, 'update', updatedValue.newValue));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newValue is optional, so how do you know that this is safe?

@mdelez
Copy link
Contributor Author

mdelez commented Sep 14, 2020

further optimization of the ValueOperationEvent service will be done in this task https://dasch.myjetbrains.com/youtrack/issue/DSP-628

Copy link
Contributor

@tobiasschweizer tobiasschweizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, now the logic is much easier to understand. :-)

@mdelez mdelez merged commit c2dff4d into master Sep 14, 2020
@mdelez mdelez deleted the fix/dsp-550-delete-value-ui-bug branch September 14, 2020 14:35
* @param valueType Value type (ReadValue, DeleteValue, BaseValue, etc.)
*/
compareObjectTypeWithValueType(objectType: string, valueType: string): boolean {
return objectType === this._readTextValueAsString ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late notice but I think there is some missing conditions:

(valueType === Constants.TextValue && objectType === this._readTextValueAsString) || ...

Otherwise text values are always included.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants