mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ACA-3669] Incorrect Version Number Displayed (#7230)
This commit is contained in:
parent
e5192c10d6
commit
01f0139504
@ -8,8 +8,8 @@
|
|||||||
"UPLOAD": {
|
"UPLOAD": {
|
||||||
"TITLE": "Upload new version",
|
"TITLE": "Upload new version",
|
||||||
"TOOLTIP": "Restriction: you must upload a file with the same name to create a new version of it",
|
"TOOLTIP": "Restriction: you must upload a file with the same name to create a new version of it",
|
||||||
"MAJOR": "major changes (2.0)",
|
"MAJOR": "major changes ({{version}})",
|
||||||
"MINOR": "minor changes (1.1)",
|
"MINOR": "minor changes ({{version}})",
|
||||||
"COMMENT": "Leave a comment",
|
"COMMENT": "Leave a comment",
|
||||||
"ADD": "Add New Version",
|
"ADD": "Add New Version",
|
||||||
"CANCEL": "Cancel"
|
"CANCEL": "Cancel"
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
<adf-version-comparison *ngIf="showVersionComparison" [node]="node" [newFileVersion]="newFileVersion"></adf-version-comparison>
|
<adf-version-comparison *ngIf="showVersionComparison" [node]="node" [newFileVersion]="newFileVersion"></adf-version-comparison>
|
||||||
|
|
||||||
<div class="adf-new-version-uploader-container" id="adf-new-version-uploader-container" fxLayout="row" fxLayoutAlign="end center" [@uploadToggle]="uploadState">
|
<div class="adf-new-version-uploader-container" id="adf-new-version-uploader-container" fxLayout="row" fxLayoutAlign="end center" [@uploadToggle]="uploadState">
|
||||||
<table class="adf-version-upload" *ngIf="uploadState !== 'close'">
|
<table class="adf-version-upload" *ngIf="uploadState !== 'close' && !versionList.isLoading">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<adf-version-upload
|
<adf-version-upload
|
||||||
id="adf-version-upload-button"
|
id="adf-version-upload-button"
|
||||||
[node]="node"
|
[node]="node"
|
||||||
[newFileVersion]="newFileVersion"
|
[newFileVersion]="newFileVersion"
|
||||||
|
[currentVersion]="versionList?.versions[0]?.entry"
|
||||||
(success)="onUploadSuccess($event)"
|
(success)="onUploadSuccess($event)"
|
||||||
(cancel)="onUploadCancel()"
|
(cancel)="onUploadCancel()"
|
||||||
(error)="onUploadError($event)">
|
(error)="onUploadError($event)">
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
<div class="adf-new-version-max-width">
|
<div class="adf-new-version-max-width">
|
||||||
<mat-radio-group class="adf-new-version-radio-group" [(ngModel)]="semanticVersion" (change)="onVersionChange()">
|
<mat-radio-group class="adf-new-version-radio-group" [(ngModel)]="semanticVersion" (change)="onVersionChange()">
|
||||||
<mat-radio-button class="adf-new-version-radio-button" id="adf-new-version-minor"[value]="'minor'">{{
|
<mat-radio-button class="adf-new-version-radio-button" id="adf-new-version-minor"[value]="'minor'">
|
||||||
'ADF_VERSION_LIST.ACTIONS.UPLOAD.MINOR' |
|
{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.MINOR' | translate: { version: minorVersion } }}
|
||||||
translate }}
|
|
||||||
</mat-radio-button>
|
</mat-radio-button>
|
||||||
<mat-radio-button class="adf-new-version-radio-button" id="adf-new-version-major" [value]="'major'">{{
|
<mat-radio-button class="adf-new-version-radio-button" id="adf-new-version-major" [value]="'major'">
|
||||||
'ADF_VERSION_LIST.ACTIONS.UPLOAD.MAJOR' |
|
{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.MAJOR' | translate: { version: majorVersion } }}
|
||||||
translate }}
|
|
||||||
</mat-radio-button>
|
</mat-radio-button>
|
||||||
</mat-radio-group>
|
</mat-radio-group>
|
||||||
<mat-form-field class="adf-new-version-max-width">
|
<mat-form-field class="adf-new-version-max-width">
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { VersionUploadComponent } from 'content-services';
|
import { VersionUploadComponent } from './version-upload.component';
|
||||||
import { ContentService, setupTestBed, UploadService } from '@alfresco/adf-core';
|
import { ContentService, setupTestBed, UploadService } from '@alfresco/adf-core';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
@ -93,4 +93,17 @@ describe('VersionUploadComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update next major version', () => {
|
||||||
|
let majorVersion = component.getNextMajorVersion('1.0');
|
||||||
|
expect(majorVersion).toEqual('2.0');
|
||||||
|
majorVersion = component.getNextMajorVersion('10.0');
|
||||||
|
expect(majorVersion).toEqual('11.0');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update next minor version', () => {
|
||||||
|
let minorVersion = component.getNextMinorVersion('1.0');
|
||||||
|
expect(minorVersion).toEqual('1.1');
|
||||||
|
minorVersion = component.getNextMinorVersion('1.10');
|
||||||
|
expect(minorVersion).toEqual('1.11');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input, ViewEncapsulation, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node, Version } from '@alfresco/js-api';
|
||||||
import { ContentService, FileUploadErrorEvent, FileUploadEvent, UploadService } from '@alfresco/adf-core';
|
import { ContentService, FileUploadErrorEvent, FileUploadEvent, UploadService } from '@alfresco/adf-core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
@ -35,6 +35,8 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
|||||||
uploadVersion: boolean = false;
|
uploadVersion: boolean = false;
|
||||||
disabled: boolean = false;
|
disabled: boolean = false;
|
||||||
onDestroy$ = new Subject();
|
onDestroy$ = new Subject();
|
||||||
|
majorVersion = '2.0';
|
||||||
|
minorVersion = '1.1';
|
||||||
|
|
||||||
/** The target node. */
|
/** The target node. */
|
||||||
@Input()
|
@Input()
|
||||||
@ -52,6 +54,15 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
showCancelButton: boolean = true;
|
showCancelButton: boolean = true;
|
||||||
|
|
||||||
|
/** Current version for a target node */
|
||||||
|
@Input()
|
||||||
|
set currentVersion(version: Version) {
|
||||||
|
if (version) {
|
||||||
|
this.minorVersion = this.getNextMinorVersion(version.id);
|
||||||
|
this.majorVersion = this.getNextMajorVersion(version.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Emitted when the file is uploaded successfully. */
|
/** Emitted when the file is uploaded successfully. */
|
||||||
@Output()
|
@Output()
|
||||||
success = new EventEmitter();
|
success = new EventEmitter();
|
||||||
@ -124,4 +135,19 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
|||||||
this.onDestroy$.complete();
|
this.onDestroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getNextMinorVersion(version: string): string {
|
||||||
|
const { major, minor } = this.getParsedVersion(version);
|
||||||
|
return `${major}.${minor + 1}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
getNextMajorVersion(version: string): string {
|
||||||
|
const { major} = this.getParsedVersion(version);
|
||||||
|
return `${major + 1 }.0`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getParsedVersion(version: string) {
|
||||||
|
const minor = version.indexOf('.') !== -1 ? Number(version.substr(version.indexOf('.') + 1)) : 0;
|
||||||
|
const major = parseInt(version, 10);
|
||||||
|
return { minor, major };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user