mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACA-213] Upload Version - version options use boolean values (#940)
* version form data interface * subscribe value data type * use form data boolean value * update tests
This commit is contained in:
committed by
Denys Vuika
parent
9b2cbdde49
commit
51b08d2283
@@ -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', () => {
|
||||
|
||||
@@ -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',
|
||||
@@ -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) {}
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
/\/[^\/]*$/,
|
||||
|
||||
Reference in New Issue
Block a user