mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2563] Upload new version information dialog (#3235)
* add majorVersion param move common part in base class * refactor upload queue * fix after refactoring * add comment functionality in versioning add minor and major option in versioning add animation in versioning add new functionality in demo shell * add animation test * add missing properties test and base upload class * fix reload after new version upload [ADF-2582] * update documentation * update doc and fix minor style issues * fix tslint error * change cachebuster * ADF-2672 version manager disable buttons * [ADF-2649] hide show actions in version list * fix tests
This commit is contained in:
@@ -1,52 +1,55 @@
|
||||
@mixin adf-accordion-theme($theme) {
|
||||
$primary: map-get($theme, primary);
|
||||
|
||||
.adf-panel-heading {
|
||||
float: left;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: normal;
|
||||
letter-spacing: normal;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.adf-panel {
|
||||
|
||||
.adf-panel-heading-selected {
|
||||
color: mat-color($primary);
|
||||
}
|
||||
&-heading {
|
||||
float: left;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-stretch: normal;
|
||||
line-height: normal;
|
||||
letter-spacing: normal;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.adf-panel-heading-icon {
|
||||
float: left;
|
||||
}
|
||||
&-heading-selected {
|
||||
color: mat-color($primary);
|
||||
}
|
||||
|
||||
.adf-panel-heading-text {
|
||||
float: left;
|
||||
padding-left: 20px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
&-heading-icon {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.mat-expansion-panel {
|
||||
transition: none !important;
|
||||
box-shadow: none !important;
|
||||
background: none !important;
|
||||
}
|
||||
&-heading-text {
|
||||
float: left;
|
||||
padding-left: 20px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.mat-expansion-panel-body {
|
||||
padding: 1px !important;
|
||||
}
|
||||
.mat-expansion-panel {
|
||||
transition: none !important;
|
||||
box-shadow: none !important;
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.mat-expansion-panel-header {
|
||||
padding: 0px !important;
|
||||
}
|
||||
.mat-expansion-panel-body {
|
||||
padding: 1px !important;
|
||||
}
|
||||
|
||||
.mat-expansion-panel-header-title {
|
||||
margin-right: 0px !important;
|
||||
}
|
||||
.mat-expansion-panel-header {
|
||||
padding: 0px !important;
|
||||
}
|
||||
|
||||
.mat-expansion-indicator {
|
||||
.mat-expansion-panel-header-title {
|
||||
margin-right: 0px !important;
|
||||
}
|
||||
|
||||
.mat-expansion-indicator {
|
||||
margin-right: 25px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ export interface FileUploadProgress {
|
||||
}
|
||||
|
||||
export interface FileUploadOptions {
|
||||
comment?: string;
|
||||
newVersion?: boolean;
|
||||
majorVersion?: boolean;
|
||||
newVersionBaseName?: string;
|
||||
parentId?: string;
|
||||
path?: string;
|
||||
@@ -66,10 +68,10 @@ export class FileModel {
|
||||
|
||||
this.options = Object.assign({}, {
|
||||
newVersion: false
|
||||
}, options);
|
||||
}, options);
|
||||
}
|
||||
|
||||
private generateId(): string {
|
||||
generateId(): string {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
let r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
|
@@ -158,7 +158,7 @@ describe('UploadService', () => {
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('autoRename=true')).toBe(false);
|
||||
expect(jasmine.Ajax.requests.mostRecent().params.has('majorVersion')).toBe(true);
|
||||
expect(jasmine.Ajax.requests.mostRecent().params.has('majorVersion')).toBe(false);
|
||||
});
|
||||
|
||||
it('If newVersionBaseName is set, name should be a param', () => {
|
||||
|
@@ -80,7 +80,7 @@ export class UploadService {
|
||||
* @returns Array of files that were not blocked from upload by the ignore list
|
||||
*/
|
||||
addToQueue(...files: FileModel[]): FileModel[] {
|
||||
const allowedFiles = files.filter(f => this.filterElement(f));
|
||||
const allowedFiles = files.filter(currentFile => this.filterElement(currentFile));
|
||||
this.queue = this.queue.concat(allowedFiles);
|
||||
this.queueChanged.next(this.queue);
|
||||
return allowedFiles;
|
||||
@@ -101,7 +101,7 @@ export class UploadService {
|
||||
*/
|
||||
uploadFilesInTheQueue(emitter: EventEmitter<any>): void {
|
||||
if (!this.activeTask) {
|
||||
let file = this.queue.find(f => f.status === FileUploadStatus.Pending);
|
||||
let file = this.queue.find(currentFile => currentFile.status === FileUploadStatus.Pending);
|
||||
if (file) {
|
||||
this.onUploadStarting(file);
|
||||
|
||||
@@ -162,7 +162,8 @@ export class UploadService {
|
||||
|
||||
if (file.options.newVersion === true) {
|
||||
opts.overwrite = true;
|
||||
opts.majorVersion = true;
|
||||
opts.majorVersion = file.options.majorVersion;
|
||||
opts.comment = file.options.comment;
|
||||
} else {
|
||||
opts.autoRename = true;
|
||||
}
|
||||
|
@@ -36,10 +36,10 @@ export class FileUtils {
|
||||
iterations.push(Promise.all(entries.map(entry => {
|
||||
if (entry.isFile) {
|
||||
return new Promise(resolveFile => {
|
||||
entry.file(function (f: File) {
|
||||
entry.file(function (file: File) {
|
||||
files.push({
|
||||
entry: entry,
|
||||
file: f,
|
||||
file: file,
|
||||
relativeFolder: entry.fullPath.replace(/\/[^\/]*$/, '')
|
||||
});
|
||||
resolveFile();
|
||||
|
@@ -136,10 +136,10 @@
|
||||
&__right {
|
||||
border-left: 1px solid mat-color($foreground, text, 0.07);
|
||||
}
|
||||
|
||||
|
||||
&__left {
|
||||
border-right: 1px solid mat-color($foreground, text, 0.07);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__thumbnails {
|
||||
@@ -163,6 +163,7 @@
|
||||
.adf-info-drawer-layout-content {
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.info-drawer-content {
|
||||
|
@@ -68,9 +68,16 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Input()
|
||||
blobFile: Blob;
|
||||
|
||||
/** @deprecated 2.4.0 use nodeId */
|
||||
/** Node Id of the file to load. */
|
||||
@Input()
|
||||
fileNodeId: string = null;
|
||||
set fileNodeId(nodeId: string) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
/** Node Id of the file to load. */
|
||||
@Input()
|
||||
nodeId: string = null;
|
||||
|
||||
/** Shared link id (to display shared file). */
|
||||
@Input()
|
||||
@@ -214,6 +221,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
extension: string;
|
||||
sidebarTemplateContext: { node: MinimalNodeEntryEntity } = { node: null };
|
||||
|
||||
private cacheBusterNumber;
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
// Extensions that are supported by the Viewer without conversion
|
||||
@@ -239,7 +248,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
isSourceDefined(): boolean {
|
||||
return (this.urlFile || this.blobFile || this.fileNodeId || this.sharedLinkId) ? true : false;
|
||||
return (this.urlFile || this.blobFile || this.nodeId || this.sharedLinkId) ? true : false;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -254,7 +263,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private onNodeUpdated(node: MinimalNodeEntryEntity) {
|
||||
if (node && node.id === this.fileNodeId) {
|
||||
if (node && node.id === this.nodeId) {
|
||||
this.generateCacheBusterNumber();
|
||||
this.setUpNodeFile(node);
|
||||
}
|
||||
}
|
||||
@@ -268,9 +278,9 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.setUpBlobData();
|
||||
} else if (this.urlFile) {
|
||||
this.setUpUrlFile();
|
||||
} else if (this.fileNodeId) {
|
||||
} else if (this.nodeId) {
|
||||
this.isLoading = true;
|
||||
this.apiService.nodesApi.getNodeInfo(this.fileNodeId).then(
|
||||
this.apiService.nodesApi.getNodeInfo(this.nodeId).then(
|
||||
(data: MinimalNodeEntryEntity) => {
|
||||
this.setUpNodeFile(data);
|
||||
},
|
||||
@@ -326,7 +336,10 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private setUpNodeFile(data: MinimalNodeEntryEntity) {
|
||||
this.mimeType = data.content.mimeType;
|
||||
this.displayName = data.name;
|
||||
|
||||
this.urlFileContent = this.apiService.contentApi.getContentUrl(data.id);
|
||||
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + this.cacheBusterNumber : this.urlFileContent;
|
||||
|
||||
this.extension = this.getFileExtension(data.name);
|
||||
|
||||
this.fileName = data.name;
|
||||
@@ -373,8 +386,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
toggleSidebar() {
|
||||
this.showSidebar = !this.showSidebar;
|
||||
if (this.showSidebar && this.fileNodeId) {
|
||||
this.apiService.getInstance().nodes.getNodeInfo(this.fileNodeId, {include: ['allowableOperations']})
|
||||
if (this.showSidebar && this.nodeId) {
|
||||
this.apiService.getInstance().nodes.getNodeInfo(this.nodeId, { include: ['allowableOperations'] })
|
||||
.then((data: MinimalNodeEntryEntity) => {
|
||||
this.sidebarTemplateContext.node = data;
|
||||
});
|
||||
@@ -658,7 +671,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
return rendition;
|
||||
} else if (status === 'NOT_CREATED') {
|
||||
try {
|
||||
await this.apiService.renditionsApi.createRendition(nodeId, {id: renditionId});
|
||||
await this.apiService.renditionsApi.createRendition(nodeId, { id: renditionId });
|
||||
return await this.waitRendition(nodeId, renditionId, 0);
|
||||
} catch (err) {
|
||||
this.logService.error(err);
|
||||
@@ -693,4 +706,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
return this.sidebarPosition === 'left' ? 'adf-viewer__sidebar__left' : 'adf-viewer__sidebar__right';
|
||||
}
|
||||
|
||||
private generateCacheBusterNumber() {
|
||||
this.cacheBusterNumber = Date.now();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user