Skip to content

Commit

Permalink
[ACA-213] Upload Version - version options use boolean values (Alfres…
Browse files Browse the repository at this point in the history
…co#940)

* version form data interface

* subscribe value data type

* use form data  boolean value

* update tests
  • Loading branch information
pionnegru authored and dhrn committed Apr 30, 2019
1 parent 5aad946 commit 60149dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ describe('AppNodeVersionFormComponent', () => {
});

it('should emit form state on changes', () => {
const formData = {
comment: 'some text',
version: true
};
spyOn(component.update, 'emit');

component.form.valueChanges.next({ test: 'test' });
expect(component.update.emit).toHaveBeenCalledWith({ test: 'test' });
component.form.valueChanges.next(formData);
expect(component.update.emit).toHaveBeenCalledWith(formData);
});

it('form should have valid state upon initialization', () => {
Expand Down
13 changes: 9 additions & 4 deletions src/app/components/node-version/node-version-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

export interface VersionFormEntry {
comment: string;
version: boolean;
}

@Component({
selector: 'app-node-version-form',
templateUrl: './node-version-form.component.html',
Expand All @@ -44,14 +49,14 @@ import { takeUntil } from 'rxjs/operators';
exportAs: 'nodeVersionForm'
})
export class AppNodeVersionFormComponent implements OnInit, OnDestroy {
@Output() update: EventEmitter<string> = new EventEmitter();
@Output() update: EventEmitter<VersionFormEntry> = new EventEmitter();

form: FormGroup;

private onDestroy$: Subject<boolean> = new Subject<boolean>();
private versionOptions = [
{ label: 'VERSION.FORM.VERSION.MINOR', value: 'minor' },
{ label: 'VERSION.FORM.VERSION.MAJOR', value: 'major' }
{ label: 'VERSION.FORM.VERSION.MINOR', value: false },
{ label: 'VERSION.FORM.VERSION.MAJOR', value: true }
];

constructor(private formBuilder: FormBuilder) {}
Expand All @@ -64,7 +69,7 @@ export class AppNodeVersionFormComponent implements OnInit, OnDestroy {

this.form.valueChanges
.pipe(takeUntil(this.onDestroy$))
.subscribe(values => {
.subscribe((values: VersionFormEntry) => {
this.update.emit(values);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/effects/upload.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class UploadEffects {
file,
{
comment: form.comment,
majorVersion: form.major ? true : false,
majorVersion: form.version,
parentId: node.parentId,
path: ((<any>file).webkitRelativePath || '').replace(
/\/[^\/]*$/,
Expand Down

0 comments on commit 60149dd

Please sign in to comment.